[3.2.0][应用升级] 优化因mac地址获取不到,导致的升级失败问题
This commit is contained in:
@@ -35,7 +35,7 @@ import com.zhjt.mogo_core_function_devatools.apm.*
|
||||
import com.mogo.eagle.core.function.api.upgrade.*
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.BadCaseManager
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig
|
||||
import com.zhjt.mogo_core_function_devatools.binding.BindingCarManager.Companion.bindingCarManager
|
||||
import com.zhjt.mogo_core_function_devatools.binding.*
|
||||
import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager
|
||||
import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigCenter.Companion.bizConfigCenter
|
||||
import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigImpl
|
||||
@@ -94,7 +94,7 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
//升级(鹰眼/工控)与监控服务
|
||||
iPCReportManager.initServer()
|
||||
moFangManager.init(mContext!!)
|
||||
bindingCarManager.init(mContext!!)
|
||||
BindingCarManager.init(mContext!!)
|
||||
apmEnvProvider.init(if(DebugConfig.isDebug()) "0" else "1", "${ DebugConfig.getNetMode() }", mDockerVersion ?: "")
|
||||
BadCaseManager.init()
|
||||
}
|
||||
@@ -319,29 +319,29 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
}
|
||||
|
||||
override fun modifyCarInfo(callBack: (ModifyBindingcarInfo) -> Unit) {
|
||||
bindingCarManager.modifyCarInfo(callBack)
|
||||
BindingCarManager.modifyCarInfo(callBack)
|
||||
}
|
||||
|
||||
override fun getBindingCarInfo(macAddress: String, widevineIDWithMd5: String) {
|
||||
bindingCarManager.getBindingCarInfo(macAddress, widevineIDWithMd5)
|
||||
BindingCarManager.getBindingCarInfo(macAddress, widevineIDWithMd5)
|
||||
}
|
||||
|
||||
override fun upgradeConfirm(images: List<String>, padSn: String, releaseId: String) {
|
||||
bindingCarManager.upgradeConfirm(images, padSn, releaseId)
|
||||
BindingCarManager.upgradeConfirm(images, padSn, releaseId)
|
||||
}
|
||||
|
||||
override fun queryContainers(padSn: String, dockerVersion: String) {
|
||||
bindingCarManager.queryContainers(padSn, dockerVersion)
|
||||
BindingCarManager.queryContainers(padSn, dockerVersion)
|
||||
}
|
||||
|
||||
override fun queryAppUpgrade() {
|
||||
bindingCarManager.queryAppUpgrade()
|
||||
BindingCarManager.queryAppUpgrade()
|
||||
}
|
||||
|
||||
override fun apmEnvProvider(): IApmEnvProvider = apmEnvProvider
|
||||
|
||||
override fun queryObuUpgrade(obuVersionName: String) {
|
||||
bindingCarManager.queryObuUpgrade(obuVersionName)
|
||||
BindingCarManager.queryObuUpgrade(obuVersionName)
|
||||
}
|
||||
|
||||
override fun upgradeProvider(): IMoGoUpgradeProvider? {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.zhjt.mogo_core_function_devatools.binding
|
||||
|
||||
import android.annotation.*
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import android.util.*
|
||||
import com.elegant.utils.UiThreadHandler
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.constants.SharedPrefsConstants
|
||||
@@ -27,15 +29,10 @@ import mogo.telematics.pad.MessagePad
|
||||
/**
|
||||
* 车辆绑定
|
||||
*/
|
||||
class BindingCarManager : IMoGoAutopilotCarConfigListener {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object BindingCarManager : IMoGoAutopilotCarConfigListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "BindingCarManager"
|
||||
|
||||
val bindingCarManager by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
BindingCarManager()
|
||||
}
|
||||
}
|
||||
private const val TAG = "BindingCarManager"
|
||||
|
||||
private var mContext: Context? = null
|
||||
|
||||
@@ -68,20 +65,7 @@ class BindingCarManager : IMoGoAutopilotCarConfigListener {
|
||||
if (!TextUtils.isEmpty(carConfigResp.macAddress)) {
|
||||
Logger.d("${SceneConstant.M_BINDING}${TAG}",
|
||||
"onAutopilotCarConfig carConfigResp.macAddress = ${carConfigResp.macAddress} ")
|
||||
var flag = false
|
||||
if (mAddress.isNullOrEmpty()) {
|
||||
flag = true
|
||||
}
|
||||
Logger.d("${SceneConstant.M_BINDING}${TAG}",
|
||||
"onAutopilotCarConfig - triggerUpgrade -> $flag")
|
||||
getBindingCarInfo(carConfigResp.macAddress, MoGoAiCloudClientConfig.getInstance().sn)
|
||||
if (flag) {
|
||||
queryAppUpgrade()
|
||||
val obuVersion = mObuVersion
|
||||
if (obuVersion != null) {
|
||||
queryObuUpgrade(obuVersion)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,12 +75,27 @@ class BindingCarManager : IMoGoAutopilotCarConfigListener {
|
||||
* @param macAddress
|
||||
*/
|
||||
fun getBindingCarInfo(macAddress: String, widevineIDWithMd5: String) {
|
||||
Log.d("UPGRADE", "-- getBindingCarInfo -- 1 -- : [mac: $macAddress, md5: $widevineIDWithMd5]")
|
||||
var flag = false
|
||||
if (!TextUtils.isEmpty(macAddress) && TextUtils.isEmpty(mAddress)) {
|
||||
Log.d("UPGRADE", "-- getBindingCarInfo -- 2 -- : [mac: $macAddress, md5: $widevineIDWithMd5]")
|
||||
flag = true
|
||||
}
|
||||
if (!TextUtils.isEmpty(macAddress) && !TextUtils.equals(macAddress, mAddress)) {
|
||||
mAddress = macAddress
|
||||
}
|
||||
if (flag) {
|
||||
Log.d("UPGRADE", "-- getBindingCarInfo -- 3 -- : [mac: $macAddress, md5: $widevineIDWithMd5]")
|
||||
queryAppUpgrade()
|
||||
val obuVersion = mObuVersion
|
||||
if (obuVersion != null && !TextUtils.isEmpty(obuVersion)) {
|
||||
queryObuUpgrade(obuVersion)
|
||||
}
|
||||
}
|
||||
CallerLogger.d("${SceneConstant.M_BINDING}${TAG}",
|
||||
"getBindingcarInfo macAddress = $macAddress--widevineIDWithMd5 = $widevineIDWithMd5 ---screenType = $screenType"
|
||||
)
|
||||
SharedPrefsMgr.getInstance(mContext!!).putString(SharedPrefsConstants.APP_MAC, macAddress)
|
||||
|
||||
mAddress = macAddress
|
||||
mWidevineIDWithMd5 = widevineIDWithMd5
|
||||
if (screenType == 1) { //司机屏
|
||||
driverScreen(macAddress, widevineIDWithMd5)
|
||||
@@ -183,12 +182,17 @@ class BindingCarManager : IMoGoAutopilotCarConfigListener {
|
||||
* 查询app是否需要升级
|
||||
*/
|
||||
fun queryAppUpgrade() {
|
||||
Logger.d("${SceneConstant.M_BINDING}${TAG}", "queryAppUpgrade---role.toString() = $role ---mAddress = $mAddress ---spMac = ${SharedPrefsMgr.getInstance(mContext!!).getString(SharedPrefsConstants.APP_MAC)}")
|
||||
(if (!mAddress.isNullOrEmpty()) mAddress else SharedPrefsMgr.getInstance(mContext!!)
|
||||
.getString(SharedPrefsConstants.APP_MAC))?.let {
|
||||
Logger.d("${SceneConstant.M_BINDING}${TAG}", "queryAppUpgrade---mAddress = $mAddress")
|
||||
Log.d("UPGRADE", "---- 1 ----")
|
||||
var macAddress = mAddress
|
||||
if (TextUtils.isEmpty(macAddress)) {
|
||||
Log.d("UPGRADE", "---- 2 ----")
|
||||
macAddress = SharedPrefsMgr.getInstance(mContext!!)
|
||||
.getString(SharedPrefsConstants.APP_MAC)
|
||||
}
|
||||
if (macAddress != null && !TextUtils.isEmpty(macAddress)) {
|
||||
Log.d("UPGRADE", "---- 3 ----[mac: $macAddress]")
|
||||
UpgradeAppNetWorkManager.instance
|
||||
?.getAppUpgradeInfo(mContext, it, role.toString() + "")
|
||||
?.getAppUpgradeInfo(mContext, macAddress, role.toString() + "")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class UpgradeAppNetWorkManager private constructor() {
|
||||
Log.d(TAG, "getAppUpgradeInfo: -> records:" + records?.entries?.joinToString(",") { itx -> "key:${itx.key} -> value:[${itx.value.joinToString(",") { "${it.first},${it.second}" } }]"})
|
||||
val versionCode = AppUtils.getAppVersionCode()
|
||||
val versionName = AppUtils.getAppVersionName()
|
||||
d(SceneConstant.M_BINDING + TAG, "getAppUpgradeInfo mac = $macAddress---type = $type---sn = $sn---versionCode =$versionCode---versionName =$versionName")
|
||||
Log.d(SceneConstant.M_BINDING + TAG, "getAppUpgradeInfo mac = $macAddress---type = $type---sn = $sn---versionCode =$versionCode---versionName =$versionName")
|
||||
val request = UpgradeAppRequest(sn, macAddress, type, versionName, "1")
|
||||
val requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request))
|
||||
provider?.recordUpgradeRecord(sn ?: "", macAddress, type, FunctionBuildConfig.isSupportPatchUpgrade)
|
||||
@@ -99,7 +99,7 @@ class UpgradeAppNetWorkManager private constructor() {
|
||||
private suspend fun doUpgrade(info: UpgradeAppInfo) {
|
||||
if (info.result != null) {
|
||||
val versionCode = AppUtils.getAppVersionCode()
|
||||
d(SceneConstant.M_BINDING + TAG, "UpgradeAppInfo url = " + info.result.appUrl + "----code = " + info.result.versionCode + "--versionCode =" + versionCode + "--info.result = " + info.result)
|
||||
Log.d(SceneConstant.M_BINDING + TAG, "UpgradeAppInfo url = " + info.result.appUrl + "----code = " + info.result.versionCode + "--versionCode =" + versionCode + "--info.result = " + info.result)
|
||||
if (info.result.versionCode > versionCode) {
|
||||
val patchInfo = info.result.patchInfo
|
||||
var downloadUrl: String = info.result.appUrl
|
||||
@@ -150,7 +150,7 @@ class UpgradeAppNetWorkManager private constructor() {
|
||||
deleteApkFile()
|
||||
}
|
||||
} else {
|
||||
d(SceneConstant.M_BINDING + TAG, "UpgradeAppInfo onNext info == null")
|
||||
Log.d(SceneConstant.M_BINDING + TAG, "UpgradeAppInfo onNext info == null")
|
||||
deleteApkFile()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user