Commit 1c365aab authored by wanglei's avatar wanglei

[测试]远程获取配置

parent d91d0843
...@@ -5,23 +5,23 @@ package com.base.appzxhy ...@@ -5,23 +5,23 @@ package com.base.appzxhy
*/ */
object GlobalConfig { object GlobalConfig {
//包名 //包名
const val PACKAGE_NAME = "com.loactation.alibabab.ccccaa" const val PACKAGE_NAME = "com.dumpster.cleaner.tbt"
// 域名 // 域名
/** /**
* Url Event 上报接口 * Url Event 上报接口
*/ */
const val URL_EVENT = "https://rp.gamexzonerk.xyz" const val URL_EVENT = "https://rp.kubukubanten.xyz"
/** /**
* Url Api 业务接口 * Url Api 业务接口
*/ */
const val URL_API = "https://api.gamexzonerk.xyz" const val URL_API = "https://api.kubukubanten.xyz"
/** /**
* Url Privacy 隐私链接 * Url Privacy 隐私链接
*/ */
const val URL_PRIVACY = "https://sites.google.com/view/locationuses/location" const val URL_PRIVACY = "https://sites.google.com/view/dumpster-cleaner/dumpster-cleaner"
/** /**
* Url Use 使用条款 * Url Use 使用条款
...@@ -31,7 +31,7 @@ object GlobalConfig { ...@@ -31,7 +31,7 @@ object GlobalConfig {
/** /**
* Key Aes 加密key * Key Aes 加密key
*/ */
const val KEY_AES = "pex50vwzuhpim3yh" const val KEY_AES = "d1mnzmn2cs20xpmx"
/** /**
* Key solar 归因key * Key solar 归因key
......
...@@ -31,12 +31,14 @@ import com.base.appzxhy.bean.config.AdConfigBean ...@@ -31,12 +31,14 @@ import com.base.appzxhy.bean.config.AdConfigBean
import com.base.appzxhy.bean.config.ConfigBean import com.base.appzxhy.bean.config.ConfigBean
import com.base.appzxhy.bean.config.PopupConfigBean import com.base.appzxhy.bean.config.PopupConfigBean
import com.base.appzxhy.business.ads.AdsMgr import com.base.appzxhy.business.ads.AdsMgr
import com.base.appzxhy.business.helper.NewComUtils.spConfig
import com.base.appzxhy.business.push.fcm.FCMManager import com.base.appzxhy.business.push.fcm.FCMManager
import com.base.appzxhy.business.push.notification.MyNotificationManager import com.base.appzxhy.business.push.notification.MyNotificationManager
import com.base.appzxhy.push.receiver.AlarmReceiver.Companion.startAlarm import com.base.appzxhy.push.receiver.AlarmReceiver.Companion.startAlarm
import com.base.appzxhy.push.receiver.ScreenStatusReceiver import com.base.appzxhy.push.receiver.ScreenStatusReceiver
import com.base.appzxhy.push.timer.TimerManager.Companion.changeTimer import com.base.appzxhy.push.timer.TimerManager.Companion.changeTimer
import com.base.appzxhy.push.work.RepeatingWorker.Companion.schedulePeriodicWork import com.base.appzxhy.push.work.RepeatingWorker.Companion.schedulePeriodicWork
import com.base.appzxhy.ui.batteryinfo.BatteryReceiver.Companion.registerBatteryReceiver
import com.base.appzxhy.ui.splash.SplashActivity import com.base.appzxhy.ui.splash.SplashActivity
...@@ -142,7 +144,7 @@ class MyApplication : Application() { ...@@ -142,7 +144,7 @@ class MyApplication : Application() {
ScreenStatusReceiver.registerScreenStatusReceiver(this) ScreenStatusReceiver.registerScreenStatusReceiver(this)
// PackageStatusReceiver.registerPackageStatusReceiver(this) // PackageStatusReceiver.registerPackageStatusReceiver(this)
// BatteryStatusReceiver.registerBatteryStatusReceiver(this) registerBatteryReceiver(this)
//workManager //workManager
schedulePeriodicWork(appContext) schedulePeriodicWork(appContext)
...@@ -160,10 +162,7 @@ class MyApplication : Application() { ...@@ -160,10 +162,7 @@ class MyApplication : Application() {
private fun initAppConfig() { private fun initAppConfig() {
Thread { Thread {
val config = AppPreferences.getInstance().getString("config", "") initConfig()
if (config.isNotEmpty()) {
initConfig(config)
}
InstallHelps.init { InstallHelps.init {
initRemoteConfig() initRemoteConfig()
...@@ -219,7 +218,6 @@ class MyApplication : Application() { ...@@ -219,7 +218,6 @@ class MyApplication : Application() {
PAUSED_VALUE = 1 PAUSED_VALUE = 1
} }
override fun onActivityPaused(activity: Activity) { override fun onActivityPaused(activity: Activity) {
PAUSED_VALUE = 2 PAUSED_VALUE = 2
lastTimePause = System.currentTimeMillis() lastTimePause = System.currentTimeMillis()
...@@ -242,7 +240,6 @@ class MyApplication : Application() { ...@@ -242,7 +240,6 @@ class MyApplication : Application() {
NewComUtils.requestCfg { config -> NewComUtils.requestCfg { config ->
LogEx.logDebug("requestCfg", "config=$config") LogEx.logDebug("requestCfg", "config=$config")
if (config != null) { if (config != null) {
AppPreferences.getInstance().put("config", config)
initConfig(config) initConfig(config)
} else { } else {
EventUtils.event("configNull") EventUtils.event("configNull")
...@@ -251,7 +248,8 @@ class MyApplication : Application() { ...@@ -251,7 +248,8 @@ class MyApplication : Application() {
} }
private fun initConfig(config: String) { private fun initConfig(config: String = spConfig) {
if (config.isEmpty()) return
// kotlin.runCatching { // kotlin.runCatching {
val configBean = Gson().fromJson(config, ConfigBean::class.java) val configBean = Gson().fromJson(config, ConfigBean::class.java)
...@@ -279,5 +277,4 @@ class MyApplication : Application() { ...@@ -279,5 +277,4 @@ class MyApplication : Application() {
} }
} }
\ No newline at end of file
...@@ -10,7 +10,6 @@ import com.applovin.sdk.AppLovinSdkInitializationConfiguration ...@@ -10,7 +10,6 @@ import com.applovin.sdk.AppLovinSdkInitializationConfiguration
import com.base.appzxhy.BuildConfig import com.base.appzxhy.BuildConfig
import com.base.appzxhy.GlobalConfig import com.base.appzxhy.GlobalConfig
import com.base.appzxhy.MyApplication import com.base.appzxhy.MyApplication
import com.base.appzxhy.bean.config.AdConfigBean
import com.base.appzxhy.bean.config.AdConfigBean.Companion.adsConfigBean import com.base.appzxhy.bean.config.AdConfigBean.Companion.adsConfigBean
import com.base.appzxhy.bean.config.ConfigBean.Companion.configBean import com.base.appzxhy.bean.config.ConfigBean.Companion.configBean
import com.base.appzxhy.business.ads.admob.AdBannerMgr import com.base.appzxhy.business.ads.admob.AdBannerMgr
...@@ -72,6 +71,15 @@ object AdsMgr { ...@@ -72,6 +71,15 @@ object AdsMgr {
var isMaxInit = false var isMaxInit = false
private set private set
var isAdUtEvent = false
fun eventAdUt() {
if (!isAdUtEvent) {
isAdUtEvent = true
EventUtils.event("ad_ut_${configBean.ut}")
}
}
/** /**
* Init 初始化 * Init 初始化
* *
...@@ -157,6 +165,8 @@ object AdsMgr { ...@@ -157,6 +165,8 @@ object AdsMgr {
isUnLimit: Boolean = false, isUnLimit: Boolean = false,
showCallBack: AdsShowCallBack? = null, showCallBack: AdsShowCallBack? = null,
) { ) {
eventAdUt()
if (configBean.isInBlackList) { if (configBean.isInBlackList) {
EventUtils.event("isInBlackList", "isInBlackList=${configBean.isInBlackList}") EventUtils.event("isInBlackList", "isInBlackList=${configBean.isInBlackList}")
showCallBack?.failed() showCallBack?.failed()
...@@ -196,6 +206,8 @@ object AdsMgr { ...@@ -196,6 +206,8 @@ object AdsMgr {
isUnLimit: Boolean = false, isUnLimit: Boolean = false,
showCallBack: AdsShowCallBack? = null, showCallBack: AdsShowCallBack? = null,
) { ) {
eventAdUt()
if (configBean.isInBlackList) { if (configBean.isInBlackList) {
EventUtils.event("isInBlackList", configBean.isInBlackList.toString()) EventUtils.event("isInBlackList", configBean.isInBlackList.toString())
showCallBack?.failed() showCallBack?.failed()
......
...@@ -4,6 +4,7 @@ import android.util.Base64 ...@@ -4,6 +4,7 @@ import android.util.Base64
import android.util.Log import android.util.Log
import com.base.appzxhy.BuildConfig import com.base.appzxhy.BuildConfig
import com.base.appzxhy.GlobalConfig import com.base.appzxhy.GlobalConfig
import com.base.appzxhy.bean.config.ConfigBean
import com.base.appzxhy.utils.AppPreferences import com.base.appzxhy.utils.AppPreferences
import com.base.appzxhy.utils.LogEx import com.base.appzxhy.utils.LogEx
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
...@@ -22,6 +23,26 @@ object NewComUtils { ...@@ -22,6 +23,26 @@ object NewComUtils {
private const val PACKAGE_NAME_PREFIX = GlobalConfig.PACKAGE_NAME private const val PACKAGE_NAME_PREFIX = GlobalConfig.PACKAGE_NAME
private const val DATA_KEY = "data" private const val DATA_KEY = "data"
//sp配置缓存
var spConfig = ""
get() {
return AppPreferences.getInstance().getString("spConfig", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("spConfig", value, true)
}
//上次请求时间
private var lastRequestTime = 0L
get() {
return AppPreferences.getInstance().getLong("lastRequestTime", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("lastRequestTime", value, true)
}
private val url: String by lazy { private val url: String by lazy {
val packageName = GlobalConfig.PACKAGE_NAME val packageName = GlobalConfig.PACKAGE_NAME
val appCode = packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault()) val appCode = packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault())
...@@ -39,7 +60,7 @@ object NewComUtils { ...@@ -39,7 +60,7 @@ object NewComUtils {
"&aid=${AppPreferences.getInstance().getString("uuid", "")}" "&aid=${AppPreferences.getInstance().getString("uuid", "")}"
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
s = "$s&mode=3" s = "$s&mode=4"
} }
s s
// mode =3 google mode=2 facebook mode=1 自然,mode=4 测试 // mode =3 google mode=2 facebook mode=1 自然,mode=4 测试
...@@ -48,7 +69,22 @@ object NewComUtils { ...@@ -48,7 +69,22 @@ object NewComUtils {
fun requestCfg(callback: (json: String?) -> Unit) { fun requestCfg(callback: (json: String?) -> Unit) {
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
val passHour = (System.currentTimeMillis() - lastRequestTime) / 3600000
if (BuildConfig.DEBUG) {
lastRequestTime = 0L
}
if (lastRequestTime != 0L && passHour < ConfigBean.configBean.getConfigInterval) {
callback.invoke(null)
Log.e(TAG, "请求间隔 passHour=$passHour")
return@launch
}
val response = doGet() val response = doGet()
if (response == null) { if (response == null) {
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
...@@ -64,8 +100,10 @@ object NewComUtils { ...@@ -64,8 +100,10 @@ object NewComUtils {
} }
return@launch return@launch
} }
lastRequestTime = System.currentTimeMillis()
val decryptedData = AESHelper.decrypt(data) val decryptedData = AESHelper.decrypt(data)
LogEx.logDebug(TAG, "decryptedData=$decryptedData")
spConfig = decryptedData
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
callback(decryptedData) callback(decryptedData)
} }
......
...@@ -81,7 +81,7 @@ class StayJobService : JobService() { ...@@ -81,7 +81,7 @@ class StayJobService : JobService() {
} }
private fun notifyForeground() { private fun notifyForeground() {
LogEx.logDebug(TAG, "notifyForeground") // LogEx.logDebug(TAG, "notifyForeground")
val notificationManager = val notificationManager =
getSystemService(NOTIFICATION_SERVICE) as NotificationManager getSystemService(NOTIFICATION_SERVICE) as NotificationManager
......
...@@ -25,7 +25,7 @@ class BatteryReceiver( ...@@ -25,7 +25,7 @@ class BatteryReceiver(
var mA = 0.0F//电流 var mA = 0.0F//电流
var avmA = 0.0F//平均电流 var avmA = 0.0F//平均电流
fun register(context: Context) { fun registerBatteryReceiver(context: Context) {
val intentFilter = IntentFilter().apply { val intentFilter = IntentFilter().apply {
addAction(Intent.ACTION_BATTERY_CHANGED) addAction(Intent.ACTION_BATTERY_CHANGED)
} }
...@@ -71,5 +71,6 @@ class BatteryReceiver( ...@@ -71,5 +71,6 @@ class BatteryReceiver(
private fun uiHandle(context: Context) { private fun uiHandle(context: Context) {
} }
} }
\ No newline at end of file
...@@ -21,6 +21,7 @@ import com.base.appzxhy.utils.ClipboardUtils.copyText ...@@ -21,6 +21,7 @@ import com.base.appzxhy.utils.ClipboardUtils.copyText
import com.base.appzxhy.utils.MyAnimationUtils import com.base.appzxhy.utils.MyAnimationUtils
import com.base.appzxhy.utils.ToastUtils.toast import com.base.appzxhy.utils.ToastUtils.toast
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.GsonBuilder
class SettingsFragment : BaseFragment<FragmentSettingsBinding>(FragmentSettingsBinding::inflate) { class SettingsFragment : BaseFragment<FragmentSettingsBinding>(FragmentSettingsBinding::inflate) {
...@@ -52,8 +53,9 @@ class SettingsFragment : BaseFragment<FragmentSettingsBinding>(FragmentSettingsB ...@@ -52,8 +53,9 @@ class SettingsFragment : BaseFragment<FragmentSettingsBinding>(FragmentSettingsB
} }
binding.tvSettings.setOnClickListener { binding.tvSettings.setOnClickListener {
val configBean = ConfigBean() val configBean = ConfigBean.configBean
val json = Gson().toJson(configBean) val gson = GsonBuilder().setPrettyPrinting().create()
val json = gson.toJson(configBean)
requireContext().copyText("json", json) requireContext().copyText("json", json)
requireContext().toast("copy json") requireContext().toast("copy json")
} }
......
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