[dev_opt_2.15.0] 调试面板添加升级信息的展示

This commit is contained in:
lixiaopeng
2023-04-04 17:21:56 +08:00
parent 8d41c335d6
commit 9f18e1c106
4 changed files with 71 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ import com.mogo.eagle.core.network.utils.*
import com.mogo.eagle.core.utilcode.breakpoint.Config
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.scene.*
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.*
import com.mogo.eagle.core.utilcode.util.FileUtils
import kotlinx.coroutines.*
@@ -44,6 +45,8 @@ class UpgradeAppNetWorkManager private constructor() {
val sn = MoGoAiCloudClientConfig.getInstance().sn //null
val macAddress = mac //"48:b0:2d:4d:31:7f"
val type = screenType //10
SharedPrefsMgr.getInstance(context!!).putString(SharedPrefsConstants.HOST_ADDRESS, HostConst.getHost())
try {
val records = provider?.getUpgradeRecords()?.also {
MogoAnalyticUtils.track("AppUpgradeRecord", it.let { TreeMap<String, Any>().also { itx -> itx.putAll(it) } })
@@ -57,6 +60,11 @@ class UpgradeAppNetWorkManager private constructor() {
provider?.recordUpgradeRecord(sn ?: "", macAddress, type, FunctionBuildConfig.isSupportPatchUpgrade)
provider?.recordUpgradeRequestStart()
val info = mUpgradeApiService.getUpgradeInfo(requestBody)
if (info != null) {
SharedPrefsMgr.getInstance(context!!).putString(SharedPrefsConstants.APP_UPGRADE_CONTENT, if (info.result != null) GsonUtils.toJson(info) + "--mac:$macAddress --type:$type --sn:$sn --versionName:$versionName" else "info.result == null --mac:$macAddress --type:$type --sn:$sn --versionName:$versionName")
} else {
SharedPrefsMgr.getInstance(context!!).putString(SharedPrefsConstants.APP_UPGRADE_CONTENT, "info == null --mac:$macAddress --type:$type --sn:$sn --versionName:$versionName")
}
if (info.result != null) {
provider?.recordUpgradeRequestSuccess(GsonUtils.toJson(info))
doUpgrade(info)
@@ -65,6 +73,9 @@ class UpgradeAppNetWorkManager private constructor() {
}
} catch (t: Throwable) {
t.printStackTrace()
SharedPrefsMgr.getInstance(context!!).putString(SharedPrefsConstants.APP_UPGRADE_CONTENT,
"$t--mac:$macAddress --type:$type --sn:$sn "
)
provider?.recordUpgradeRequestFailed(t.message ?: "更新接口请求失败")
deleteApkFile()
}