工控机升级
工控机升级云端获取数据版本
This commit is contained in:
@@ -321,18 +321,6 @@ class MoGoAutopilotProvider :
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机升级确认
|
||||
*/
|
||||
override fun setIPCUpgradeAffirm() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机升级取消
|
||||
*/
|
||||
override fun setIPCUpgradeCancel() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 演示模式(美化模式)
|
||||
* isEnable = true 开启
|
||||
|
||||
@@ -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<String> 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());
|
||||
|
||||
@@ -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<IPCUpgradeStateInfo> ,
|
||||
}
|
||||
|
||||
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<IPCUpgradeStateInfo> ,
|
||||
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<IPCUpgradeStateInfo> ,
|
||||
* @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<String>,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<String>()
|
||||
for(i in 0 until images.length()){
|
||||
if(!i.toString().contains(dockerVersion)){
|
||||
dockerList.add(images[i].toString())
|
||||
}
|
||||
}
|
||||
//将数组结果回调
|
||||
CallerBindingCarListenerManager.invokeQueryContainersResponse(dockerList)
|
||||
},
|
||||
onError = {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
fun destroy(){
|
||||
|
||||
@@ -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<Any>
|
||||
|
||||
/**
|
||||
* 获取新工控机docker版本
|
||||
* @param padSn SN
|
||||
*/
|
||||
@GET("/api/pushServer/queryContainers")
|
||||
suspend fun queryContainers(@Query("padSn") padSn: String): Response<Any>
|
||||
}
|
||||
@@ -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<String>,padSn: String,releaseId: String,
|
||||
onSuccess: ((String) -> Unit),onError: ((String) -> Unit)){
|
||||
request<BaseResponse<Any?>> {
|
||||
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<Response<Any?>>{
|
||||
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!!)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<MoGoHmiContract.View?, HmiPresenter?>(),
|
||||
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<MoGoHmiContract.View?, HmiPresenter?>(),
|
||||
|
||||
}
|
||||
|
||||
override fun showAdUpgradeDialog(
|
||||
images: List<String>,
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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<String>,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<String>?=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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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<String>?=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<String>) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user