From 5c352cf1284739f3a3c2457aa241881788380687 Mon Sep 17 00:00:00 2001 From: xuxinchao <13522809046@163.com> Date: Thu, 19 May 2022 19:48:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E6=8E=A7=E6=9C=BA=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 工控机升级云端获取数据版本 --- .../autopilot/MoGoAutopilotProvider.kt | 12 - .../bindingcar/BindingcarProvider.java | 23 ++ .../function/ipcupgrade/IPCUpgradeManager.kt | 93 +++++- .../network/IPCUpgradeApiService.kt | 35 ++ .../network/IPCUpgradeNetWorkModel.kt | 95 ++++++ .../ipcupgrade/network/UpgradeHostConst.kt | 28 ++ .../core/function/hmi/ui/MoGoHmiFragment.kt | 23 ++ .../function/hmi/ui/tools/AdUpgradeDialog.kt | 16 +- .../hmi/ui/tools/AutoPilotAndCheckView.kt | 35 +- .../function/hmi/ui/widget/CheckSystemView.kt | 27 +- .../hmi/ui/widget/SystemVersionView.kt | 303 ++++++++---------- .../AdUpgradeStateHelper.kt | 93 ++---- .../data/bindingcar/IPCQueryContainersInfo.kt | 11 + .../data/bindingcar/IPCUpgradeStateInfo.kt | 5 +- .../api/autopilot/IMoGoAutopilotProvider.kt | 10 - .../api/bindingcar/IMoGoBindingCarListener.kt | 12 + .../bindingcar/IMoGoBindingcarProvider.java | 17 + .../api/hmi/warning/IMoGoWaringProvider.kt | 11 + .../call/autopilot/CallerAutoPilotManager.kt | 14 - .../CallerBindingCarListenerManager.kt | 65 ++++ .../function/call/hmi/CallerHmiManager.kt | 15 + 21 files changed, 638 insertions(+), 305 deletions(-) create mode 100644 core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/IPCUpgradeApiService.kt create mode 100644 core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/IPCUpgradeNetWorkModel.kt create mode 100644 core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/UpgradeHostConst.kt rename core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/{autopilot => bindingcar}/AdUpgradeStateHelper.kt (57%) create mode 100644 core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/IPCQueryContainersInfo.kt create mode 100644 core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/bindingcar/IMoGoBindingCarListener.kt create mode 100644 core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/bindingcar/CallerBindingCarListenerManager.kt diff --git a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt index 2ef43afaa6..129f809740 100644 --- a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt +++ b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt @@ -321,18 +321,6 @@ class MoGoAutopilotProvider : } } - /** - * 工控机升级确认 - */ - override fun setIPCUpgradeAffirm() { - } - - /** - * 工控机升级取消 - */ - override fun setIPCUpgradeCancel() { - } - /** * 演示模式(美化模式) * isEnable = true 开启 diff --git a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/BindingcarProvider.java b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/BindingcarProvider.java index d4bb9dc475..b54bce69f8 100644 --- a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/BindingcarProvider.java +++ b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/bindingcar/BindingcarProvider.java @@ -16,6 +16,8 @@ import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; import org.jetbrains.annotations.NotNull; +import java.util.List; + /** * @author lixiaopeng @@ -63,6 +65,27 @@ public class BindingcarProvider implements IMoGoBindingcarProvider { // } } + /** + * 确认升级工控机docker版本 + * @param images docker列表 + * @param padSn SN + * @param releaseId 任务ID + */ + @Override + public void upgradeConfirm(List images, String padSn, String releaseId) { + IPCUpgradeManager.Companion.getINSTANCE().upgradeConfirm(images, padSn, releaseId); + } + + /** + * 获取新工控机docker版本 + * @param padSn SN + * @param dockerVersion 当前工控机版本 + */ + @Override + public void queryContainers(String padSn,String dockerVersion) { + IPCUpgradeManager.Companion.getINSTANCE().queryContainers(padSn,dockerVersion); + } + @Override public void modifyCarInfo(BindingcarCallBack callBack) { BindingcarNetWorkManager.getInstance().modifyBindingcar(mAddress, mWidevineIDWithMd5, callBack, getScreenType()); diff --git a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/IPCUpgradeManager.kt b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/IPCUpgradeManager.kt index 3adbbbeeb3..cc58d51b57 100644 --- a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/IPCUpgradeManager.kt +++ b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/IPCUpgradeManager.kt @@ -4,10 +4,17 @@ import android.content.Context import android.util.Log import com.mogo.aicloud.services.socket.IMogoOnMessageListener import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager +import com.mogo.cloud.passport.MoGoAiCloudClient import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo import com.mogo.eagle.core.data.bindingcar.IPCUpgradeStateInfo import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.bindingcar.CallerBindingCarListenerManager +import com.mogo.eagle.core.function.call.hmi.CallerHmiManager +import com.mogo.eagle.core.function.ipcupgrade.network.IPCUpgradeNetWorkModel +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.util.GsonUtils +import org.json.JSONObject /** * @author XuXinChao @@ -26,6 +33,11 @@ class IPCUpgradeManager: IMogoOnMessageListener , } private var mContext: Context? = null + private val ipcUpgradeNetWorkModel = IPCUpgradeNetWorkModel() + private var autopilotStatus: Int? = null //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中 + + private var hasIPCUpgradeTask = false //是否有工控机升级任务,默认没有该任务 + private var ipcUpgradeStateInfoTask: IPCUpgradeStateInfo?=null fun initServer(context: Context){ mContext = context @@ -40,8 +52,32 @@ class IPCUpgradeManager: IMogoOnMessageListener , return IPCUpgradeStateInfo::class.java } - override fun onMsgReceived(obj: IPCUpgradeStateInfo?) { + override fun onMsgReceived(ipcUpgradeStateInfo: IPCUpgradeStateInfo?) { + CallerLogger.i(TAG,"IPCUpgradeManager received msg${ipcUpgradeStateInfo}") + ipcUpgradeStateInfo?.let { + if(it.status.isEmpty() || it.status == "0"){ + if(autopilotStatus == 2){ + //当前处于自动驾驶状态时,不弹窗提示,结束自动驾驶时弹窗 + hasIPCUpgradeTask = true + ipcUpgradeStateInfoTask=it + }else{ + var releaseId="" + if(it.releaseId!=null){ + releaseId = it.releaseId.toString() + } + //弹窗提示,确认是否进行工控机升级 + CallerHmiManager.showAdUpgradeDialog( + it.images, + MoGoAiCloudClient.getInstance().aiCloudClientConfig.sn, + releaseId) + } + }else{ + //更新下载or升级状态 + CallerHmiManager.showAdUpgradeStatus(it) + } + + } } /** @@ -49,7 +85,62 @@ class IPCUpgradeManager: IMogoOnMessageListener , * @param autoPilotStatusInfo 状态信息 */ override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { + autopilotStatus = autoPilotStatusInfo.state + //有升级任务,且不处于自动驾驶状态,进行升级提示 + if(hasIPCUpgradeTask && autopilotStatus!=2){ + ipcUpgradeStateInfoTask?.let { + var releaseId="" + if(it.releaseId!=null){ + releaseId = it.releaseId.toString() + } + CallerHmiManager.showAdUpgradeDialog( + it.images, + MoGoAiCloudClient.getInstance().aiCloudClientConfig.sn, + releaseId) + //将升级任务置为false + hasIPCUpgradeTask = false + } + } + } + /** + * 确认升级工控机docker版本 + * @param images docker列表 + * @param padSn SN + * @param releaseId 任务ID + */ + fun upgradeConfirm(images: List,padSn: String,releaseId: String){ + ipcUpgradeNetWorkModel.upgradeConfirm(images,padSn,releaseId, + onSuccess = { + + }, + onError = { + + }) + } + + /** + * 获取新工控机docker版本 + * @param padSn SN + * @param dockerVersion 当前工控机版本 + */ + fun queryContainers(padSn: String,dockerVersion: String){ + ipcUpgradeNetWorkModel.queryContainers(padSn, + onSuccess = { + val jsonObject = JSONObject(it) + val images = jsonObject.getJSONArray("images") + val dockerList = ArrayList() + for(i in 0 until images.length()){ + if(!i.toString().contains(dockerVersion)){ + dockerList.add(images[i].toString()) + } + } + //将数组结果回调 + CallerBindingCarListenerManager.invokeQueryContainersResponse(dockerList) + }, + onError = { + + }) } fun destroy(){ diff --git a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/IPCUpgradeApiService.kt b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/IPCUpgradeApiService.kt new file mode 100644 index 0000000000..d1503a1c2f --- /dev/null +++ b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/IPCUpgradeApiService.kt @@ -0,0 +1,35 @@ +package com.mogo.eagle.core.function.ipcupgrade.network + +import com.mogo.eagle.core.data.BaseResponse +import com.mogo.eagle.core.data.Response +import okhttp3.RequestBody +import retrofit2.http.* + +/** + * @author XuXinChao + * @description 工控机升级网络请求接口 + * @since: 2022/5/17 + */ +interface IPCUpgradeApiService { + + /** + * 确认升级工控机docker版本 + * @param imageName docker域名 + * @param imageVersion docker版本 + * @param padSn SN + * @param releaseId 任务ID + */ + @Headers( + "Content-Type:application/json", + "Accept: application/json" + ) + @POST("/api/pushServer/confirm") + suspend fun upgradeConfirm(@Body requestBody: RequestBody): BaseResponse + + /** + * 获取新工控机docker版本 + * @param padSn SN + */ + @GET("/api/pushServer/queryContainers") + suspend fun queryContainers(@Query("padSn") padSn: String): Response +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/IPCUpgradeNetWorkModel.kt b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/IPCUpgradeNetWorkModel.kt new file mode 100644 index 0000000000..ed05dd8180 --- /dev/null +++ b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/IPCUpgradeNetWorkModel.kt @@ -0,0 +1,95 @@ +package com.mogo.eagle.core.function.ipcupgrade.network + +import com.mogo.eagle.core.data.BaseResponse +import com.mogo.eagle.core.data.Response +import com.mogo.eagle.core.function.ipcupgrade.network.UpgradeHostConst.Companion.getBaseUrl +import com.mogo.eagle.core.network.MoGoRetrofitFactory +import com.mogo.eagle.core.network.apiCall +import com.mogo.eagle.core.network.apiResponseCall +import com.mogo.eagle.core.network.request +import com.mogo.eagle.core.utilcode.util.GsonUtils +import okhttp3.MediaType +import okhttp3.RequestBody +import org.json.JSONArray +import org.json.JSONObject + +/** + * @author XuXinChao + * @description 工控机升级网络请求 + * @since: 2022/5/17 + */ +class IPCUpgradeNetWorkModel { + + private fun getNetWorkApi(baseUrl: String =getBaseUrl()): IPCUpgradeApiService{ + return MoGoRetrofitFactory.getInstanceNoCallAdapter(baseUrl) + .create(IPCUpgradeApiService::class.java) + } + + /** + * 确认升级工控机docker版本 + * @param images docker列表 + * @param padSn SN + * @param releaseId 任务ID + */ + fun upgradeConfirm(images: List,padSn: String,releaseId: String, + onSuccess: ((String) -> Unit),onError: ((String) -> Unit)){ + request> { + val requestJson = JSONObject() + val imagesJsonArray = JSONArray() + images.iterator().forEach { + imagesJsonArray.put(it) + } + requestJson.put("images",imagesJsonArray) + requestJson.put("padSn",padSn) + requestJson.put("releaseId",releaseId) + val requestBody:RequestBody= RequestBody.create( + MediaType.parse("application/json; charset=utf-8"), + requestJson.toString() + ) + loader{ + apiCall{ + getNetWorkApi(getBaseUrl()).upgradeConfirm(requestBody) + } + } + onSuccess{ + onSuccess.invoke("") + } + + onError { + onError.invoke("") + } + + } + } + + /** + * 获取新工控机docker版本 + * @param padSn SN + */ + fun queryContainers(padSn: String,onSuccess: ((String) -> Unit),onError: ((String) -> Unit)){ + request>{ + loader { + apiResponseCall{ + getNetWorkApi(getBaseUrl()).queryContainers(padSn) + } + } + onSuccess{ + if(it.msg == "success"){ + onSuccess.invoke(GsonUtils.toJson(it.data)) + }else{ + onError.invoke("query Containers fail") + } + } + + onError { + if(it.message!=null){ + onError.invoke(it.message!!) + } + } + + } + } + + + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/UpgradeHostConst.kt b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/UpgradeHostConst.kt new file mode 100644 index 0000000000..83cbb65a39 --- /dev/null +++ b/core/function-impl/mogo-core-function-bindingcar/src/main/java/com/mogo/eagle/core/function/ipcupgrade/network/UpgradeHostConst.kt @@ -0,0 +1,28 @@ +package com.mogo.eagle.core.function.ipcupgrade.network + +import com.mogo.commons.debug.DebugConfig + +/** + * @author XuXinChao + * @description 工控机升级域名管理 + * @since: 2022/5/17 + */ +class UpgradeHostConst { + + companion object{ + + private const val HOST_DEV = "http://mysunflower-qa.zhidaoauto.com" + private const val HOST_RELEASE = "http://mysunflower-qa.zhidaoauto.com" + + fun getBaseUrl(): String { + return when (DebugConfig.getNetMode()) { + DebugConfig.NET_MODE_DEV -> HOST_DEV + DebugConfig.NET_MODE_QA -> HOST_DEV + DebugConfig.NET_MODE_DEMO -> HOST_RELEASE + DebugConfig.NET_MODE_RELEASE -> HOST_RELEASE + else -> HOST_RELEASE + } + } + } + +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt index 5b9e5ac910..991406e9a6 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/MoGoHmiFragment.kt @@ -14,6 +14,7 @@ import com.alibaba.android.arouter.facade.annotation.Route import com.mogo.commons.AbsMogoApplication import com.mogo.commons.mvp.MvpFragment import com.mogo.commons.voice.AIAssist +import com.mogo.eagle.core.data.bindingcar.IPCUpgradeStateInfo import com.mogo.eagle.core.data.camera.CameraEntity import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.config.HmiBuildConfig @@ -49,6 +50,7 @@ import com.mogo.eagle.core.function.hmi.ui.notice.NoticeNormalBannerView import com.mogo.eagle.core.function.hmi.ui.setting.DebugSettingView import com.mogo.eagle.core.function.hmi.ui.setting.IPCReportWindow import com.mogo.eagle.core.function.hmi.ui.setting.ReportListFloatWindow +import com.mogo.eagle.core.function.hmi.ui.tools.AdUpgradeDialog import com.mogo.eagle.core.function.hmi.ui.tools.AutoPilotAndCheckView import com.mogo.eagle.core.function.hmi.ui.widget.V2XNotificationView import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils @@ -116,6 +118,7 @@ class MoGoHmiFragment : MvpFragment(), private var reportListFloatWindow: ReportListFloatWindow?=null private var ipcReportWindow: IPCReportWindow?=null + private var adUpgradeDialog: AdUpgradeDialog?=null override fun vipIdentification(visible: Boolean) { ThreadUtils.runOnUiThread { @@ -957,6 +960,26 @@ class MoGoHmiFragment : MvpFragment(), } + override fun showAdUpgradeDialog( + images: List, + padSn: String, + releaseId: String + ) { + ThreadUtils.runOnUiThread{ + if(adUpgradeDialog == null){ + adUpgradeDialog = AdUpgradeDialog(requireContext(),images, padSn, releaseId) + } + adUpgradeDialog?.showUpgradeDialog() + } + } + + override fun showAdUpgradeStatus(ipcUpgradeStateInfo: IPCUpgradeStateInfo) { + ThreadUtils.runOnUiThread{ + toolsView?.showAdUpgradeStatus(ipcUpgradeStateInfo) + } + } + + override fun setTurnLightFunction(isOpen: Boolean) { HmiBuildConfig.isShowTurnLightView = isOpen } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AdUpgradeDialog.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AdUpgradeDialog.kt index 8023e363b8..789a94c7b3 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AdUpgradeDialog.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AdUpgradeDialog.kt @@ -3,6 +3,7 @@ package com.mogo.eagle.core.function.hmi.ui.tools import android.content.Context import android.widget.TextView import androidx.lifecycle.LifecycleObserver +import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager import com.mogo.eagle.core.function.hmi.R import com.mogo.module.common.dialog.BaseFloatDialog @@ -11,27 +12,38 @@ import com.mogo.module.common.dialog.BaseFloatDialog * @description 工控机确认升级对话框 * @since: 2022/1/13 */ -class AdUpgradeDialog(context: Context) : BaseFloatDialog(context), LifecycleObserver { +class AdUpgradeDialog(context: Context,images: List,padSn: String,releaseId: String) + : BaseFloatDialog(context), LifecycleObserver { private var upgradeConfirm : TextView? = null private var upgradeCancel : TextView? = null private var clickListener: ClickListener? = null + private var images: List?=null + private var imageVersion: String?=null + private var padSn: String?=null + private var releaseId: String?=null + init { setContentView(R.layout.dialog_ad_upgrade) - setCanceledOnTouchOutside(true) + setCanceledOnTouchOutside(false) upgradeConfirm=findViewById(R.id.tv_upgrade_confirm) upgradeCancel=findViewById(R.id.tv_upgrade_cancel) upgradeConfirm?.setOnClickListener{ clickListener?.confirm() + //确认升级 + CallerBindingcarManager.getBindingcarProvider().upgradeConfirm(images, padSn, releaseId) dismiss() } upgradeCancel?.setOnClickListener { clickListener?.cancel() dismiss() } + this.images = images + this.padSn = padSn + this.releaseId = releaseId } fun setClickListener(clickListener: ClickListener) { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt index daf126f9c7..139f36e197 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/tools/AutoPilotAndCheckView.kt @@ -5,17 +5,21 @@ import android.content.Context import android.graphics.Color import android.graphics.drawable.ColorDrawable import android.util.AttributeSet +import android.util.Log import android.view.LayoutInflater import android.view.View import android.widget.FrameLayout +import com.mogo.cloud.passport.MoGoAiCloudClient import com.mogo.eagle.core.data.app.AppConfigInfo import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo +import com.mogo.eagle.core.data.bindingcar.IPCUpgradeStateInfo import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager +import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.function.hmi.ui.utils.KeyBoardUtil import com.mogo.eagle.core.utilcode.kotlin.onClick @@ -139,6 +143,7 @@ class AutoPilotAndCheckView @JvmOverloads constructor( // val speed = "30" // etInputSpeed.setText(speed) // etInputSpeed.setSelection(speed.length) + } fun setClickListener(clickListener: ClickListener) { @@ -161,34 +166,12 @@ class AutoPilotAndCheckView @JvmOverloads constructor( } } - /** - * 展示工控机下载、升级状态信息 - * @param upgradeMode 升级模式(提示升级、静默升级) - * @param downloadStatus 下载状态 - * @param currentProgress 当前已经下载包体大小 - * @param totalProgress 下载包体总大小 - * @param downloadVersion 下载版本 - * @param upgradeStatus 升级状态 - */ - fun showAdUpgradeStatus( - upgradeMode: Int, - downloadStatus: Int, - currentProgress: Int, - totalProgress: Int, - downloadVersion: String, - upgradeStatus: Int - ) { - systemVersionView?.showAdUpgradeStatus( - upgradeMode, - downloadStatus, - currentProgress, - totalProgress, - downloadVersion, - upgradeStatus - ) - checkSystemView?.setAdUpgradeStatus(downloadStatus, upgradeStatus) + fun showAdUpgradeStatus(ipcUpgradeStateInfo: IPCUpgradeStateInfo){ + systemVersionView?.showAdUpgradeStatus(ipcUpgradeStateInfo) } + + override fun onAttachedToWindow() { super.onAttachedToWindow() CallerAutoPilotStatusListenerManager.addListener(TAG, this) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CheckSystemView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CheckSystemView.kt index 5fc33d3bca..3d9d4a7660 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CheckSystemView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/CheckSystemView.kt @@ -6,7 +6,6 @@ import android.view.Gravity import android.view.LayoutInflater import android.view.View import androidx.constraintlayout.widget.ConstraintLayout -import com.mogo.eagle.core.data.autopilot.AdUpgradeStateHelper import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener @@ -33,8 +32,8 @@ class CheckSystemView @JvmOverloads constructor( private var autopilotStatus: Int? = null //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中 private var dockerRebootDialog: DockerRebootDialog? = null - private var downloadStatus: Int = -1 //下载状态 - private var upgradeStatus: Int = -1 //升级状态 + private var downloadStatus: String = "" //下载状态 + private var upgradeStatus: String = "" //升级状态 init { LayoutInflater.from(context).inflate(R.layout.view_check_system, this, true) @@ -55,14 +54,18 @@ class CheckSystemView @JvmOverloads constructor( if (autopilotStatus == 2) { //当前处于自动驾驶状态,不可进行重启,Toast提示 ToastUtils.showShort("请先退出自动驾驶状态") - } else if (AdUpgradeStateHelper.showCannotReboot( - downloadStatus, - upgradeStatus - ) - ) { - //当工控机处于下载或者升级状态,需要先进行升级 - ToastUtils.showShort("请先完成新自动驾驶系统的下载/升级") - } else { + } + +// else if (AdUpgradeStateHelper.showCannotReboot( +// downloadStatus, +// upgradeStatus +// ) +// ) { +// //当工控机处于下载或者升级状态,需要先进行升级 +// ToastUtils.showShort("请先完成新自动驾驶系统的下载/升级") +// } + + else { //确认重启 CallerLogger.d("$M_HMI$TAG", "reboot confirm") CallerAutoPilotManager.setIPCReboot() @@ -80,7 +83,7 @@ class CheckSystemView @JvmOverloads constructor( } } - fun setAdUpgradeStatus(downloadStatus: Int, upgradeStatus: Int) { + fun setAdUpgradeStatus(downloadStatus: String, upgradeStatus: String) { this.downloadStatus = downloadStatus this.upgradeStatus = upgradeStatus } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt index 6787f8fb1e..0fdc8af523 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/SystemVersionView.kt @@ -5,22 +5,24 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.view.View import androidx.constraintlayout.widget.ConstraintLayout -import com.mogo.eagle.core.data.autopilot.AdUpgradeStateHelper +import com.mogo.cloud.passport.MoGoAiCloudClient import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo +import com.mogo.eagle.core.data.bindingcar.AdUpgradeStateHelper +import com.mogo.eagle.core.data.bindingcar.IPCUpgradeStateInfo import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager +import com.mogo.eagle.core.function.api.bindingcar.IMoGoBindingCarListener import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.function.call.bindingcar.CallerBindingCarListenerManager +import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager +import com.mogo.eagle.core.function.call.hmi.CallerHmiManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.function.hmi.R -import com.mogo.eagle.core.function.hmi.ui.tools.AdUpgradeDialog import com.mogo.eagle.core.utilcode.util.AppUtils +import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.eagle.core.utilcode.util.ToastUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler import kotlinx.android.synthetic.main.view_system_version.view.* -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch /** * @author XuXinChao @@ -31,7 +33,7 @@ class SystemVersionView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoAutopilotStatusListener { +) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoAutopilotStatusListener,IMoGoBindingCarListener { companion object { const val TAG = "SystemVersionView" @@ -40,15 +42,13 @@ class SystemVersionView @JvmOverloads constructor( private var connectStatus = false private var dockerVersion: String? = null //工控机版本 private var autopilotStatus: Int? = null //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中 - private var adUpgradeDialog: AdUpgradeDialog? = null - private var upgradeMode: Int = -1 //升级模式 - private var downloadStatus: Int = -1 //下载状态 - private var currentProgress: Int = -1 //当前已下载包体大小 + private var ipcUpgradeStateInfo: IPCUpgradeStateInfo?=null + + private var needQueryContainers: Boolean = false + private var dockerList: List?=null private var previousProgress: Int = -1 //前一秒的下载进度,用于计算下载剩余时间 - private var totalProgress: Int = -1 //包体总大小 - private var downloadVersion: String? = null //工控机docker版本 - private var upgradeStatus: Int = -1 //升级状态 + private var currentProgress: Int = -1 //当前已下载包体大小 init { LayoutInflater.from(context).inflate(R.layout.view_system_version, this, true) @@ -67,62 +67,46 @@ class SystemVersionView @JvmOverloads constructor( //工控机版本视图点击事件 ivAdVersion.setOnClickListener { CallerLogger.i("$M_HMI$$TAG", "ad version view clicked") - CallerLogger.i( - "$M_HMI$$TAG", - "upgradeMode=$upgradeMode , downloadStatus=$downloadStatus , upgradeStatus=$upgradeStatus" - ) - if (AdUpgradeStateHelper.isDownloading(downloadStatus)) { - //点击Toast提示:下载剩余时间 - ToastUtils.showShort( - "预计" + AdUpgradeStateHelper.getRemainingTime( - totalProgress, - previousProgress, - currentProgress - ) + "下载完成" - ) - } else if (AdUpgradeStateHelper.getUpgradeStatus()) { - //工控机状态为“升级中” - ToastUtils.showShort("新版本升级中,预计5分钟升级完成") - } else if (AdUpgradeStateHelper.isUpgradeFailed(upgradeStatus)) { - //如果升级失败,则Toast提示:升级失败,请联系运维人员 - ToastUtils.showShort("升级失败,请联系运维人员") - } else if (AdUpgradeStateHelper.isHintUpgradeMode(upgradeMode) && AdUpgradeStateHelper.isDownloadFinish( - downloadStatus, - upgradeStatus - ) - ) { - //如果升级模式为“提示升级”,并且下载状态为已经下载完成,点击弹出升级确认弹窗 - if (adUpgradeDialog == null) { - adUpgradeDialog = AdUpgradeDialog(context) - adUpgradeDialog?.setClickListener(object : AdUpgradeDialog.ClickListener { - override fun confirm() { - if (autopilotStatus == 2) { - //当前处于自动驾驶状态,不可进行升级,Toast提示 - ToastUtils.showShort("升级前请先退出自动驾驶模式") - } else { - //确认升级 - CallerLogger.i("$M_HMI$$TAG", "upgrade confirm") - //设置当前状态为“升级中” - AdUpgradeStateHelper.setUpgradeStatus(true) - //TODO - CallerAutoPilotManager.setIPCUpgradeAffirm() - //将角标设为升级中 - ivAdStatus?.setImageResource(R.drawable.icon_upgrading) - adCircularProgressView?.visibility = View.GONE - ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) - } - } - - override fun cancel() { - //取消升级 - CallerLogger.i("$M_HMI$$TAG", "upgrade cancel") - //取消升级命令不下发 -// CallerAutoPilotManager.setIPCUpgradeCancel() - } - - }) + if(AdUpgradeStateHelper.isUpgradeableStatus()){ + if(autopilotStatus == 2){ + //当前处于自动驾驶状态,不可进行升级,Toast提示 + ToastUtils.showShort("升级前请先退出自动驾驶模式") + }else{ + dockerList?.let { + //弹窗提示,确认是否进行工控机升级 + CallerHmiManager.showAdUpgradeDialog(it, + MoGoAiCloudClient.getInstance().aiCloudClientConfig.sn, + "" + ) + } } - adUpgradeDialog?.showUpgradeDialog() + } + ipcUpgradeStateInfo?.let { + when { + AdUpgradeStateHelper.isDownloading(it.status) -> { + //下载中,点击Toast提示:下载剩余时间 + ToastUtils.showShort( + "预计" + AdUpgradeStateHelper.getRemainingTime( + it.progress.progressDetail.total, + previousProgress, + currentProgress + ) + "下载完成" + ) + } + AdUpgradeStateHelper.isUpgrading(it.status) -> { + //工控机状态为“升级中” + ToastUtils.showShort("新版本升级中,预计5分钟升级完成") + } + AdUpgradeStateHelper.isUpgradeFailed(it.status) -> { + //如果升级失败,则Toast提示:升级失败,请联系运维人员 + ToastUtils.showShort("升级失败,请联系运维人员") + } + AdUpgradeStateHelper.isUpgradeSuccess(it.status) -> { + //升级成功 + ToastUtils.showLong("已是最新版本") + } + } + } } @@ -131,117 +115,76 @@ class SystemVersionView @JvmOverloads constructor( /** * 设置工控机下载、升级状态信息 - * @param upgradeMode 升级模式(提示升级、静默升级) - * @param downloadStatus 下载状态 - * @param currentProgress 当前已经下载包体大小 - * @param totalProgress 下载包体总大小 - * @param downloadVersion 下载版本 - * @param upgradeStatus 升级状态 */ - fun setAdUpgradeInfo( - upgradeMode: Int, downloadStatus: Int, currentProgress: Int, totalProgress: Int, - downloadVersion: String, upgradeStatus: Int - ) { - this.upgradeMode = upgradeMode - this.downloadStatus = downloadStatus + private fun setAdUpgradeInfo(ipcUpgradeStateInfo: IPCUpgradeStateInfo) { this.previousProgress = this.currentProgress - this.currentProgress = currentProgress - this.totalProgress = totalProgress - this.downloadVersion = downloadVersion - this.upgradeStatus = upgradeStatus + this.currentProgress = ipcUpgradeStateInfo.progress.progressDetail.current + this.ipcUpgradeStateInfo = ipcUpgradeStateInfo } /** * 展示工控机下载、升级状态信息 - * @param upgradeMode 升级模式(提示升级、静默升级) - * @param downloadStatus 下载状态 - * @param currentProgress 当前已经下载包体大小 - * @param totalProgress 下载包体总大小 - * @param downloadVersion 下载版本 - * @param upgradeStatus 升级状态 + * */ - fun showAdUpgradeStatus( - upgradeMode: Int, - downloadStatus: Int, - currentProgress: Int, - totalProgress: Int, - downloadVersion: String, - upgradeStatus: Int - ) { - - GlobalScope.launch(Dispatchers.Main) { - //设置工控机下载、升级状态信息 - setAdUpgradeInfo( - upgradeMode, - downloadStatus, - currentProgress, - totalProgress, - downloadVersion, - upgradeStatus - ) - - if (AdUpgradeStateHelper.isDownloading(downloadStatus)) { - //正在下载,展示“下载中”角标,展示进度条,并设置当前下载进度 - ivAdStatus?.setImageResource(R.drawable.icon_downloading) - adCircularProgressView?.let { - it.visibility = View.VISIBLE - CallerLogger.i( - "$M_HMI$$TAG", - "下载中=currentProgress=$currentProgress , totalProgress=$totalProgress , downloadProgress=" + AdUpgradeStateHelper.downloadProgress( - currentProgress, - totalProgress - ) - ) - - it.setProgress( - AdUpgradeStateHelper.downloadProgress( - currentProgress, - totalProgress - ) - ) - } - } else if (AdUpgradeStateHelper.isDownloadFinish(downloadStatus, upgradeStatus)) { - //下载完成,处于可升级状态,展示“可升级”角标,将AD背景变为蓝色,并隐藏下载进度条(当状态为“升级中”时,不进行设置(存在升级命令已下发,但工控机未立即升级现象)) - if (!AdUpgradeStateHelper.getUpgradeStatus()) { - ivAdStatus?.setImageResource(R.drawable.icon_upgradeable) - ivAdVersion?.setBackgroundResource(R.drawable.version_upgradeable_background) - adCircularProgressView?.visibility = View.GONE - if (AdUpgradeStateHelper.isQuietUpgradeMode(upgradeMode)) { - //如果升级模式为“静默升级”,则下载完成后,调用升级命令进行升级 - CallerAutoPilotManager.setIPCUpgradeAffirm() - AdUpgradeStateHelper.setUpgradeStatus(true) + fun showAdUpgradeStatus(ipcUpgradeStateInfo: IPCUpgradeStateInfo){ + ThreadUtils.runOnUiThread{ + setAdUpgradeInfo(ipcUpgradeStateInfo) + AdUpgradeStateHelper.setUpgradeableStatus(false) + ipcUpgradeStateInfo.status.let {status-> + when { + AdUpgradeStateHelper.isDownloading(status) -> { + //正在下载,展示“下载中”角标,展示进度条,并设置当前下载进度 + ivAdStatus?.setImageResource(R.drawable.icon_downloading) + adCircularProgressView?.let {adCircularProgressView-> + adCircularProgressView.visibility = View.VISIBLE + CallerLogger.i( + "$M_HMI$$TAG", "showAdUpgradeStatus status=$status" + ) + adCircularProgressView.setProgress( + AdUpgradeStateHelper.downloadProgress( + ipcUpgradeStateInfo.progress.progressDetail.current, + ipcUpgradeStateInfo.progress.progressDetail.total + ) + ) + } + ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) + } + AdUpgradeStateHelper.isDownloadFailed(status) -> { + //下载失败,将状态设为“最新版”角标,并隐藏进度条 + ivAdStatus?.setImageResource(R.drawable.icon_latest_version) + adCircularProgressView?.visibility = View.GONE + ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) + } + AdUpgradeStateHelper.isUpgrading(status) ->{ + //升级中,将状态设为“升级中”角标,并隐藏进度条 + ivAdStatus?.setImageResource(R.drawable.icon_upgrading) + adCircularProgressView?.visibility = View.GONE + ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) + } + AdUpgradeStateHelper.isUpgradeSuccess(status) -> { + //升级成功,将状态设为“最新版”角标,并隐藏进度条 + ivAdStatus?.setImageResource(R.drawable.icon_latest_version) + adCircularProgressView?.visibility = View.GONE + ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) + } + AdUpgradeStateHelper.isUpgradeFailed(status) -> { + //升级失败,将状态设为“升级失败”角标,并隐藏进度条 + ivAdStatus?.setImageResource(R.drawable.icon_upgrade_failed) + adCircularProgressView?.visibility = View.GONE + ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) + } + else -> { + //其他状态,均显示“最新版”,并隐藏进度条 + ivAdStatus?.setImageResource(R.drawable.icon_latest_version) + adCircularProgressView?.visibility = View.GONE + ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) } } - - } else if (AdUpgradeStateHelper.isDownloadFailed(downloadStatus)) { - //下载失败,将状态设为“最新版”角标,并隐藏进度条 - ivAdStatus?.setImageResource(R.drawable.icon_latest_version) - adCircularProgressView?.visibility = View.GONE - ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) - } else if (AdUpgradeStateHelper.isUpgradeSuccess(upgradeStatus)) { - //升级成功,将状态设为“最新版”角标,并隐藏进度条 - ivAdStatus?.setImageResource(R.drawable.icon_latest_version) - adCircularProgressView?.visibility = View.GONE - AdUpgradeStateHelper.setUpgradeStatus(false) - ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) - } else if (AdUpgradeStateHelper.isUpgradeFailed(upgradeStatus)) { - //升级失败,将状态设为“升级失败”角标,并隐藏进度条 - ivAdStatus?.setImageResource(R.drawable.icon_upgrade_failed) - adCircularProgressView?.visibility = View.GONE - AdUpgradeStateHelper.setUpgradeStatus(false) - ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) - } else { - //其他状态,均显示“最新版”,并隐藏进度条 - ivAdStatus?.setImageResource(R.drawable.icon_latest_version) - adCircularProgressView?.visibility = View.GONE - ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) } - } } - /** * 展示当前鹰眼版本 */ @@ -271,6 +214,8 @@ class SystemVersionView @JvmOverloads constructor( return } CallerAutoPilotStatusListenerManager.addListener(TAG, this) + CallerBindingCarListenerManager.registerDevaToolsLogCatchListener(TAG,this) + needQueryContainers = true } override fun onDetachedFromWindow() { @@ -279,6 +224,8 @@ class SystemVersionView @JvmOverloads constructor( return } CallerAutoPilotStatusListenerManager.removeListener(TAG) + CallerBindingCarListenerManager.unRegisterDevaToolsLogCatchListener(TAG) + needQueryContainers = false } override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) { @@ -289,6 +236,13 @@ class SystemVersionView @JvmOverloads constructor( "$M_HMI$TAG", "onAutopilotStatusResponse connectStatus=$connectStatus , dockerVersion=$dockerVersion , autopilotStatus=$autopilotStatus" ) + if(needQueryContainers && !AdUpgradeStateHelper.isUpgradeableStatus()){ + dockerVersion?.let { + //查询是否有新的工控机docker版本 + CallerBindingcarManager.getBindingcarProvider().queryContainers(MoGoAiCloudClient.getInstance().aiCloudClientConfig.sn,dockerVersion) + needQueryContainers = false + } + } setViewStatus() } @@ -296,4 +250,21 @@ class SystemVersionView @JvmOverloads constructor( showCurrentAdVersion() } + override fun queryContainersResponse(dockerList: List) { + this.dockerList = dockerList + if(dockerList.isNotEmpty()){ + //有更新任务,将状态设为“可升级”角标,并隐藏进度条 + ivAdStatus?.setImageResource(R.drawable.icon_upgradeable) + adCircularProgressView?.visibility = View.GONE + ivAdVersion?.setBackgroundResource(R.drawable.version_upgradeable_background) + AdUpgradeStateHelper.setUpgradeableStatus(true) + }else{ + ToastUtils.showLong("已是最新版本") + ivAdStatus?.setImageResource(R.drawable.icon_latest_version) + adCircularProgressView?.visibility = View.GONE + ivAdVersion?.setBackgroundResource(R.drawable.version_latest_background) + AdUpgradeStateHelper.setUpgradeableStatus(false) + } + } + } \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AdUpgradeStateHelper.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/AdUpgradeStateHelper.kt similarity index 57% rename from core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AdUpgradeStateHelper.kt rename to core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/AdUpgradeStateHelper.kt index 61c79e7ec3..1bd49ab863 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AdUpgradeStateHelper.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/AdUpgradeStateHelper.kt @@ -1,4 +1,4 @@ -package com.mogo.eagle.core.data.autopilot +package com.mogo.eagle.core.data.bindingcar /** * @author XuXinChao @@ -8,21 +8,15 @@ package com.mogo.eagle.core.data.autopilot class AdUpgradeStateHelper { companion object{ - private const val UPGRADE_QUIET = 0 //静默升级 - private const val UPGRADE_HINT = 3 //提示升级 + private const val DOWNLOADING = "30" //下载中 + private const val DOWNLOAD_FINISH = "31" //下载成功 + private const val DOWNLOAD_FAILED = "32" //下载失败 - private const val DOWNLOAD_START = 30 //开始下载 - private const val DOWNLOAD_FINISH = 31 //下载完成 - private const val DOWNLOAD_FAILED = 32 //下载失败 + private const val UPGRADING = "50" //升级中 + private const val UPGRADE_SUCCEED = "51" //升级成功 + private const val UPGRADE_FAILED = "52" //升级失败 - private const val UPGRADE_AFFIRM = 60 //是否升级 - private const val UPGRADE_SUCCEED = 61 //升级成功 - private const val UPGRADE_FAILED = 62 //升级失败 - - private const val USER_AFFIRM = 63 //用户确认 - private const val USER_CANCEL = 64 //用户取消 - - private var UPGRADING = false //工控机是否处于“升级中”状态 + private var UPGRADEABLE = false //是否是可升级状态 /** * 如果工控机处于“下载中”、“可升级(下载完成)”、“升级中”、“升级失败”状态时,工具箱入口显示红色角标 @@ -30,8 +24,8 @@ class AdUpgradeStateHelper { * @param upgradeStatus 升级状态 */ @JvmStatic - fun showUpgradeTips(downloadStatus: Int,upgradeStatus: Int) : Boolean{ - return isDownloading(downloadStatus) || isDownloadFinish(downloadStatus,upgradeStatus) || getUpgradeStatus() || isUpgradeFailed(upgradeStatus) + fun showUpgradeTips(downloadStatus: String,upgradeStatus: String) : Boolean{ + return isDownloading(downloadStatus) || isDownloadFinish(downloadStatus) || isUpgradeFailed(upgradeStatus) } /** @@ -40,8 +34,17 @@ class AdUpgradeStateHelper { * @param upgradeStatus 升级状态 */ @JvmStatic - fun showCannotReboot(downloadStatus: Int,upgradeStatus: Int): Boolean{ - return isDownloading(downloadStatus)|| isDownloadFinish(downloadStatus,upgradeStatus) || getUpgradeStatus() + fun showCannotReboot(downloadStatus: String,upgradeStatus: String): Boolean{ + return isDownloading(downloadStatus)|| isDownloadFinish(downloadStatus) + } + + @JvmStatic + fun isUpgradeableStatus(): Boolean{ + return UPGRADEABLE + } + + fun setUpgradeableStatus(upgradeStatus: Boolean){ + UPGRADEABLE = upgradeStatus } /** @@ -49,18 +52,17 @@ class AdUpgradeStateHelper { * @param downloadStatus 下载状态 */ @JvmStatic - fun isDownloading(downloadStatus: Int) : Boolean{ - return downloadStatus == DOWNLOAD_START + fun isDownloading(downloadStatus: String) : Boolean{ + return downloadStatus == DOWNLOADING } /** * 工控机是否处于“下载完成”(可升级)状态 * @param downloadStatus 下载状态 - * @param upgradeStatus 升级状态 */ @JvmStatic - fun isDownloadFinish(downloadStatus: Int,upgradeStatus: Int) : Boolean{ - return downloadStatus == DOWNLOAD_FINISH && upgradeStatus == USER_AFFIRM + fun isDownloadFinish(downloadStatus: String) : Boolean{ + return downloadStatus == DOWNLOAD_FINISH } /** @@ -68,16 +70,20 @@ class AdUpgradeStateHelper { * @param downloadStatus 下载状态 */ @JvmStatic - fun isDownloadFailed(downloadStatus: Int) : Boolean{ + fun isDownloadFailed(downloadStatus: String) : Boolean{ return downloadStatus == DOWNLOAD_FAILED } + fun isUpgrading(upgradeStatus: String): Boolean{ + return upgradeStatus == UPGRADING + } + /** * 工控机是否处于“升级成功”状态 * @param upgradeStatus 升级状态 */ @JvmStatic - fun isUpgradeSuccess(upgradeStatus: Int) : Boolean{ + fun isUpgradeSuccess(upgradeStatus: String) : Boolean{ return upgradeStatus == UPGRADE_SUCCEED } @@ -86,7 +92,7 @@ class AdUpgradeStateHelper { * @param upgradeStatus 升级状态 */ @JvmStatic - fun isUpgradeFailed(upgradeStatus: Int) : Boolean{ + fun isUpgradeFailed(upgradeStatus: String) : Boolean{ return upgradeStatus == UPGRADE_FAILED } @@ -100,41 +106,6 @@ class AdUpgradeStateHelper { return (currentProgress.toDouble()/totalProgress.toDouble()*100).toInt() } - /** - * 工控机升级模式是否是静默升级 - * @param upgradeMode 升级模式 - */ - @JvmStatic - fun isQuietUpgradeMode(upgradeMode: Int) : Boolean{ - return upgradeMode == UPGRADE_QUIET - } - - /** - * 工控机升级模式是否是提示升级 - * @param upgradeMode 升级模式 - */ - @JvmStatic - fun isHintUpgradeMode(upgradeMode: Int) : Boolean{ - return upgradeMode == UPGRADE_HINT - } - - /** - * 获取是否处于“升级中”状态 - */ - @JvmStatic - fun getUpgradeStatus() : Boolean{ - return UPGRADING - } - - /** - * 设置是否处于“升级中”状态 - * @param upgrading 是否是升级中 - */ - @JvmStatic - fun setUpgradeStatus(upgrading: Boolean){ - UPGRADING = upgrading - } - /** * 获取工控机包体下载剩余时间 */ diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/IPCQueryContainersInfo.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/IPCQueryContainersInfo.kt new file mode 100644 index 0000000000..33b1f1e186 --- /dev/null +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/IPCQueryContainersInfo.kt @@ -0,0 +1,11 @@ +package com.mogo.eagle.core.data.bindingcar + +/** + * @author XuXinChao + * @description 主动查询工控机新版本接口返回实体类 + * @since: 2022/5/18 + */ +data class IPCQueryContainersInfo( + val images: List, + val padSn: String +) \ No newline at end of file diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/IPCUpgradeStateInfo.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/IPCUpgradeStateInfo.kt index 35f62555ab..beda315feb 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/IPCUpgradeStateInfo.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/bindingcar/IPCUpgradeStateInfo.kt @@ -1,5 +1,7 @@ package com.mogo.eagle.core.data.bindingcar +import androidx.annotation.Nullable + /** * @author XuXinChao * @description 工控机镜像升级状态实体类 @@ -9,7 +11,8 @@ data class IPCUpgradeStateInfo( val callback_url: String, val images: List, val progress: Progress, - val release_id: String, + @Nullable + val releaseId: String?, val status: String, val token: String ) diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotProvider.kt index 2737da0c8f..1815e0867f 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/autopilot/IMoGoAutopilotProvider.kt @@ -108,16 +108,6 @@ interface IMoGoAutopilotProvider : IMoGoFunctionServerProvider { */ fun setIPCReboot() - /** - * 工控机升级确认 - */ - fun setIPCUpgradeAffirm() - - /** - * 工控机升级取消 - */ - fun setIPCUpgradeCancel() - /** * 演示模式(美化模式) * isEnable = true 开启 diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/bindingcar/IMoGoBindingCarListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/bindingcar/IMoGoBindingCarListener.kt new file mode 100644 index 0000000000..db8578a5d2 --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/bindingcar/IMoGoBindingCarListener.kt @@ -0,0 +1,12 @@ +package com.mogo.eagle.core.function.api.bindingcar + +/** + * @author XuXinChao + * @description + * @since: 2022/5/18 + */ +interface IMoGoBindingCarListener { + + fun queryContainersResponse(dockerList: List) + +} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/bindingcar/IMoGoBindingcarProvider.java b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/bindingcar/IMoGoBindingcarProvider.java index fee5fe552a..5b8e1062b8 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/bindingcar/IMoGoBindingcarProvider.java +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/bindingcar/IMoGoBindingcarProvider.java @@ -2,6 +2,8 @@ package com.mogo.eagle.core.function.api.bindingcar; import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider; +import java.util.List; + /** * @author lixiaopeng * @description 修改车辆信息 @@ -10,4 +12,19 @@ import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider; public interface IMoGoBindingcarProvider extends IMoGoFunctionServerProvider { void modifyCarInfo(BindingcarCallBack callBack); void getBindingcarInfo(String macAddress, String widevineIDWithMd5); + + /** + * 确认升级工控机docker版本 + * @param images docker列表 + * @param padSn SN + * @param releaseId 任务ID + */ + void upgradeConfirm(List images, String padSn, String releaseId); + + /** + * 获取新工控机docker版本 + * @param padSn SN + * @param dockerVersion 当前工控机版本 + */ + void queryContainers(String padSn,String dockerVersion); } diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt index 4ada8a9e6d..81c46f9114 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/hmi/warning/IMoGoWaringProvider.kt @@ -1,6 +1,7 @@ package com.mogo.eagle.core.function.api.hmi.warning import android.view.View +import com.mogo.eagle.core.data.bindingcar.IPCUpgradeStateInfo import com.mogo.eagle.core.data.enums.WarningDirectionEnum import com.mogo.eagle.core.data.notice.NoticeNormalData import com.mogo.eagle.core.data.notice.NoticeTrafficStylePushData @@ -204,6 +205,16 @@ interface IMoGoWaringProvider : IMoGoHmiViewProxy { */ fun showModifyBindingcarDialog() + /** + * 呈现工控机升级确认框 + */ + fun showAdUpgradeDialog(images: List,padSn: String,releaseId: String) + + /** + * 更新工控机下载、升级状态 + */ + fun showAdUpgradeStatus(ipcUpgradeStateInfo: IPCUpgradeStateInfo) + /** *注册工控机升级提示圆点View的回调 * @param 提示圆点View diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotManager.kt index 13e19f76d9..a80d04bf99 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotManager.kt @@ -140,20 +140,6 @@ object CallerAutoPilotManager { providerApi?.setIPCReboot() } - /** - * 设置工控机升级确认 - */ - fun setIPCUpgradeAffirm() { - providerApi?.setIPCUpgradeAffirm() - } - - /** - * 设置工控机升级取消 - */ - fun setIPCUpgradeCancel() { - providerApi?.setIPCUpgradeCancel() - } - /** * 演示模式(美化模式) * isEnable = true 开启 diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/bindingcar/CallerBindingCarListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/bindingcar/CallerBindingCarListenerManager.kt new file mode 100644 index 0000000000..41c979cae1 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/bindingcar/CallerBindingCarListenerManager.kt @@ -0,0 +1,65 @@ +package com.mogo.eagle.core.function.call.bindingcar + +import androidx.annotation.Nullable +import com.mogo.eagle.core.function.api.bindingcar.IMoGoBindingCarListener +import java.util.concurrent.ConcurrentHashMap + +/** + * @author XuXinChao + * @description + * @since: 2022/5/18 + */ +object CallerBindingCarListenerManager { + + private val BINDING_CAR_LISTENER: ConcurrentHashMap = + ConcurrentHashMap() + + /** + * 添加监听 + * @param tag 标记,用来注销监听使用 + * @param listener 监听回调 + */ + fun registerDevaToolsLogCatchListener( + @Nullable tag: String, + @Nullable listener: IMoGoBindingCarListener + ) { + if (BINDING_CAR_LISTENER.containsKey(tag)) { + return + } + BINDING_CAR_LISTENER[tag] = listener + } + + /** + * 删除监听 + * @param tag 标记,用来注销监听使用 + */ + fun unRegisterDevaToolsLogCatchListener(@Nullable tag: String) { + if (!BINDING_CAR_LISTENER.containsKey(tag)) { + return + } + BINDING_CAR_LISTENER.remove(tag) + } + + /** + * 删除监听 + * @param listener 要删除的监听对象 + */ + fun unRegisterDevaToolsLogCatchListener(@Nullable listener: IMoGoBindingCarListener) { + if (!BINDING_CAR_LISTENER.containsValue(listener)) { + return + } + BINDING_CAR_LISTENER.forEach { + if (it.value == listener) { + BINDING_CAR_LISTENER.remove(it.key) + } + } + } + + fun invokeQueryContainersResponse(dockerList: List){ + BINDING_CAR_LISTENER.forEach { + val listener = it.value + listener.queryContainersResponse(dockerList) + } + } + +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt index 4fdf413da5..a12d3ca256 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/hmi/CallerHmiManager.kt @@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.call.hmi import android.view.View import com.alibaba.android.arouter.launcher.ARouter +import com.mogo.eagle.core.data.bindingcar.IPCUpgradeStateInfo import com.mogo.eagle.core.data.constants.MoGoFragmentPaths import com.mogo.eagle.core.data.enums.WarningDirectionEnum import com.mogo.eagle.core.data.notice.NoticeNormalData @@ -268,6 +269,20 @@ object CallerHmiManager : CallerBase() { waringProviderApi?.showModifyBindingcarDialog() } + /** + * 呈现工控机升级确认框 + */ + fun showAdUpgradeDialog(images: List,padSn: String,releaseId: String){ + waringProviderApi?.showAdUpgradeDialog(images, padSn, releaseId) + } + + /** + * 更新工控机下载、升级状态 + */ + fun showAdUpgradeStatus(ipcUpgradeStateInfo: IPCUpgradeStateInfo){ + waringProviderApi?.showAdUpgradeStatus(ipcUpgradeStateInfo) + } + fun showNoSignalView() { waringProviderApi?.showNoSignView() }