ad upgrade

fix bug
This commit is contained in:
xuxinchao
2022-02-14 10:44:38 +08:00
parent b575fdc527
commit 772a923ee7
3 changed files with 76 additions and 48 deletions

View File

@@ -1,5 +1,8 @@
package com.mogo.eagle.core.data.autopilot
import android.util.Log
import java.util.logging.Logger
/**
* @author XuXinChao
* @description 工控机升级状态实体类
@@ -30,7 +33,7 @@ class AdUpgradeStateHelper {
* @param upgradeStatus 升级状态
*/
fun showUpgradeTips(downloadStatus: Int,upgradeStatus: Int) : Boolean{
return isDownloading(downloadStatus) || isDownloadFinish(downloadStatus) || isUpgradeFailed(upgradeStatus)
return isDownloading(downloadStatus) || isDownloadFinish(downloadStatus,upgradeStatus) || getUpgradeStatus() || isUpgradeFailed(upgradeStatus)
}
/**
@@ -44,9 +47,10 @@ class AdUpgradeStateHelper {
/**
* 工控机是否处于“下载完成”(可升级)状态
* @param downloadStatus 下载状态
* @param upgradeStatus 升级状态
*/
fun isDownloadFinish(downloadStatus: Int) : Boolean{
return downloadStatus == DOWNLOAD_FINISH
fun isDownloadFinish(downloadStatus: Int,upgradeStatus: Int) : Boolean{
return downloadStatus == DOWNLOAD_FINISH && upgradeStatus == USER_AFFIRM
}
/**
@@ -79,7 +83,7 @@ class AdUpgradeStateHelper {
* @param totalProgress 包体总大小
*/
fun downloadProgress(currentProgress: Int,totalProgress: Int) : Int{
return currentProgress*100/totalProgress
return (currentProgress.toDouble()/totalProgress.toDouble()*100).toInt()
}
/**