[2.15.0] 添加下载错误的回调

This commit is contained in:
lixiaopeng
2023-04-19 15:26:56 +08:00
parent 570147ca0f
commit 124e21f601
6 changed files with 37 additions and 4 deletions

View File

@@ -60,7 +60,7 @@ class UpgradeAppNetWorkManager private constructor() {
provider?.recordUpgradeRecord(sn ?: "", macAddress, type, FunctionBuildConfig.isSupportPatchUpgrade)
provider?.recordUpgradeRequestStart()
val info = mUpgradeApiService.getUpgradeInfo(requestBody)
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")
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 --versionCode:$versionCode")
if (info.result != null) {
provider?.recordUpgradeRequestSuccess(GsonUtils.toJson(info))
doUpgrade(info)

View File

@@ -2,6 +2,7 @@ package com.zhjt.mogo_core_function_devatools.upgrade
import android.content.Context
import android.content.pm.PackageInstaller
import android.util.Log
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.upgrade.IMoGoUpgradeProvider
import com.mogo.eagle.core.function.call.base.CallerBase
@@ -229,10 +230,17 @@ class UpgradeManager : IDownload {
CallerDevaToolsUpgradeListenerManager.addListener(
TAG,
object : IMogoDevaToolsUpgradeListener {
override fun onStart(url: String?) {}
override fun onPause(url: String?) {}
override fun onStart(url: String?) {
CallerLogger.d("$M_DEVA$TAG", "updateUpgradeProgress onStart ----> ")
}
override fun onPause(url: String?) {
CallerLogger.d("$M_DEVA$TAG", "updateUpgradeProgress onPause ----> ")
}
override fun onProgress(url: String?, length: Int) {
updateStatusBarDownloadView(true, "download", length)
// CallerLogger.d("$M_DEVA$TAG", "updateUpgradeProgress onPause ----> length = $length")
if (length in 1..99) {
updateStatusBarDownloadView(true, "download", length)
}
}
override fun onFinished(url: String?, localPath: String) {
@@ -242,6 +250,10 @@ class UpgradeManager : IDownload {
}
override fun onError(url: String?, errorMsg: String?) {
CallerLogger.d("$M_DEVA$TAG", "updateUpgradeProgress errorMsg = $errorMsg")
Log.e(TAG, "updateUpgradeProgress errorMsg = $errorMsg")
//出错后去掉下载进度ui提示检查网络
updateStatusBarDownloadView(false, "download", 0)
}
})
}