和obu联调升级功能完成
This commit is contained in:
@@ -227,4 +227,7 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
bindingCarManager.queryAppUpgrade()
|
||||
}
|
||||
|
||||
override fun queryObuUpgrade(obuVersionName: String) {
|
||||
bindingCarManager.queryObuUpgrade(obuVersionName)
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.config.HmiBuildConfig
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager
|
||||
import com.mogo.eagle.core.function.call.obu.CallerObuApiManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isDriver
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isPassenger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
@@ -59,9 +60,6 @@ class BindingCarManager : IMoGoAutopilotCarConfigListener {
|
||||
if (carConfigResp != null && !TextUtils.isEmpty(carConfigResp.macAddress)) {
|
||||
Log.d("Upgrade", "MoGoHandAdasMsgManager address = " + carConfigResp.macAddress)
|
||||
getBindingCarInfo(carConfigResp.macAddress, MoGoAiCloudClientConfig.getInstance().sn)
|
||||
|
||||
//obu的升级,只需要司机屏连接
|
||||
queryObuUpgrade(carConfigResp.macAddress)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,21 +157,21 @@ class BindingCarManager : IMoGoAutopilotCarConfigListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询app是否需要升级
|
||||
* 查询app是否需要升级 TODO 打开升级 注释
|
||||
*/
|
||||
fun queryAppUpgrade() {
|
||||
// UpgradeAppNetWorkManager.getInstance()
|
||||
// .getAppUpgradeInfo(mContext, mAddress, role.toString() + "")
|
||||
|
||||
ObuUpgradeAppNetWorkManager.getInstance().getObuUpgradeInfo(mContext, "")
|
||||
}
|
||||
|
||||
/**
|
||||
* 司机屏 处理obu升级即可,乘客屏不需要处理
|
||||
*
|
||||
* obu的升级,只需要司机屏连接
|
||||
*/
|
||||
private fun queryObuUpgrade(macAddress: String) {
|
||||
// ObuUpgradeAppNetWorkManager.getInstance().getObuUpgradeInfo(mContext, macAddress)
|
||||
fun queryObuUpgrade(obuVersionName: String) {
|
||||
Log.d("liyz", "isConnected = ${CallerObuApiManager.isConnected()} --- mAddress = $mAddress")
|
||||
ObuUpgradeAppNetWorkManager.getInstance().getObuUpgradeInfo(mContext, mAddress, obuVersionName)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.util.Log;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.constants.HostConst;
|
||||
import com.mogo.eagle.core.data.bindingcar.UpgradeAppInfo;
|
||||
import com.mogo.eagle.core.data.obu.MogoObuConst;
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager;
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
@@ -50,21 +51,14 @@ public class ObuUpgradeAppNetWorkManager {
|
||||
/**
|
||||
* 获取obu升级信息,obu升级服务端使用app升级接口,根据screenType区分类型
|
||||
* mac :工控机mac地址, TODO 立即升级,还是
|
||||
* screenType : 类型 liyz
|
||||
* screenType : 类型
|
||||
*/
|
||||
public void getObuUpgradeInfo(Context context, String mac) {
|
||||
public void getObuUpgradeInfo(Context context, String mac, String versionName) {
|
||||
// String sn = "X20202203105S688HZ";
|
||||
String mac1 = "48:b0:2d:4d:33:40"; //liyz
|
||||
|
||||
// MogoObuManager().getInstance().readSystemBConfig(context, obuIp, listener)
|
||||
|
||||
//obuIp?
|
||||
// MogoObuManager().getInstance().uploadUpgradePackage(obuIp, upgradePackage, listener)
|
||||
|
||||
Log.e("liyz", "ObuUpgradeAppNetWorkManager getObuUpgradeInfo -----------> ");
|
||||
String mac1 = "48:b0:2d:4d:33:40";
|
||||
String sn = MoGoAiCloudClientConfig.getInstance().getSn();
|
||||
String obuVersionName = String.valueOf(AppUtils.getAppVersionCode()); // TODO 获取obu的版本号, string和int 服务端处理
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "getObuUpgradeInfo mac = " + mac1 + " ---sn = " + sn + " ---obuVersionName = " + obuVersionName);
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "getObuUpgradeInfo mac = " + mac1 + " ---sn = " + sn + " ---versionName = " + versionName);
|
||||
UpgradeAppRequest request = new UpgradeAppRequest(sn, mac1, "7");
|
||||
RequestBody requestBody = RequestBody.create(MediaType.get("application/json;charset=UTF-8"), GsonUtil.jsonFromObject(request));
|
||||
mUpgradeApiService.getUpgradeInfo(requestBody)
|
||||
@@ -78,11 +72,12 @@ public class ObuUpgradeAppNetWorkManager {
|
||||
@Override
|
||||
public void onNext(@NonNull UpgradeAppInfo info) {
|
||||
if (info != null && info.result != null) {
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "getObuUpgradeInfo appFileName = " + info.result.getAppFileName() + " ----url = " + info.result.getAppUrl() + " ----name = " + info.result.getVersionName() + " --obuVersionName =" + obuVersionName + " ---info.result = " + info.result);
|
||||
Log.d("liyz", "getObuUpgradeInfo appFileName = " + info.result.getAppFileName() + " ----url = " + info.result.getAppUrl() + " ----name = " + info.result.getVersionName() + " --obuVersionName =" + obuVersionName + " ---info.result = " + info.result);
|
||||
// if (!String.valueOf(info.result.getVersionName()).equals(obuVersionName)) { //判断是否下载,当文件名称不一致的时候,就下载 TODO
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "getObuUpgradeInfo appFileName = " + info.result.getAppFileName() + " ----url = " + info.result.getAppUrl() + " ----name = " + info.result.getVersionName() + " --obuVersionName =" + versionName + " ---info.result = " + info.result);
|
||||
Log.d("liyz", "getObuUpgradeInfo appFileName = " + info.result.getAppFileName() + " ----url = " + info.result.getAppUrl() + " ----name = " + info.result.getVersionName() + " --obuVersionName =" + versionName + " ---info.result = " + info.result);
|
||||
if (!String.valueOf(info.result.getVersionName()).equals(versionName)) { //判断是否下载,当文件名称不一致的时候,就下载 TODO liyz
|
||||
Log.d("liyz", "getObuUpgradeInfo ------2------ ");
|
||||
CallerDevaToolsManager.INSTANCE.downLoadPackage(info.result.getAppFileName(), info.result.getAppUrl());
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_BINDING + TAG, "getObuUpgradeInfo onNext info == null");
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.core.app.NotificationCompat
|
||||
import com.elegant.utils.UiThreadHandler
|
||||
import com.mogo.eagle.core.data.obu.MogoObuConst
|
||||
import com.mogo.eagle.core.function.api.devatools.IMogoDevaToolsUpgradeListener
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsUpgradeListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.updateStatusBarDownloadView
|
||||
import com.mogo.eagle.core.function.call.obu.CallerObuApiManager
|
||||
import com.mogo.eagle.core.utilcode.breakpoint.Config
|
||||
import com.mogo.eagle.core.utilcode.breakpoint.bean.ThreadBean
|
||||
import com.mogo.eagle.core.utilcode.breakpoint.callback.IDownload
|
||||
@@ -93,10 +95,8 @@ class UpgradeManager : IDownload {
|
||||
}
|
||||
if (downloadUrl != null) {
|
||||
if (map.isNullOrEmpty()) {
|
||||
Log.d("liyz", "onFinished ----1------")
|
||||
CallerDevaToolsUpgradeListenerManager.invokeUpgradeFinish(downloadUrl)
|
||||
} else {
|
||||
Log.d("liyz", "onFinished ----2------")
|
||||
findKey(downloadUrl) {
|
||||
CallerDevaToolsUpgradeListenerManager.invokeUpgradeFinish(it)
|
||||
}
|
||||
@@ -106,7 +106,6 @@ class UpgradeManager : IDownload {
|
||||
|
||||
override fun onError(downloadUrl: String?, errorMsg: String?) {
|
||||
CallerLogger.d("$M_DEVA$TAG","onError downloadUrl : $downloadUrl , errorMsg : $errorMsg")
|
||||
Log.e("liyz","onError downloadUrl : $downloadUrl , errorMsg : $errorMsg")
|
||||
if (downloadUrl != null) {
|
||||
if (map.isNullOrEmpty()) {
|
||||
CallerDevaToolsUpgradeListenerManager.invokeUpgradeError(downloadUrl, errorMsg ?: "未知错误")
|
||||
@@ -121,7 +120,6 @@ class UpgradeManager : IDownload {
|
||||
private fun findKey(downloadUrl: String?, findResult: (downloadUrl: String) -> Unit) {
|
||||
downloadUrl?.let { url ->
|
||||
map?.iterator()?.forEach {
|
||||
Log.d("liyz", "findKey it.value = ${it.value} ----url = $url")
|
||||
if (it.value == url) {
|
||||
findResult.invoke(it.key)
|
||||
}
|
||||
@@ -178,23 +176,30 @@ class UpgradeManager : IDownload {
|
||||
override fun onFinished(url: String?) {
|
||||
//下载完成,解压文件
|
||||
try {
|
||||
///storage/emulated/0/obu/MOGO_OBUAPPS_V503A_PACK.zip
|
||||
Log.d("liyz", " onFinished file = ${Config.downLoadObuPath + mDownloadFileName} ")
|
||||
// storage/emulated/0/obu/MOGO_OBUAPPS_V503A_PACK.zip
|
||||
val files = ZipUtils.unzipFile(Config.downLoadObuPath + mDownloadFileName, Config.downLoadUnzipObuPath)
|
||||
Log.d("liyz", " onFinished files = $files ")
|
||||
//1传给obu升级,升级成功,2需要删除相应文件夹 TODO
|
||||
Log.d("liyz", " onFinished file = ${Config.downLoadObuPath + mDownloadFileName} -----files = $files ")
|
||||
//1传给obu升级,升级成功,2需要删除相应文件夹
|
||||
// onFinished files = [/storage/emulated/0/obuunzip/MOGO_OBUAPPS_V503A_PATCH.tar.gz, /storage/emulated/0/obuunzip/README.txt, /storage/emulated/0/obuunzip/version.json]
|
||||
|
||||
|
||||
var md5Path = ""
|
||||
var tarPath = ""
|
||||
for (f in files) {
|
||||
if (f.path.contains(".md5")) {
|
||||
md5Path = f.path
|
||||
}
|
||||
if (f.path.contains(".gz")) {
|
||||
tarPath = f.path
|
||||
}
|
||||
}
|
||||
Log.d("liyz", "---md5Path = $md5Path -----tarPath = $tarPath ")
|
||||
CallerObuApiManager.uploadObuPack(arrayOf(md5Path, tarPath))
|
||||
} catch (e: IOException) {
|
||||
//解压失败
|
||||
Log.e("liyz", "unzip failed -----> ")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(url: String?, errorMsg: String?) {
|
||||
Log.d("liyz", " onProgress errorMsg = $errorMsg ")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user