[8.4.0]
[升级] [支持mis和myflow 升级]
This commit is contained in:
@@ -212,6 +212,9 @@ object BindingCarManager : IMoGoAutopilotCarConfigListener, IMoGoCloudListener {
|
||||
|
||||
/**
|
||||
* 查询app是否需要升级
|
||||
* ①:设置车辆类型和车辆业务模式后也请求一次
|
||||
* ②:页面点击版本号后升级
|
||||
* ③:连接车辆后 向地盘查询信息 地盘返回信息后查询更新包
|
||||
*/
|
||||
fun queryAppUpgrade(block: ((Boolean, String?) -> Unit)?) {
|
||||
CallerLogger.d(M_DEVA + "UPGRADE", "---- 1 ----")
|
||||
@@ -228,6 +231,7 @@ object BindingCarManager : IMoGoAutopilotCarConfigListener, IMoGoCloudListener {
|
||||
CallerLogger.d(M_DEVA + "UPGRADE", "---- 3 ----[mac: $macAddress]")
|
||||
UpgradeAppNetWorkManager.instance
|
||||
?.getAppUpgradeInfo(mContext, macAddress, AppIdentityModeUtils.getMisChannelCode(FunctionBuildConfig.appIdentityMode).toString() + "", block)
|
||||
UpgradeAppNetWorkManager.instance?.getAppUpgradeInfoMyFlow(mContext, block)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,4 +20,14 @@ interface UpgradeApiService {
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("eagleEye-mis/config/versionInfo")
|
||||
suspend fun getUpgradeInfo(@Body requestBody: RequestBody): UpgradeAppInfo
|
||||
|
||||
/**
|
||||
* 获取升级信息
|
||||
* , @Query("resources") String i
|
||||
* @return [UpgradeAppInfo]
|
||||
*/
|
||||
@Headers("Content-Type:application/json;charset=UTF-8")
|
||||
@POST("api/deploy/openapi/checkForAppUpdate")
|
||||
suspend fun getUpgradeInfo4Myflow(@Body requestBody: UpgradeAppMyFlowRequest): UpgradeAppInfo
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.zhjt.mogo_core_function_devatools.upgrade;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
* @description 获取app升级信息
|
||||
* @since: 11/15/21
|
||||
*/
|
||||
public class UpgradeAppMyFlowRequest implements Serializable {
|
||||
private String sn;
|
||||
private String appType;
|
||||
|
||||
public UpgradeAppMyFlowRequest(String sn, String appType) {
|
||||
this.sn = sn;
|
||||
this.appType = appType;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public String getAppType() {
|
||||
return appType;
|
||||
}
|
||||
|
||||
public void setAppType(String appType) {
|
||||
this.appType = appType;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.zhjt.mogo_core_function_devatools.upgrade
|
||||
|
||||
import android.content.*
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Build
|
||||
import android.text.TextUtils
|
||||
import android.util.*
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.mogo.commons.constants.*
|
||||
import com.mogo.commons.utils.*
|
||||
import com.mogo.eagle.core.data.config.*
|
||||
@@ -26,6 +23,8 @@ import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.getMisChannelCode
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.*
|
||||
import com.mogo.commons.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.getMisChannelType
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.eagle.core.utilcode.util.FileUtils
|
||||
@@ -42,7 +41,9 @@ import java.util.concurrent.TimeUnit
|
||||
*/
|
||||
class UpgradeAppNetWorkManager private constructor() {
|
||||
|
||||
private val mUpgradeApiService: UpgradeApiService = MoGoRetrofitFactory.getInstance(HostConst.getHost()).create(UpgradeApiService::class.java)
|
||||
|
||||
private val mUpgradeApiService: UpgradeApiService by lazy { MoGoRetrofitFactory.getInstance(HostConst.getHost()).create(UpgradeApiService::class.java) }
|
||||
private val mUpgradeMyFlowApiService: UpgradeApiService by lazy { MoGoRetrofitFactory.getInstance(HostConst.getMyFlowHost()).create(UpgradeApiService::class.java) }
|
||||
|
||||
private val scope by lazy { CoroutineScope(Dispatchers.IO + SupervisorJob()) }
|
||||
|
||||
@@ -50,6 +51,7 @@ class UpgradeAppNetWorkManager private constructor() {
|
||||
|
||||
@Volatile
|
||||
private var upgradeJob: Job? = null
|
||||
private var upgradeMyFlowJob: Job? = null
|
||||
|
||||
// 标识静默升级是否已触发下载,如果为true, 直接返回,防止重复下载
|
||||
@Volatile
|
||||
@@ -109,13 +111,14 @@ class UpgradeAppNetWorkManager private constructor() {
|
||||
provider?.recordUpgradeRequestStart()
|
||||
val info = mUpgradeApiService.getUpgradeInfo(requestBody)
|
||||
val response = GsonUtils.toJson(info)
|
||||
Log.d(TAG,"MIS网络请求返回:${response}")
|
||||
SharedPrefsMgr.getInstance().putString(SharedPrefsConstants.APP_UPGRADE_CONTENT, if (info.result != null) response + "--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) {
|
||||
runCatching {
|
||||
block?.invoke(true, response)
|
||||
}
|
||||
provider?.recordUpgradeRequestSuccess(response)
|
||||
doUpgrade(info)
|
||||
doUpgrade(info.result)
|
||||
} else {
|
||||
// val error = info.msg?:"请检查升级服务日志"
|
||||
val error = info.msg?:StringUtils.getString(com.mogo.eagle.core.widget.R.string.module_core_check_upgrade_log_normal)
|
||||
@@ -125,6 +128,7 @@ class UpgradeAppNetWorkManager private constructor() {
|
||||
provider?.recordUpgradeRequestFailed(error)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
Log.d(TAG,"MIS网络请求返回:错误信息:${t.message}")
|
||||
t.printStackTrace()
|
||||
SharedPrefsMgr.getInstance().putString(SharedPrefsConstants.APP_UPGRADE_CONTENT,
|
||||
"$t--mac:$macAddress --type:$type --sn:$sn "
|
||||
@@ -143,13 +147,94 @@ class UpgradeAppNetWorkManager private constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun doUpgrade(info: UpgradeAppInfo) {
|
||||
if (info.result != null) {
|
||||
|
||||
fun getAppUpgradeInfoMyFlow(context: Context?, block: ((Boolean, String?) -> Unit)? = null) {
|
||||
Logger.d(TAG, "myflow vin address is null or empty.---------")
|
||||
upgradeMyFlowJob?.safeCancel()
|
||||
scope.launch {
|
||||
var tempVin = CallerAutoPilotControlManager.getVIN() ?: ""
|
||||
var type = AppIdentityModeUtils.getMisChannelType(FunctionBuildConfig.appIdentityMode) //"10"
|
||||
while (TextUtils.isEmpty(tempVin)) {
|
||||
Logger.d(TAG, "myflow vin address is null or empty.")
|
||||
MogoAnalyticUtils.track("AppUpgradeParamsMyFlow", HashMap<String, Any>().also { it["vin"] = tempVin })
|
||||
delay(TimeUnit.MINUTES.toMillis(1))
|
||||
tempVin = CallerAutoPilotControlManager.getVIN() ?: ""
|
||||
}
|
||||
while (TextUtils.isEmpty(type)) {
|
||||
Logger.d(TAG, "myflow type is 0")
|
||||
delay((TimeUnit.MINUTES.toMillis(1)))
|
||||
MogoAnalyticUtils.track("AppUpgradeParamsMyFLow", HashMap<String, Any>().also { it["type"] = type })
|
||||
type = AppIdentityModeUtils.getMisChannelType(FunctionBuildConfig.appIdentityMode).toString()
|
||||
}
|
||||
Logger.d(TAG, "myflow start upgrade request ...")
|
||||
SharedPrefsMgr.getInstance().putString(SharedPrefsConstants.HOST_ADDRESS_MyFLow, HostConst.getMyFlowHost())
|
||||
try {
|
||||
val records = provider?.getUpgradeRecords()?.also {
|
||||
MogoAnalyticUtils.track("AppUpgradeRecord", TreeMap<String, Any>().also { itx ->
|
||||
it.entries.forEach { entry ->
|
||||
itx[entry.key] = entry.value.joinToString(",") {
|
||||
"${ it.first } -> ${ it.second }"
|
||||
}
|
||||
}
|
||||
itx["role"] = type
|
||||
})
|
||||
}
|
||||
Log.d(TAG, "myflow getAppUpgradeInfo: -> records:" + records?.entries?.joinToString(",") { itx -> "key:${itx.key} -> value:[${itx.value.joinToString(",") { "${it.first},${it.second}" } }]"})
|
||||
val latestMacAddress = CallerAutoPilotControlManager.getVIN()
|
||||
if (!TextUtils.equals(latestMacAddress, tempVin)) {
|
||||
tempVin = latestMacAddress
|
||||
}
|
||||
Log.d(SceneConstant.M_DEVA + TAG, "myflow getAppUpgradeInfo vin = $tempVin---type = $type")
|
||||
val request = UpgradeAppMyFlowRequest(tempVin, type)
|
||||
val requestJson = GsonUtil.jsonFromObject(request)
|
||||
val requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), requestJson)
|
||||
provider?.recordUpgradeRecord(tempVin ?: "", "", type, FunctionBuildConfig.isSupportPatchUpgrade)
|
||||
provider?.recordUpgradeRequestStart()
|
||||
Log.d(TAG,"MyFLow网络请求参数:${requestJson}")
|
||||
val info = mUpgradeMyFlowApiService.getUpgradeInfo4Myflow(request)
|
||||
val response = GsonUtils.toJson(info)
|
||||
Log.d(TAG,"MyFLow网络请求返回:${response}")
|
||||
SharedPrefsMgr.getInstance().putString(SharedPrefsConstants.APP_UPGRADE_CONTENT_MyFlow, if (info.result != null) response + "--vin:$tempVin" else "info.result == null --vin:$tempVin --type:$type")
|
||||
if (info.data != null) {
|
||||
runCatching {
|
||||
block?.invoke(true, response)
|
||||
}
|
||||
provider?.recordUpgradeRequestSuccess(response)
|
||||
doUpgrade(info.data.toAppInfo())
|
||||
} else {
|
||||
// val error = info.msg?:"请检查升级服务日志"
|
||||
val error = info.msg?:StringUtils.getString(com.mogo.eagle.core.widget.R.string.module_core_check_upgrade_log_normal)
|
||||
runCatching {
|
||||
block?.invoke(false, error)
|
||||
}
|
||||
provider?.recordUpgradeRequestFailed(error)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
Log.d(TAG,"MyFLow网络请求返回:错误信息:${t.message}")
|
||||
t.printStackTrace()
|
||||
SharedPrefsMgr.getInstance().putString(SharedPrefsConstants.APP_UPGRADE_CONTENT, "$t--vin:$tempVin --type:$type ")
|
||||
// provider?.recordUpgradeRequestFailed(t.message ?: "更新接口请求失败")
|
||||
provider?.recordUpgradeRequestFailed(t.message ?: StringUtils.getString(com.mogo.eagle.core.widget.R.string.module_core_update_api_request_failed))
|
||||
deleteApkFile()
|
||||
}
|
||||
delay(TimeUnit.HOURS.toMillis(1))
|
||||
if (mDownloadRequested) {
|
||||
mDownloadRequested = false
|
||||
}
|
||||
getAppUpgradeInfoMyFlow(context)
|
||||
}.also {
|
||||
upgradeMyFlowJob = it
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private suspend fun doUpgrade(result: AppInfo?) {
|
||||
if (result != null) {
|
||||
val versionCode = AppUtils.getAppVersionCode()
|
||||
Log.d(SceneConstant.M_DEVA + 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
|
||||
Log.d(SceneConstant.M_DEVA + TAG, "UpgradeAppInfo url = " + result.appUrl + "----code = " + result.versionCode + "--versionCode =" + versionCode + "--info.result = " + result)
|
||||
if (result.versionCode > versionCode) {
|
||||
val patchInfo = result.patchInfo
|
||||
var downloadUrl: String = result.appUrl
|
||||
val provider = upgradeProvider()
|
||||
var isGoFullUpgrade = true
|
||||
if (patchInfo != null) {
|
||||
@@ -185,7 +270,7 @@ class UpgradeAppNetWorkManager private constructor() {
|
||||
}
|
||||
if (isGoFullUpgrade) {
|
||||
Log.d("ApkInstaller", "走全量升级 --- 1 ----")
|
||||
provider?.recordUpgradeRecord(info.result.versionName, null, 0)
|
||||
provider?.recordUpgradeRecord(result.versionName, null, 0)
|
||||
}
|
||||
//系统安装所有APP列表埋点统计
|
||||
installedInfoAnalytics()
|
||||
@@ -214,7 +299,7 @@ class UpgradeAppNetWorkManager private constructor() {
|
||||
}
|
||||
}
|
||||
activity?.lifeCycleScope?.launchWhenResumed {
|
||||
showUpgradeDialog(downloadUrl.substring(downloadUrl.lastIndexOf("/") + 1), downloadUrl, info.result.installTitle, info.result.installContent, info.result.installType)
|
||||
showUpgradeDialog(downloadUrl.substring(downloadUrl.lastIndexOf("/") + 1), downloadUrl, result.installTitle, result.installContent, result.installType)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -19,6 +19,8 @@ data class UrlConfig(
|
||||
val eagleMisUrl: String,
|
||||
@SerializedName("eagle_dns_url")
|
||||
val eagleDnsUrl: String,
|
||||
@SerializedName("myflow_url")
|
||||
val myflowUrl: String,
|
||||
@SerializedName("bind_driver_qr_url")
|
||||
val bindDriverQRUrl: String,
|
||||
@SerializedName("chart_socket_url")
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mogo.eagle.core.data.deva.bindingcar
|
||||
|
||||
data class AppInfoMyFlow(
|
||||
val appType: String,
|
||||
val artifactId: Int,
|
||||
val fileAddr: String,
|
||||
val hashType: String,
|
||||
val hashValue: String,
|
||||
val notifyMsg: String,
|
||||
val product: String,
|
||||
val sn: String,
|
||||
val taskItemId: Int?,
|
||||
val versionCode: Int?,
|
||||
val versionNo: String
|
||||
){
|
||||
fun toAppInfo():AppInfo{
|
||||
val appInfo = AppInfo()
|
||||
appInfo.appUrl = fileAddr
|
||||
appInfo.versionCode = versionCode?:0
|
||||
appInfo.versionName = versionNo
|
||||
appInfo.screenType = appType
|
||||
appInfo.installTitle = "版本升级"
|
||||
appInfo.installContent = notifyMsg
|
||||
appInfo.installType = "1"
|
||||
appInfo.appFileName = product
|
||||
return appInfo
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,16 @@ public class UpgradeAppInfo extends BaseData {
|
||||
|
||||
public AppInfo result;
|
||||
|
||||
public AppInfoMyFlow data;
|
||||
|
||||
public AppInfoMyFlow getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(AppInfoMyFlow data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setResult(AppInfo data) {
|
||||
this.result = data;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,18 @@ fun AppIdentityModeUtils.getMisChannelCode(appIdentityMode: String): Int {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取值要与mis后台配置对应上
|
||||
* https://mogogo.zhidaozhixing.com/eagleEye-mis/appInfo/query/all?keyWord=&pageNum=1&pageSize=20
|
||||
*/
|
||||
fun AppIdentityModeUtils.getMisChannelType(appIdentityMode: String): String {
|
||||
return when {
|
||||
isPassenger(appIdentityMode) -> "PASSENGER_APP" // 出租乘客端
|
||||
isDriver(appIdentityMode) -> "DRIVER_APP" // 出租司机端
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user