[8.1.0]OTA升级下载过程中展示剩余时间

This commit is contained in:
xuxinchao
2025-06-19 11:13:44 +08:00
parent 49c678949b
commit 8d682b555f
4 changed files with 45 additions and 19 deletions

View File

@@ -199,7 +199,7 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
productName = productName.trim().substringAfterLast(":")
}
val otaUpgradeInfo = OtaUpgradeInfo(token, productStatus,failReason,upgradeReason,
taskId,taskItemId,otaType,productName,needRestart,isDelay,curSize,totalSize)
taskId,taskItemId,otaType,productName,needRestart,isDelay,curSize,totalSize,leftTime)
otaUpgradeList.add(otaUpgradeInfo)
}
CallerHmiManager.showOTADownloadStatusDialog(true,otaUpgradeList)
@@ -338,7 +338,7 @@ object OTAUpgradeManager: IMoGoAutopilotStatusListener, IDataCenterBizListener,
productName = productName.trim().substringAfterLast(":")
}
val otaUpgradeInfo = OtaUpgradeInfo(token, productStatus,failReason,upgradeReason,
taskId,taskItemId,otaType,productName,needRestart,isDelay,curSize,totalSize)
taskId,taskItemId,otaType,productName,needRestart,isDelay,curSize,totalSize,leftTime)
otaUpgradeList.add(otaUpgradeInfo)
}
if(!upgradeComplete){

View File

@@ -37,6 +37,17 @@ class OTADownloadStatusAdapter(private val context: Context): RecyclerView.Adapt
holder.tvDownloadProgress.text = "部署中"
}
holder.pbDownloadProgress.progress = (otaUpgradeInfo.cur_size*100/otaUpgradeInfo.total_size).toInt()
if(otaUpgradeInfo.left_time <= 0){
holder.tvDownloadTime.visibility = View.INVISIBLE
}else{
holder.tvDownloadTime.visibility = View.VISIBLE
val upgradeTime = if(otaUpgradeInfo.left_time > 60){
"剩余${otaUpgradeInfo.left_time/60}分钟${otaUpgradeInfo.left_time%60}"
}else{
"剩余${otaUpgradeInfo.left_time%60}"
}
holder.tvDownloadTime.text = upgradeTime
}
// 0:默认(未开始), 1:下载中, 2:下载完成, 3:升级完成, 4:升级失败
// holder.tvDownloadStatus.text = when (otaUpgradeInfo.status) {
// 1 -> {
@@ -64,6 +75,7 @@ class OTADownloadStatusAdapter(private val context: Context): RecyclerView.Adapt
var tvProductName: TextView = itemView.findViewById(R.id.tvProductName)
var tvDownloadProgress: TextView = itemView.findViewById(R.id.tvDownloadProgress)
var pbDownloadProgress: ProgressBar = itemView.findViewById(R.id.pbDownloadProgress)
var tvDownloadTime: TextView = itemView.findViewById(R.id.tvDownloadTime)
}
}

View File

@@ -6,39 +6,51 @@
android:layout_marginTop="@dimen/dp_54"
android:layout_marginBottom="@dimen/dp_14">
<TextView
android:id="@+id/tvProductName"
android:layout_width="@dimen/dp_769"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:textColor="@color/white"
android:textSize="@dimen/sp_36"
/>
<ProgressBar
android:id="@+id/pbDownloadProgress"
android:layout_width="@dimen/dp_769"
android:layout_height="@dimen/dp_10"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvProductName"
android:layout_marginTop="@dimen/dp_11"
style="?android:attr/progressBarStyleHorizontal"
android:progressDrawable="@drawable/progressbar_ota_download"
android:max="100"
android:progress="0"
/>
<TextView
android:id="@+id/tvProductName"
android:layout_width="@dimen/dp_600"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/pbDownloadProgress"
app:layout_constraintLeft_toLeftOf="@id/pbDownloadProgress"
android:layout_marginBottom="@dimen/dp_11"
android:textColor="@color/white"
android:textSize="@dimen/sp_36"
/>
<TextView
android:id="@+id/tvDownloadProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/pbDownloadProgress"
app:layout_constraintTop_toBottomOf="@id/pbDownloadProgress"
app:layout_constraintRight_toRightOf="@id/pbDownloadProgress"
android:layout_marginBottom="@dimen/dp_11"
android:textColor="@color/white"
android:textSize="@dimen/sp_36"
android:layout_marginTop="@dimen/dp_11"
android:textColor="#999999"
android:textSize="@dimen/sp_30"
/>
<TextView
android:id="@+id/tvDownloadTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/pbDownloadProgress"
app:layout_constraintLeft_toLeftOf="@id/pbDownloadProgress"
android:layout_marginTop="@dimen/dp_11"
android:textColor="#999999"
android:textSize="@dimen/sp_30"
/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -14,7 +14,9 @@ package com.mogo.eagle.core.data.deva.ota
* @param is_delay 是否是延时升级
* @param cur_size 当前已下载文件大小
* @param total_size 下载文件总大小
* @param left_time 剩余时间
*/
data class OtaUpgradeInfo(var token: String,var status: Int,var fail_reason: String,var upgrade_reason: String,
var task_id: Int,var task_item_id: Int,var ota_type: Int,var product_name: String,
var need_restart: Boolean,var is_delay: Boolean,var cur_size:Double,var total_size: Double)
var need_restart: Boolean,var is_delay: Boolean,var cur_size:Double,
var total_size: Double,var left_time: Int)