From: xue <2144439972@qq.com> Date: Fri, 10 Oct 2025 02:22:59 +0000 (+0800) Subject: 增加夜间升级 X-Git-Tag: V1.0.9_20251128_194606_LN~268^2~4 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=6f3b3184552c6f11f5b71c4ae0bf3dfdedb17b86;p=mirrors%2FFD230.git 增加夜间升级 --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaModel.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaModel.h index 74e8d3834..3d8b0efd2 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaModel.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaModel.h @@ -62,6 +62,11 @@ namespace OHOS bool IsBatterySufficient() const; bool IsMemorySufficient() const; + // 夜间更新状态管理 + void SetNightUpdateEnabled(bool enabled); + bool IsNightUpdateEnabled() const; + void ClearNightUpdateStatus(); // 更新成功后清除状态 + void HandleDownloadSuccess(int type); void HandleDownloadProgress(int progress); void HandleDownloadFail(int type); @@ -80,6 +85,9 @@ namespace OHOS // 状态栏更新定时器 void* m_statusBarTimer; // 状态栏更新定时器 bool m_statusBarTimerActive; // 定时器激活状态 + + // 夜间更新状态 + bool m_nightUpdateEnabled; // 夜间更新是否启用 }; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp index 0d0819329..128f0e644 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaModel.cpp @@ -7,6 +7,7 @@ #include "wearable_log.h" #include "ln_api.h" #include "custom_utils.h" +#include "kv_store.h" #include "battery_hal.h" #include "battery_service.h" #include "custom_runtime.h" @@ -33,6 +34,18 @@ namespace OHOS // 初始化状态栏定时器 m_statusBarTimer = nullptr; m_statusBarTimerActive = false; + + // 初始化夜间更新状态 + m_nightUpdateEnabled = false; + + // 从KV存储中读取夜间更新状态 + char temp[10] = { 0 }; + (void)UtilsGetValue("night_update_enabled", temp, 10); + if(strcmp(temp, "1") == 0) + { + m_nightUpdateEnabled = true; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaModel: Night update is enabled from KV storage"); + } } OtaModel::~OtaModel() @@ -424,8 +437,37 @@ namespace OHOS if(OtaDownloadView::GetInstance()) { OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_DOWNLOAD, OtaView::OTA_VIEW_UPDATE_SUCCESS); - OtaDownloadView::GetInstance()->UpdateDownloadSuccess("下载失败"); + OtaSuccessView::GetInstance()->UpdateDownloadSuccess("下载失败"); + } + + } + + /*************************夜间更新状态管理*************************/ + void OtaModel::SetNightUpdateEnabled(bool enabled) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaModel::SetNightUpdateEnabled: %d", enabled); + m_nightUpdateEnabled = enabled; + + // 保存到KV存储 + if (enabled) { + UtilsSetValue("night_update_enabled", "1"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaModel: Night update enabled and saved to KV storage"); + } else { + UtilsSetValue("night_update_enabled", "0"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaModel: Night update disabled and saved to KV storage"); } + } + bool OtaModel::IsNightUpdateEnabled() const + { + return m_nightUpdateEnabled; + } + + void OtaModel::ClearNightUpdateStatus() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaModel::ClearNightUpdateStatus: Clearing night update status"); + m_nightUpdateEnabled = false; + UtilsSetValue("night_update_enabled", "0"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaModel: Night update status cleared from KV storage"); } } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp index 65660b79b..6c89f3771 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp @@ -136,11 +136,15 @@ namespace OHOS } else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE) { //夜间升级 - //夜间升级操作 + //夜间升级操作 - 设置夜间更新状态为启用 + OtaModel::GetInstance()->SetNightUpdateEnabled(true); OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_NIGHT_UPDATE, OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS); } else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS || currentView == OtaView::OTA_VIEW_UPDATE_SUCCESS) { //夜间升级成功 + // 清除夜间更新状态 + if(currentView == OtaView::OTA_VIEW_UPDATE_SUCCESS) + OtaModel::GetInstance()->ClearNightUpdateStatus(); ThunderBirdModel::GetInstance()->ResetOtaStatus(); NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD); } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp index 24c083ef7..3c1b84d88 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp @@ -78,29 +78,37 @@ namespace OHOS WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Background image added to ScrollView"); } - int otaStatus = ThunderBirdModel::GetInstance()->GetOtaStatus(); - if(otaStatus == OTA_UI_STATUS_OPTIONAL_START)//选择升级 - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "选择升级"); - ChangeView(MAX_OTA_VIEW, OTA_VIEW_NORMAL); - } - else if(otaStatus == OTA_UI_STATUS_FORCE_START)//强制升级 - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "强制升级"); - ChangeView(MAX_OTA_VIEW, OTA_VIEW_UPDATE_NOW); - } - else //下载界面,需要根据文件下载类型判断 - { - int downloadFileType = ThunderBirdModel::GetInstance()->GetDownloadFile(); - if(downloadFileType != -1) + // 检查夜间更新状态 + if (OtaModel::GetInstance()->IsNightUpdateEnabled()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "检测到夜间更新已启用,直接开始更新"); + // 如果夜间更新已启用,直接进入更新流程 + ChangeView(MAX_OTA_VIEW, OTA_VIEW_COUNTDOWN); + } + else { + int otaStatus = ThunderBirdModel::GetInstance()->GetOtaStatus(); + if(otaStatus == OTA_UI_STATUS_OPTIONAL_START)//选择升级 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "选择升级"); + ChangeView(MAX_OTA_VIEW, OTA_VIEW_NORMAL); + } + else if(otaStatus == OTA_UI_STATUS_FORCE_START)//强制升级 + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "强制升级"); + ChangeView(MAX_OTA_VIEW, OTA_VIEW_UPDATE_NOW); + } + else //下载界面,需要根据文件下载类型判断 { - ChangeView(MAX_OTA_VIEW, OTA_VIEW_DOWNLOAD); - if(OtaDownloadView::GetInstance()) + int downloadFileType = ThunderBirdModel::GetInstance()->GetDownloadFile(); + if(downloadFileType != -1) { - OtaDownloadView::GetInstance()->SetDownloadType(downloadFileType); + ChangeView(MAX_OTA_VIEW, OTA_VIEW_DOWNLOAD); + if(OtaDownloadView::GetInstance()) + { + OtaDownloadView::GetInstance()->SetDownloadType(downloadFileType); + } } + } - }