[3.2.0][应用升级] 优化升级弹窗展示逻辑,防止Activity未创建导致崩溃

This commit is contained in:
renwj
2023-05-25 15:36:44 +08:00
parent 9954f46c70
commit c4510198d3

View File

@@ -146,7 +146,15 @@ class UpgradeAppNetWorkManager private constructor() {
Log.d("ApkInstaller", "EB5设备直接走静默不弹窗...")
CallerDevaToolsManager.downLoadPackage(if (isGoFullUpgrade) APK else PATCH, downloadUrl.substring(downloadUrl.lastIndexOf("/") + 1), downloadUrl)
} else {
withContext(Dispatchers.Main) {
var activity = AppStateManager.currentActivity()
while (activity == null) {
delay(2000)
activity = AppStateManager.currentActivity()
if (activity != null) {
break
}
}
activity?.lifeCycleScope?.launchWhenResumed {
showUpgradeDialog(downloadUrl.substring(downloadUrl.lastIndexOf("/") + 1), downloadUrl, info.result.installTitle, info.result.installContent, info.result.installType)
}
}