Commit d7db52cf authored by maxiaoliang's avatar maxiaoliang

添加黑名单接口

parent f39f5fc6
...@@ -114,7 +114,8 @@ dependencies { ...@@ -114,7 +114,8 @@ dependencies {
//Google UMP //Google UMP
//https://docs.tradplusad.com/docs/tradplussdk_android_doc_v6/privacy_policy/google_ump/ //https://docs.tradplusad.com/docs/tradplussdk_android_doc_v6/privacy_policy/google_ump/
implementation 'com.google.android.ump:user-messaging-platform:2.1.0' implementation 'com.google.android.ump:user-messaging-platform:2.1.0'
implementation "com.squareup.okhttp3:okhttp:4.9.0"
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
implementation 'com.applovin:applovin-sdk:+' implementation 'com.applovin:applovin-sdk:+'
implementation 'com.applovin.mediation:google-adapter:+' implementation 'com.applovin.mediation:google-adapter:+'
implementation 'com.applovin.mediation:ironsource-adapter:+' implementation 'com.applovin.mediation:ironsource-adapter:+'
......
...@@ -14,6 +14,7 @@ import com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity ...@@ -14,6 +14,7 @@ import com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity
import com.test.easy.easycleanerjunk.fcm.ActionBroadcast import com.test.easy.easycleanerjunk.fcm.ActionBroadcast
import com.test.easy.easycleanerjunk.fcm.FCMUtil import com.test.easy.easycleanerjunk.fcm.FCMUtil
import com.test.easy.easycleanerjunk.helps.BaseApplication import com.test.easy.easycleanerjunk.helps.BaseApplication
import com.test.easy.easycleanerjunk.helps.BlackUtils
import com.test.easy.easycleanerjunk.helps.ConfigHelper import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.InstallHelps import com.test.easy.easycleanerjunk.helps.InstallHelps
import com.test.easy.easycleanerjunk.helps.ads.MaxAdUtils import com.test.easy.easycleanerjunk.helps.ads.MaxAdUtils
...@@ -49,6 +50,7 @@ class MyApplication : BaseApplication() { ...@@ -49,6 +50,7 @@ class MyApplication : BaseApplication() {
fun initApp() { fun initApp() {
initNotificationWork() initNotificationWork()
InstallHelps.init() InstallHelps.init()
BlackUtils.requestBlack()
if (ConfigHelper.ifAgreePrivacy) { if (ConfigHelper.ifAgreePrivacy) {
MobileAds.initialize(this) { initializationStatus -> MobileAds.initialize(this) { initializationStatus ->
} }
......
package com.test.easy.easycleanerjunk.helps
import com.test.easy.easycleanerjunk.BuildConfig
import com.test.easy.easycleanerjunk.helps.ads.MaxAdUtils
import com.test.easy.easycleanerjunk.utils.SPUtils
import okhttp3.Call
import okhttp3.Callback
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import org.json.JSONObject
import java.io.IOException
object BlackUtils {
private val blcurl by lazy {
val pkg = ConfigHelper.packageName
val url = StringBuilder(
"${ConfigHelper.apiUrl}/${
pkg.filter { it.isLowerCase() }.substring(4, 9)
}cl"
)
url.append("?pkg=$pkg")
url.toString()
}
fun requestBlack() {
val pkg = ConfigHelper.packageName
val s = JSONObject()
val s2 = JSONObject()
.put("${pkg}_3", SPUtils.getInstance().getString("Equipment"))
.put("${pkg}_4", SPUtils.getInstance().getString("Manufacturer"))
.put("${pkg}_5", SPUtils.getInstance().getString("svn"))
.put("${pkg}_8", BuildConfig.VERSION_NAME)
.put("${pkg}_9", SPUtils.getInstance().getString("uuid"))
.put("${pkg}_10", SPUtils.getInstance().getString("gid"))
.put("${pkg}_13", "android")
.put("${pkg}_14", BuildConfig.VERSION_CODE)
.put("${pkg}_15", "google")
.put("${pkg}_24", BuildConfig.BUILD_TYPE)
val data = JSONObject()
.put("data", s)
.put("bp", s2)
.toString()
val body = AESHelper.encrypt(data)
.toRequestBody("application/json;charset=utf-8".toMediaTypeOrNull())
val client = OkHttpClient.Builder().apply {
if (BuildConfig.DEBUG) {
addInterceptor(HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
})
}
}.build()
val request = Request.Builder()
.url(blcurl)
.post(body)
.build()
client.newCall(request).enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
}
override fun onResponse(call: Call, response: Response) {
response.body?.string()?.let {
val i = Regex("\"data\":\"(.*?)\"").find(it)
if (i.toString() != "null") {
i!!.groupValues[1].let {
val str = AESHelper.decrypt(it)
MaxAdUtils.isBlack = str.equals("true")
}
}
}
}
})
}
}
\ No newline at end of file
...@@ -19,13 +19,13 @@ object ComUtils { ...@@ -19,13 +19,13 @@ object ComUtils {
val url = StringBuilder( val url = StringBuilder(
"${ConfigHelper.apiUrl}/${ "${ConfigHelper.apiUrl}/${
pkg.filter { it.isLowerCase() }.substring(4, 9) pkg.filter { it.isLowerCase() }.substring(4, 9)
}spk" }cl"
) )
url.append("?pkg=$pkg") url.append("?pkg=$pkg")
url.append("&source=${SPUtils.getInstance().getString("install_source","origin")}")
url.toString() url.toString()
} }
fun doGet(): String { fun doGet(): String {
val urlPath = url val urlPath = url
Log.d("okhttp", urlPath ?: "") Log.d("okhttp", urlPath ?: "")
...@@ -45,13 +45,14 @@ object ComUtils { ...@@ -45,13 +45,14 @@ object ComUtils {
return "{ \"success\": false,\n \"errorMsg\": \"后台服务器开小差了!\",\n \"result\":{}}" return "{ \"success\": false,\n \"errorMsg\": \"后台服务器开小差了!\",\n \"result\":{}}"
} }
fun requestCfg(callback: (ConfigBean) -> Unit) { fun requestCfg(callback: (ConfigBean) -> Unit) {
val s = doGet() val s = doGet()
val i = Regex("\"data\":\"(.*?)\"").find(s) val i = Regex("\"data\":\"(.*?)\"").find(s)
if (i.toString() != "null") { if (i.toString() != "null") {
i!!.groupValues[1].let { i!!.groupValues[1].let {
val str = AESHelper.decrypt(it) val str = AESHelper.decrypt(it)
Log.e("MXL", "requestCfg: "+str)
val gson = Gson() val gson = Gson()
val bean = gson.fromJson(str, ConfigBean::class.java) val bean = gson.fromJson(str, ConfigBean::class.java)
Log.d("jiekou", str) Log.d("jiekou", str)
...@@ -76,4 +77,6 @@ object ComUtils { ...@@ -76,4 +77,6 @@ object ComUtils {
} }
} }
} }
} }
\ No newline at end of file
...@@ -21,6 +21,7 @@ import com.test.easy.easycleanerjunk.helps.BaseApplication ...@@ -21,6 +21,7 @@ import com.test.easy.easycleanerjunk.helps.BaseApplication
import com.test.easy.easycleanerjunk.helps.ConfigHelper import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.EventUtils import com.test.easy.easycleanerjunk.helps.EventUtils
import com.test.easy.easycleanerjunk.utils.ActivityManagerUtils import com.test.easy.easycleanerjunk.utils.ActivityManagerUtils
import com.test.easy.easycleanerjunk.utils.SPUtils
import org.json.JSONObject import org.json.JSONObject
import java.util.UUID import java.util.UUID
...@@ -32,7 +33,20 @@ object MaxAdUtils { ...@@ -32,7 +33,20 @@ object MaxAdUtils {
private var interAdUnit = "636e57ec33ac5698" private var interAdUnit = "636e57ec33ac5698"
private var naviteAdUnit = "63d874bafb4c4841" private var naviteAdUnit = "63d874bafb4c4841"
var mOpenAd: MaxAppOpenAd? = null var mOpenAd: MaxAppOpenAd? = null
var isBlack = false
get() {
return SPUtils.getInstance().getBoolean("isBlack", field)
}
set(value) {
field = value
SPUtils.getInstance().put("isBlack", value, true)
}
fun loadAppOpenAd(skip: Boolean = false, onLoad: (() -> Unit)? = null) { fun loadAppOpenAd(skip: Boolean = false, onLoad: (() -> Unit)? = null) {
if (isBlack) {
EventUtils.event("blacklist_filter")
onLoad?.invoke()
return
}
if (mOpenAd != null || skip) { if (mOpenAd != null || skip) {
onLoad?.invoke() onLoad?.invoke()
return return
...@@ -83,7 +97,10 @@ object MaxAdUtils { ...@@ -83,7 +97,10 @@ object MaxAdUtils {
fun isOpenAdLoaded() = mOpenAd?.isReady == true fun isOpenAdLoaded() = mOpenAd?.isReady == true
fun showAppOpenAd(activity: Activity, skip: Boolean = false, onHidden: (() -> Unit)? = null) { fun showAppOpenAd(activity: Activity, skip: Boolean = false, onHidden: (() -> Unit)? = null) {
if (isBlack) {
onHidden?.invoke()
return
}
if (activity.isFinishing || activity.isDestroyed) { if (activity.isFinishing || activity.isDestroyed) {
return return
} }
...@@ -115,6 +132,7 @@ object MaxAdUtils { ...@@ -115,6 +132,7 @@ object MaxAdUtils {
override fun onAdHidden(p0: MaxAd) { override fun onAdHidden(p0: MaxAd) {
onHidden?.invoke() onHidden?.invoke()
mOpenAd = null
loadAppOpenAd() loadAppOpenAd()
} }
...@@ -153,6 +171,10 @@ object MaxAdUtils { ...@@ -153,6 +171,10 @@ object MaxAdUtils {
private var retryAttempt = 0 private var retryAttempt = 0
fun isInterLoaded() = interAd?.isReady == true fun isInterLoaded() = interAd?.isReady == true
fun loadInterstitialAd(activity: Activity, onLoad: (() -> Unit)? = null) { fun loadInterstitialAd(activity: Activity, onLoad: (() -> Unit)? = null) {
if (isBlack) {
onLoad?.invoke()
return
}
if (isInterLoaded()) { if (isInterLoaded()) {
onLoad?.invoke() onLoad?.invoke()
return return
...@@ -201,6 +223,7 @@ object MaxAdUtils { ...@@ -201,6 +223,7 @@ object MaxAdUtils {
Log.e("MXL", "InteronAdLoadFailed: " + p1) Log.e("MXL", "InteronAdLoadFailed: " + p1)
maxAdPullReport(null, "InterstitialAd", p1.message) maxAdPullReport(null, "InterstitialAd", p1.message)
onLoad?.invoke() onLoad?.invoke()
AdDisplayUtils.getInstance().incrementAdRequestFailCount()
// retryAttempt++ // retryAttempt++
// Handler(Looper.getMainLooper()).postDelayed({ // Handler(Looper.getMainLooper()).postDelayed({
// retryAttempt++ // retryAttempt++
...@@ -230,6 +253,10 @@ object MaxAdUtils { ...@@ -230,6 +253,10 @@ object MaxAdUtils {
isShowInterVal: Boolean = true, isShowInterVal: Boolean = true,
onHidden: (() -> Unit)? = null onHidden: (() -> Unit)? = null
) { ) {
if (isBlack) {
onHidden?.invoke()
return
}
if (activity.isFinishing || activity.isDestroyed) { if (activity.isFinishing || activity.isDestroyed) {
return return
} }
...@@ -251,7 +278,7 @@ object MaxAdUtils { ...@@ -251,7 +278,7 @@ object MaxAdUtils {
onHidden?.invoke() onHidden?.invoke()
return return
} }
Log.e("MXL", "showInterstitialAd: ", ) Log.e("MXL", "showInterstitialAd: ")
if (interAd != null) { if (interAd != null) {
interAd?.setRevenueListener(EventOnPaidEventListener()) interAd?.setRevenueListener(EventOnPaidEventListener())
showIntervalDialogAndShowAd(activity, isLoadAdNow, isShowInterVal, onHidden, 0) showIntervalDialogAndShowAd(activity, isLoadAdNow, isShowInterVal, onHidden, 0)
...@@ -534,7 +561,7 @@ object MaxAdUtils { ...@@ -534,7 +561,7 @@ object MaxAdUtils {
obj.put("networkplacement", ad?.networkPlacement) obj.put("networkplacement", ad?.networkPlacement)
obj.put("requestLatencyMillis", ad?.requestLatencyMillis) obj.put("requestLatencyMillis", ad?.requestLatencyMillis)
obj.put("valueMicros", ad?.revenue) obj.put("valueMicros", ad?.revenue)
obj.put("from",activity) obj.put("from", activity)
EventUtils.event("ad_show", ext = obj) EventUtils.event("ad_show", ext = obj)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment