修复强制升级逻辑
authorxue <2144439972@qq.com>
Mon, 8 Dec 2025 03:46:39 +0000 (11:46 +0800)
committerxue <2144439972@qq.com>
Mon, 8 Dec 2025 03:46:39 +0000 (11:46 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaView.h
code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp

index 6f6deb8..861d42d 100644 (file)
@@ -86,6 +86,9 @@ namespace OHOS
         void UpdateSignalDisplay();
         void UpdateSignalBarDisplay(int signalBars, bool state);
 
+        // OTA状态
+        int16_t m_otaStatus = -1;
+
     private:
         void InitUI();
         void ClearAll();
index 6dd2770..04ec806 100644 (file)
@@ -6,6 +6,8 @@
 #include "ota/include/OtaCountdownView.h"
 #include "ota/include/OtaPresenter.h"
 #include "ota/include/OtaModel.h"
+#include "ota/include/OtaView.h"
+#include "ln_api_interface.h"
 #include "wearable_log.h"
 
 namespace OHOS
@@ -77,15 +79,22 @@ namespace OHOS
         // 创建提示标签
         RemindLabel = new UILabelExt();
         if (RemindLabel) {
-            RemindLabel->SetPosition(80, 275, 200, 25);
             RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
             RemindLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff);
-            RemindLabel->SetText("按     退出    按     确认");
             RemindLabel->SetVisible(true);
+            if (OtaView::GetInstance()->m_otaStatus == OTA_UI_STATUS_FORCE_START) {
+                RemindLabel->SetPosition(136, 275, 88, 25);
+                RemindLabel->SetText("按     确认");
+            }
+            else {
+                RemindLabel->SetPosition(80, 275, 200, 25);
+                RemindLabel->SetText("按     退出    按     确认");
+            }
             group->Add(RemindLabel);
         }
 
+
         // 创建提示图标
         RemindIcon = new UIImageView();
         if (RemindIcon) {
@@ -93,7 +102,12 @@ namespace OHOS
             RemindIcon->SetPosition(105, 276, 22, 22);
             RemindIcon->SetResizeMode(UIImageView::CONTAIN);
             RemindIcon->SetSrc("/user/res/volume_down.bin");
-            RemindIcon->SetVisible(true);
+            if (OtaView::GetInstance()->m_otaStatus == OTA_UI_STATUS_FORCE_START) {
+                RemindIcon->SetVisible(false);
+            }
+            else {
+                RemindIcon->SetVisible(true);
+            }
             group->Add(RemindIcon);
         }
 
@@ -101,7 +115,12 @@ namespace OHOS
         RemindIcon2 = new UIImageView();
         if (RemindIcon2) {
             RemindIcon2->SetAutoEnable(false);
-            RemindIcon2->SetPosition(211, 276, 22, 22);
+            if (OtaView::GetInstance()->m_otaStatus == OTA_UI_STATUS_FORCE_START) {
+                RemindIcon2->SetPosition(160, 277, 22, 22);
+            }
+            else {
+                RemindIcon2->SetPosition(211, 276, 22, 22);
+            }
             RemindIcon2->SetResizeMode(UIImageView::CONTAIN);
             RemindIcon2->SetSrc("/user/res/volume_up.bin");
             RemindIcon2->SetVisible(true);
index 9f1916e..3feb6a5 100644 (file)
@@ -149,7 +149,7 @@ namespace OHOS
                         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) {
+                    else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS) {
                       //夜间升级成功
                         // 清除夜间更新状态
                         
@@ -187,7 +187,7 @@ namespace OHOS
                 //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "强制升级界面跳转升级中");
                 //     OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_UPDATE_NOW, OtaView::OTA_VIEW_NIGHT_UPDATE);
                 // }
-                else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE || currentView == OtaView::OTA_VIEW_COUNTDOWN) {
+                else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE) {
                     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "夜间升级界面跳转普通升级");
                     ThunderBirdModel::GetInstance()->ResetOtaStatus();
                     //do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_WS_EXIT_SLEEP, NULL, 0);
@@ -196,6 +196,18 @@ namespace OHOS
                     #endif
                     NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD);
                 }
+                else if (currentView == OtaView::OTA_VIEW_DOWNLOAD) {
+                    // 如果OTA状态为强制升级,不允许跳转
+                    if (OtaView::GetInstance()->m_otaStatus == OTA_UI_STATUS_FORCE_START) 
+                    return;
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "下载界面跳转普通升级");
+                    ThunderBirdModel::GetInstance()->ResetOtaStatus();
+                    //do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_WS_EXIT_SLEEP, NULL, 0);
+                    #ifdef SUPPORT_CAT1_SERVICE
+                    cat_sync_timer_control(1);
+                    #endif
+                    NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD);
+                }
                 else if (currentView == OtaView::OTA_VIEW_NETWORK_ERROR || currentView == OtaView::OTA_VIEW_LOW_BATTERY || currentView == OtaView::OTA_VIEW_MEMORY_ERROR ||currentView == OtaView::OTA_VIEW_UPDATE_FAILED) {
                     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "网络异常、电量不足、内存不足界面跳转普通升级");
                     ThunderBirdModel::GetInstance()->ResetOtaStatus();
index 0b331ee..e14e505 100644 (file)
@@ -73,24 +73,14 @@ namespace OHOS
         // 创建提示标签
         RemindLabel = new UILabelExt();
         if (RemindLabel) {
-            RemindLabel->SetPosition(136, 275, 88, 25);
+            RemindLabel->SetPosition(61, 253, 238, 28);
             RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
             RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20);
             RemindLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff);
-            RemindLabel->SetText("按     确认");
+            RemindLabel->SetText("稍等片刻,设备正在重启...");
             RemindLabel->SetVisible(true);
             group->Add(RemindLabel);
         }
-        RemindIcon = new UIImageView();
-        if (RemindIcon)
-        {
-            RemindIcon->SetAutoEnable(false);
-            RemindIcon->SetPosition(159, 276, 22, 22);
-            RemindIcon->SetResizeMode(UIImageView::CONTAIN);
-            RemindIcon->SetSrc("/user/res/volume_up.bin");
-            RemindIcon->SetVisible(true);
-            group->Add(RemindIcon);
-        }
         RemindIcon1 = new UIImageView();
         if (RemindIcon1)
         {
@@ -116,7 +106,6 @@ namespace OHOS
         if (TextLabel) { delete TextLabel; TextLabel = nullptr; }
         if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; }
         if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; }
-        if (RemindIcon) { delete RemindIcon; RemindIcon = nullptr; }
         if (RemindIcon1) { delete RemindIcon1; RemindIcon1 = nullptr; }
     }
 
index b9a38b6..0ed2f2f 100644 (file)
@@ -93,13 +93,13 @@ namespace OHOS
             ChangeView(MAX_OTA_VIEW, OTA_VIEW_COUNTDOWN);
         }
         else {
-            int otaStatus = ThunderBirdModel::GetInstance()->GetOtaStatus();
-            if(otaStatus == OTA_UI_STATUS_OPTIONAL_START)//选择升级
+            m_otaStatus = ThunderBirdModel::GetInstance()->GetOtaStatus();
+            if(m_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)//强制升级
+            else if(m_otaStatus == OTA_UI_STATUS_FORCE_START)//强制升级
             {
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "强制升级");
                 ChangeView(MAX_OTA_VIEW, OTA_VIEW_UPDATE_NOW);