ad upgrade
ad upgrade code update
This commit is contained in:
@@ -12,6 +12,7 @@ import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.voice.AIAssist
|
||||
import com.mogo.eagle.core.data.autopilot.AdUpgradeStateHelper
|
||||
import com.mogo.eagle.core.data.autopilot.AutoPilotRecordResult
|
||||
import com.mogo.eagle.core.data.camera.CameraEntity
|
||||
import com.mogo.eagle.core.data.config.HmiBuildConfig
|
||||
@@ -981,47 +982,30 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机下载状态信息
|
||||
* 展示工控机下载、升级状态信息
|
||||
* @param upgradeMode 升级模式(提示升级、静默升级)
|
||||
* @param downloadStatus 下载状态
|
||||
* @param currentProgress 当前已经下载包体大小
|
||||
* @param totalProgress 下载包体总大小
|
||||
* @param downloadVersion 下载版本
|
||||
* @param downloadStatus 下载状态(0:下载完成;1:正在下载;2:下载失败)
|
||||
* @param downloadProgress 下载进度
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
override fun showAdDownloadStatus(
|
||||
downloadVersion: String,
|
||||
override fun showAdUpgradeStatus(
|
||||
upgradeMode: Int,
|
||||
downloadStatus: Int,
|
||||
downloadProgress: Int
|
||||
currentProgress: Int,
|
||||
totalProgress: Int,
|
||||
downloadVersion: String,
|
||||
upgradeStatus: Int
|
||||
) {
|
||||
// if (downloadProgress>0){
|
||||
// //新版工控机包处于下载中或已下载完成状态,展示工具箱提示角标
|
||||
// viewUpgradeTips.visibility = View.VISIBLE
|
||||
// }
|
||||
if(downloadStatus==0){
|
||||
//新版本工控机包下载完成,处于可升级状态,展示工具箱提示角标
|
||||
//如果工控机处于“下载中”、“可升级(下载完成)”、“升级中”、“升级失败”状态时,工具箱入口显示红色角标
|
||||
if(AdUpgradeStateHelper.showUpgradeTips(downloadStatus, upgradeStatus)){
|
||||
viewUpgradeTips.visibility = View.VISIBLE
|
||||
}else if(downloadStatus==1){
|
||||
//新版本工控机包正在下载中,展示工具箱提示角标
|
||||
viewUpgradeTips.visibility = View.VISIBLE
|
||||
}else if(downloadStatus==2){
|
||||
//新版本工控机包下载失败,隐藏工具箱提交角标
|
||||
viewUpgradeTips.visibility = View.GONE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机升级状态信息
|
||||
* @param upgradeStatus 升级状态(true代表升级成功、false代表升级不成功)
|
||||
*/
|
||||
override fun showAdUpgradeStatus(upgradeStatus: Boolean) {
|
||||
if(upgradeStatus){
|
||||
//工控机升级成功,隐藏工具箱提示角标
|
||||
viewUpgradeTips.visibility = View.GONE
|
||||
}else{
|
||||
//工控机升级失败,展示工具箱提示角标
|
||||
viewUpgradeTips.visibility = View.VISIBLE
|
||||
viewUpgradeTips.visibility = View.GONE
|
||||
}
|
||||
//TODO 给工具箱空间传递状态
|
||||
// toolsView?.setStatus(true)
|
||||
//将状态同步到工具箱
|
||||
toolsView?.showAdUpgradeStatus(upgradeMode,downloadStatus, currentProgress, totalProgress, downloadVersion, upgradeStatus)
|
||||
}
|
||||
|
||||
private fun dismissBadCaseFloatView() {
|
||||
|
||||
@@ -21,6 +21,8 @@ class AdUpgradeDialog(context: Context) : BaseFloatDialog(context), LifecycleObs
|
||||
private var upgradeConfirm : TextView? = null
|
||||
private var upgradeCancel : TextView? = null
|
||||
|
||||
private var clickListener: ClickListener? = null
|
||||
|
||||
init {
|
||||
setContentView(R.layout.dialog_ad_upgrade)
|
||||
setCanceledOnTouchOutside(true)
|
||||
@@ -29,18 +31,28 @@ class AdUpgradeDialog(context: Context) : BaseFloatDialog(context), LifecycleObs
|
||||
|
||||
upgradeConfirm?.setOnClickListener{
|
||||
Logger.i(TAG,"upgradeConfirm click")
|
||||
clickListener?.confirm()
|
||||
}
|
||||
upgradeCancel?.setOnClickListener {
|
||||
Logger.i(TAG,"upgradeCancel click")
|
||||
clickListener?.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
fun setClickListener(clickListener: ClickListener) {
|
||||
this.clickListener = clickListener
|
||||
}
|
||||
|
||||
fun showUpgradeDialog(){
|
||||
if(isShowing){
|
||||
return
|
||||
}
|
||||
|
||||
show()
|
||||
}
|
||||
|
||||
interface ClickListener{
|
||||
fun confirm()
|
||||
fun cancel()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -112,6 +112,20 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
this.clickListener = clickListener
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机下载、升级状态信息
|
||||
* @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)
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
|
||||
@@ -5,6 +5,7 @@ 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.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
@@ -28,18 +29,19 @@ class SystemVersionView @JvmOverloads constructor(
|
||||
|
||||
companion object {
|
||||
const val TAG = "SystemVersionView"
|
||||
|
||||
const val AD_LATEST_VERSION = 1 //AD最新版
|
||||
const val AD_DOWNING = 2 //AD下载中
|
||||
const val AD_DOWNLOAD_FAIL = 3 //AD下载失败
|
||||
const val AD_UPGRADEABLE = 4 //AD下载成功,可升级状态
|
||||
const val AD_UPGRADING = 5 //AD升级中
|
||||
const val AD_UPGRADE_FAIL = 6 //AD升级失败
|
||||
}
|
||||
|
||||
private var connectStatus = false
|
||||
private var adUpgradeDialog : AdUpgradeDialog? = null
|
||||
private var adStatus = AD_LATEST_VERSION //工控机默认为最新版
|
||||
|
||||
private var upgradeMode: Int=-1 //升级模式
|
||||
private var downloadStatus: Int=-1 //下载状态
|
||||
private var currentProgress: Int=0 //当前已下载包体大小
|
||||
private var previousProgress: Int=0 //前一秒的下载进度,用于计算下载剩余时间
|
||||
private var totalProgress: Int=0 //包体总大小
|
||||
private var downloadVersion: String?=null //工控机docker版本
|
||||
private var upgradeStatus: Int=-1 //升级状态
|
||||
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_system_version, this, true)
|
||||
@@ -57,42 +59,122 @@ class SystemVersionView @JvmOverloads constructor(
|
||||
//工控机版本视图点击事件
|
||||
ivAdVersion.setOnClickListener {
|
||||
Logger.i(TAG,"ad version view clicked")
|
||||
when(adStatus){
|
||||
AD_LATEST_VERSION -> {
|
||||
//最新版
|
||||
Logger.i(TAG,"upgradeMode="+upgradeMode+" downloadStatus="+downloadStatus+" upgradeStatus="+upgradeStatus)
|
||||
if(AdUpgradeStateHelper.isDownloading(downloadStatus)){
|
||||
//点击Toast提示:下载剩余时间
|
||||
ToastUtils.showShort("预计"+AdUpgradeStateHelper.getRemainingTime(totalProgress,previousProgress,currentProgress)+"下载完成")
|
||||
}else if(AdUpgradeStateHelper.isHintUpgradeMode(upgradeMode) && AdUpgradeStateHelper.isDownloadFinish(downloadStatus)){
|
||||
//如果升级模式为“提示升级”,并且下载状态为已经下载完成,点击弹出升级确认弹窗
|
||||
if(adUpgradeDialog == null){
|
||||
adUpgradeDialog = AdUpgradeDialog(context)
|
||||
adUpgradeDialog?.setClickListener(object : AdUpgradeDialog.ClickListener{
|
||||
override fun confirm() {
|
||||
//确认升级
|
||||
Logger.i(TAG,"upgrade confirm")
|
||||
//设置当前状态为“升级中”
|
||||
AdUpgradeStateHelper.setUpgradeStatus(true)
|
||||
//TODO
|
||||
// AdasManager.getInstance().sendBaseInfo(IPCUpgradeInfo.affirm());
|
||||
|
||||
}
|
||||
AD_DOWNING -> {
|
||||
//下载中
|
||||
//TODO 需要向工控机要下载时间
|
||||
ToastUtils.showShort("新版本下载中,预计XX分钟下载完成")
|
||||
}
|
||||
AD_DOWNLOAD_FAIL -> {
|
||||
//下载失败
|
||||
}
|
||||
|
||||
}
|
||||
AD_UPGRADEABLE -> {
|
||||
//下载成功,可升级,点击弹起升级确认弹窗
|
||||
if(adUpgradeDialog == null){
|
||||
adUpgradeDialog = AdUpgradeDialog(context)
|
||||
}
|
||||
adUpgradeDialog?.showUpgradeDialog()
|
||||
}
|
||||
AD_UPGRADING -> {
|
||||
//升级中
|
||||
ToastUtils.showShort("新版本升级中,预计5分钟升级完成")
|
||||
}
|
||||
AD_UPGRADE_FAIL -> {
|
||||
//升级失败
|
||||
ToastUtils.showShort("升级失败,请联系运维人员")
|
||||
}
|
||||
override fun cancel() {
|
||||
//取消升级
|
||||
Logger.i(TAG,"upgrade cancel")
|
||||
//TODO
|
||||
// AdasManager.getInstance().sendBaseInfo(IPCUpgradeInfo.cancel());
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
adUpgradeDialog?.showUpgradeDialog()
|
||||
}else if(AdUpgradeStateHelper.getUpgradeStatus()){
|
||||
//工控机状态为“升级中”
|
||||
ToastUtils.showShort("新版本升级中,预计5分钟升级完成")
|
||||
}else if(AdUpgradeStateHelper.isUpgradeFailed(upgradeStatus)){
|
||||
//如果升级失败,则Toast提示:升级失败,请联系运维人员
|
||||
ToastUtils.showShort("升级失败,请联系运维人员")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置工控机下载、升级状态信息
|
||||
* @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
|
||||
this.previousProgress=this.currentProgress
|
||||
this.currentProgress=currentProgress
|
||||
this.totalProgress=totalProgress
|
||||
this.downloadVersion=downloadVersion
|
||||
this.upgradeStatus=upgradeStatus
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机下载、升级状态信息
|
||||
* @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){
|
||||
//设置工控机下载、升级状态信息
|
||||
setAdUpgradeInfo(upgradeMode, downloadStatus, currentProgress, totalProgress, downloadVersion, upgradeStatus)
|
||||
|
||||
if(AdUpgradeStateHelper.isDownloading(downloadStatus)){
|
||||
//正在下载,展示“下载中”角标,展示进度条,并设置当前下载进度
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_downloading)
|
||||
adCircularProgressView?.let {
|
||||
it.visibility = View.VISIBLE
|
||||
it.setProgress(AdUpgradeStateHelper.downloadProgress(currentProgress,totalProgress))
|
||||
}
|
||||
}else if(AdUpgradeStateHelper.isDownloadFinish(downloadStatus)){
|
||||
//下载完成,处于可升级状态,展示“可升级”角标,将AD背景变为蓝色,并隐藏下载进度条
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_upgradeable)
|
||||
ivAdVersion?.setBackgroundResource(R.drawable.version_upgradeable_background)
|
||||
adCircularProgressView?.visibility = View.GONE
|
||||
if(AdUpgradeStateHelper.isQuietUpgradeMode(upgradeMode)){
|
||||
//如果升级模式为“静默升级”,则下载完成后,调用升级命令进行升级
|
||||
//TODO 升级
|
||||
// AdasManager.getInstance().sendBaseInfo(IPCUpgradeInfo.affirm());
|
||||
AdUpgradeStateHelper.setUpgradeStatus(true)
|
||||
}
|
||||
}else if(AdUpgradeStateHelper.isDownloadFailed(downloadStatus)){
|
||||
//下载失败,将状态设为“最新版”角标,并隐藏进度条
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_latest_version)
|
||||
adCircularProgressView?.visibility = View.GONE
|
||||
} else if(AdUpgradeStateHelper.isUpgradeSuccess(upgradeStatus)){
|
||||
//升级成功,将状态设为“最新版”角标,并隐藏进度条
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_latest_version)
|
||||
adCircularProgressView?.visibility = View.GONE
|
||||
AdUpgradeStateHelper.setUpgradeStatus(false)
|
||||
}else if(AdUpgradeStateHelper.isUpgradeFailed(upgradeStatus)){
|
||||
//升级失败,将状态设为“升级失败”角标,并隐藏进度条
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_upgrade_failed)
|
||||
adCircularProgressView?.visibility = View.GONE
|
||||
AdUpgradeStateHelper.setUpgradeStatus(false)
|
||||
}else{
|
||||
//其他状态,均显示“最新版”,并隐藏进度条
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_latest_version)
|
||||
adCircularProgressView?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 展示当前鹰眼版本
|
||||
*/
|
||||
@@ -111,54 +193,6 @@ class SystemVersionView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机下载状态信息
|
||||
* @param downloadVersion 下载版本
|
||||
* @param downloadStatus 下载状态(0:下载完成;1:正在下载;2:下载失败)
|
||||
* @param downloadProgress 下载进度
|
||||
*/
|
||||
fun showAdDownloadStatus(downloadVersion : String,downloadStatus : Int,downloadProgress : Int){
|
||||
if(downloadStatus==0){
|
||||
//下载完成,处于可升级状态,展示“可升级”角标,将AD背景变为蓝色,并隐藏下载进度条
|
||||
adStatus = AD_UPGRADEABLE
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_upgradeable)
|
||||
ivAdVersion?.setBackgroundResource(R.drawable.version_upgradeable_background)
|
||||
adCircularProgressView?.visibility = View.GONE
|
||||
}else if(downloadStatus==1){
|
||||
//正在下载,展示“下载中”角标,展示进度条,并设置当前下载进度
|
||||
adStatus = AD_DOWNING
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_downloading)
|
||||
adCircularProgressView?.let {
|
||||
it.visibility = View.VISIBLE
|
||||
it.setProgress(downloadProgress)
|
||||
}
|
||||
}else if(downloadStatus==2){
|
||||
//下载失败,目前暂时将状态设为“最新版”角标,并隐藏进度条
|
||||
adStatus = AD_DOWNLOAD_FAIL
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_latest_version)
|
||||
adCircularProgressView?.visibility = View.GONE
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机升级状态信息
|
||||
* @param upgradeStatus 升级状态(true代表升级成功、false代表升级不成功)
|
||||
*/
|
||||
fun showAdUpgradeStatus(upgradeStatus : Boolean){
|
||||
if(upgradeStatus){
|
||||
//AD升级成功,工控机图标展示最新版样式
|
||||
adStatus = AD_LATEST_VERSION
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_latest_version)
|
||||
}else{
|
||||
//AD升级失败,工控机图标展示升级失败样式
|
||||
adStatus = AD_UPGRADE_FAIL
|
||||
ivAdStatus?.setImageResource(R.drawable.icon_upgrade_failed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.mogo.eagle.core.data.autopilot
|
||||
|
||||
/**
|
||||
* @author XuXinChao
|
||||
* @description 工控机升级状态实体类
|
||||
* @since: 2022/1/21
|
||||
*/
|
||||
class AdUpgradeStateHelper {
|
||||
|
||||
companion object{
|
||||
private const val UPGRADE_QUIET = 0 //静默升级
|
||||
private const val UPGRADE_HINT = 3 //提示升级
|
||||
|
||||
private const val DOWNLOAD_START = 30 //开始下载
|
||||
private const val DOWNLOAD_FINISH = 31 //下载完成
|
||||
private const val DOWNLOAD_FAILED = 32 //下载失败
|
||||
|
||||
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 //工控机是否处于“升级中”状态
|
||||
|
||||
/**
|
||||
* 如果工控机处于“下载中”、“可升级(下载完成)”、“升级中”、“升级失败”状态时,工具箱入口显示红色角标
|
||||
* @param downloadStatus 下载状态
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
fun showUpgradeTips(downloadStatus: Int,upgradeStatus: Int) : Boolean{
|
||||
return isDownloading(downloadStatus) || isDownloadFinish(downloadStatus) || isUpgradeFailed(upgradeStatus)
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机是否处于“下载中”状态
|
||||
* @param downloadStatus 下载状态
|
||||
*/
|
||||
fun isDownloading(downloadStatus: Int) : Boolean{
|
||||
return downloadStatus == DOWNLOAD_START
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机是否处于“下载完成”(可升级)状态
|
||||
* @param downloadStatus 下载状态
|
||||
*/
|
||||
fun isDownloadFinish(downloadStatus: Int) : Boolean{
|
||||
return downloadStatus == DOWNLOAD_FINISH
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机是否处于“下载失败”状态
|
||||
* @param downloadStatus 下载状态
|
||||
*/
|
||||
fun isDownloadFailed(downloadStatus: Int) : Boolean{
|
||||
return downloadStatus == DOWNLOAD_FAILED
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机是否处于“升级成功”状态
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
fun isUpgradeSuccess(upgradeStatus: Int) : Boolean{
|
||||
return upgradeStatus == UPGRADE_SUCCEED
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机是否处于“升级失败”状态
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
fun isUpgradeFailed(upgradeStatus: Int) : Boolean{
|
||||
return upgradeStatus == UPGRADE_FAILED
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据已下载包体大小和包体总大小获取当前下载进度 0-100
|
||||
* @param currentProgress 当前已下载包体大小
|
||||
* @param totalProgress 包体总大小
|
||||
*/
|
||||
fun downloadProgress(currentProgress: Int,totalProgress: Int) : Int{
|
||||
return currentProgress*100/totalProgress
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机升级模式是否是静默升级
|
||||
* @param upgradeMode 升级模式
|
||||
*/
|
||||
fun isQuietUpgradeMode(upgradeMode: Int) : Boolean{
|
||||
return upgradeMode == UPGRADE_QUIET
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机升级模式是否是提示升级
|
||||
* @param upgradeMode 升级模式
|
||||
*/
|
||||
fun isHintUpgradeMode(upgradeMode: Int) : Boolean{
|
||||
return upgradeMode == UPGRADE_HINT
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取是否处于“升级中”状态
|
||||
*/
|
||||
fun getUpgradeStatus() : Boolean{
|
||||
return UPGRADING
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否处于“升级中”状态
|
||||
* @param upgrading 是否是升级中
|
||||
*/
|
||||
fun setUpgradeStatus(upgrading: Boolean){
|
||||
UPGRADING = upgrading
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工控机包体下载剩余时间
|
||||
*/
|
||||
fun getRemainingTime(totalProgress: Int,previousProgress: Int,currentProgress: Int) : String{
|
||||
//剩余包体大小
|
||||
val remainingSize = totalProgress - currentProgress
|
||||
//目前下载进度回调是1秒回调一次,据此计算每秒下载的包大小
|
||||
val speed = currentProgress - previousProgress
|
||||
//剩余包体的大小除以每秒下载的大小,获得剩余下载时间
|
||||
val time = remainingSize/speed
|
||||
//转换为分秒格式返回
|
||||
val minute = time/60
|
||||
val second = time%60
|
||||
if(minute>0 && second>0){
|
||||
return minute.toString()+"分钟"+second+"秒"
|
||||
}else if(minute>0){
|
||||
return minute.toString()+"分钟"
|
||||
}else if(second>0){
|
||||
return second.toString()+"秒"
|
||||
}else{
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -164,17 +164,15 @@ interface IMoGoWaringProvider {
|
||||
fun showBrakeLight(brakeLight: Int)
|
||||
|
||||
/**
|
||||
* 展示工控机下载状态信息
|
||||
* 展示工控机下载、升级状态信息
|
||||
* @param upgradeMode 升级模式(提示升级、静默升级)
|
||||
* @param downloadStatus 下载状态
|
||||
* @param currentProgress 当前已经下载包体大小
|
||||
* @param totalProgress 下载包体总大小
|
||||
* @param downloadVersion 下载版本
|
||||
* @param downloadStatus 下载状态(0:下载完成;1:正在下载;2:下载失败)
|
||||
* @param downloadProgress 下载进度
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
fun showAdDownloadStatus(downloadVersion : String,downloadStatus : Int,downloadProgress : Int)
|
||||
|
||||
/**
|
||||
* 展示工控机升级状态信息
|
||||
* @param upgradeStatus 升级状态(true代表升级成功、false代表升级不成功)
|
||||
*/
|
||||
fun showAdUpgradeStatus(upgradeStatus : Boolean)
|
||||
fun showAdUpgradeStatus(upgradeMode : Int,downloadStatus : Int,currentProgress : Int,totalProgress : Int
|
||||
,downloadVersion : String,upgradeStatus : Int)
|
||||
|
||||
}
|
||||
@@ -236,21 +236,17 @@ object CallerHmiManager : CallerBase() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机下载状态信息
|
||||
* 展示工控机下载、升级状态信息
|
||||
* @param upgradeMode 升级模式(提示升级、静默升级)
|
||||
* @param downloadStatus 下载状态
|
||||
* @param currentProgress 当前已经下载包体大小
|
||||
* @param totalProgress 下载包体总大小
|
||||
* @param downloadVersion 下载版本
|
||||
* @param downloadStatus 下载状态(0:下载完成;1:正在下载;2:下载失败)
|
||||
* @param downloadProgress 下载进度
|
||||
* @param upgradeStatus 升级状态
|
||||
*/
|
||||
fun showAdDownloadStatus(downloadVersion : String,downloadStatus : Int,downloadProgress : Int){
|
||||
waringProviderApi.showAdDownloadStatus(downloadVersion,downloadStatus,downloadProgress)
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示工控机升级状态信息
|
||||
* @param upgradeStatus 升级状态(true代表升级成功、false代表升级不成功)
|
||||
*/
|
||||
fun showAdUpgradeStatus(upgradeStatus : Boolean){
|
||||
waringProviderApi.showAdUpgradeStatus(upgradeStatus)
|
||||
fun showAdUpgradeStatus(upgradeMode : Int, downloadStatus : Int,currentProgress : Int,totalProgress : Int
|
||||
,downloadVersion : String,upgradeStatus : Int){
|
||||
waringProviderApi.showAdUpgradeStatus(upgradeMode,downloadStatus, currentProgress, totalProgress, downloadVersion, upgradeStatus)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -230,39 +230,21 @@ public class OnAdasListenerAdapter implements OnAdasListener {
|
||||
*/
|
||||
@Override
|
||||
public void onUpgradeStateInfo(IPCUpgradeStateInfo info) {
|
||||
// if(info!=null){
|
||||
// Logger.d(TAG,"onUpgradeStateInfo : "+info.getUpgradeStatus());
|
||||
// boolean upgradeStatus=false;//工控机升级状态,true代表升级成功 false代表升级失败,默认为false
|
||||
// if(info.getUpgradeStatus() == IPCUpgradeStateInfo.Status.SUCCESSFUL.code){
|
||||
// upgradeStatus=true;//升级成功
|
||||
// //升级结束确认
|
||||
// AdasManager.getInstance().sendBaseInfo(IPCUpgradeInfo.upgradeFinishAffirm());
|
||||
// }else if(info.getUpgradeStatus() == IPCUpgradeStateInfo.Status.FAILED.code){
|
||||
// upgradeStatus=false;//升级失败
|
||||
// }
|
||||
// Logger.d(TAG,"onUpgradeStateInfo : "+(upgradeStatus ? "升级成功" :"升级失败"));
|
||||
// CallerHmiManager.INSTANCE.showAdUpgradeStatus(upgradeStatus);
|
||||
// }else{
|
||||
// Logger.d(TAG,"onUpgradeStateInfo : upgrade status info is null");
|
||||
// }
|
||||
if(info != null){
|
||||
Logger.d(TAG,"onUpgradeStateInfo "+
|
||||
" upgrade mode="+info.getUpgradeMode()+
|
||||
" download status="+info.getDownloadStatus()+
|
||||
" download progress current="+info.getProgress().getCurrent()+
|
||||
" download progress total="+info.getProgress().getTotal()+
|
||||
" download version="+info.getImages()+
|
||||
" upgrade status="+info.getUpgradeStatus());
|
||||
CallerHmiManager.INSTANCE.showAdUpgradeStatus(info.getUpgradeMode(),info.getDownloadStatus(),info.getProgress().getCurrent(),
|
||||
info.getProgress().getTotal(),info.getImages(),info.getUpgradeStatus());
|
||||
}else{
|
||||
Logger.d(TAG,"onUpgradeStateInfo : upgrade state info is null");
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 工控机下载状态
|
||||
// * @param info 工控机升级包下载进度
|
||||
// */
|
||||
// @Override
|
||||
// public void onUpgradePatchDownloadStatus(IPCUpgradePatchDownloadStatusInfo info) {
|
||||
// if(info!=null){
|
||||
// Logger.d(TAG,"onUpgradePatchDownloadStatus : status="+info.getDownloadStatus() +
|
||||
// " version="+info.getDownloadVersion()+ " progress="+info.getDownloadProgress());
|
||||
// CallerHmiManager.INSTANCE.showAdDownloadStatus(info.getDownloadVersion(),info.getDownloadStatus(),info.getDownloadProgress());
|
||||
// }else{
|
||||
// Logger.d(TAG,"onUpgradePatchDownloadStatus : download status info is null");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user