[6.9.0]OTA升级
This commit is contained in:
@@ -29,6 +29,7 @@ import com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_FRAGMENT_HMI
|
||||
import com.mogo.eagle.core.data.deva.bindingcar.IPCUpgradeStateInfo
|
||||
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.BIZ_RTS
|
||||
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.V2I
|
||||
import com.mogo.eagle.core.data.deva.ota.OtaUpgradeInfo
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.enums.WarningDirectionEnum
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
@@ -58,7 +59,9 @@ import com.mogo.eagle.core.function.hmi.ui.setting.StatusView
|
||||
import com.mogo.eagle.core.function.hmi.ui.setting.ToolsView.Companion.toolsView
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.AdUpgradeDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.ModifyBindingCarDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.OTADownloadStatusDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.OTAUpgradeDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.OTAUpgradeTipView
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.ToBindingCarDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.UpgradeAppDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.utils.HmiActionLog
|
||||
@@ -660,15 +663,59 @@ class MoGoHmiProvider : IMoGoHmiProvider {
|
||||
CallerHmiViewControlListenerManager.invokeColdStartProcessView()
|
||||
}
|
||||
|
||||
var otaUpgradeDialog: OTAUpgradeDialog ?= null
|
||||
var otaDownloadStatusDialog: OTADownloadStatusDialog ?= null
|
||||
var otaUpgradeTipView: OTAUpgradeTipView ?= null
|
||||
|
||||
/**
|
||||
* 展示OTA升级弹窗
|
||||
*/
|
||||
override fun showOTAUpgradeDialog() {
|
||||
ThreadUtils.runOnUiThread{
|
||||
if (context != null){
|
||||
OTAUpgradeDialog.show(context)
|
||||
context?.let {
|
||||
if(otaUpgradeDialog == null){
|
||||
otaUpgradeDialog = OTAUpgradeDialog(it)
|
||||
}
|
||||
if(otaUpgradeDialog?.isShowing == false){
|
||||
otaUpgradeDialog?.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示OTA升级下载状态弹窗
|
||||
*/
|
||||
override fun showOTADownloadStatusDialog(list: List<OtaUpgradeInfo>) {
|
||||
ThreadUtils.runOnUiThread{
|
||||
if(otaDownloadStatusDialog?.isShowing == true){
|
||||
return@runOnUiThread
|
||||
}
|
||||
context?.let {
|
||||
if(otaDownloadStatusDialog == null){
|
||||
otaDownloadStatusDialog = OTADownloadStatusDialog(it)
|
||||
}
|
||||
otaDownloadStatusDialog?.notifyDownloadStatus(list)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示OTA升级提示
|
||||
* @param visible 设置是否可见
|
||||
*/
|
||||
override fun showOTAUpgradeTipView(visible: Boolean) {
|
||||
ThreadUtils.runOnUiThread{
|
||||
if(otaUpgradeDialog?.isShowing == true){
|
||||
return@runOnUiThread
|
||||
}
|
||||
if(otaUpgradeTipView == null){
|
||||
context?.let {
|
||||
otaUpgradeTipView = OTAUpgradeTipView(it)
|
||||
}
|
||||
}
|
||||
otaUpgradeTipView?.setDisplayStatus(visible)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.tools
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.mogo.eagle.core.data.deva.ota.OtaUpgradeInfo
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.dialog.BaseFloatDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.tools.adapter.OTADownloadStatusAdapter
|
||||
import kotlinx.android.synthetic.main.dialog_ota_download_status.rvDownloadStatus
|
||||
|
||||
/**
|
||||
* OTA升级下载状态对话框
|
||||
*/
|
||||
class OTADownloadStatusDialog(context: Context) :
|
||||
BaseFloatDialog(context,TAG), LifecycleObserver {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "OTADownloadStatusDialog"
|
||||
}
|
||||
|
||||
private var otaDownloadStatusAdapter: OTADownloadStatusAdapter ?= null
|
||||
|
||||
|
||||
init{
|
||||
setContentView(R.layout.dialog_ota_download_status)
|
||||
setCanceledOnTouchOutside(false)
|
||||
initView()
|
||||
}
|
||||
|
||||
private fun initView(){
|
||||
val linearLayoutManager = LinearLayoutManager(context)
|
||||
linearLayoutManager.orientation = LinearLayoutManager.VERTICAL
|
||||
otaDownloadStatusAdapter = OTADownloadStatusAdapter(context)
|
||||
rvDownloadStatus.adapter = otaDownloadStatusAdapter
|
||||
rvDownloadStatus.layoutManager = linearLayoutManager
|
||||
}
|
||||
|
||||
fun notifyDownloadStatus(list: List<OtaUpgradeInfo>){
|
||||
if(!this.isShowing){
|
||||
show()
|
||||
}
|
||||
otaDownloadStatusAdapter?.setData(list)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.tools
|
||||
|
||||
import android.content.Context
|
||||
import android.os.CountDownTimer
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.dialog.BaseFloatDialog
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.zhjt.mogo_core_function_devatools.ota.OTAUpgradeConfig
|
||||
import kotlinx.android.synthetic.main.dialog_ota_upgrade.tv_upgrade_countdown
|
||||
import kotlinx.android.synthetic.main.dialog_ota_upgrade.tv_upgrade_later
|
||||
import kotlinx.android.synthetic.main.dialog_ota_upgrade.tv_upgrade_now
|
||||
import system_master.SsmInfo
|
||||
|
||||
/**
|
||||
@@ -17,26 +22,12 @@ class OTAUpgradeDialog(context: Context) :
|
||||
|
||||
companion object {
|
||||
private const val TAG = "OTAUpgradeDialog"
|
||||
private var otaUpgradeDialog: OTAUpgradeDialog? = null
|
||||
|
||||
fun show(context: Context?) {
|
||||
context?.let {
|
||||
if (otaUpgradeDialog == null) {
|
||||
otaUpgradeDialog = OTAUpgradeDialog(it)
|
||||
}
|
||||
otaUpgradeDialog?.let { dialog ->
|
||||
if (dialog.isShowing) {
|
||||
return
|
||||
}
|
||||
dialog.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
private const val UPGRADE_WAITING_TIME = 300000L //升级确认等待时间
|
||||
private const val WAITING_TICK_TIME = 1000L //等待确认间隔时间
|
||||
}
|
||||
|
||||
private var clickListener: ClickListener? = null
|
||||
private lateinit var tvUpgradeNow: TextView //立即升级
|
||||
private lateinit var tvUpgradeLater: TextView //稍后升级
|
||||
private var upgradeWaitingTimer: CountDownTimer ?= null //等待升级确认计时器
|
||||
|
||||
init{
|
||||
setContentView(R.layout.dialog_ota_upgrade)
|
||||
@@ -45,21 +36,32 @@ class OTAUpgradeDialog(context: Context) :
|
||||
}
|
||||
|
||||
private fun initView(){
|
||||
tvUpgradeNow = findViewById(R.id.tv_upgrade_now)
|
||||
tvUpgradeLater = findViewById(R.id.tv_upgrade_later)
|
||||
//立即升级
|
||||
tvUpgradeNow.setOnClickListener {
|
||||
tv_upgrade_now.setOnClickListener {
|
||||
CallerAutoPilotControlManager.sendSsmFuncOtaDownloadResponse(OTAUpgradeConfig.otaToken,SsmInfo.IfUpgrade.IMMEDIATELY)
|
||||
dismiss()
|
||||
}
|
||||
//稍后升级
|
||||
tvUpgradeLater.setOnClickListener {
|
||||
tv_upgrade_later.setOnClickListener {
|
||||
CallerAutoPilotControlManager.sendSsmFuncOtaDownloadResponse(OTAUpgradeConfig.otaToken,SsmInfo.IfUpgrade.DELAY)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
upgradeWaitingTimer = object: CountDownTimer(UPGRADE_WAITING_TIME,WAITING_TICK_TIME){
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
tv_upgrade_countdown.text = millisUntilFinished.toInt().toString()
|
||||
}
|
||||
}
|
||||
|
||||
override fun dismiss() {
|
||||
super.dismiss()
|
||||
otaUpgradeDialog = null
|
||||
override fun onFinish() {
|
||||
CallerAutoPilotControlManager.sendSsmFuncOtaDownloadResponse(OTAUpgradeConfig.otaToken,SsmInfo.IfUpgrade.DELAY)
|
||||
ThreadUtils.runOnUiThread {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
upgradeWaitingTimer?.start()
|
||||
}
|
||||
|
||||
fun setClickListener(clickListener: ClickListener) {
|
||||
@@ -73,4 +75,13 @@ class OTAUpgradeDialog(context: Context) :
|
||||
fun upgradeLater()
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
upgradeWaitingTimer?.cancel()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.tools
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import kotlinx.android.synthetic.main.view_ota_upgrade_tip.view.btn_upgrade
|
||||
|
||||
/**
|
||||
* OTA升级任务标记提示
|
||||
*/
|
||||
class OTAUpgradeTipView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr){
|
||||
|
||||
companion object {
|
||||
private const val TAG = "OTAUpgradeTipView"
|
||||
}
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_ota_upgrade_tip, this, true)
|
||||
initView()
|
||||
}
|
||||
|
||||
private fun initView(){
|
||||
btn_upgrade.setOnClickListener {
|
||||
//打开升级弹窗
|
||||
CallerHmiManager.showOTAUpgradeDialog()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置视图是否可见
|
||||
* @param visible 是否可见
|
||||
*/
|
||||
fun setDisplayStatus(visible: Boolean){
|
||||
if(visible){
|
||||
if(this@OTAUpgradeTipView.visibility == View.VISIBLE){
|
||||
return
|
||||
}else{
|
||||
this@OTAUpgradeTipView.visibility = View.VISIBLE
|
||||
}
|
||||
}else{
|
||||
if(this@OTAUpgradeTipView.visibility != View.VISIBLE){
|
||||
return
|
||||
}else{
|
||||
this@OTAUpgradeTipView.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.tools.adapter
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.data.deva.ota.OtaUpgradeInfo
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
|
||||
/**
|
||||
* OTA升级下载状态适配器
|
||||
*/
|
||||
class OTADownloadStatusAdapter(private val context: Context): RecyclerView.Adapter<OTADownloadStatusAdapter.DownloadStatusHolder>() {
|
||||
|
||||
private var data: List<OtaUpgradeInfo> ?= null
|
||||
|
||||
fun setData(list: List<OtaUpgradeInfo>){
|
||||
this.data = list
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DownloadStatusHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.item_ota_download_status, parent, false)
|
||||
return DownloadStatusHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: DownloadStatusHolder, position: Int) {
|
||||
data?.let {
|
||||
val otaUpgradeInfo = it[position]
|
||||
holder.pbDownloadProgress.progress = (otaUpgradeInfo.cur_size*100/otaUpgradeInfo.total_size).toInt()
|
||||
// 0:默认(未开始), 1:下载中, 2:下载完成, 3:升级完成, 4:升级失败
|
||||
holder.tvDownloadStatus.text = when (otaUpgradeInfo.status) {
|
||||
1 -> {
|
||||
"下载中"
|
||||
}
|
||||
2 -> {
|
||||
"下载完成"
|
||||
}
|
||||
3 -> {
|
||||
"升级完成"
|
||||
}
|
||||
4 -> {
|
||||
"升级失败"
|
||||
}
|
||||
else -> {
|
||||
"默认(未开始)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount() = data?.size ?: 0
|
||||
|
||||
class DownloadStatusHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
|
||||
var pbDownloadProgress: ProgressBar = itemView.findViewById(R.id.pbDownloadProgress)
|
||||
var tvDownloadStatus: TextView = itemView.findViewById(R.id.tvDownloadStatus)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvDownloadStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -21,6 +21,18 @@
|
||||
android:layout_marginTop="50dp"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_upgrade_countdown"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_upgrade_title"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_upgrade_title"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:layout_marginEnd="@dimen/dp_50"
|
||||
android:textSize="@dimen/sp_30"
|
||||
android:textColor="@color/white"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_upgrade_content"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@@ -141,6 +141,15 @@
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.tools.OTAUpgradeTipView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:layout_marginTop="@dimen/dp_39"
|
||||
/>
|
||||
|
||||
<!-- 事件弹框 -->
|
||||
<com.mogo.eagle.core.function.hmi.ui.v2n.RoadV2NEventWindowView
|
||||
android:id="@+id/roadV2NEventWindowView"
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_upgrade"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="OTA升级"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
Reference in New Issue
Block a user