[6.9.0]OTA升级修改
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.zhjt.mogo_core_function_devatools.ota
|
||||
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.deva.ota.OtaUpgradeInfo
|
||||
@@ -17,6 +18,9 @@ import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import system_master.SsmInfo
|
||||
import java.util.Locale
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
|
||||
/**
|
||||
* OTA升级管理类
|
||||
@@ -56,6 +60,17 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定频SSM接口
|
||||
* 1hz hq m1 MAP350开始支持,其他车型MAP360开始支持
|
||||
* 定频SSM接入后 onStatusQueryResp 状态查询应答接口将弃用
|
||||
* @param statusInf 数据
|
||||
*/
|
||||
override fun onSystemStatus(statusInf: SsmInfo.SsmStatusInf) {
|
||||
//判断当前SSM版本是否支持OTA升级
|
||||
OTAUpgradeConfig.supportOTA = parseVersion(true, statusInf.masterVersion) >= 40800
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否有订单
|
||||
* @param inOrder true有订单 false没有订单
|
||||
@@ -270,5 +285,49 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
|
||||
|
||||
}
|
||||
|
||||
private val pattern = Pattern.compile("\\d+\\.\\d+\\.\\d+")
|
||||
|
||||
/**
|
||||
* 解析版本 格式 xxx.xxx.xxx(x的数量不固定)
|
||||
* 仅用于版本比较,不能用于展示
|
||||
* 例如:
|
||||
* "12.03.04" 解析结果:120304
|
||||
* "2.11.0" 解析结果:21100
|
||||
* "3.0.0" 解析结果:30000
|
||||
* 目前已用于DockerVersion和MaserVersion的解析
|
||||
*
|
||||
* @param isUseAll 是否使用全部截取数据 true:表示 12.34.56 截取之后 123456 false:表示12.34.56 截取之后 12
|
||||
* @param ver 版本字符串 例如:"MAP-taxi_RoboTaxi_df_2.8.0.3_20220928_test" 解析结果为:280
|
||||
* @return -1表示解析失败
|
||||
*/
|
||||
private fun parseVersion(isUseAll: Boolean, ver: String): Int {
|
||||
var version = -1
|
||||
if (!TextUtils.isEmpty(ver)) {
|
||||
try {
|
||||
val matcher: Matcher = pattern.matcher(ver)
|
||||
if (matcher.find()) {
|
||||
var group = matcher.group()
|
||||
if (!TextUtils.isEmpty(group)) {
|
||||
val format = "%02d"
|
||||
if (isUseAll) {
|
||||
val temp = group.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }
|
||||
.toTypedArray()
|
||||
group = String.format(Locale.getDefault(), format, temp[0].toInt())
|
||||
group += String.format(Locale.getDefault(), format, temp[1].toInt())
|
||||
group += String.format(Locale.getDefault(), format, temp[2].toInt())
|
||||
} else {
|
||||
group = group.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }
|
||||
.toTypedArray()[0]
|
||||
}
|
||||
version = group.toInt()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "版本解析失败=$ver", e)
|
||||
}
|
||||
}
|
||||
return version
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user