[6.4.4][apm] 注释掉apm相关逻辑
This commit is contained in:
@@ -18,7 +18,7 @@ import com.mogo.eagle.core.data.deva.scene.SceneModule
|
||||
import com.mogo.eagle.core.data.deva.scene.SceneTAG
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.function.api.devatools.IDevaToolsProvider
|
||||
import com.mogo.eagle.core.function.api.devatools.apm.*
|
||||
//import com.mogo.eagle.core.function.api.devatools.apm.*
|
||||
import com.mogo.eagle.core.function.api.devatools.block.*
|
||||
import com.mogo.eagle.core.function.api.devatools.strict.*
|
||||
import com.mogo.eagle.core.function.api.devatools.download.*
|
||||
@@ -37,7 +37,7 @@ import com.tencent.matrix.report.Issue
|
||||
import com.tencent.matrix.trace.TracePlugin
|
||||
import com.tencent.matrix.trace.config.SharePluginInfo
|
||||
import com.tencent.matrix.trace.config.TraceConfig
|
||||
import com.zhjt.mogo_core_function_devatools.apm.*
|
||||
//import com.zhjt.mogo_core_function_devatools.apm.*
|
||||
import com.mogo.eagle.core.function.api.upgrade.*
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.utilcode.kotlin.lifeCycleScope
|
||||
@@ -90,7 +90,7 @@ class DevaToolsProvider : IDevaToolsProvider, IAppStateListener {
|
||||
|
||||
private var mContext: Context? = null
|
||||
|
||||
private val apmEnvProvider by lazy { ApmEnvProviderImpl() }
|
||||
// private val apmEnvProvider by lazy { ApmEnvProviderImpl() }
|
||||
|
||||
private val strictModeProvider by lazy { StrictModeProviderImpl() }
|
||||
|
||||
@@ -159,7 +159,7 @@ class DevaToolsProvider : IDevaToolsProvider, IAppStateListener {
|
||||
//升级(鹰眼/工控)与监控服务
|
||||
iPCReportManager.initServer()
|
||||
BindingCarManager.init(mContext!!)
|
||||
apmEnvProvider.init(if(DebugConfig.isDebug()) "0" else "1", "${ DebugConfig.getNetMode() }", mDockerVersion ?: "")
|
||||
// apmEnvProvider.init(if(DebugConfig.isDebug()) "0" else "1", "${ DebugConfig.getNetMode() }", mDockerVersion ?: "")
|
||||
BadCaseManager.init(mContext!!)
|
||||
if (DebugConfig.isDebug()) {
|
||||
SdtManager.init(mContext!!, true, DetectResultImpl())
|
||||
@@ -513,13 +513,13 @@ class DevaToolsProvider : IDevaToolsProvider, IAppStateListener {
|
||||
}
|
||||
|
||||
override fun envConfigChange(cityCode: String, netMode: Int) {
|
||||
apmEnvProvider.onEnvChanged(if(DebugConfig.isDebug()) "0" else "1", "${ DebugConfig.getNetMode() }", mDockerVersion ?: "")
|
||||
// apmEnvProvider.onEnvChanged(if(DebugConfig.isDebug()) "0" else "1", "${ DebugConfig.getNetMode() }", mDockerVersion ?: "")
|
||||
EnvChangeManager.changeTo(cityCode, netMode)
|
||||
}
|
||||
|
||||
override fun dockerVersion(dockerVersion: String?) {
|
||||
mDockerVersion = dockerVersion
|
||||
apmEnvProvider.onEnvChanged(if(DebugConfig.isDebug()) "0" else "1","${ DebugConfig.getNetMode() }", dockerVersion ?: "")
|
||||
// apmEnvProvider.onEnvChanged(if(DebugConfig.isDebug()) "0" else "1","${ DebugConfig.getNetMode() }", dockerVersion ?: "")
|
||||
BadCaseConfig.dockerVersion = dockerVersion
|
||||
}
|
||||
|
||||
@@ -550,7 +550,7 @@ class DevaToolsProvider : IDevaToolsProvider, IAppStateListener {
|
||||
BindingCarManager.queryAppUpgrade()
|
||||
}
|
||||
|
||||
override fun apmEnvProvider(): IApmEnvProvider = apmEnvProvider
|
||||
// override fun apmEnvProvider(): IApmEnvProvider = apmEnvProvider
|
||||
|
||||
override fun queryObuUpgrade(obuVersionName: String) {
|
||||
BindingCarManager.queryObuUpgrade(obuVersionName)
|
||||
|
||||
@@ -1,145 +1,145 @@
|
||||
package com.zhjt.mogo_core_function_devatools.apm
|
||||
|
||||
import android.os.Process
|
||||
import android.text.TextUtils
|
||||
import android.widget.Toast
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_INIT_ENV_RESTART
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_SOURCE_INIT
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_TYPE_STATUS
|
||||
import com.mogo.eagle.core.function.api.devatools.apm.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.zhjt.mogo_core_function_devatools.apm.config.*
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import kotlinx.coroutines.*
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import kotlin.coroutines.*
|
||||
|
||||
class ApmEnvProviderImpl: IApmEnvProvider, CoroutineScope {
|
||||
|
||||
private val TAG = "ApmEnvProvider"
|
||||
|
||||
private val scope by lazy { CoroutineScope(Dispatchers.IO + SupervisorJob()) }
|
||||
|
||||
private val hasInit by lazy { AtomicBoolean(false) }
|
||||
|
||||
private val mBuildType by lazy { AtomicReference<String>() }
|
||||
private val mNetType by lazy { AtomicReference<String>() }
|
||||
private val mDockerVersion by lazy { AtomicReference<String>() }
|
||||
|
||||
override val coroutineContext: CoroutineContext
|
||||
get() = scope.coroutineContext
|
||||
|
||||
override fun init(buildType: String, netType: String, dockerVersion: String) {
|
||||
launch {
|
||||
if (ApmEnvConfig.isFirstEnter()) {
|
||||
if (!TextUtils.isEmpty(buildType)) {
|
||||
ApmEnvConfig.setBuildType(buildType)
|
||||
}
|
||||
if (!TextUtils.isEmpty(netType)) {
|
||||
ApmEnvConfig.setNetType(netType)
|
||||
}
|
||||
if (!TextUtils.isEmpty(dockerVersion)) {
|
||||
ApmEnvConfig.setDockerVersion(dockerVersion)
|
||||
}
|
||||
}
|
||||
hasInit.set(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onEnvChanged(buildType: String, netType: String, dockerVersion: String) {
|
||||
if (!hasInit.get()) {
|
||||
return
|
||||
}
|
||||
if (mBuildType.get() == buildType && mNetType.get() == netType && mDockerVersion.get() == dockerVersion) {
|
||||
return
|
||||
}
|
||||
launch {
|
||||
var buildTypeChanged = false
|
||||
if (ApmEnvConfig.getBuildType() != buildType) {
|
||||
buildTypeChanged = true
|
||||
ApmEnvConfig.setBuildType(buildType)
|
||||
}
|
||||
var netTypeChanged = false
|
||||
if (ApmEnvConfig.getNetType() != netType) {
|
||||
netTypeChanged = true
|
||||
ApmEnvConfig.setNetType(netType)
|
||||
}
|
||||
var dockerVersionChanged = false
|
||||
val version = ApmEnvConfig.getDockerVersion()
|
||||
if (!TextUtils.isEmpty(version) && !TextUtils.isEmpty(dockerVersion) && version != dockerVersion) {
|
||||
val f1 = version?.endsWith("release", true) == true
|
||||
val f2 = dockerVersion.endsWith("release", true)
|
||||
dockerVersionChanged = if (f1 && f2) false else f1 || f2
|
||||
if (dockerVersionChanged) {
|
||||
ApmEnvConfig.setDockerVersion(dockerVersion)
|
||||
}
|
||||
}
|
||||
var isFirstDockerVersionSet = false
|
||||
if (TextUtils.isEmpty(version) && !TextUtils.isEmpty(dockerVersion)) {
|
||||
isFirstDockerVersionSet = true
|
||||
ApmEnvConfig.setDockerVersion(dockerVersion)
|
||||
}
|
||||
var isEnvValid = true
|
||||
if (dockerVersionChanged || isFirstDockerVersionSet) {
|
||||
isEnvValid = buildType == "0" || (buildType == "1" && netType == DebugConfig.NET_MODE_RELEASE.toString() && dockerVersion.endsWith("release", true))
|
||||
}
|
||||
val appRelaunched = ApmEnvConfig.isAppRelaunched()
|
||||
if ((!isEnvValid || (buildTypeChanged || netTypeChanged || dockerVersionChanged)) && !appRelaunched) {
|
||||
ApmEnvConfig.setAppRelaunched(true)
|
||||
restartApp(mapOf<String,Any>("buildType" to buildType, "netType" to netType,"dockerVersion" to dockerVersion))
|
||||
return@launch
|
||||
}
|
||||
if (isFirstDockerVersionSet) {
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (appRelaunched) {
|
||||
ApmEnvConfig.setAppRelaunched(false)
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(buildType)) {
|
||||
mBuildType.set(buildType)
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(netType)) {
|
||||
mNetType.set(netType)
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(dockerVersion)) {
|
||||
mDockerVersion.set(dockerVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = CHAIN_TYPE_STATUS,
|
||||
linkCode = CHAIN_SOURCE_INIT,
|
||||
nodeAliasCode = CHAIN_CODE_INIT_ENV_RESTART,
|
||||
paramIndexes = [0]
|
||||
)
|
||||
private fun restartApp(envStr:Map<String,Any>) {
|
||||
launch(Dispatchers.Main) {
|
||||
Toast.makeText(Utils.getApp(), "发现系统环境不一致,正在重启...", Toast.LENGTH_SHORT).show()
|
||||
delay(50)
|
||||
Utils.getApp().packageManager.getLaunchIntentForPackage(Utils.getApp().packageName)?.also {
|
||||
ActivityUtils.startActivity(it)
|
||||
}
|
||||
Process.killProcess(Process.myPid())
|
||||
}
|
||||
}
|
||||
|
||||
override fun isDebugEnabled(): Boolean? {
|
||||
return runBlocking {
|
||||
val oldBuildType = ApmEnvConfig.getBuildType()
|
||||
val oldNetType = ApmEnvConfig.getNetType()
|
||||
val oldDockerVersion = ApmEnvConfig.getDockerVersion()
|
||||
if (TextUtils.isEmpty(oldBuildType) || TextUtils.isEmpty(oldNetType) || TextUtils.isEmpty(oldDockerVersion)) {
|
||||
null
|
||||
} else {
|
||||
DebugConfig.isDebug() || (oldBuildType != "1" || oldNetType != DebugConfig.NET_MODE_RELEASE.toString() || !(oldDockerVersion?.endsWith("release", true) ?: false))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.zhjt.mogo_core_function_devatools.apm
|
||||
//
|
||||
//import android.os.Process
|
||||
//import android.text.TextUtils
|
||||
//import android.widget.Toast
|
||||
//import com.mogo.commons.debug.DebugConfig
|
||||
//import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_CODE_INIT_ENV_RESTART
|
||||
//import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_SOURCE_INIT
|
||||
//import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_TYPE_STATUS
|
||||
////import com.mogo.eagle.core.function.api.devatools.apm.*
|
||||
//import com.mogo.eagle.core.utilcode.util.*
|
||||
//import com.zhjt.mogo_core_function_devatools.apm.config.*
|
||||
//import com.zhjt.service.chain.ChainLog
|
||||
//import kotlinx.coroutines.*
|
||||
//import java.util.concurrent.atomic.AtomicBoolean
|
||||
//import java.util.concurrent.atomic.AtomicReference
|
||||
//import kotlin.coroutines.*
|
||||
//
|
||||
//class ApmEnvProviderImpl: IApmEnvProvider, CoroutineScope {
|
||||
//
|
||||
// private val TAG = "ApmEnvProvider"
|
||||
//
|
||||
// private val scope by lazy { CoroutineScope(Dispatchers.IO + SupervisorJob()) }
|
||||
//
|
||||
// private val hasInit by lazy { AtomicBoolean(false) }
|
||||
//
|
||||
// private val mBuildType by lazy { AtomicReference<String>() }
|
||||
// private val mNetType by lazy { AtomicReference<String>() }
|
||||
// private val mDockerVersion by lazy { AtomicReference<String>() }
|
||||
//
|
||||
// override val coroutineContext: CoroutineContext
|
||||
// get() = scope.coroutineContext
|
||||
//
|
||||
// override fun init(buildType: String, netType: String, dockerVersion: String) {
|
||||
// launch {
|
||||
// if (ApmEnvConfig.isFirstEnter()) {
|
||||
// if (!TextUtils.isEmpty(buildType)) {
|
||||
// ApmEnvConfig.setBuildType(buildType)
|
||||
// }
|
||||
// if (!TextUtils.isEmpty(netType)) {
|
||||
// ApmEnvConfig.setNetType(netType)
|
||||
// }
|
||||
// if (!TextUtils.isEmpty(dockerVersion)) {
|
||||
// ApmEnvConfig.setDockerVersion(dockerVersion)
|
||||
// }
|
||||
// }
|
||||
// hasInit.set(true)
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun onEnvChanged(buildType: String, netType: String, dockerVersion: String) {
|
||||
// if (!hasInit.get()) {
|
||||
// return
|
||||
// }
|
||||
// if (mBuildType.get() == buildType && mNetType.get() == netType && mDockerVersion.get() == dockerVersion) {
|
||||
// return
|
||||
// }
|
||||
// launch {
|
||||
// var buildTypeChanged = false
|
||||
// if (ApmEnvConfig.getBuildType() != buildType) {
|
||||
// buildTypeChanged = true
|
||||
// ApmEnvConfig.setBuildType(buildType)
|
||||
// }
|
||||
// var netTypeChanged = false
|
||||
// if (ApmEnvConfig.getNetType() != netType) {
|
||||
// netTypeChanged = true
|
||||
// ApmEnvConfig.setNetType(netType)
|
||||
// }
|
||||
// var dockerVersionChanged = false
|
||||
// val version = ApmEnvConfig.getDockerVersion()
|
||||
// if (!TextUtils.isEmpty(version) && !TextUtils.isEmpty(dockerVersion) && version != dockerVersion) {
|
||||
// val f1 = version?.endsWith("release", true) == true
|
||||
// val f2 = dockerVersion.endsWith("release", true)
|
||||
// dockerVersionChanged = if (f1 && f2) false else f1 || f2
|
||||
// if (dockerVersionChanged) {
|
||||
// ApmEnvConfig.setDockerVersion(dockerVersion)
|
||||
// }
|
||||
// }
|
||||
// var isFirstDockerVersionSet = false
|
||||
// if (TextUtils.isEmpty(version) && !TextUtils.isEmpty(dockerVersion)) {
|
||||
// isFirstDockerVersionSet = true
|
||||
// ApmEnvConfig.setDockerVersion(dockerVersion)
|
||||
// }
|
||||
// var isEnvValid = true
|
||||
// if (dockerVersionChanged || isFirstDockerVersionSet) {
|
||||
// isEnvValid = buildType == "0" || (buildType == "1" && netType == DebugConfig.NET_MODE_RELEASE.toString() && dockerVersion.endsWith("release", true))
|
||||
// }
|
||||
// val appRelaunched = ApmEnvConfig.isAppRelaunched()
|
||||
// if ((!isEnvValid || (buildTypeChanged || netTypeChanged || dockerVersionChanged)) && !appRelaunched) {
|
||||
// ApmEnvConfig.setAppRelaunched(true)
|
||||
// restartApp(mapOf<String,Any>("buildType" to buildType, "netType" to netType,"dockerVersion" to dockerVersion))
|
||||
// return@launch
|
||||
// }
|
||||
// if (isFirstDockerVersionSet) {
|
||||
// return@launch
|
||||
// }
|
||||
//
|
||||
// if (appRelaunched) {
|
||||
// ApmEnvConfig.setAppRelaunched(false)
|
||||
// }
|
||||
//
|
||||
// if (!TextUtils.isEmpty(buildType)) {
|
||||
// mBuildType.set(buildType)
|
||||
// }
|
||||
//
|
||||
// if (!TextUtils.isEmpty(netType)) {
|
||||
// mNetType.set(netType)
|
||||
// }
|
||||
//
|
||||
// if (!TextUtils.isEmpty(dockerVersion)) {
|
||||
// mDockerVersion.set(dockerVersion)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @ChainLog(
|
||||
// linkChainLog = CHAIN_TYPE_STATUS,
|
||||
// linkCode = CHAIN_SOURCE_INIT,
|
||||
// nodeAliasCode = CHAIN_CODE_INIT_ENV_RESTART,
|
||||
// paramIndexes = [0]
|
||||
// )
|
||||
// private fun restartApp(envStr:Map<String,Any>) {
|
||||
// launch(Dispatchers.Main) {
|
||||
// Toast.makeText(Utils.getApp(), "发现系统环境不一致,正在重启...", Toast.LENGTH_SHORT).show()
|
||||
// delay(50)
|
||||
// Utils.getApp().packageManager.getLaunchIntentForPackage(Utils.getApp().packageName)?.also {
|
||||
// ActivityUtils.startActivity(it)
|
||||
// }
|
||||
// Process.killProcess(Process.myPid())
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// override fun isDebugEnabled(): Boolean? {
|
||||
// return runBlocking {
|
||||
// val oldBuildType = ApmEnvConfig.getBuildType()
|
||||
// val oldNetType = ApmEnvConfig.getNetType()
|
||||
// val oldDockerVersion = ApmEnvConfig.getDockerVersion()
|
||||
// if (TextUtils.isEmpty(oldBuildType) || TextUtils.isEmpty(oldNetType) || TextUtils.isEmpty(oldDockerVersion)) {
|
||||
// null
|
||||
// } else {
|
||||
// DebugConfig.isDebug() || (oldBuildType != "1" || oldNetType != DebugConfig.NET_MODE_RELEASE.toString() || !(oldDockerVersion?.endsWith("release", true) ?: false))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user