[2.15.0] 优化obu升级
This commit is contained in:
@@ -185,7 +185,6 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
|
||||
override fun updateUpgradeProgress() {
|
||||
upgradeManager.updateUpgradeProgress(mContext!!)
|
||||
upgradeManager.updateObuUpgradeStatus(mContext!!)
|
||||
}
|
||||
|
||||
override fun showStatusBar(ctx: Context, container: ViewGroup) {
|
||||
|
||||
@@ -185,6 +185,7 @@ class BindingCarManager : IMoGoAutopilotCarConfigListener {
|
||||
* obu的升级,只需要司机屏连接
|
||||
*/
|
||||
fun queryObuUpgrade(obuVersionName: String) {
|
||||
CallerLogger.d("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", "screenType = $screenType ----role = $role")
|
||||
if (screenType == 1) {
|
||||
CallerLogger.d("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}","queryObuUpgrade isConnected = ${CallerObuApiManager.isConnected()} --- mAddress = $mAddress")
|
||||
ObuUpgradeAppNetWorkManager.instance?.getObuUpgradeInfo(mContext, if(!mAddress.isNullOrEmpty()) mAddress else SharedPrefsMgr.getInstance(mContext!!).getString(SharedPrefsConstants.APP_MAC), obuVersionName)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.zhjt.mogo_core_function_devatools.upgrade
|
||||
|
||||
import android.content.*
|
||||
import android.util.Log
|
||||
import com.mogo.cloud.passport.*
|
||||
import com.mogo.commons.constants.*
|
||||
import com.mogo.eagle.core.data.deva.bindingcar.*
|
||||
import com.mogo.eagle.core.data.obu.MogoObuConst.TAG_UPGRADE_OBU
|
||||
import com.mogo.eagle.core.function.api.devatools.download.DownloadType.OBU
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager.downLoadPackage
|
||||
import com.mogo.eagle.core.function.call.obu.CallerObuApiManager.deleteObuFile
|
||||
@@ -43,22 +45,22 @@ class ObuUpgradeAppNetWorkManager private constructor() {
|
||||
scope.launch {
|
||||
try {
|
||||
val sn = MoGoAiCloudClientConfig.getInstance().sn
|
||||
d(SceneConstant.M_BINDING + TAG, "getObuUpgradeInfo mac = $mac ---sn = $sn ---versionName = $versionName")
|
||||
d(SceneConstant.M_BINDING + TAG_UPGRADE_OBU, "getObuUpgradeInfo mac = $mac ---sn = $sn ---versionName = $versionName --host = ${HostConst.getHost()}")
|
||||
val request = UpgradeAppRequest(sn, mac, "7", null, "0")
|
||||
val requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request))
|
||||
val info = mUpgradeApiService.getUpgradeInfo(requestBody)
|
||||
if (info.result == null) {
|
||||
d(SceneConstant.M_BINDING + TAG, "getObuUpgradeInfo onNext info == null")
|
||||
d(SceneConstant.M_BINDING + TAG_UPGRADE_OBU, "getObuUpgradeInfo onNext info == null")
|
||||
deleteObuFile()
|
||||
} else {
|
||||
d(SceneConstant.M_BINDING + TAG, "getObuUpgradeInfo appFileName = " + info.result.appFileName + " ----url = " + info.result.appUrl + " ----name = " + info.result.versionName + " --obuVersionName =" + versionName + " ---info.result = " + info.result)
|
||||
d(SceneConstant.M_BINDING + TAG_UPGRADE_OBU, "getObuUpgradeInfo appFileName = " + info.result.appFileName + " ----url = " + info.result.appUrl + " ----name = " + info.result.versionName + " --obuVersionName =" + versionName + " ---info.result = " + info.result)
|
||||
if (info.result.versionName.toString() != versionName) { //判断是否下载,当文件名称不一致的时候,就下载
|
||||
downLoadPackage(OBU, info.result.appFileName, info.result.appUrl)
|
||||
}
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
e(SceneConstant.M_BINDING + TAG, "getObuUpgradeInfo e = $t") //请求出错,需要删除相关文件
|
||||
e(SceneConstant.M_BINDING + TAG_UPGRADE_OBU, "getObuUpgradeInfo e = $t") //请求出错,需要删除相关文件
|
||||
deleteObuFile()
|
||||
}
|
||||
}
|
||||
@@ -66,7 +68,6 @@ class ObuUpgradeAppNetWorkManager private constructor() {
|
||||
|
||||
companion object {
|
||||
@Volatile private var requestNoticeManager: ObuUpgradeAppNetWorkManager? = null
|
||||
private const val TAG = "ObuUpgrade"
|
||||
val instance: ObuUpgradeAppNetWorkManager?
|
||||
get() {
|
||||
if (requestNoticeManager == null) {
|
||||
|
||||
@@ -207,6 +207,8 @@ class UpgradeManager : IDownload {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (type == OBU) {
|
||||
handleObuUpgrade(localPath)
|
||||
}
|
||||
CallerDevaToolsUpgradeListenerManager.invokeUpgradeFinish(downloadUrl, localPath)
|
||||
}
|
||||
@@ -219,6 +221,10 @@ class UpgradeManager : IDownload {
|
||||
val type = types[downloadUrl]
|
||||
if (type == APK || type == PATCH) {
|
||||
scope.launch { upgradeProvider?.recordDownloadFailed(downloadUrl,errorMsg ?: "下载失败") }
|
||||
} else if (type == OBU) {
|
||||
CallerLogger.e("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", "----updateObuUpgradeStatus errorMsg = $errorMsg ")
|
||||
//下载失败,删除文件夹
|
||||
CallerObuApiManager.deleteObuFile()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,48 +264,63 @@ class UpgradeManager : IDownload {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 对下载的obu文件进行处理
|
||||
*/
|
||||
private fun handleObuUpgrade(localPath: String) {
|
||||
//下载完成,解压文件
|
||||
try {
|
||||
CallerLogger.d("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", " onFinished localPath = $localPath")
|
||||
Log.d("liyz", " onFinished localPath = $localPath")
|
||||
val dest = File(localPath)
|
||||
val files = ZipUtils.unzipFile(localPath, Config.downLoadUnzipObuPath)
|
||||
CallerLogger.d("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", " onFinished file = ${Config.downLoadObuPath + dest.name} -----files = $files ")
|
||||
//1传给obu升级,升级成功,2需要删除相应文件夹
|
||||
var md5Path = ""
|
||||
var tarPath = ""
|
||||
for (f in files) {
|
||||
if (f.path.contains(".md5")) {
|
||||
md5Path = f.path
|
||||
}
|
||||
if (f.path.contains(".gz")) {
|
||||
tarPath = f.path
|
||||
}
|
||||
}
|
||||
CallerLogger.d("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", "updateObuUpgradeStatus ---md5Path = $md5Path -----tarPath = $tarPath ")
|
||||
CallerObuApiManager.uploadObuPack(arrayOf(md5Path, tarPath))
|
||||
} catch (e: IOException) {
|
||||
CallerLogger.e("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", "----updateObuUpgradeStatus e = $e ")
|
||||
//解压失败,删除文件夹
|
||||
CallerObuApiManager.deleteObuFile()
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* obu升级包下载监听
|
||||
*/
|
||||
fun updateObuUpgradeStatus(context: Context) {
|
||||
CallerDevaToolsUpgradeListenerManager.addListener(
|
||||
TAG,
|
||||
object : IMogoDevaToolsUpgradeListener {
|
||||
override fun onStart(url: String?) {}
|
||||
override fun onPause(url: String?) {}
|
||||
override fun onProgress(url: String?, length: Int) {
|
||||
}
|
||||
|
||||
override fun onFinished(url: String?, localPath: String) {
|
||||
//下载完成,解压文件
|
||||
try {
|
||||
val dest = File(localPath)
|
||||
val files = ZipUtils.unzipFile(localPath, Config.downLoadUnzipObuPath)
|
||||
CallerLogger.d("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", " onFinished file = ${Config.downLoadObuPath + dest.name} -----files = $files ")
|
||||
//1传给obu升级,升级成功,2需要删除相应文件夹
|
||||
var md5Path = ""
|
||||
var tarPath = ""
|
||||
for (f in files) {
|
||||
if (f.path.contains(".md5")) {
|
||||
md5Path = f.path
|
||||
}
|
||||
if (f.path.contains(".gz")) {
|
||||
tarPath = f.path
|
||||
}
|
||||
}
|
||||
CallerLogger.d("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", "updateObuUpgradeStatus ---md5Path = $md5Path -----tarPath = $tarPath ")
|
||||
CallerObuApiManager.uploadObuPack(arrayOf(md5Path, tarPath))
|
||||
} catch (e: IOException) {
|
||||
//解压失败,删除文件夹
|
||||
CallerObuApiManager.deleteObuFile()
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(url: String?, errorMsg: String?) {
|
||||
//下载失败,删除文件夹
|
||||
CallerObuApiManager.deleteObuFile()
|
||||
}
|
||||
})
|
||||
}
|
||||
// fun updateObuUpgradeStatus(context: Context) {
|
||||
// CallerDevaToolsUpgradeListenerManager.addListener(
|
||||
// TAG,
|
||||
// object : IMogoDevaToolsUpgradeListener {
|
||||
// override fun onStart(url: String?) {
|
||||
// CallerLogger.d("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", "----updateObuUpgradeStatus onStart ")
|
||||
// }
|
||||
// override fun onPause(url: String?) {
|
||||
// CallerLogger.d("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", "----updateObuUpgradeStatus onPause ")
|
||||
// }
|
||||
// override fun onProgress(url: String?, length: Int) {
|
||||
// }
|
||||
//
|
||||
// override fun onFinished(url: String?, localPath: String) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun onError(url: String?, errorMsg: String?) {
|
||||
// CallerLogger.e("${SceneConstant.M_OBU}${MogoObuConst.TAG_UPGRADE_OBU}", "----updateObuUpgradeStatus errorMsg = $errorMsg ")
|
||||
// //下载失败,删除文件夹
|
||||
// CallerObuApiManager.deleteObuFile()
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user