From: xue <2144439972@qq.com> Date: Thu, 25 Sep 2025 06:12:19 +0000 (+0800) Subject: 优化ota X-Git-Tag: V1.0.9_20251128_194606_LN~250^2~54 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=51f3353d09f1908537ac4a81684dac381180c47e;p=mirrors%2FFD230.git 优化ota --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaFailedView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaFailedView.h index 5f1c83a6b..83ad733a7 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaFailedView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaFailedView.h @@ -35,6 +35,7 @@ namespace OHOS UILabelExt *RemindLabel{nullptr}; UIImageView *RemindIcon{nullptr}; UIImageView *RemindIcon2{nullptr}; + UIImageView *RemindIcon1{nullptr}; }; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaSuccessView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaSuccessView.h index 1fd3430c6..5915a3565 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaSuccessView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaSuccessView.h @@ -31,8 +31,10 @@ namespace OHOS UIViewGroup *group{nullptr}; UIImageView *background{nullptr}; UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; UILabelExt *RemindLabel{nullptr}; UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon1{nullptr}; }; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaView.h index 9b99c53e3..adc2f7bcf 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaView.h @@ -87,11 +87,16 @@ namespace OHOS void ClearAll(); UIViewGroup* CreateIndependentStatusBar(); // 创建独立的状态栏 + // 各个子界面的UI创建方法 + UIViewGroup* CreateOtaNormalView(); // 创建正常升级界面 + UIViewGroup* CreateOtaUpdatingView(); // 创建更新中界面 + int16_t currentView_; UIViewGroup *group[MAX_OTA_VIEW]{nullptr}; UIScrollView *ScrollView_{nullptr}; + UIImageView *backgroundImageView{nullptr}; // 最底层背景图片 UIViewGroup *group1{nullptr}; UILabelExt *timeLabel{nullptr}; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp index 48ff60ee0..e9dc58eb2 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp @@ -46,14 +46,8 @@ namespace OHOS } // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 + // 创建文本标签 TextLabel = new UILabelExt(); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaFailedView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaFailedView.cpp index 439a76105..dbab9c717 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaFailedView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaFailedView.cpp @@ -43,20 +43,12 @@ namespace OHOS group->SetStyle(STYLE_BACKGROUND_OPA, 0xff); } - // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 // 创建文本标签 TextLabel = new UILabelExt(); if (TextLabel) { - TextLabel->SetPosition(90, 102, 180, 42); + TextLabel->SetPosition(127, 122, 150, 42); TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); @@ -68,11 +60,8 @@ namespace OHOS // 创建小文本标签 LittleTextLabel = new UILabelExt(); if (LittleTextLabel) { - LittleTextLabel->SetPosition(60, 162, 240, 28); - LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); - LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffcccccc); - LittleTextLabel->SetText("更新过程中出现错误"); + LittleTextLabel->SetPosition(70, 184, 220, 28); + LittleTextLabel->SetText("请检查网络和电量后重试"); LittleTextLabel->SetVisible(true); group->Add(LittleTextLabel); } @@ -99,6 +88,13 @@ namespace OHOS RemindIcon->SetVisible(true); group->Add(RemindIcon); } + if (RemindIcon1) + { + RemindIcon1->SetPosition(83, 124, 36, 36); + RemindIcon1->SetSrc("/user/res/warning.bin"); + RemindIcon1->SetVisible(true); + group->Add(RemindIcon1); + } // 创建第二个提示图标 RemindIcon2 = new UIImageView(); @@ -122,12 +118,12 @@ namespace OHOS group = nullptr; } - if (background) { delete background; background = nullptr; } + // background已移至OtaView.cpp,无需在此清理 if (TextLabel) { delete TextLabel; TextLabel = nullptr; } if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; } - if (TextLabel) { delete TextLabel; TextLabel = nullptr; } if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; } if (RemindIcon) { delete RemindIcon; RemindIcon = nullptr; } if (RemindIcon2) { delete RemindIcon2; RemindIcon2 = nullptr; } + if (RemindIcon1) { delete RemindIcon1; RemindIcon1 = nullptr; } } } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaLowBatteryView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaLowBatteryView.cpp index 43da11706..651c249fa 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaLowBatteryView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaLowBatteryView.cpp @@ -43,14 +43,8 @@ namespace OHOS } // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 + // 创建文本标签 TextLabel = new UILabelExt(); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaMemoryErrorView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaMemoryErrorView.cpp index 33cc03700..162ddd989 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaMemoryErrorView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaMemoryErrorView.cpp @@ -43,14 +43,8 @@ namespace OHOS } // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 + // 创建文本标签 TextLabel = new UILabelExt(); 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 b8add056d..8b7940a99 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 @@ -140,6 +140,8 @@ namespace OHOS // 检查内存是否足够(至少100MB) // TODO: 实现实际的内存检查 // int freeMemory = get_free_memory(); + const char* memoryInfo = get_system_memory_info(); + printf("memoryInfo: %s\r\n", memoryInfo); int freeMemory = 200; // 暂时返回200MB可用内存 return (freeMemory >= 100); } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNetworkErrorView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNetworkErrorView.cpp index 42ab949a9..a1e07b618 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNetworkErrorView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNetworkErrorView.cpp @@ -43,14 +43,8 @@ namespace OHOS } // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 + // 创建文本标签 TextLabel = new UILabelExt(); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateSuccessView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateSuccessView.cpp index ff75906da..bcbfdb7a4 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateSuccessView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateSuccessView.cpp @@ -44,14 +44,8 @@ namespace OHOS } // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 + // 创建文本标签 TextLabel = new UILabelExt(); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateView.cpp index 6b3dcfc90..1f020eeba 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateView.cpp @@ -44,14 +44,8 @@ namespace OHOS } // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 + // 创建文本标签 TextLabel = new UILabelExt(); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNormalView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNormalView.cpp index fd1c66fd7..cbe21bf0b 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNormalView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNormalView.cpp @@ -42,15 +42,7 @@ namespace OHOS group->SetStyle(STYLE_BACKGROUND_OPA, 0xff); } - // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 // 创建文本标签 TextLabel = new UILabelExt(); if (TextLabel) { @@ -133,10 +125,7 @@ namespace OHOS } // 显式删除所有UI组件 - if (background) { - delete background; - background = nullptr; - } + // background已移至OtaView.cpp,无需在此清理 if (TextLabel) { delete TextLabel; TextLabel = nullptr; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaObviousView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaObviousView.cpp index be22c567a..51ddb48ef 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaObviousView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaObviousView.cpp @@ -43,15 +43,7 @@ namespace OHOS group->SetStyle(STYLE_BACKGROUND_OPA, 0xff); } - // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 // 创建文本标签 TextLabel = new UILabelExt(); @@ -123,7 +115,7 @@ namespace OHOS group = nullptr; } - if (background) { delete background; background = nullptr; } + // background已移至OtaView.cpp,无需在此清理 if (TextLabel) { delete TextLabel; TextLabel = nullptr; } if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; } if (TextLabel) { delete TextLabel; TextLabel = nullptr; } 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 42ab8af10..4495bbf18 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 @@ -267,31 +267,42 @@ namespace OHOS else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE) { //夜间升级 //夜间升级操作 - OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_NIGHT_UPDATE, OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS); } - else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS) { + else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS || currentView == OtaView::OTA_VIEW_UPDATE_SUCCESS) { //夜间升级成功 NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD); } + //倒计时界面确认,开始升级,定时器停止,进入升级中界面 + else if (currentView == OtaView::OTA_VIEW_COUNTDOWN) { + do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0); + OtaModel::GetInstance()->StopCountdownTimer(); + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_COUNTDOWN, OtaView::OTA_VIEW_UPDATING); + } + //升级失败界面重试 + else if (currentView == OtaView::OTA_VIEW_UPDATE_FAILED) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "升级失败界面重试"); + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_UPDATE_FAILED, OtaView::OTA_VIEW_COUNTDOWN); + } break; case static_cast(ZliteKeyCode::ZLITE_KEY_VENDOR_DOWN)://VENDOR_DOWN键 if (currentView == OtaView::OTA_VIEW_NORMAL) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "普通升级界面跳转升级中"); - OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_NORMAL, OtaView::OTA_VIEW_NIGHT_UPDATE); } else if (currentView == OtaView::OTA_VIEW_UPDATE_NOW) { 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) { + else if (currentView == OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS || currentView == OtaView::OTA_VIEW_NIGHT_UPDATE || currentView == OtaView::OTA_VIEW_COUNTDOWN) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "夜间升级界面跳转普通升级"); 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, "网络异常、电量不足、内存不足界面跳转普通升级"); + NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD); + } break; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp index ff5bf86a1..59879160f 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp @@ -45,27 +45,28 @@ namespace OHOS } // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 + // 创建文本标签 TextLabel = new UILabelExt(); if (TextLabel) { - TextLabel->SetPosition(90, 102, 180, 84); + TextLabel->SetPosition(127, 122, 164, 42); TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); - TextLabel->SetText("设定成功!\n记得充好电哦"); TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + TextLabel->SetText("更新成功"); TextLabel->SetVisible(true); group->Add(TextLabel); } + if (LittleTextLabel) + { + LittleTextLabel->SetPosition(80, 184, 220, 28); + LittleTextLabel->SetText("你的设备已是最新版本"); + LittleTextLabel->SetVisible(true); + group->Add(LittleTextLabel); + } // 创建提示标签 RemindLabel = new UILabelExt(); @@ -78,18 +79,20 @@ namespace OHOS RemindLabel->SetVisible(true); group->Add(RemindLabel); } - - // 创建提示图标 - RemindIcon = new UIImageView(); - if (RemindIcon) { - RemindIcon->SetAutoEnable(false); + if (RemindIcon) + { RemindIcon->SetPosition(160, 277, 22, 22); - RemindIcon->SetResizeMode(UIImageView::CONTAIN); - RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetSrc("/user/res/volume_up.bin"); RemindIcon->SetVisible(true); group->Add(RemindIcon); } - + if (RemindIcon1) + { + RemindIcon1->SetPosition(98, 124, 36, 36); + RemindIcon1->SetSrc("/user/res/completed.bin"); + RemindIcon1->SetVisible(true); + group->Add(RemindIcon1); + } return group; } @@ -101,10 +104,12 @@ namespace OHOS group = nullptr; } - if (background) { delete background; background = nullptr; } + // background已移至OtaView.cpp,无需在此清理 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; } } } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdateNowView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdateNowView.cpp index b9486bc10..c41183e32 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdateNowView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdateNowView.cpp @@ -43,14 +43,8 @@ namespace OHOS } // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 + // 创建文本标签 TextLabel = new UILabelExt(); @@ -120,7 +114,7 @@ namespace OHOS group = nullptr; } - if (background) { delete background; background = nullptr; } + // background已移至OtaView.cpp,无需在此清理 if (TextLabel) { delete TextLabel; TextLabel = nullptr; } if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; } if (TextLabel) { delete TextLabel; TextLabel = nullptr; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdatingView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdatingView.cpp index c9b0e25fe..442e237b8 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdatingView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdatingView.cpp @@ -45,36 +45,29 @@ namespace OHOS group->SetStyle(STYLE_BACKGROUND_OPA, 0xff); } - // 创建背景 - background = new UIImageView(); - if (background) { - background->SetAutoEnable(false); - background->SetResizeMode(UIImageView::CONTAIN); - background->SetPosition(0, 0, 360, 360); - background->SetResizeMode(UIImageView::COVER); - background->SetSrc("/user/res/yellowbg.bin"); - group->Add(background); - } + // 背景图已移至OtaView.cpp作为最底层背景 // 创建标题标签 titleLabel = new UILabelExt(); if (titleLabel) { + titleLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); + titleLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + titleLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); titleLabel->SetPosition(90, 108, 180, 82); titleLabel->SetText("更新中\n请勿关闭设备"); titleLabel->SetVisible(true); group->Add(titleLabel); } - // 创建进度条 progressBar = new UIBoxProgress(); if (progressBar) { - progressBar->SetPosition(80, 150, 200, 20); - progressBar->SetValidWidth(200); - progressBar->SetValidHeight(20); + progressBar->SetPosition(56, 279, 248, 4); progressBar->SetRange(100, 0); - progressBar->SetStyle(STYLE_BORDER_RADIUS, 10); - progressBar->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff333333); - progressBar->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff45A5FF); + progressBar->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0xff); + progressBar->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xffb4a9a0); + progressBar->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + progressBar->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000); + progressBar->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); progressBar->SetValue(0); group->Add(progressBar); } @@ -82,7 +75,7 @@ namespace OHOS // 创建进度百分比标签 LittleTextLabel = new UILabelExt(); if (LittleTextLabel) { - LittleTextLabel->SetPosition(56, 180, 44, 28); + LittleTextLabel->SetPosition(56, 243, 44, 28); LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); @@ -114,7 +107,7 @@ namespace OHOS group = nullptr; } - if (background) { delete background; background = nullptr; } + // background已移至OtaView.cpp,无需在此清理 if (titleLabel) { delete titleLabel; titleLabel = nullptr; } if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; } if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; } 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 4272320ab..2b6b69628 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 @@ -66,6 +66,17 @@ namespace OHOS AddViewToRootContainer(ScrollView_); } + // 创建最底层背景图片 + backgroundImageView = new UIImageView(); + if (backgroundImageView) { + backgroundImageView->SetAutoEnable(false); + backgroundImageView->SetPosition(0, 0, 360, 360); + backgroundImageView->SetResizeMode(UIImageView::COVER); + backgroundImageView->SetSrc("/user/res/yellowbg.bin"); + ScrollView_->Add(backgroundImageView); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Background image added to ScrollView"); + } + int otaStatus = ThunderBirdModel::GetInstance()->GetOtaStatus(); if(otaStatus == OTA_UI_STATUS_OPTIONAL_START)//选择升级 { @@ -336,7 +347,9 @@ namespace OHOS group[hideView]->SetVisible(false); } ClickFunc(showView); + group[showView]->SetStyle(STYLE_BACKGROUND_OPA, 0x00); group[showView]->SetVisible(true); + ScrollView_->Invalidate(); } @@ -348,15 +361,77 @@ namespace OHOS void OtaView::ClearAll() { - // 清理所有视图组 + // 清理所有视图组 - 先从ScrollView中移除,然后让各个view对象自己清理 for (int i = 0; i < MAX_OTA_VIEW; i++) { if (group[i]) { - group[i]->RemoveAll(); - delete group[i]; + // 先从ScrollView中移除 + if (ScrollView_) { + ScrollView_->Remove(group[i]); + } + // 不在这里删除group[i],让各个view对象自己清理 group[i] = nullptr; } } + // 清理状态栏相关视图 + if (group1) { + // 先从ScrollView中移除 + if (ScrollView_) { + ScrollView_->Remove(group1); + } + // 清理状态栏子视图 + if (timeLabel) { + group1->Remove(timeLabel); + delete timeLabel; + timeLabel = nullptr; + } + if (NoSignal) { + group1->Remove(NoSignal); + delete NoSignal; + NoSignal = nullptr; + } + for (int i = 0; i < 4; i++) { + if (showSignalStrength[i]) { + group1->Remove(showSignalStrength[i]); + delete showSignalStrength[i]; + showSignalStrength[i] = nullptr; + } + } + if (batteryimage) { + group1->Remove(batteryimage); + delete batteryimage; + batteryimage = nullptr; + } + if (progress) { + group1->Remove(progress); + delete progress; + progress = nullptr; + } + if (batteryLabel) { + group1->Remove(batteryLabel); + delete batteryLabel; + batteryLabel = nullptr; + } + if (chargeBatteryicon) { + group1->Remove(chargeBatteryicon); + delete chargeBatteryicon; + chargeBatteryicon = nullptr; + } + // 最后删除group1 + group1->RemoveAll(); + delete group1; + group1 = nullptr; + } + + // 清理背景图片 + if (backgroundImageView) { + if (ScrollView_) { + ScrollView_->Remove(backgroundImageView); + } + delete backgroundImageView; + backgroundImageView = nullptr; + } + // 清理滚动视图 if (ScrollView_) { ScrollView_->RemoveAll(); @@ -364,7 +439,7 @@ namespace OHOS ScrollView_ = nullptr; } - // Clean up all view pointers + // Clean up all view pointers - these will clean up their own UI components if (g_pOtaNormalView) { delete g_pOtaNormalView; g_pOtaNormalView = nullptr; @@ -413,8 +488,6 @@ namespace OHOS delete g_pOtaNightUpdateSuccessView; g_pOtaNightUpdateSuccessView = nullptr; } - - } @@ -629,6 +702,19 @@ namespace OHOS // 更新电池进度条 progress->SetValue(batteryLevel); + // 根据充电状态和电量设置进度条颜色 + + if (isCharging) { + // 充电时显示绿色 + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Green().full); // 绿色 + } else if (batteryLevel <= 20) { + // 电量低于20%显示红色 + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Red().full); // 红色 + } else { + // 正常状态显示蓝色 + progress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, Color::Blue().full); // 蓝色 + } + // 更新充电图标显示 chargeBatteryicon->SetVisible(isCharging); }