From 401c17064cee2e5552adbe86bde87ae4ac317197 Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Tue, 23 Sep 2025 19:38:52 +0800 Subject: [PATCH] =?utf8?q?=E5=88=86=E7=A6=BBota=E6=88=90slice?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativelauncher/include/AppViewIDs.h | 1 + .../nativeui/ota/include/OtaCountdownView.h | 42 ++ .../nativeui/ota/include/OtaFailedView.h | 41 ++ .../nativeui/ota/include/OtaLowBatteryView.h | 41 ++ .../nativeui/ota/include/OtaMemoryErrorView.h | 42 ++ .../nativeapp/nativeui/ota/include/OtaModel.h | 64 ++ .../ota/include/OtaNetworkErrorView.h | 42 ++ .../ota/include/OtaNightUpdateSuccessView.h | 39 ++ .../nativeui/ota/include/OtaNightUpdateView.h | 41 ++ .../nativeui/ota/include/OtaNormalView.h | 42 ++ .../nativeui/ota/include/OtaObviousView.h | 42 ++ .../nativeui/ota/include/OtaPresenter.h | 59 ++ .../nativeui/ota/include/OtaSuccessView.h | 39 ++ .../nativeui/ota/include/OtaUpdateNowView.h | 41 ++ .../nativeui/ota/include/OtaUpdatingView.h | 43 ++ .../nativeapp/nativeui/ota/include/OtaView.h | 113 ++++ .../nativeui/ota/src/OtaCountdownView.cpp | 146 ++++ .../nativeui/ota/src/OtaFailedView.cpp | 133 ++++ .../nativeui/ota/src/OtaLowBatteryView.cpp | 136 ++++ .../nativeui/ota/src/OtaMemoryErrorView.cpp | 148 ++++ .../nativeui/ota/src/OtaNetworkErrorView.cpp | 149 +++++ .../ota/src/OtaNightUpdateSuccessView.cpp | 110 +++ .../nativeui/ota/src/OtaNightUpdateView.cpp | 136 ++++ .../nativeui/ota/src/OtaNormalView.cpp | 165 +++++ .../nativeui/ota/src/OtaObviousView.cpp | 135 ++++ .../nativeui/ota/src/OtaPresenter.cpp | 300 +++++++++ .../nativeui/ota/src/OtaSuccessView.cpp | 110 +++ .../nativeui/ota/src/OtaUpdateNowView.cpp | 131 ++++ .../nativeui/ota/src/OtaUpdatingView.cpp | 135 ++++ .../ln/nativeapp/nativeui/ota/src/OtaView.cpp | 431 ++++++++++++ .../thunderbird/include/ThunderBirdMainView.h | 7 +- .../thunderbird/include/ThunderBirdOtaView.h | 55 -- .../thunderbird/src/ThunderBirdMainView.cpp | 65 +- .../thunderbird/src/ThunderBirdModel.cpp | 139 ++-- .../thunderbird/src/ThunderBirdOtaView.cpp | 633 ------------------ .../thunderbird/src/ThunderBirdPresenter.cpp | 110 ++- .../nativeui/uiservice/src/ui_service.cpp | 10 +- .../zhihui/leiniao/imsl_ln/leiniao_api_at.c | 113 ++++ code/sdk/zhihui/leiniao/imsl_ln/ln_api.c | 1 + .../leiniao/ln_api_cpp/ln_api_interface.cpp | 6 +- 40 files changed, 3367 insertions(+), 869 deletions(-) create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaCountdownView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaFailedView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaLowBatteryView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaMemoryErrorView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaModel.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNetworkErrorView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNightUpdateSuccessView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNightUpdateView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNormalView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaObviousView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaPresenter.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaSuccessView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaUpdateNowView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaUpdatingView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaView.h create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaFailedView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaLowBatteryView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaMemoryErrorView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNetworkErrorView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateSuccessView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNormalView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaObviousView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdateNowView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdatingView.cpp create mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp delete mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdOtaView.h delete mode 100644 code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdOtaView.cpp diff --git a/code/sdk/application/wearable/ln/nativeapp/nativelauncher/include/AppViewIDs.h b/code/sdk/application/wearable/ln/nativeapp/nativelauncher/include/AppViewIDs.h index 25768eb3b..760d27369 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativelauncher/include/AppViewIDs.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativelauncher/include/AppViewIDs.h @@ -31,6 +31,7 @@ typedef enum : uint16_t { VIEW_MAIN_SAMPLE = 5, VIEW_MAIN_ALARM = 6, VIEW_MAIN_ACTIVITY = 7, + VIEW_OTA = 8, // OTA升级界面 VIEW_ALARM_POP_UP, VIEW_CALLER_SAMPLE, VIEW_MAEKPHONE_SAMPLE, diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaCountdownView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaCountdownView.h new file mode 100644 index 000000000..3f090712e --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaCountdownView.h @@ -0,0 +1,42 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Countdown View - OTA更新倒计时界面 + */ +#ifndef OTA_COUNTDOWN_VIEW_H +#define OTA_COUNTDOWN_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaCountdownView : public View + { + public: + OtaCountdownView(); + virtual ~OtaCountdownView(); + + static OtaCountdownView* GetInstance(); + void UpdateCountdown(int value); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + }; +} + +#endif // OTA_COUNTDOWN_VIEW_H 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 new file mode 100644 index 000000000..5f1c83a6b --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaFailedView.h @@ -0,0 +1,41 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Failed View - OTA更新失败界面 + */ +#ifndef OTA_FAILED_VIEW_H +#define OTA_FAILED_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaFailedView : public View + { + public: + OtaFailedView(); + virtual ~OtaFailedView(); + + static OtaFailedView* GetInstance(); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + }; +} + +#endif // OTA_FAILED_VIEW_H \ No newline at end of file diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaLowBatteryView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaLowBatteryView.h new file mode 100644 index 000000000..bcc4cfe47 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaLowBatteryView.h @@ -0,0 +1,41 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Low Battery View - OTA电量不足界面 + */ +#ifndef OTA_LOW_BATTERY_VIEW_H +#define OTA_LOW_BATTERY_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaLowBatteryView : public View + { + public: + OtaLowBatteryView(); + virtual ~OtaLowBatteryView(); + + static OtaLowBatteryView* GetInstance(); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + }; +} + +#endif // OTA_LOW_BATTERY_VIEW_H diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaMemoryErrorView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaMemoryErrorView.h new file mode 100644 index 000000000..ddd928e7b --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaMemoryErrorView.h @@ -0,0 +1,42 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Memory Error View - OTA内存不足界面 + */ +#ifndef OTA_MEMORY_ERROR_VIEW_H +#define OTA_MEMORY_ERROR_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaMemoryErrorView : public View + { + public: + OtaMemoryErrorView(); + virtual ~OtaMemoryErrorView(); + + static OtaMemoryErrorView* GetInstance(); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + UIImageView *RemindIcon3{nullptr}; + }; +} + +#endif // OTA_MEMORY_ERROR_VIEW_H 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 new file mode 100644 index 000000000..8bc383d81 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaModel.h @@ -0,0 +1,64 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Model - 独立的OTA升级数据模型 + */ +#ifndef OTA_MODEL_H +#define OTA_MODEL_H + +#include +#include + +namespace OHOS +{ + class OtaModel + { + public: + static OtaModel *GetInstance(); + + // OTA状态管理 + void SetOtaStatus(int status); + int GetOtaStatus() const; + + // OTA进度管理 + void SetOtaProgress(int progress); + int GetOtaProgress() const; + + // 倒计时管理 + void SetCountdownActive(bool active); + bool IsCountdownActive() const; + void SetCountdownValue(int value); + int GetCountdownValue() const; + + // 倒计时定时器管理 + void StartCountdownTimer(uint32_t startVal = 5); + void StopCountdownTimer(); + void CountdownCallback(); + + // OTA操作 + int StartOtaUpdate(); + int StopOtaUpdate(); + int CheckOtaUpdate(); + void CheckOtaResult(int status); + void UpdateOtaProgress(int progress); + + // 网络状态检查 + bool HasNetwork() const; + bool IsBatterySufficient() const; + bool IsMemorySufficient() const; + + private: + OtaModel(); + virtual ~OtaModel(); + OtaModel(const OtaModel &) = delete; + OtaModel &operator=(const OtaModel &) = delete; + + int m_otaStatus; // OTA状态 + int m_otaProgress; // OTA进度 + bool m_countdownActive; // 倒计时是否激活 + int m_countdownValue; // 倒计时值 + void* m_countdownTimer; // 倒计时定时器 + }; +} + +#endif // OTA_MODEL_H diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNetworkErrorView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNetworkErrorView.h new file mode 100644 index 000000000..92801bdc0 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNetworkErrorView.h @@ -0,0 +1,42 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Network Error View - OTA网络异常界面 + */ +#ifndef OTA_NETWORK_ERROR_VIEW_H +#define OTA_NETWORK_ERROR_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaNetworkErrorView : public View + { + public: + OtaNetworkErrorView(); + virtual ~OtaNetworkErrorView(); + + static OtaNetworkErrorView* GetInstance(); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + UIImageView *RemindIcon3{nullptr}; + }; +} + +#endif // OTA_NETWORK_ERROR_VIEW_H diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNightUpdateSuccessView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNightUpdateSuccessView.h new file mode 100644 index 000000000..5c411977d --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNightUpdateSuccessView.h @@ -0,0 +1,39 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Night Update Success View - OTA夜间更新成功界面 + */ +#ifndef OTA_NIGHT_UPDATE_SUCCESS_VIEW_H +#define OTA_NIGHT_UPDATE_SUCCESS_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaNightUpdateSuccessView : public View + { + public: + OtaNightUpdateSuccessView(); + virtual ~OtaNightUpdateSuccessView(); + + static OtaNightUpdateSuccessView* GetInstance(); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + }; +} + +#endif // OTA_NIGHT_UPDATE_SUCCESS_VIEW_H diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNightUpdateView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNightUpdateView.h new file mode 100644 index 000000000..adf2268ba --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNightUpdateView.h @@ -0,0 +1,41 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Night Update View - OTA夜间更新界面 + */ +#ifndef OTA_NIGHT_UPDATE_VIEW_H +#define OTA_NIGHT_UPDATE_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaNightUpdateView : public View + { + public: + OtaNightUpdateView(); + virtual ~OtaNightUpdateView(); + + static OtaNightUpdateView* GetInstance(); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + }; +} + +#endif // OTA_NIGHT_UPDATE_VIEW_H diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNormalView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNormalView.h new file mode 100644 index 000000000..ee294d6c4 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaNormalView.h @@ -0,0 +1,42 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Normal View - OTA就绪界面 + */ +#ifndef OTA_NORMAL_VIEW_H +#define OTA_NORMAL_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaNormalView : public View + { + public: + OtaNormalView(); + virtual ~OtaNormalView(); + + static OtaNormalView* GetInstance(); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *LittleTextLabel_2{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + }; +} + +#endif // OTA_NORMAL_VIEW_H diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaObviousView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaObviousView.h new file mode 100644 index 000000000..13e6ba65a --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaObviousView.h @@ -0,0 +1,42 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Obvious View - OTA有新功能界面 + */ +#ifndef OTA_OBVIOUS_VIEW_H +#define OTA_OBVIOUS_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaObviousView : public View + { + public: + OtaObviousView(); + virtual ~OtaObviousView(); + + static OtaObviousView* GetInstance(); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *LittleTextLabel_2{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + }; +} + +#endif // OTA_OBVIOUS_VIEW_H diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaPresenter.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaPresenter.h new file mode 100644 index 000000000..d97108c0a --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaPresenter.h @@ -0,0 +1,59 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Presenter - 独立的OTA升级界面控制器 + */ +#ifndef OTA_PRESENTER_H +#define OTA_PRESENTER_H + +#include "Presenter.h" +#include "View.h" +#include "AppViewIDs.h" +#include "NativeRegisterManager.h" +#include "components/ui_view.h" +#include "common/key_code.h" +#include "key/KeyInputListener.h" + + +namespace OHOS +{ + class OtaView; + class OtaModel; + + class OtaPresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener + { + public: + OtaPresenter(); + virtual ~OtaPresenter(); + + void OnStart() override; + void OnResume() override; + void OnStop() override; + + // 事件处理 + bool OnKeyAct(UIView &view, const KeyEvent &event) override; + bool OnClick(UIView &view, const ClickEvent &event) override; + + // OTA相关功能 + void StartOtaUpdate(); + void UpdateOtaProgress(int progress); + void UpdateOtaStatus(int status); + + // 定时器相关 + void StartOtaCountdown(uint32_t startVal); + void UpdateCountdown(int value); + + private: + void HandleOtaStatusChange(int status); + void HandleKeyPress(uint16_t keyId, uint16_t keyState); + + int m_otaStatus; + bool m_otaCountdownActive; + int m_otaCountdownValue; + int m_otaProgress; + }; +} + +#endif // OTA_PRESENTER_H 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 new file mode 100644 index 000000000..1fd3430c6 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaSuccessView.h @@ -0,0 +1,39 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Success View - OTA更新成功界面 + */ +#ifndef OTA_SUCCESS_VIEW_H +#define OTA_SUCCESS_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaSuccessView : public View + { + public: + OtaSuccessView(); + virtual ~OtaSuccessView(); + + static OtaSuccessView* GetInstance(); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + }; +} + +#endif // OTA_SUCCESS_VIEW_H diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaUpdateNowView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaUpdateNowView.h new file mode 100644 index 000000000..78cfa0070 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaUpdateNowView.h @@ -0,0 +1,41 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Update Now View - OTA强制更新界面 + */ +#ifndef OTA_UPDATE_NOW_VIEW_H +#define OTA_UPDATE_NOW_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaUpdateNowView : public View + { + public: + OtaUpdateNowView(); + virtual ~OtaUpdateNowView(); + + static OtaUpdateNowView* GetInstance(); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *TextLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIImageView *RemindIcon{nullptr}; + UIImageView *RemindIcon2{nullptr}; + }; +} + +#endif // OTA_UPDATE_NOW_VIEW_H diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaUpdatingView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaUpdatingView.h new file mode 100644 index 000000000..e55e2a395 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaUpdatingView.h @@ -0,0 +1,43 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Updating View - OTA更新中界面 + */ +#ifndef OTA_UPDATING_VIEW_H +#define OTA_UPDATING_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_box_progress.h" + +namespace OHOS +{ + class OtaPresenter; + + class OtaUpdatingView : public View + { + public: + OtaUpdatingView(); + virtual ~OtaUpdatingView(); + + static OtaUpdatingView* GetInstance(); + void UpdateProgress(int progress); + UIViewGroup* InitUI(); + void ClearAll(); + + private: + + UIViewGroup *group{nullptr}; + UIImageView *background{nullptr}; + UILabelExt *titleLabel{nullptr}; + UILabelExt *LittleTextLabel{nullptr}; + UILabelExt *RemindLabel{nullptr}; + UIBoxProgress *progressBar{nullptr}; + int currentProgress{0}; + }; +} + +#endif // OTA_UPDATING_VIEW_H 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 new file mode 100644 index 000000000..821097f9a --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/include/OtaView.h @@ -0,0 +1,113 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA View - 独立的OTA升级界面 + */ +#ifndef OTA_VIEW_H +#define OTA_VIEW_H + +#include "View.h" +#include "Presenter.h" +#include "components/ui_view_group.h" +#include "components/ui_label_ext.h" +#include "components/ui_label.h" +#include "components/ui_image_view.h" +#include "components/ui_box_progress.h" +#include "components/ui_scroll_view.h" +#include "ota/include/OtaNormalView.h" +#include "ota/include/OtaObviousView.h" +#include "ota/include/OtaSuccessView.h" +#include "ota/include/OtaUpdatingView.h" +#include "ota/include/OtaUpdateNowView.h" +#include "ota/include/OtaFailedView.h" +#include "ota/include/OtaCountdownView.h" +#include "ota/include/OtaLowBatteryView.h" +#include "ota/include/OtaNetworkErrorView.h" +#include "ota/include/OtaMemoryErrorView.h" +#include "ota/include/OtaNightUpdateView.h" +#include "ota/include/OtaNightUpdateSuccessView.h" +#include "thunderbird/include/ThunderBirdMainView.h" + + +namespace OHOS +{ + class OtaPresenter; + + class OtaView : public View + { + public: + OtaView(); + virtual ~OtaView(); + + static OtaView* GetInstance(); + void OnStart() override; + void OnStop() override; + + // void UpdateCountdown(int value); + // void SetRemindProgress(int16_t value); + + enum : int16_t { + OTA_VIEW_NORMAL, // OTA就绪 + OTA_VIEW_OBVIOUS, // 有新功能 + OTA_VIEW_UPDATE_NOW, // 需要立即更新 + OTA_VIEW_UPDATING, // 更新中 + OTA_VIEW_NIGHT_UPDATE, // 设置夜间更新 + OTA_VIEW_NIGHT_UPDATE_SUCCESS, // 设置夜间更新成功 + OTA_VIEW_COUNTDOWN, // 更新倒计时 + OTA_VIEW_LOW_BATTERY, // 电量不足 + OTA_VIEW_NETWORK_ERROR, // 网络异常 + OTA_VIEW_MEMORY_ERROR, // 内存不足 + OTA_VIEW_UPDATE_SUCCESS, // 更新成功 + OTA_VIEW_UPDATE_FAILED, // 更新未完成 + MAX_OTA_VIEW, + }; + bool ChangeOtaNormalView(int16_t thisView); + bool ChangeOtaObviousView(int16_t thisView); + bool ChangeOtaSuccessView(int16_t thisView); + bool ChangeOtaUpdatingView(int16_t thisView); + bool ChangeOtaUpdateNowView(int16_t thisView); + bool ChangeOtaFailedView(int16_t thisView); + bool ChangeOtaCountdownView(int16_t thisView); + bool ChangeOtaLowBatteryView(int16_t thisView); + bool ChangeOtaNetworkErrorView(int16_t thisView); + bool ChangeOtaMemoryErrorView(int16_t thisView); + bool ChangeOtaNightUpdateView(int16_t thisView); + bool ChangeOtaNightUpdateSuccessView(int16_t thisView); + bool ClickFunc(int16_t interface); + void ChangeView(int16_t hideView, int16_t showView); + int16_t GetCurrentView(); + + private: + void InitUI(); + void ClearAll(); + + + int16_t currentView_; + UIViewGroup *group[MAX_OTA_VIEW]{nullptr}; + UIScrollView *ScrollView_{nullptr}; + + UIViewGroup *group1{nullptr}; + UILabelExt *timeLabel{nullptr}; + UIImageView *showSignalStrength[4]{nullptr}; // 信号强度 + UIImageView *NoSignal{nullptr}; // 无信号 + UIImageView *batteryimage{nullptr}; // 电池图片 + UILabel *batteryLabel{nullptr}; // 电池电量 + UIBoxProgress *progress{nullptr}; // 电池进度条 + UIImageView *chargeBatteryicon{nullptr}; // 充电图标 + + OtaNormalView *g_pOtaNormalView{nullptr}; + OtaObviousView *g_pOtaObviousView{nullptr}; + OtaUpdatingView *g_pOtaUpdatingView{nullptr}; + OtaUpdateNowView *g_pOtaUpdateNowView{nullptr}; + OtaSuccessView *g_pOtaSuccessView{nullptr}; + OtaFailedView *g_pOtaFailedView{nullptr}; + OtaCountdownView *g_pOtaCountdownView{nullptr}; + OtaLowBatteryView *g_pOtaLowBatteryView{nullptr}; + OtaNetworkErrorView *g_pOtaNetworkErrorView{nullptr}; + OtaMemoryErrorView *g_pOtaMemoryErrorView{nullptr}; + OtaNightUpdateView *g_pOtaNightUpdateView{nullptr}; + OtaNightUpdateSuccessView *g_pOtaNightUpdateSuccessView{nullptr}; + }; +} + +#endif // OTA_VIEW_H 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 new file mode 100644 index 000000000..48ff60ee0 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaCountdownView.cpp @@ -0,0 +1,146 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Countdown View - OTA更新倒计时界面实现 + */ +#include "ota/include/OtaCountdownView.h" +#include "ota/include/OtaPresenter.h" +#include "ota/include/OtaModel.h" +#include "wearable_log.h" + +namespace OHOS + +{ + static OtaCountdownView *g_pOtaCountdownView{nullptr}; + OtaCountdownView::OtaCountdownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaCountdownView::OtaCountdownView"); + g_pOtaCountdownView = this; + } + + OtaCountdownView::~OtaCountdownView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaCountdownView::~OtaCountdownView"); + ClearAll(); + g_pOtaCountdownView = nullptr; + } + + + + + + OtaCountdownView* OtaCountdownView::GetInstance() + { + return g_pOtaCountdownView; + } + + UIViewGroup* OtaCountdownView::InitUI() + { + OtaModel::GetInstance()->StartCountdownTimer(); + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(60, 102, 240, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + TextLabel->SetText("设备更新即将开始"); + TextLabel->SetVisible(true); + group->Add(TextLabel); + } + + // 创建小文本标签(倒计时数字) + LittleTextLabel = new UILabelExt(); + if (LittleTextLabel) { + LittleTextLabel->SetPosition(166, 172, 29, 67); + LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 48); + LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + LittleTextLabel->SetText("5"); + LittleTextLabel->SetVisible(true); + group->Add(LittleTextLabel); + } + + // 创建提示标签 + 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + + // 创建第二个提示图标 + RemindIcon2 = new UIImageView(); + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + group->Add(RemindIcon2); + } + + return group; + } + + void OtaCountdownView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { + background->SetAutoEnable(false); delete background; background = nullptr; } + 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) { + RemindIcon->SetAutoEnable(false); delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); delete RemindIcon2; RemindIcon2 = nullptr; } + } + + void OtaCountdownView::UpdateCountdown(int value) + { + if (LittleTextLabel) { + LittleTextLabel->SetText(std::to_string(value).c_str()); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaCountdownView::UpdateCountdown: %d", value); + } +} 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 new file mode 100644 index 000000000..439a76105 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaFailedView.cpp @@ -0,0 +1,133 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Failed View - OTA更新失败界面实现 + */ +#include "ota/include/OtaFailedView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS + +{ + static OtaFailedView *g_pOtaFailedView{nullptr}; + OtaFailedView::OtaFailedView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaFailedView::OtaFailedView"); + g_pOtaFailedView = this; + } + + OtaFailedView::~OtaFailedView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaFailedView::~OtaFailedView"); + ClearAll(); + g_pOtaFailedView = nullptr; + } + + + + + + OtaFailedView* OtaFailedView::GetInstance() + { + return g_pOtaFailedView; + } + + UIViewGroup* OtaFailedView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(90, 102, 180, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + TextLabel->SetText("更新未完成"); + TextLabel->SetVisible(true); + group->Add(TextLabel); + } + + // 创建小文本标签 + 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->SetVisible(true); + group->Add(LittleTextLabel); + } + + // 创建提示标签 + 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + + // 创建第二个提示图标 + RemindIcon2 = new UIImageView(); + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + group->Add(RemindIcon2); + } + + return group; + } + + void OtaFailedView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { delete background; background = nullptr; } + 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; } + } +} 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 new file mode 100644 index 000000000..43da11706 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaLowBatteryView.cpp @@ -0,0 +1,136 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Low Battery View - OTA电量不足界面实现 + */ +#include "ota/include/OtaLowBatteryView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static OtaLowBatteryView *g_pOtaLowBatteryView{nullptr}; + OtaLowBatteryView::OtaLowBatteryView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaLowBatteryView::OtaLowBatteryView"); + g_pOtaLowBatteryView = this; + } + + OtaLowBatteryView::~OtaLowBatteryView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaLowBatteryView::~OtaLowBatteryView"); + ClearAll(); + g_pOtaLowBatteryView = nullptr; + } + + + + + + OtaLowBatteryView* OtaLowBatteryView::GetInstance() + { + return g_pOtaLowBatteryView; + } + + UIViewGroup* OtaLowBatteryView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(82, 124, 240, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + TextLabel->SetText("电量不足无法更新"); + TextLabel->SetVisible(true); + group->Add(TextLabel); + } + + // 创建小文本标签 + LittleTextLabel = new UILabelExt(); + if (LittleTextLabel) { + LittleTextLabel->SetPosition(72, 186, 192, 25); + LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); + LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffcccccc); + LittleTextLabel->SetText("请至少充至50%电量哦"); + LittleTextLabel->SetVisible(true); + group->Add(LittleTextLabel); + } + + // 创建提示标签 + RemindLabel = new UILabelExt(); + if (RemindLabel) { + RemindLabel->SetPosition(136, 275, 88, 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(160, 277, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + + // 创建警告图标 + RemindIcon2 = new UIImageView(); + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetPosition(38, 124, 36, 36); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + RemindIcon2->SetSrc("/user/res/warning.bin"); + RemindIcon2->SetVisible(true); + group->Add(RemindIcon2); + } + + return group; + } + + void OtaLowBatteryView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { + background->SetAutoEnable(false); delete background; background = nullptr; } + 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) { + RemindIcon->SetAutoEnable(false); delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); delete RemindIcon2; RemindIcon2 = nullptr; } + } + +} 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 new file mode 100644 index 000000000..33cc03700 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaMemoryErrorView.cpp @@ -0,0 +1,148 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Memory Error View - OTA内存不足界面实现 + */ +#include "ota/include/OtaMemoryErrorView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static OtaMemoryErrorView *g_pOtaMemoryErrorView{nullptr}; + OtaMemoryErrorView::OtaMemoryErrorView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaMemoryErrorView::OtaMemoryErrorView"); + g_pOtaMemoryErrorView = this; + } + + OtaMemoryErrorView::~OtaMemoryErrorView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaMemoryErrorView::~OtaMemoryErrorView"); + ClearAll(); + g_pOtaMemoryErrorView = nullptr; + } + + + + + + OtaMemoryErrorView* OtaMemoryErrorView::GetInstance() + { + return g_pOtaMemoryErrorView; + } + + UIViewGroup* OtaMemoryErrorView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(82, 124, 240, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + TextLabel->SetText("内存不足无法更新"); + TextLabel->SetVisible(true); + group->Add(TextLabel); + } + + // 创建小文本标签 + LittleTextLabel = new UILabelExt(); + if (LittleTextLabel) { + LittleTextLabel->SetPosition(90, 184, 180, 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->SetVisible(true); + group->Add(LittleTextLabel); + } + + // 创建提示标签 + 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + + // 创建第二个提示图标 + RemindIcon2 = new UIImageView(); + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + group->Add(RemindIcon2); + } + + // 创建警告图标 + RemindIcon3 = new UIImageView(); + if (RemindIcon3) { + RemindIcon3->SetAutoEnable(false); + RemindIcon3->SetPosition(38, 124, 36, 36); + RemindIcon3->SetResizeMode(UIImageView::CONTAIN); + RemindIcon3->SetSrc("/user/res/warning.bin"); + RemindIcon3->SetVisible(true); + group->Add(RemindIcon3); + } + + return group; + } + + void OtaMemoryErrorView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { + background->SetAutoEnable(false); delete background; background = nullptr; } + 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) { + RemindIcon->SetAutoEnable(false); delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); delete RemindIcon2; RemindIcon2 = nullptr; } + if (RemindIcon3) { + RemindIcon3->SetAutoEnable(false); delete RemindIcon3; RemindIcon3 = nullptr; } + } +} 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 new file mode 100644 index 000000000..42ab949a9 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNetworkErrorView.cpp @@ -0,0 +1,149 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Network Error View - OTA网络异常界面实现 + */ +#include "ota/include/OtaNetworkErrorView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static OtaNetworkErrorView *g_pOtaNetworkErrorView{nullptr}; + OtaNetworkErrorView::OtaNetworkErrorView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaNetworkErrorView::OtaNetworkErrorView"); + g_pOtaNetworkErrorView = this; + } + + OtaNetworkErrorView::~OtaNetworkErrorView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaNetworkErrorView::~OtaNetworkErrorView"); + ClearAll(); + g_pOtaNetworkErrorView = nullptr; + } + + + + + + OtaNetworkErrorView* OtaNetworkErrorView::GetInstance() + { + return g_pOtaNetworkErrorView; + } + + UIViewGroup* OtaNetworkErrorView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(112, 124, 180, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + TextLabel->SetText("网络连接异常"); + TextLabel->SetVisible(true); + group->Add(TextLabel); + } + + // 创建小文本标签 + LittleTextLabel = new UILabelExt(); + if (LittleTextLabel) { + LittleTextLabel->SetPosition(100, 184, 160, 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->SetVisible(true); + group->Add(LittleTextLabel); + } + + // 创建提示标签 + 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + + // 创建第二个提示图标 + RemindIcon2 = new UIImageView(); + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + group->Add(RemindIcon2); + } + + // 创建警告图标 + RemindIcon3 = new UIImageView(); + if (RemindIcon3) { + RemindIcon3->SetAutoEnable(false); + RemindIcon3->SetPosition(68, 124, 36, 36); + RemindIcon3->SetResizeMode(UIImageView::CONTAIN); + RemindIcon3->SetSrc("/user/res/warning.bin"); + RemindIcon3->SetVisible(true); + group->Add(RemindIcon3); + } + + return group; + } + + + void OtaNetworkErrorView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { + background->SetAutoEnable(false); delete background; background = nullptr; } + 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) { + RemindIcon->SetAutoEnable(false); delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); delete RemindIcon2; RemindIcon2 = nullptr; } + if (RemindIcon3) { + RemindIcon3->SetAutoEnable(false); delete RemindIcon3; RemindIcon3 = nullptr; } + } +} 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 new file mode 100644 index 000000000..ff75906da --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateSuccessView.cpp @@ -0,0 +1,110 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Night Update Success View - OTA夜间更新成功界面实现 + */ +#include "ota/include/OtaNightUpdateSuccessView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static OtaNightUpdateSuccessView *g_pOtaNightUpdateSuccessView{nullptr}; + + OtaNightUpdateSuccessView::OtaNightUpdateSuccessView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaNightUpdateSuccessView::OtaNightUpdateSuccessView"); + g_pOtaNightUpdateSuccessView = this; + } + + OtaNightUpdateSuccessView::~OtaNightUpdateSuccessView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaNightUpdateSuccessView::~OtaNightUpdateSuccessView"); + ClearAll(); + g_pOtaNightUpdateSuccessView = nullptr; + } + + + + + + OtaNightUpdateSuccessView* OtaNightUpdateSuccessView::GetInstance() + { + return g_pOtaNightUpdateSuccessView; + } + + UIViewGroup* OtaNightUpdateSuccessView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(90, 102, 180, 84); + 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->SetVisible(true); + group->Add(TextLabel); + } + + // 创建提示标签 + RemindLabel = new UILabelExt(); + if (RemindLabel) { + RemindLabel->SetPosition(136, 275, 88, 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(160, 277, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + return group; + } + + + void OtaNightUpdateSuccessView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { + background->SetAutoEnable(false); delete background; background = nullptr; } + if (TextLabel) { delete TextLabel; TextLabel = nullptr; } + if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; } + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); delete RemindIcon; RemindIcon = nullptr; } + } +} 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 new file mode 100644 index 000000000..6b3dcfc90 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNightUpdateView.cpp @@ -0,0 +1,136 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Night Update View - OTA夜间更新界面实现 + */ +#include "ota/include/OtaNightUpdateView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS + +{ + static OtaNightUpdateView *g_pOtaNightUpdateView{nullptr}; + OtaNightUpdateView::OtaNightUpdateView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaNightUpdateView::OtaNightUpdateView"); + g_pOtaNightUpdateView = this; + } + + OtaNightUpdateView::~OtaNightUpdateView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaNightUpdateView::~OtaNightUpdateView"); + ClearAll(); + g_pOtaNightUpdateView = nullptr; + } + + + + + + OtaNightUpdateView* OtaNightUpdateView::GetInstance() + { + return g_pOtaNightUpdateView; + } + + UIViewGroup* OtaNightUpdateView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(45, 102, 270, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + TextLabel->SetText("设置夜间更新"); + TextLabel->SetVisible(true); + group->Add(TextLabel); + } + + // 创建小文本标签 + LittleTextLabel = new UILabelExt(); + if (LittleTextLabel) { + LittleTextLabel->SetPosition(75, 162, 210, 28); + LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); + LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffcccccc); + LittleTextLabel->SetText("电量>50%,网络正常"); + LittleTextLabel->SetVisible(true); + group->Add(LittleTextLabel); + } + + // 创建提示标签 + 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + + // 创建第二个提示图标 + RemindIcon2 = new UIImageView(); + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + group->Add(RemindIcon2); + } + + return group; + } + + + void OtaNightUpdateView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { + background->SetAutoEnable(false); delete background; background = nullptr; } + if (TextLabel) { delete TextLabel; TextLabel = nullptr; } + if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; } + if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; } + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); delete RemindIcon2; RemindIcon2 = nullptr; } + } +} 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 new file mode 100644 index 000000000..fd1c66fd7 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaNormalView.cpp @@ -0,0 +1,165 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Normal View - OTA就绪界面实现 + */ +#include "ota/include/OtaNormalView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static OtaNormalView *g_pOtaNormalView{nullptr}; + + OtaNormalView::OtaNormalView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaNormalView::OtaNormalView"); + g_pOtaNormalView = this; + } + + OtaNormalView::~OtaNormalView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaNormalView::~OtaNormalView"); + ClearAll(); + g_pOtaNormalView = nullptr; + } + + OtaNormalView* OtaNormalView::GetInstance() + { + return g_pOtaNormalView; + } + + + + + UIViewGroup* OtaNormalView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(45, 102, 270, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + TextLabel->SetText("新的体验优化已就绪"); + TextLabel->SetVisible(true); + group->Add(TextLabel); + } + + // 创建小文本标签 + LittleTextLabel = new UILabelExt(); + if (LittleTextLabel) { + LittleTextLabel->SetPosition(0, 162, 360, 28); + LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); + LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffcccccc); + LittleTextLabel->SetText("全新功能已推出,现在Amby可以哄你睡觉"); + LittleTextLabel->SetVisible(true); + group->Add(LittleTextLabel); + } + + // 创建第二个小文本标签 + LittleTextLabel_2 = new UILabelExt(); + if (LittleTextLabel_2) { + LittleTextLabel_2->SetPosition(94, 194, 172, 28); + LittleTextLabel_2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel_2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); + LittleTextLabel_2->SetStyle(STYLE_TEXT_COLOR, 0xffcccccc); + LittleTextLabel_2->SetText("更新预计需要5分钟"); + LittleTextLabel_2->SetVisible(true); + group->Add(LittleTextLabel_2); + } + + // 创建提示标签 + 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + + // 创建第二个提示图标 + RemindIcon2 = new UIImageView(); + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + group->Add(RemindIcon2); + } + + return group; + } + + void OtaNormalView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + // 显式删除所有UI组件 + if (background) { + delete background; + background = nullptr; + } + if (TextLabel) { + delete TextLabel; + TextLabel = nullptr; + } + if (LittleTextLabel) { + delete LittleTextLabel; + LittleTextLabel = nullptr; + } + if (LittleTextLabel_2) { + delete LittleTextLabel_2; + LittleTextLabel_2 = nullptr; + } + if (RemindLabel) { + delete RemindLabel; + RemindLabel = nullptr; + } + if (RemindIcon) { + delete RemindIcon; + RemindIcon = nullptr; + } + if (RemindIcon2) { + delete RemindIcon2; + RemindIcon2 = 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 new file mode 100644 index 000000000..be22c567a --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaObviousView.cpp @@ -0,0 +1,135 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Obvious View - OTA有新功能界面实现 + */ +#include "ota/include/OtaObviousView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS +{ + static OtaObviousView *g_pOtaObviousView{nullptr}; + + OtaObviousView::OtaObviousView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaObviousView::OtaObviousView"); + g_pOtaObviousView = this; + } + + OtaObviousView::~OtaObviousView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaObviousView::~OtaObviousView"); + ClearAll(); + g_pOtaObviousView = nullptr; + } + + + + + + OtaObviousView* OtaObviousView::GetInstance() + { + return g_pOtaObviousView; + } + + UIViewGroup* OtaObviousView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(66, 102, 240, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + TextLabel->SetText("有新功能更新可用"); + TextLabel->SetVisible(true); + group->Add(TextLabel); + } + + // 创建小文本标签 + LittleTextLabel = new UILabelExt(); + if (LittleTextLabel) { + LittleTextLabel->SetPosition(0, 162, 360, 28); + LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); + LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffcccccc); + LittleTextLabel->SetText("全新功能已推出,现在Amby可以哄你睡觉"); + LittleTextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + LittleTextLabel->SetVisible(true); + group->Add(LittleTextLabel); + } + + // 创建提示标签 + 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + + // 创建第二个提示图标 + RemindIcon2 = new UIImageView(); + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + group->Add(RemindIcon2); + } + + return group; + } + + void OtaObviousView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { delete background; background = nullptr; } + if (TextLabel) { delete TextLabel; TextLabel = nullptr; } + if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; } + if (TextLabel) { delete TextLabel; TextLabel = nullptr; } + if (LittleTextLabel_2) { delete LittleTextLabel_2; LittleTextLabel_2 = nullptr; } + if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; } + if (RemindIcon) { delete RemindIcon; RemindIcon = nullptr; } + if (RemindIcon2) { delete RemindIcon2; RemindIcon2 = 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 new file mode 100644 index 000000000..42ab8af10 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaPresenter.cpp @@ -0,0 +1,300 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Presenter - 独立的OTA升级界面控制器实现 + */ +#include "ota/include/OtaPresenter.h" +#include "ota/include/OtaView.h" +#include "ota/include/OtaModel.h" +#include "wearable_log.h" +#include "ln_api.h" +#include "custom_utils.h" +#include "dock/input_device.h" +#include "ota/include/OtaView.h" +#include "ota/include/OtaPresenter.h" +#include "ota/include/OtaNormalView.h" +#include "ota/include/OtaObviousView.h" +#include "ota/include/OtaSuccessView.h" +#include "ota/include/OtaUpdatingView.h" +#include "ota/include/OtaCountdownView.h" +#include "ota/include/OtaLowBatteryView.h" +#include "ota/include/OtaNetworkErrorView.h" +#include "ota/include/OtaMemoryErrorView.h" +#include "ota/include/OtaFailedView.h" +#include "ota/include/OtaUpdateNowView.h" +#include "ota/include/OtaNightUpdateView.h" +#include "ota/include/OtaNightUpdateSuccessView.h" + +namespace OHOS +{ + REGIST_SLICE(VIEW_OTA, OtaView, OtaPresenter); + OtaPresenter::OtaPresenter() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::OtaPresenter"); + m_otaStatus = 0; + m_otaCountdownActive = false; + m_otaCountdownValue = 0; + m_otaProgress = 0; + } + + OtaPresenter::~OtaPresenter() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::~OtaPresenter"); + } + + void OtaPresenter::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::OnStart"); + Presenter::OnStart(); + } + + void OtaPresenter::OnResume() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::OnResume"); + Presenter::OnResume(); + // 设置按键监听器 + RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)this; + RootView::GetInstance()->SetOnKeyActListener(keyactListener); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::OnResume set key listener"); + } + + void OtaPresenter::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::OnStop"); + // StopOtaCountdown(); // 这个函数需要实现 + Presenter::OnStop(); + } + + bool OtaPresenter::OnClick(UIView &view, const ClickEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::OnClick"); + UNUSED(view); + UNUSED(event); + return false; + } + + bool OtaPresenter::OnKeyAct(UIView &view, const KeyEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::OnKeyAct"); + UNUSED(view); + + uint16_t keyId = event.GetKeyId(); + uint16_t keyState = event.GetState(); + + HandleKeyPress(keyId, keyState); + return true; + } + + void OtaPresenter::StartOtaUpdate() + { + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::StartOtaUpdate"); + + // // 检查网络状态 + // if (!OtaModel::GetInstance()->HasNetwork()) { + // UpdateOtaStatus(OTA_VIEW_NETWORK_ERROR); + // return; + // } + + // // 检查电量 + // if (!OtaModel::GetInstance()->IsBatterySufficient()) { + // UpdateOtaStatus(OTA_VIEW_LOW_BATTERY); + // return; + // } + + // // 检查内存 + // if (!OtaModel::GetInstance()->IsMemorySufficient()) { + // UpdateOtaStatus(OTA_VIEW_MEMORY_ERROR); + // return; + // } + + // // 开始OTA更新 + // int result = OtaModel::GetInstance()->StartOtaUpdate(); + // if (result == 0) { + // UpdateOtaStatus(OTA_VIEW_UPDATING); + // } else { + // UpdateOtaStatus(OTA_VIEW_UPDATE_FAILED); + // } + } + + // void OtaPresenter::StopOtaUpdate() + // { + // // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::StopOtaUpdate"); + + // // OtaModel::GetInstance()->StopOtaUpdate(); + // // UpdateOtaStatus(OTA_VIEW_UPDATE_FAILED); + // } + + void OtaPresenter::UpdateOtaProgress(int progress) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::UpdateOtaProgress: %d", progress); + + // m_otaProgress = progress; + // OtaModel::GetInstance()->SetOtaProgress(progress); + + // // 更新UI + // OtaView *view = static_cast(GetView()); + // if (view) { + // view->SetRemindProgress(progress); + // } + + // // 如果进度达到100%,更新状态为成功 + // if (progress >= 100) { + // UpdateOtaStatus(OTA_VIEW_UPDATE_SUCCESS); + // } + } + + void OtaPresenter::UpdateOtaStatus(int status) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::UpdateOtaStatus: %d", status); + + // m_otaStatus = status; + // OtaModel::GetInstance()->SetOtaStatus(status); + + // // 更新UI + // OtaView *view = static_cast(GetView()); + // if (view) { + // view->Show(status); + // } + + // HandleOtaStatusChange(status); + } + + // int OtaPresenter::GetOtaStatus() const + // { + // return m_otaStatus; + // } + + void OtaPresenter::StartOtaCountdown(uint32_t startVal) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::StartOtaCountdown: %u", startVal); + + m_otaCountdownActive = true; + m_otaCountdownValue = startVal; + + OtaModel::GetInstance()->SetCountdownActive(true); + OtaModel::GetInstance()->SetCountdownValue(startVal); + + // 显示倒计时界面 + // UpdateOtaStatus(OTA_VIEW_COUNTDOWN); + } + + // void OtaPresenter::StopOtaCountdown() + // { + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::StopOtaCountdown"); + + // m_otaCountdownActive = false; + // m_otaCountdownValue = 0; + + // OtaModel::GetInstance()->SetCountdownActive(false); + // OtaModel::GetInstance()->SetCountdownValue(0); + // } + + void OtaPresenter::UpdateCountdown(int value) + { + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::UpdateCountdown: %d", value); + + // m_otaCountdownValue = value; + // OtaModel::GetInstance()->SetCountdownValue(value); + + // // 更新UI + // OtaView *view = static_cast(GetView()); + // if (view) { + // view->UpdateCountdown(value); + // } + + // // 如果倒计时结束,开始更新 + // if (value <= 0) { + // StopOtaCountdown(); + // StartOtaUpdate(); + // } + } + + void OtaPresenter::HandleOtaStatusChange(int status) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaPresenter::HandleOtaStatusChange: %d", status); + + } + + void OtaPresenter::HandleKeyPress(uint16_t keyId, uint16_t keyState) + { + int16_t currentView = OtaView::GetInstance()->GetCurrentView(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaPresenter::HandleKeyPress: keyId=%d, keyState=%d", keyId, keyState); + + if (keyState == InputDevice::STATE_LONG_PRESS && keyId == static_cast(ZliteKeyCode::ZLITE_KEY_POWER)) { + NativeAbility::GetInstance().SwitchSlice(VIEW_REBOOT); + return; + } + // 处理按键事件 + if (keyState == InputDevice::STATE_PRESS) { + switch (keyId) { + case static_cast(ZliteKeyCode::ZLITE_KEY_POWER): + + break; + case static_cast(ZliteKeyCode::ZLITE_KEY_VENDOR_UP)://VENDOR_UP键 + if (currentView == OtaView::OTA_VIEW_NORMAL) { + //普通升级 + int result = OtaModel::GetInstance()->StartOtaUpdate(); + if(result == 0) { + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_NORMAL, OtaView::OTA_VIEW_UPDATING); + } + else if(result == -1) { + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_NORMAL, OtaView::OTA_VIEW_NETWORK_ERROR); + } + else if(result == -2) { + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_NORMAL, OtaView::OTA_VIEW_LOW_BATTERY); + } + else if(result == -3) { + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_NORMAL, OtaView::OTA_VIEW_MEMORY_ERROR); + } + } + else if (currentView == OtaView::OTA_VIEW_UPDATE_NOW) { + //强制升级 + //int result = OtaModel::GetInstance()->StartOtaUpdate(); + int result = 0; + if(result == 0) { + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_UPDATE_NOW, OtaView::OTA_VIEW_COUNTDOWN); + } + else if(result == -1) { + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_UPDATE_NOW, OtaView::OTA_VIEW_NETWORK_ERROR); + } + else if(result == -2) { + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_UPDATE_NOW, OtaView::OTA_VIEW_LOW_BATTERY); + } + else if(result == -3) { + OtaView::GetInstance()->ChangeView(OtaView::OTA_VIEW_UPDATE_NOW, OtaView::OTA_VIEW_MEMORY_ERROR); + } + } + 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) { + //夜间升级成功 + NativeAbility::GetInstance().SwitchSlice(VIEW_THUNDER_BIRD); + } + 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) { + 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 new file mode 100644 index 000000000..ff5bf86a1 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaSuccessView.cpp @@ -0,0 +1,110 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Success View - OTA更新成功界面实现 + */ +#include "ota/include/OtaSuccessView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS + +{ + static OtaSuccessView *g_pOtaSuccessView{nullptr}; + OtaSuccessView::OtaSuccessView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaSuccessView::OtaSuccessView"); + g_pOtaSuccessView = this; + } + + OtaSuccessView::~OtaSuccessView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaSuccessView::~OtaSuccessView"); + ClearAll(); + g_pOtaSuccessView = nullptr; + } + + + + + + + OtaSuccessView* OtaSuccessView::GetInstance() + { + return g_pOtaSuccessView; + } + + UIViewGroup* OtaSuccessView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(90, 102, 180, 84); + 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->SetVisible(true); + group->Add(TextLabel); + } + + // 创建提示标签 + RemindLabel = new UILabelExt(); + if (RemindLabel) { + RemindLabel->SetPosition(136, 275, 88, 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(160, 277, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + + return group; + } + + void OtaSuccessView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { delete background; background = nullptr; } + if (TextLabel) { delete TextLabel; TextLabel = nullptr; } + if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; } + if (RemindIcon) { delete RemindIcon; RemindIcon = 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 new file mode 100644 index 000000000..b9486bc10 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdateNowView.cpp @@ -0,0 +1,131 @@ + /* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Update Now View - OTA强制更新界面实现 + */ +#include "ota/include/OtaUpdateNowView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS + +{ + static OtaUpdateNowView *g_pOtaUpdateNowView{nullptr}; + OtaUpdateNowView::OtaUpdateNowView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaUpdateNowView::OtaUpdateNowView"); + g_pOtaUpdateNowView = this; + } + + OtaUpdateNowView::~OtaUpdateNowView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaUpdateNowView::~OtaUpdateNowView"); + ClearAll(); + g_pOtaUpdateNowView = nullptr; + } + + + + + OtaUpdateNowView* OtaUpdateNowView::GetInstance() + { + return g_pOtaUpdateNowView; + } + + UIViewGroup* OtaUpdateNowView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建文本标签 + TextLabel = new UILabelExt(); + if (TextLabel) { + TextLabel->SetPosition(90, 102, 180, 42); + TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 24); + TextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + TextLabel->SetText("需要立即更新"); + TextLabel->SetVisible(true); + group->Add(TextLabel); + } + + // 创建小文本标签 + LittleTextLabel = new UILabelExt(); + if (LittleTextLabel) { + LittleTextLabel->SetPosition(60, 162, 240, 56); + LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); + LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffcccccc); + LittleTextLabel->SetText("为保障您的产品安全,部分功能将在更新后恢复使用"); + LittleTextLabel->SetVisible(true); + group->Add(LittleTextLabel); + } + + // 创建提示标签 + 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); + group->Add(RemindLabel); + } + + // 创建提示图标 + RemindIcon = new UIImageView(); + if (RemindIcon) { + RemindIcon->SetAutoEnable(false); + RemindIcon->SetPosition(105, 276, 22, 22); + RemindIcon->SetResizeMode(UIImageView::CONTAIN); + RemindIcon->SetSrc("/user/res/volume_down.bin"); + RemindIcon->SetVisible(true); + group->Add(RemindIcon); + } + + // 创建第二个提示图标 + RemindIcon2 = new UIImageView(); + if (RemindIcon2) { + RemindIcon2->SetAutoEnable(false); + RemindIcon2->SetPosition(211, 276, 22, 22); + RemindIcon2->SetResizeMode(UIImageView::CONTAIN); + RemindIcon2->SetSrc("/user/res/volume_up.bin"); + RemindIcon2->SetVisible(true); + group->Add(RemindIcon2); + } + return group; + } + + void OtaUpdateNowView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { delete background; background = nullptr; } + 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; } + } +} 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 new file mode 100644 index 000000000..c9b0e25fe --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaUpdatingView.cpp @@ -0,0 +1,135 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA Updating View - OTA更新中界面实现 + */ +#include "ota/include/OtaUpdatingView.h" +#include "ota/include/OtaPresenter.h" +#include "wearable_log.h" + +namespace OHOS + +{ + static OtaUpdatingView *g_pOtaUpdatingView{nullptr}; + + OtaUpdatingView::OtaUpdatingView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaUpdatingView::OtaUpdatingView"); + currentProgress = 0; + g_pOtaUpdatingView = this; + } + + OtaUpdatingView::~OtaUpdatingView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaUpdatingView::~OtaUpdatingView"); + ClearAll(); + g_pOtaUpdatingView = nullptr; + } + + + + + + OtaUpdatingView* OtaUpdatingView::GetInstance() + { + return g_pOtaUpdatingView; + } + + UIViewGroup* OtaUpdatingView::InitUI() + { + // 创建主容器 + group = new UIViewGroup(); + if (group) { + group->SetPosition(0, 0, 360, 360); + group->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + 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); + } + + // 创建标题标签 + titleLabel = new UILabelExt(); + if (titleLabel) { + 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->SetRange(100, 0); + progressBar->SetStyle(STYLE_BORDER_RADIUS, 10); + progressBar->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xff333333); + progressBar->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xff45A5FF); + progressBar->SetValue(0); + group->Add(progressBar); + } + + // 创建进度百分比标签 + LittleTextLabel = new UILabelExt(); + if (LittleTextLabel) { + LittleTextLabel->SetPosition(56, 180, 44, 28); + LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); + LittleTextLabel->SetStyle(STYLE_TEXT_COLOR, 0xffffffff); + LittleTextLabel->SetText("0%"); + LittleTextLabel->SetVisible(true); + group->Add(LittleTextLabel); + } + + // 创建提示标签 + RemindLabel = new UILabelExt(); + if (RemindLabel) { + RemindLabel->SetPosition(170, 246, 150, 22); + RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 18); + RemindLabel->SetStyle(STYLE_TEXT_COLOR, 0xffcccccc); + RemindLabel->SetText("更新还需5分钟"); + RemindLabel->SetVisible(true); + group->Add(RemindLabel); + } + return group; + } + + + void OtaUpdatingView::ClearAll() + { + if (group) { + group->RemoveAll(); + delete group; + group = nullptr; + } + + if (background) { delete background; background = nullptr; } + if (titleLabel) { delete titleLabel; titleLabel = nullptr; } + if (LittleTextLabel) { delete LittleTextLabel; LittleTextLabel = nullptr; } + if (RemindLabel) { delete RemindLabel; RemindLabel = nullptr; } + if (progressBar) { delete progressBar; progressBar = nullptr; } + } + + void OtaUpdatingView::UpdateProgress(int progress) + { + currentProgress = progress; + if (progressBar) { + progressBar->SetValue(progress); + } + if (LittleTextLabel) { + LittleTextLabel->SetText((std::to_string(progress) + "%").c_str()); + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaUpdatingView::UpdateProgress: %d", progress); + } +} 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 new file mode 100644 index 000000000..9081678f6 --- /dev/null +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/ota/src/OtaView.cpp @@ -0,0 +1,431 @@ +/* + * @Author: Assistant + * @Date: 2024-12-19 + * @Description: OTA View - 独立的OTA升级界面实现 + */ +#include "ota/include/OtaView.h" +#include "ota/include/OtaPresenter.h" +#include "ota/include/OtaNormalView.h" +#include "ota/include/OtaObviousView.h" +#include "ota/include/OtaSuccessView.h" +#include "ota/include/OtaUpdatingView.h" +#include "ota/include/OtaCountdownView.h" +#include "ota/include/OtaLowBatteryView.h" +#include "ota/include/OtaNetworkErrorView.h" +#include "ota/include/OtaMemoryErrorView.h" +#include "ota/include/OtaFailedView.h" +#include "ota/include/OtaUpdateNowView.h" +#include "ota/include/OtaNightUpdateView.h" +#include "ota/include/OtaNightUpdateSuccessView.h" +#include "wearable_log.h" +#include "custom_utils.h" +#include "thunderbird/include/ThunderBirdModel.h" +#include "thunderbird/include/ThunderBirdMainView.h" +#include "ln_api_interface.h" + +namespace OHOS +{ + static OtaView *g_pOtaView{nullptr}; + OtaView::OtaView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaView::OtaView"); + ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); + g_pOtaView = this; + } + + OtaView::~OtaView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaView::~OtaView"); + ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 关闭屏幕常亮 + ClearAll(); + g_pOtaView = nullptr; + } + OtaView* OtaView::GetInstance() + { + return g_pOtaView; + } + + void OtaView::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaView::OnStart"); + View::OnStart(); + InitUI(); + } + + void OtaView::InitUI() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaView::InitUI"); + + // 创建滚动视图 + ScrollView_ = new UIScrollView(); + if (ScrollView_) { + ScrollView_->SetPosition(0, 0, 360, 360); + ScrollView_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000); + ScrollView_->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + AddViewToRootContainer(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); + } + + // ScrollView_->Add(ThunderBirdMainView::GetInstance()->InitBaseData()); // 最上面状态栏 + } + + void OtaView::OnStop() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OtaView::OnStop"); + View::OnStop(); + } + + + + bool OtaView::ChangeOtaNormalView(int16_t thisView) // 切换正常界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaNormalView = new OtaNormalView(); + if (g_pOtaNormalView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaNormalView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaNormalView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + bool OtaView::ChangeOtaObviousView(int16_t thisView) // 切换有新功能界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaObviousView = new OtaObviousView(); + if (g_pOtaObviousView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaObviousView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaObviousView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + + bool OtaView::ChangeOtaUpdatingView(int16_t thisView) // 切换正在更新界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaUpdatingView = new OtaUpdatingView(); + if (g_pOtaUpdatingView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaUpdatingView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaUpdatingView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + bool OtaView::ChangeOtaUpdateNowView(int16_t thisView) // 切换需要立即更新界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaUpdateNowView = new OtaUpdateNowView(); + if (g_pOtaUpdateNowView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaUpdateNowView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaUpdateNowView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + bool OtaView::ChangeOtaCountdownView(int16_t thisView) // 切换倒计时界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaCountdownView = new OtaCountdownView(); + if (g_pOtaCountdownView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaCountdownView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaCountdownView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + bool OtaView::ChangeOtaLowBatteryView(int16_t thisView) // 切换电量不足界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaLowBatteryView = new OtaLowBatteryView(); + if (g_pOtaLowBatteryView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaLowBatteryView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaLowBatteryView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + bool OtaView::ChangeOtaNetworkErrorView(int16_t thisView) // 切换网络异常界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaNetworkErrorView = new OtaNetworkErrorView(); + if (g_pOtaNetworkErrorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaNetworkErrorView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaNetworkErrorView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + bool OtaView::ChangeOtaMemoryErrorView(int16_t thisView) // 切换内存不足界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaMemoryErrorView = new OtaMemoryErrorView(); + if (g_pOtaMemoryErrorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaMemoryErrorView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaMemoryErrorView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + bool OtaView::ChangeOtaSuccessView(int16_t thisView) // 切换成功界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaSuccessView = new OtaSuccessView(); + if (g_pOtaSuccessView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaSuccessView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaSuccessView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + bool OtaView::ChangeOtaNightUpdateView(int16_t thisView) // 切换夜间更新界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaNightUpdateView = new OtaNightUpdateView(); + if (g_pOtaNightUpdateView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaNightUpdateView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaNightUpdateView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + bool OtaView::ChangeOtaNightUpdateSuccessView(int16_t thisView) // 切换夜间更新成功界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaNightUpdateSuccessView = new OtaNightUpdateSuccessView(); + if (g_pOtaNightUpdateSuccessView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaNightUpdateSuccessView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaNightUpdateSuccessView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + + bool OtaView::ChangeOtaFailedView(int16_t thisView) // 切换失败界面接口 + { + if (group[thisView] == nullptr) + { + g_pOtaFailedView = new OtaFailedView(); + if (g_pOtaFailedView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaFailedView new fail %d", thisView); + return false; + } + group[thisView] = g_pOtaFailedView->InitUI(); + ScrollView_->Add(group[thisView]); + } + return true; + } + + struct OtaViewMapper + { + const int16_t viewId; // 视图ID + bool (OtaView::*func)(int16_t); // 对应的视图切换函数指针 + }; + + static const OtaViewMapper ViewMapper[] = { + {OtaView::OTA_VIEW_NORMAL, &OtaView::ChangeOtaNormalView}, + {OtaView::OTA_VIEW_OBVIOUS, &OtaView::ChangeOtaObviousView}, + {OtaView::OTA_VIEW_UPDATE_NOW, &OtaView::ChangeOtaUpdateNowView}, + {OtaView::OTA_VIEW_UPDATING, &OtaView::ChangeOtaUpdatingView}, + {OtaView::OTA_VIEW_NIGHT_UPDATE, &OtaView::ChangeOtaNightUpdateView}, + {OtaView::OTA_VIEW_NIGHT_UPDATE_SUCCESS, &OtaView::ChangeOtaNightUpdateSuccessView}, + {OtaView::OTA_VIEW_COUNTDOWN, &OtaView::ChangeOtaCountdownView}, + {OtaView::OTA_VIEW_LOW_BATTERY, &OtaView::ChangeOtaLowBatteryView}, + {OtaView::OTA_VIEW_NETWORK_ERROR, &OtaView::ChangeOtaNetworkErrorView}, + {OtaView::OTA_VIEW_MEMORY_ERROR, &OtaView::ChangeOtaMemoryErrorView}, + {OtaView::OTA_VIEW_UPDATE_SUCCESS, &OtaView::ChangeOtaSuccessView}, + {OtaView::OTA_VIEW_UPDATE_FAILED, &OtaView::ChangeOtaFailedView}, + }; + + bool OtaView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]); + + for (int i = 0; i < funcSize; i++) + { + if (interface == ViewMapper[i].viewId) + { + bool jug = (this->*(ViewMapper[i].func))(interface); + if (jug == false) + { + return false; + } + return true; + } + } + return false; + } + + void OtaView::ChangeView(int16_t hideView, int16_t showView) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaView::ChangeView hideView = %d, showView = %d", hideView, showView); + if (hideView > MAX_OTA_VIEW) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OtaView:: OtaViewId Overstep ones bounds"); + return; + } + currentView_ = showView; + if (hideView != MAX_OTA_VIEW) + { + if (group[hideView] == nullptr) + { + return; + } + group[hideView]->SetVisible(false); + } + ClickFunc(showView); + group[showView]->SetVisible(true); + ScrollView_->Invalidate(); + } + + int16_t OtaView::GetCurrentView() + { + return currentView_; + } + + + void OtaView::ClearAll() + { + // 清理所有视图组 + for (int i = 0; i < MAX_OTA_VIEW; i++) { + if (group[i]) { + group[i]->RemoveAll(); + delete group[i]; + group[i] = nullptr; + } + } + + // 清理滚动视图 + if (ScrollView_) { + ScrollView_->RemoveAll(); + delete ScrollView_; + ScrollView_ = nullptr; + } + + // Clean up all view pointers + if (g_pOtaNormalView) { + delete g_pOtaNormalView; + g_pOtaNormalView = nullptr; + } + if (g_pOtaObviousView) { + delete g_pOtaObviousView; + g_pOtaObviousView = nullptr; + } + if (g_pOtaSuccessView) { + delete g_pOtaSuccessView; + g_pOtaSuccessView = nullptr; + } + if (g_pOtaUpdatingView) { + delete g_pOtaUpdatingView; + g_pOtaUpdatingView = nullptr; + } + if (g_pOtaUpdateNowView) { + delete g_pOtaUpdateNowView; + g_pOtaUpdateNowView = nullptr; + } + if (g_pOtaFailedView) { + delete g_pOtaFailedView; + g_pOtaFailedView = nullptr; + } + if (g_pOtaCountdownView) { + delete g_pOtaCountdownView; + g_pOtaCountdownView = nullptr; + } + if (g_pOtaLowBatteryView) { + delete g_pOtaLowBatteryView; + g_pOtaLowBatteryView = nullptr; + } + if (g_pOtaNetworkErrorView) { + delete g_pOtaNetworkErrorView; + g_pOtaNetworkErrorView = nullptr; + } + if (g_pOtaMemoryErrorView) { + delete g_pOtaMemoryErrorView; + g_pOtaMemoryErrorView = nullptr; + } + if (g_pOtaNightUpdateView) { + delete g_pOtaNightUpdateView; + g_pOtaNightUpdateView = nullptr; + } + if (g_pOtaNightUpdateSuccessView) { + delete g_pOtaNightUpdateSuccessView; + g_pOtaNightUpdateSuccessView = nullptr; + } + + + } + + + + // void OtaView::UpdateCountdown(int value) + // { + // // if (TextLabel) { + // // char countdownText[64]; + // // snprintf(countdownText, sizeof(countdownText), "%d", value); + // // TextLabel->SetText(countdownText); + // // } + // } + + // void OtaView::SetRemindProgress(int16_t value) + // { + // // remindProgressValue_ = value; + // // if (VolumeProgress) { + // // VolumeProgress->SetValue(value); + // // } + // } +} diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h index 51b2039e5..3f84df3ea 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdMainView.h @@ -15,7 +15,7 @@ #include "thunderbird/include/ThunderBirdModel.h" #include "thunderbird/include/ThunderBirdPresenter.h" // 各子界面头文件 -#include "thunderbird/include/ThunderBirdOtaView.h" +// OTA界面已独立为slice,不再需要此头文件 #include "thunderbird/include/ThunderBirdGuideView.h" #include "thunderbird/include/ThunderBirdLullabyView.h" #include "thunderbird/include/ThunderBirdDialogueView.h" @@ -29,7 +29,6 @@ namespace OHOS typedef enum : uint8_t { THUNDERBIRDMENUVIEW = 0, // 主界面 - THUNDERBIRD_OTAVIEW, THUNDERBIRD_GUIDEVIEW, THUNDERBIRD_LULLABYVIEW, THUNDERBIRD_DIALOGUEVIEW, @@ -50,7 +49,7 @@ namespace OHOS // 视图切换(按组显示/隐藏) bool ChangeThunderBirdView(int16_t); - bool ChangeThunderBirdOtaView(int16_t); + // OTA界面已独立为slice,不再需要此函数 bool ChangeThunderBirdGuideView(int16_t); bool ChangeThunderBirdLullabyView(int16_t); bool ChangeThunderBirdDialogueView(int16_t); @@ -131,7 +130,7 @@ namespace OHOS bool notifiedChargeFull{false}; // 各子界面对象指针 - ThunderBirdOtaView *g_pThunderBirdOtaView{nullptr}; + // OTA界面已独立为slice,不再需要此指针 ThunderBirdGuideView *g_pThunderBirdGuideView{nullptr}; ThunderBirdLullabyView *g_pThunderBirdLullabyView{nullptr}; ThunderBirdDialogueView *g_pThunderBirdDialogueView{nullptr}; diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdOtaView.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdOtaView.h deleted file mode 100644 index ca82f2b09..000000000 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdOtaView.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef THUNDERBIRD_OTA_VIEW_H_ -#define THUNDERBIRD_OTA_VIEW_H_ - -#include "View.h" -#include "components/ui_view_group.h" -#include "components/ui_label_ext.h" -#include "components/ui_image_view.h" -#include "components/ui_box_progress.h" - -namespace OHOS -{ - class ThunderBirdOtaView - { - public: - ThunderBirdOtaView(); - virtual ~ThunderBirdOtaView(); - static ThunderBirdOtaView *GetInstance(void); - UIViewGroup *ThunderBirdOtaViewInit(void); - void ClearAll(void); - void Show(int16_t showView); - void UpdateCountdown(int value); - void SetRemindProgress(int16_t value); - enum : int16_t { - THUNDERBIRD_OTAVIEW_NORMAL = 0, // OTA就绪 - THUNDERBIRD_OTAVIEW_OBVIOUS, // 有新功能 - THUNDERBIRD_OTAVIEW_UPDATE_NOW, // 需要立即更新 - THUNDERBIRD_OTAVIEW_UPDATING, // 更新中 - THUNDERBIRD_OTAVIEW_NIGHT_UPDATE, // 设置夜间更新 - THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS, // 设置夜间更新成功 - THUNDERBIRD_OTAVIEW_COUNTDOWN, // 更新倒计时 - THUNDERBIRD_OTAVIEW_LOW_BATTERY, // 电量不足 - THUNDERBIRD_OTAVIEW_NETWORK_ERROR, // 网络异常 - THUNDERBIRD_OTAVIEW_MEMORY_ERROR, // 内存不足 - THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS, // 更新成功 - THUNDERBIRD_OTAVIEW_UPDATE_FAILED, // 更新未完成 - }; - - private: - UIViewGroup *group{nullptr}; - UILabelExt *titleLabel{nullptr}; - UILabelExt *TextLabel{nullptr}; - UILabelExt *LittleTextLabel{nullptr}; - UILabelExt *LittleTextLabel_2{nullptr}; - UILabelExt *RemindLabel{nullptr}; - UIImageView *RemindIcon{nullptr}; - UIImageView *RemindIcon2{nullptr}; - UIImageView *RemindIcon3{nullptr}; - UIBoxProgress *VolumeProgress{nullptr}; - UIImageView *BackGround{nullptr}; - int16_t remindProgressValue_{0}; - }; -} - -#endif - diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp index 257198b8d..4905c8942 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdMainView.cpp @@ -112,11 +112,7 @@ namespace OHOS } // 释放各子界面对象 - if (g_pThunderBirdOtaView) - { - delete g_pThunderBirdOtaView; - g_pThunderBirdOtaView = nullptr; - } + // OTA界面已独立为slice,不再需要清理 if (g_pThunderBirdGuideView) { delete g_pThunderBirdGuideView; @@ -269,8 +265,8 @@ namespace OHOS ScrollView_->SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE); ScrollView_->SetStyle(STYLE_BACKGROUND_COLOR, Color::Black().full); ScrollView_->SetOnDragListener(presenter_); - ScrollView_->SetTouchable(true); - ScrollView_->SetDraggable(true); + ScrollView_->SetTouchable(false); + ScrollView_->SetDraggable(false); AddViewToRootContainer(ScrollView_); Initback(); // 最底层 @@ -300,18 +296,7 @@ namespace OHOS } else if(ThunderBirdModel::GetInstance()->StartBootOperation() == 1) { - if(ThunderBirdModel::GetInstance()->ota_update_boot() == 1)//强制OTA升级 - { - ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW); - } - else if(ThunderBirdModel::GetInstance()->ota_update_boot() == 0)//可选OTA升级 - { - ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL); - } - else//其他 - { ChangeView(MAXVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING); - } } ScrollView_->Add(InitBaseData()); // 最上面状态栏 @@ -399,21 +384,7 @@ namespace OHOS } } - bool ThunderBirdMainView::ChangeThunderBirdOtaView(int16_t thisView) // 切换Ota界面接口 - { - if (group[thisView] == nullptr) - { - g_pThunderBirdOtaView = new ThunderBirdOtaView(); - if (g_pThunderBirdOtaView == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdOtaView new fail %d", thisView); - return false; - } - group[thisView] = g_pThunderBirdOtaView->ThunderBirdOtaViewInit(); - ScrollView_->Add(group[thisView]); - } - return true; - } + // OTA界面已独立为slice,不再需要此函数 bool ThunderBirdMainView::ChangeThunderBirdGuideView(int16_t thisView) // 切换引导界面接口 { @@ -522,7 +493,6 @@ namespace OHOS }; static const TBViewMapper ViewMapper[] = { - {THUNDERBIRD_OTAVIEW, &ThunderBirdMainView::ChangeThunderBirdOtaView}, {THUNDERBIRD_GUIDEVIEW, &ThunderBirdMainView::ChangeThunderBirdGuideView}, {THUNDERBIRD_LULLABYVIEW, &ThunderBirdMainView::ChangeThunderBirdLullabyView}, {THUNDERBIRD_DIALOGUEVIEW, &ThunderBirdMainView::ChangeThunderBirdDialogueView}, @@ -573,10 +543,7 @@ namespace OHOS { ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); // 关闭屏幕常亮 } - if(prevSubView_ == ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING)//上一个界面是OTA升级界面 - { - videoPlay_->StartVideoPlay(); - } + // OTA界面已独立为slice,不再需要此检查 // 保存上一级视图信息 prevView_ = currentView_; prevSubView_ = currentSubView_; @@ -606,12 +573,7 @@ namespace OHOS g_pThunderBirdLullabyView->Show(subView); } break; - case THUNDERBIRD_OTAVIEW: - if (g_pThunderBirdOtaView) - { - g_pThunderBirdOtaView->Show(subView); - } - break; + // OTA界面已独立为slice,不再需要此case case THUNDERBIRD_DIALOGUEVIEW: if (g_pThunderBirdDialogueView) { @@ -724,7 +686,7 @@ namespace OHOS } UIViewGroup *ThunderBirdMainView::InitBaseData() { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitBaseData"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PullUpDownView::InitBaseData"); if (group1 == nullptr) { group1 = new UIViewGroup(); @@ -736,6 +698,7 @@ namespace OHOS } group1->SetPosition(90, 14, 175, 40); group1->SetStyle(STYLE_BACKGROUND_OPA, 0); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group1 init success"); timeLabel = new UILabelExt(); if (timeLabel == nullptr) @@ -750,6 +713,7 @@ namespace OHOS timeLabel->SetVisible(true); timeLabel->SetText(ThunderBirdModel::GetInstance()->GetCurrentTimeStr().c_str()); // 每秒变化 group1->Add(timeLabel); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "timeLabel add success"); /* -------------------------------- NoSignal -------------------------------- */ if (NoSignal == nullptr) { @@ -766,6 +730,7 @@ namespace OHOS NoSignal->SetSrc(DROPDOWN_NOSIGNAL_IMAGE); NoSignal->SetVisible(false); group1->Add(NoSignal); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "NoSignal add success"); /* -------------------------------------------------------------------------- */ // 定义一个结构体,用于存储 ImageView 的信息 struct ImageViewInfo @@ -802,6 +767,7 @@ namespace OHOS group1->Add(showSignalStrength[i]); showSignalStrength[i]->SetVisible(true); } + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "showSignalStrength add success"); /* ----------------------------------- 电池 ----------------------------------- */ batteryimage = new UIImageView(); if (batteryimage == nullptr) @@ -815,6 +781,7 @@ namespace OHOS std::string batteryimagesPath = "/user/res/Battery_White.bin"; batteryimage->SetSrc(batteryimagesPath.c_str()); group1->Add(batteryimage); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryimage add success"); /* -------------------------------------------------------------------------- */ progress = new UIBoxProgress(); if (progress == nullptr) @@ -833,6 +800,7 @@ namespace OHOS progress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000); progress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); group1->Add(progress); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "progress add success"); /* -----------------------------------电量--------------------------------------- */ batteryLabel = new UILabel(); if (batteryLabel == nullptr) @@ -846,6 +814,7 @@ namespace OHOS batteryLabel->SetStyle(STYLE_TEXT_COLOR, Color::White().full); batteryLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_LEFT); group1->Add(batteryLabel); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "batteryLabel add success"); /* ----------------------------------充电图标-------------------------------------- */ chargeBatteryicon = new UIImageView(); if (!chargeBatteryicon) @@ -859,12 +828,14 @@ namespace OHOS chargeBatteryicon->SetResizeMode(UIImageView::CONTAIN); chargeBatteryicon->SetVisible(false); group1->Add(chargeBatteryicon); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "chargeBatteryicon add success"); /* -------------------------------------------------------------------------- */ // ScrollView_->Add(group1); /* -------------------------------------------------------------------------- */ - updateSignalDisplay(); + //updateSignalDisplay(); /* -------------------------------------------------------------------------- */ - UpdateBatteryProcess(); + //UpdateBatteryProcess(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "InitBaseData add success"); return group1; } void ThunderBirdMainView::UpdateTimeText(const char *time) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index b4f10ff43..3b1691d65 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -16,7 +16,6 @@ #include "thunderbird/include/ThunderBirdModel.h" #include "thunderbird/include/ThunderBirdReminderView.h" - #include "thunderbird/include/ThunderBirdOtaView.h" #include "thunderbird/include/ThunderBirdLullabyView.h" #include "thunderbird/include/ThunderBirdMainView.h" #include "thunderbird/include/ThunderBirdPresenter.h" @@ -162,35 +161,35 @@ { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StartOtaCountdown: startVal=%u", startVal); - // 范围保护 - if (startVal < 1) { startVal = 1; } - if (startVal > 5) { startVal = 5; } + // // 范围保护 + // if (startVal < 1) { startVal = 1; } + // if (startVal > 5) { startVal = 5; } - // 设置OTA倒计时状态 - m_otaCountdownActive = true; - m_otaCountdownValue = (int)startVal; + // // 设置OTA倒计时状态 + // m_otaCountdownActive = true; + // m_otaCountdownValue = (int)startVal; - // 立即刷新一次当前值 - if (ThunderBirdOtaView::GetInstance()) { - ThunderBirdOtaView::GetInstance()->UpdateCountdown(m_otaCountdownValue); - } + // // 立即刷新一次当前值 + // if (ThunderBirdOtaView::GetInstance()) { + // ThunderBirdOtaView::GetInstance()->UpdateCountdown(m_otaCountdownValue); + // } - // 确保状态管理定时器正在运行 - if (m_statusTimer == nullptr) { - StartStatusTimer(1000); // 1秒间隔 - } + // // 确保状态管理定时器正在运行 + // if (m_statusTimer == nullptr) { + // StartStatusTimer(1000); // 1秒间隔 + // } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA countdown started: %d seconds", m_otaCountdownValue); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA countdown started: %d seconds", m_otaCountdownValue); } void ThunderBirdModel::StopOtaCountdown(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StopOtaCountdown"); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StopOtaCountdown"); - // 停止OTA倒计时 - m_otaCountdownActive = false; - m_otaCountdownValue = 0; + // // 停止OTA倒计时 + // m_otaCountdownActive = false; + // m_otaCountdownValue = 0; - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA countdown stopped"); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA countdown stopped"); } @@ -241,27 +240,27 @@ { do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_GET_TASK, nullptr, 0);//获取是否需要OTA升级 - if(uapi_ln_ota_get_update_type() == 1)//强制OTA升级 - { - ThunderBirdMainView::GetInstance()->ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW); - return 1; - } - else if(uapi_ln_ota_get_update_type() == 0)//可选OTA升级 - { - ThunderBirdMainView::GetInstance()->ChangeView(MAXVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL); - return 0; - } + // if(uapi_ln_ota_get_update_type() == 1)//强制OTA升级 + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_OTA); + // return 1; + // } + // else if(uapi_ln_ota_get_update_type() == 0)//可选OTA升级 + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_OTA); + // return 0; + // } return -1; } /*************************OTA升级进度*************************/ void ThunderBirdModel::UpdateOtaProgress(int progress) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::UpdateOtaProgress: %d", progress); - if(ThunderBirdOtaView::GetInstance()) - { - ThunderBirdOtaView::GetInstance()->SetRemindProgress(progress); - } + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::UpdateOtaProgress: %d", progress); + // if(ThunderBirdOtaView::GetInstance()) + // { + // ThunderBirdOtaView::GetInstance()->SetRemindProgress(progress); + // } } /*************************OTA升级状态*************************/ @@ -269,24 +268,14 @@ { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::UpdateOtaStatus: %d", status); m_otaStatus = status; - int current_view = ThunderBirdMainView::GetInstance()->GetCurrentView(); // 更新状态检查 - if(status == 1)//OTA升级 - { - // ThunderBirdMainView::GetInstance()->ChangeView(current_view, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW); - NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); - } - else if(status == 2)//OTA升级失败 - { - // ThunderBirdMainView::GetInstance()->ChangeView(current_view, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED); - NativeAbility::GetInstance().ChangeSlice(VIEW_THUNDER_BIRD); - } - else if(status == 3)//OTA升级成功 + if(status == 1 || status == 2 || status == 3)//OTA升级 { - // ThunderBirdMainView::GetInstance()->ChangeView(current_view, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS); + NativeAbility::GetInstance().ChangeSlice(VIEW_OTA); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "进入OTA"); } - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "进入OTA界面"); - } + } + /*************************获取OTA升级状态*************************/ int ThunderBirdModel::GetOtaStatus() { @@ -1033,9 +1022,16 @@ { // ==================== 网络状态处理 ==================== // 更新网络状态信息(包括SIM卡、信号强度、网络连接等) + // 先检查Cat1电源状态 UpdateNetworkStatus(); - + // if( HasCat1Power() == false) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Cat1电源状态异常,跳过网络检查"); + // return; + // } + // 检查网络状态是否有网 + if(HasNetwork()) { if(get_is_ln_get_device_token_success() == 0) @@ -1076,27 +1072,27 @@ UpdateDeviceStatus(); // 处理OTA倒计时定时器 - if (m_otaCountdownActive) { - if (m_otaCountdownValue <= 0) { - // OTA倒计时结束,停止定时器并开始OTA - m_otaCountdownActive = false; - m_otaCountdownValue = 0; + // if (m_otaCountdownActive) { + // if (m_otaCountdownValue <= 0) { + // // OTA倒计时结束,停止定时器并开始OTA + // m_otaCountdownActive = false; + // m_otaCountdownValue = 0; - // 自动跳转到开始OTA界面 - do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0); - ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA countdown completed, starting OTA"); - } else { - // 更新倒计时值 - m_otaCountdownValue--; + // // 自动跳转到开始OTA界面 + // do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_DOWNLOAD, NULL, 0); + // ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATING); + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA countdown completed, starting OTA"); + // } else { + // // 更新倒计时值 + // m_otaCountdownValue--; - // 更新UI显示 - if (ThunderBirdOtaView::GetInstance()) { - ThunderBirdOtaView::GetInstance()->UpdateCountdown(m_otaCountdownValue); - } - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA countdown: %d", m_otaCountdownValue); - } - } + // // 更新UI显示 + // if (ThunderBirdOtaView::GetInstance()) { + // ThunderBirdOtaView::GetInstance()->UpdateCountdown(m_otaCountdownValue); + // } + // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "OTA countdown: %d", m_otaCountdownValue); + // } + // } // 处理计数定时器 if (m_countUpActive) { @@ -1374,7 +1370,6 @@ { return m_hasNetwork; } - /** * @brief 检查网络状态是否发生变化 * @return true表示网络状态发生变化,false表示无变化 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdOtaView.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdOtaView.cpp deleted file mode 100644 index 837a5c68a..000000000 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdOtaView.cpp +++ /dev/null @@ -1,633 +0,0 @@ -#include "thunderbird/include/ThunderBirdOtaView.h" -#include "thunderbird/include/ThunderBirdModel.h" -#include "thunderbird/include/ThunderBirdPresenter.h" -#include "wearable_log.h" -#include "custom_utils.h" - -namespace OHOS -{ - static ThunderBirdOtaView *g_pThunderBirdOtaView{nullptr}; - - ThunderBirdOtaView::ThunderBirdOtaView() - { - g_pThunderBirdOtaView = this; - } - - ThunderBirdOtaView::~ThunderBirdOtaView() - { - g_pThunderBirdOtaView = nullptr; - ClearAll(); - } - - ThunderBirdOtaView *ThunderBirdOtaView::GetInstance(void) - { - return g_pThunderBirdOtaView; - } - - void ThunderBirdOtaView::ClearAll(void) - { - if (group != nullptr) - { - // 移除所有子组件 - group->RemoveAll(); - - // 删除子组件 - if (titleLabel != nullptr) { delete titleLabel; titleLabel = nullptr; } - if (TextLabel != nullptr) { delete TextLabel; TextLabel = nullptr; } - if (LittleTextLabel != nullptr) { delete LittleTextLabel; LittleTextLabel = nullptr; } - if (LittleTextLabel_2 != nullptr) { delete LittleTextLabel_2; LittleTextLabel_2 = nullptr; } - if (RemindLabel != nullptr) { delete RemindLabel; RemindLabel = nullptr; } - if (RemindIcon != nullptr) { delete RemindIcon; RemindIcon = nullptr; } - if (RemindIcon2 != nullptr) { delete RemindIcon2; RemindIcon2 = nullptr; } - if (BackGround != nullptr) { delete BackGround; BackGround = nullptr; } - - // 最后删除group - delete group; - group = nullptr; - } - } - - UIViewGroup *ThunderBirdOtaView::ThunderBirdOtaViewInit(void) - { - group = new UIViewGroup(); - if (group == nullptr) - { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdOtaView::group null!"); - return nullptr; - } - group->SetPosition(0, 0, 360, 360); - - BackGround = new UIImageView(); - if (BackGround) - { - BackGround->SetAutoEnable(false); - BackGround->SetPosition(0, 0, 360, 360); - BackGround->SetSrc("/user/res/yellowbg.bin"); - BackGround->SetStyle(STYLE_BACKGROUND_OPA, 0xff); - BackGround->SetResizeMode(UIImageView::CONTAIN); - BackGround->SetVisible(false); - group->Add(BackGround); - } - - // 公共控件 - TextLabel = new UILabelExt(); - if (TextLabel) - { - TextLabel->SetPosition(0, 104, 360, 48); - TextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - TextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - TextLabel->SetStyle(STYLE_LINE_SPACE, 10); - //TextLabel->SetStyle(STYLE_LETTER_SPACE, 1); - TextLabel->SetVisible(false); - group->Add(TextLabel); - } - LittleTextLabel = new UILabelExt(); - if (LittleTextLabel) - { - LittleTextLabel->SetPosition(0, 180, 360, 40); - LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); - LittleTextLabel->SetVisible(false); - group->Add(LittleTextLabel); - } - LittleTextLabel_2 = new UILabelExt(); - if (LittleTextLabel_2) - { - LittleTextLabel_2->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - LittleTextLabel_2->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); - LittleTextLabel_2->SetVisible(false); - group->Add(LittleTextLabel_2); - } - RemindLabel = new UILabelExt(); - if (RemindLabel) - { - RemindLabel->SetPosition(0, 180, 360, 40); - RemindLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - RemindLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); - RemindLabel->SetVisible(false); - group->Add(RemindLabel); - } - RemindIcon = new UIImageView(); - if (RemindIcon) - { - RemindIcon->SetAutoEnable(false); - RemindIcon->SetVisible(false); - RemindIcon->SetResizeMode(UIImageView::CONTAIN); - group->Add(RemindIcon); - } - RemindIcon2 = new UIImageView(); - if (RemindIcon2) - { - RemindIcon2->SetAutoEnable(false); - RemindIcon2->SetVisible(false); - RemindIcon2->SetResizeMode(UIImageView::CONTAIN); - group->Add(RemindIcon2); - } - RemindIcon3 = new UIImageView(); - if (RemindIcon3) - { - RemindIcon3->SetAutoEnable(false); - RemindIcon3->SetVisible(false); - RemindIcon3->SetResizeMode(UIImageView::CONTAIN); - group->Add(RemindIcon3); - } - VolumeProgress = new UIBoxProgress(); - if (VolumeProgress) - { - VolumeProgress->SetPosition(56, 279, 248, 4); - VolumeProgress->SetRange(100, 0); - VolumeProgress->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0xff); - VolumeProgress->SetBackgroundStyle(STYLE_BACKGROUND_COLOR, 0xffb4a9a0); - VolumeProgress->SetForegroundStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); - VolumeProgress->SetForegroundStyle(STYLE_TEXT_COLOR, 0xff000000); - VolumeProgress->SetForegroundStyle(STYLE_LINE_COLOR, 0xff45A5FF); - group->Add(VolumeProgress); - } - return group; - } - - void ThunderBirdOtaView::Show(int16_t showView) - { - if (group == nullptr) { return; } - if (BackGround) { BackGround->SetVisible(true);} - if (TextLabel) { TextLabel->SetVisible(false); } - if (LittleTextLabel) - { - LittleTextLabel->SetVisible(false); - TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); - LittleTextLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); - LittleTextLabel->SetRollSpeed(35); - LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 20); - } - if (LittleTextLabel_2) { LittleTextLabel_2->SetVisible(false);} - if (RemindLabel) { RemindLabel->SetVisible(false);} - if (RemindIcon) { RemindIcon->SetVisible(false); } - if (RemindIcon2) { RemindIcon2->SetVisible(false); } - if (RemindIcon3) { RemindIcon3->SetVisible(false); } - if (VolumeProgress) { VolumeProgress->SetVisible(false); } - ThunderBirdModel::GetInstance()->StopOtaCountdown(); - switch (showView) - { - case THUNDERBIRD_OTAVIEW_NORMAL: - { - if (TextLabel) - { - TextLabel->SetPosition(45, 102, 270, 42); - TextLabel->SetText("新的体验优化已就绪"); - TextLabel->SetVisible(true); - } - if (LittleTextLabel) - { - LittleTextLabel->SetText("全新功能已推出,现在Amby可以哄你睡觉"); - LittleTextLabel->SetPosition(0, 162, 360, 28); - LittleTextLabel->SetVisible(true); - } - if (LittleTextLabel_2) - { - LittleTextLabel_2->SetPosition(94, 194, 172, 28); - LittleTextLabel_2->SetText("更新预计需要5分钟"); - LittleTextLabel_2->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(80, 275, 200, 25); - RemindLabel->SetText("按 退出 按 更新"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(105, 276, 22, 22); - RemindIcon->SetSrc("/user/res/volume_down.bin"); - RemindIcon->SetVisible(true); - } - if (RemindIcon2) - { - RemindIcon2->SetPosition(211, 276, 22, 22); - RemindIcon2->SetSrc("/user/res/volume_up.bin"); - RemindIcon2->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_OBVIOUS: - { - if (TextLabel) - { - TextLabel->SetPosition(66, 102, 240, 42); - TextLabel->SetText("有新功能更新可用"); - TextLabel->SetVisible(true); - } - if (LittleTextLabel) - { - LittleTextLabel->SetText("全新功能已推出,现在Amby可以哄你睡觉"); - LittleTextLabel->SetPosition(0, 162, 360, 28); - LittleTextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - LittleTextLabel->SetVisible(true); - } - if (LittleTextLabel_2) - { - LittleTextLabel_2->SetText("更新预计需要5分钟"); - LittleTextLabel_2->SetPosition(94, 194, 172, 28); - LittleTextLabel_2->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(80, 275, 200, 25); - RemindLabel->SetText("按 退出 按 更新"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(105, 276, 22, 22); - RemindIcon->SetSrc("/user/res/volume_down.bin"); - RemindIcon->SetVisible(true); - } - if (RemindIcon2) - { - RemindIcon2->SetPosition(211, 276, 22, 22); - RemindIcon2->SetSrc("/user/res/volume_up.bin"); - RemindIcon2->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_UPDATE_NOW: - { - if (TextLabel) - { - TextLabel->SetPosition(90, 102, 180, 42); - TextLabel->SetText("需要立即更新"); - TextLabel->SetVisible(true); - } - if (LittleTextLabel) - { - LittleTextLabel->SetText("为保障您的产品安全,部分功能将在更新后恢复使用"); - LittleTextLabel->SetPosition(60, 162, 240, 56); - LittleTextLabel->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(80, 275, 200, 25); - RemindLabel->SetText("按 退出 按 更新"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(105, 276, 22, 22); - RemindIcon->SetSrc("/user/res/volume_down.bin"); - RemindIcon->SetVisible(true); - } - if (RemindIcon2) - { - RemindIcon2->SetPosition(211, 276, 22, 22); - RemindIcon2->SetSrc("/user/res/volume_up.bin"); - RemindIcon2->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_NIGHT_UPDATE: - { - if (TextLabel) - { - TextLabel->SetPosition(45, 102, 270, 42); - TextLabel->SetText("设置夜间更新"); - TextLabel->SetVisible(true); - } - if (LittleTextLabel) - { - LittleTextLabel->SetText("电量>50%,网络正常"); - LittleTextLabel->SetPosition(75, 162, 210, 28); - LittleTextLabel->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(80, 275, 200, 25); - RemindLabel->SetText("按 退出 按 确认"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(105, 276, 22, 22); - RemindIcon->SetSrc("/user/res/volume_down.bin"); - RemindIcon->SetVisible(true); - } - if (RemindIcon2) - { - RemindIcon2->SetPosition(211, 276, 22, 22); - RemindIcon2->SetSrc("/user/res/volume_up.bin"); - RemindIcon2->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_NIGHT_UPDATE_SUCCESS: - { - if (TextLabel) - { - TextLabel->SetPosition(90, 102, 180, 84); - TextLabel->SetText("设定成功!\n记得充好电哦"); - TextLabel->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); - TextLabel->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(136, 275, 88, 25); - RemindLabel->SetText("按 确认"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(160, 277, 22, 22); - RemindIcon->SetSrc("/user/res/volume_down.bin"); - RemindIcon->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_COUNTDOWN: - { - ThunderBirdModel::GetInstance()->StartOtaCountdown(5); - if (TextLabel) - { - TextLabel->SetPosition(60, 102, 240, 42); - TextLabel->SetText("设备更新即将开始"); - TextLabel->SetVisible(true); - } - if (LittleTextLabel) - { - LittleTextLabel->SetText("5"); - LittleTextLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 48); - LittleTextLabel->SetPosition(166, 172, 29, 67); - LittleTextLabel->SetVisible(true); - } - - if (RemindLabel) - { - RemindLabel->SetPosition(80, 275, 200, 25); - RemindLabel->SetText("按 退出 按 确认"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(105, 276, 22, 22); - RemindIcon->SetSrc("/user/res/volume_down.bin"); - RemindIcon->SetVisible(true); - } - if (RemindIcon2) - { - RemindIcon2->SetPosition(211, 276, 22, 22); - RemindIcon2->SetSrc("/user/res/volume_up.bin"); - RemindIcon2->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_LOW_BATTERY: - { - if (TextLabel) - { - TextLabel->SetPosition(82, 124, 240, 42); - TextLabel->SetText("电量不足无法更新"); - TextLabel->SetVisible(true); - } - if (LittleTextLabel) - { - LittleTextLabel->SetText("请至少充至50%电量哦"); - LittleTextLabel->SetPosition(72, 186, 192, 25); - LittleTextLabel->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(136, 275, 88, 25); - RemindLabel->SetText("按 退出"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(160, 277, 22, 22); - RemindIcon->SetSrc("/user/res/volume_down.bin"); - RemindIcon->SetVisible(true); - } - if (RemindIcon2) - { - RemindIcon2->SetPosition(38, 124, 36, 36); - RemindIcon2->SetSrc("/user/res/warning.bin"); - RemindIcon2->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_NETWORK_ERROR: - { - if (TextLabel) - { - TextLabel->SetText("网络连接异常"); - TextLabel->SetPosition(112, 124, 180, 42); - TextLabel->SetVisible(true); - } - if (LittleTextLabel) - { - LittleTextLabel->SetText("请检查网络后重试"); - LittleTextLabel->SetPosition(100, 184, 160, 28); - LittleTextLabel->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(80, 275, 200, 25); - RemindLabel->SetText("按 退出 按 重试"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(105, 276, 22, 22); - RemindIcon->SetSrc("/user/res/volume_down.bin"); - RemindIcon->SetVisible(true); - } - if (RemindIcon2) - { - RemindIcon2->SetPosition(211, 276, 22, 22); - RemindIcon2->SetSrc("/user/res/volume_up.bin"); - RemindIcon2->SetVisible(true); - } - if (RemindIcon3) - { - RemindIcon3->SetPosition(68, 124, 36, 36); - RemindIcon3->SetSrc("/user/res/warning.bin"); - RemindIcon3->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_MEMORY_ERROR: - { - if (TextLabel) - { - TextLabel->SetPosition(82, 124, 240, 42); - TextLabel->SetText("内存不足无法更新"); - TextLabel->SetVisible(true); - } - if (LittleTextLabel) - { - LittleTextLabel->SetText("请及时清理内存空间"); - LittleTextLabel->SetPosition(90, 184, 180, 28); - LittleTextLabel->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(80, 275, 200, 25); - RemindLabel->SetText("按 退出 按 清理"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(105, 276, 22, 22); - RemindIcon->SetSrc("/user/res/volume_down.bin"); - RemindIcon->SetVisible(true); - } - if (RemindIcon2) - { - RemindIcon2->SetPosition(211, 276, 22, 22); - RemindIcon2->SetSrc("/user/res/volume_up.bin"); - RemindIcon2->SetVisible(true); - } - if (RemindIcon3) - { - RemindIcon3->SetPosition(38, 124, 36, 36); - RemindIcon3->SetSrc("/user/res/warning.bin"); - RemindIcon3->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_UPDATING: - { - if(ThunderBirdModel::GetInstance()->GetOtaStatus() != 1)//如果不是下载状态 则返回 - { - ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED); - return; - } - //屏幕常亮 - ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); - //暂停视频播放 - ThunderBirdMainView::GetInstance()->videoPlay_->PauseVideoPlay(); - if (TextLabel) - { - TextLabel->SetPosition(90, 108, 180, 82); - TextLabel->SetText("更新中\n请勿关闭设备"); - TextLabel->SetVisible(true); - } - if (VolumeProgress) - { - VolumeProgress->SetVisible(true); - } - if(LittleTextLabel) - { - LittleTextLabel->SetPosition(56, 243, 44, 28); - LittleTextLabel->SetText((std::to_string(remindProgressValue_) + "%").c_str()); - LittleTextLabel->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(170, 246, 150, 22); - RemindLabel->SetText("更新还需5分钟"); - RemindLabel->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_UPDATE_SUCCESS: - { - if (TextLabel) - { - TextLabel->SetPosition(127, 122, 164, 42); - TextLabel->SetText("更新成功"); - TextLabel->SetVisible(true); - } - if (LittleTextLabel) - { - LittleTextLabel->SetPosition(80, 184, 220, 28); - LittleTextLabel->SetText("你的设备已是最新版本"); - LittleTextLabel->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(136, 275, 88, 25); - RemindLabel->SetText("按 确认"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(160, 277, 22, 22); - RemindIcon->SetSrc("/user/res/volume_up.bin"); - RemindIcon->SetVisible(true); - } - if (RemindIcon2) - { - RemindIcon2->SetPosition(98, 124, 36, 36); - RemindIcon2->SetSrc("/user/res/completed.bin"); - RemindIcon2->SetVisible(true); - } - break; - } - case THUNDERBIRD_OTAVIEW_UPDATE_FAILED: - { - if (TextLabel) - { - TextLabel->SetPosition(127, 122, 150, 42); - TextLabel->SetText("更新未完成"); - TextLabel->SetVisible(true); - } - if (LittleTextLabel) - { - LittleTextLabel->SetPosition(70, 184, 220, 28); - LittleTextLabel->SetText("请检查网络和电量后重试"); - LittleTextLabel->SetVisible(true); - } - if (RemindLabel) - { - RemindLabel->SetPosition(80, 275, 200, 25); - RemindLabel->SetText("按 退出 按 重试"); - RemindLabel->SetVisible(true); - } - if (RemindIcon) - { - RemindIcon->SetPosition(105, 276, 22, 22); - RemindIcon->SetSrc("/user/res/volume_down.bin"); - RemindIcon->SetVisible(true); - } - if (RemindIcon2) - { - RemindIcon2->SetPosition(211, 276, 22, 22); - RemindIcon2->SetSrc("/user/res/volume_up.bin"); - RemindIcon2->SetVisible(true); - } - if (RemindIcon3) - { - RemindIcon3->SetPosition(83, 124, 36, 36); - RemindIcon3->SetSrc("/user/res/completed.bin"); - RemindIcon3->SetVisible(true); - } - break; - } - default: - break; - } - } - - void ThunderBirdOtaView::UpdateCountdown(int value)//更新倒计时 - { - if (LittleTextLabel == nullptr) - { - return; - } - if (value < 1) { value = 1; } - if (value > 5) { value = 5; } - LittleTextLabel->SetText(std::to_string(value).c_str()); - LittleTextLabel->Invalidate(); - } - - void ThunderBirdOtaView::SetRemindProgress(int16_t value)//更新进度 - { - if (VolumeProgress == nullptr) - { - return; - } - if (value < 0) { value = 0; } - if (value > 100) { value = 100;} - VolumeProgress->SetValue(value); - VolumeProgress->Invalidate(); - } -} - - diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index d6b403189..9dbc8b3b5 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -7,7 +7,6 @@ */ #include "thunderbird/include/ThunderBirdPresenter.h" #include "thunderbird/include/ThunderBirdGuideView.h" -#include "thunderbird/include/ThunderBirdOtaView.h" #include "thunderbird/include/ThunderBirdLullabyView.h" #include "thunderbird/include/ThunderBirdDialogueView.h" #include "thunderbird/include/ThunderBirdReminderView.h" @@ -36,7 +35,6 @@ #endif namespace OHOS { - static int i=0;//版本临时变量 REGIST_SLICE(VIEW_THUNDER_BIRD, ThunderBirdMainView, ThunderBirdPresenter); @@ -410,8 +408,8 @@ namespace OHOS case THUNDERBIRD_DIALOGUEVIEW://对话界面 return HandleDialogueViewNavigation(currentSubView, keyType); - case THUNDERBIRD_OTAVIEW://OTA界面 - return HandleOtaViewNavigation(currentSubView, keyType); + // case THUNDERBIRD_OTAVIEW://OTA界面 + // return HandleOtaViewNavigation(currentSubView, keyType); case THUNDERBIRD_LULLABYVIEW://哄睡界面 return HandleLullabyViewNavigation(currentSubView, keyType); @@ -477,49 +475,49 @@ namespace OHOS */ bool ThunderBirdPresenter::HandleOtaViewNavigation(int16_t currentSubView, KeyType keyType) { - if(keyType == KEY_TYPE_VENDOR_UP)//VENDOR_UP键 - { - switch (currentSubView) { - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW: - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL: - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS: - // 确认升级,检查条件 - return CheckOtaConditionsAndProceed(); + // if(keyType == KEY_TYPE_VENDOR_UP)//VENDOR_UP键 + // { + // switch (currentSubView) { + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW: + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL: + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS: + // // 确认升级,检查条件 + // return CheckOtaConditionsAndProceed(); - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN: - // 进入更新中,手动确认,不等待 - ThunderBirdModel::GetInstance()->StopOtaCountdown();//取消倒计时界面整个定时器 - ThunderBirdModel::GetInstance()->StartOtaCountdown(0);//直接进入更新中,定时器会自己跳转与执行指令 - break; - - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE: - ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING); - break; + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN: + // // 进入更新中,手动确认,不等待 + // ThunderBirdModel::GetInstance()->StopOtaCountdown();//取消倒计时界面整个定时器 + // ThunderBirdModel::GetInstance()->StartOtaCountdown(0);//直接进入更新中,定时器会自己跳转与执行指令 + // break; + + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE: + // ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING); + // break; - // VENDOR_DOWN键的特殊处理 + // // VENDOR_DOWN键的特殊处理 - } - return true; - } - else if(keyType == KEY_TYPE_VENDOR_DOWN)//VENDOR_DOWN键 - { - switch (currentSubView) { - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW: - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL: - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS: - ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE); - break; + // } + // return true; + // } + // else if(keyType == KEY_TYPE_VENDOR_DOWN)//VENDOR_DOWN键 + // { + // switch (currentSubView) { + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_NOW: + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NORMAL: + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_OBVIOUS: + // ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE); + // break; - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE: - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED: - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_LOW_BATTERY: - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NETWORK_ERROR: - case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_MEMORY_ERROR: - ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING); - break; - } - return true; - } + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NIGHT_UPDATE: + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_UPDATE_FAILED: + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_LOW_BATTERY: + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NETWORK_ERROR: + // case ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_MEMORY_ERROR: + // ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING); + // break; + // } + // return true; + // } return true; } @@ -528,20 +526,20 @@ namespace OHOS */ bool ThunderBirdPresenter::CheckOtaConditionsAndProceed() { - if (ThunderBirdMainView::GetInstance()->Batteryvalue <= 50) { - // 低电量 - ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_LOW_BATTERY); - } else if (uapi_dev_runtime_get_cat1_signal() == 99) { - // 无网络 - ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NETWORK_ERROR); - } else if (0) { // 获取内存状态 - // 内存不足 - ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_MEMORY_ERROR); - } else { - // 条件满足,开始倒计时 - ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN); + // if (ThunderBirdMainView::GetInstance()->Batteryvalue <= 50) { + // // 低电量 + // ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_LOW_BATTERY); + // } else if (uapi_dev_runtime_get_cat1_signal() == 99) { + // // 无网络 + // ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_NETWORK_ERROR); + // } else if (0) { // 获取内存状态 + // // 内存不足 + // ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_MEMORY_ERROR); + // } else { + // // 条件满足,开始倒计时 + // ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_OTAVIEW, THUNDERBIRD_OTAVIEW, ThunderBirdOtaView::THUNDERBIRD_OTAVIEW_COUNTDOWN); - } + // } return true; } diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp index 8496ed389..0dd70dfb9 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/uiservice/src/ui_service.cpp @@ -41,6 +41,7 @@ #include "TransitionType.h" #include "thunderbird/include/ThunderBirdModel.h" +#include "ota/include/OtaModel.h" extern "C" errcode_t uapi_pm_add_sleep_veto(pm_id_t veto_id); extern "C" errcode_t uapi_pm_remove_sleep_veto(pm_id_t veto_id); @@ -282,11 +283,18 @@ void SendMsgToUIService(int32_t msgId, uint32_t msgValue, void *data, int32_t da /* -------------------------------------------------------------------------- */ void HandleJumpOtaView(Request *request) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_UI_SERVICE, "HandleJumpOtaView msg_id = %d",request->msgId); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandleJumpOtaView msg_id = %d",request->msgId); // OHOS::ThunderBirdModel::GetInstance()->UpdateOtaStatus(status); int status = *(int *)request->data; + if(status == 1 || status == 2) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandleJumpOtaView status = %d",status); GraphicService::GetInstance()->PostGraphicEvent( std::bind(&OHOS::ThunderBirdModel::UpdateOtaStatus,OHOS::ThunderBirdModel::GetInstance(), status)); + } else if(status == 3 || status == 4) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_UI_SERVICE, "HandleJumpOtaView status = %d",status); + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(&OHOS::OtaModel::CheckOtaResult,OHOS::OtaModel::GetInstance(),status)); + } } /* -------------------------------------------------------------------------- */ #ifdef __cplusplus diff --git a/code/sdk/zhihui/leiniao/imsl_ln/leiniao_api_at.c b/code/sdk/zhihui/leiniao/imsl_ln/leiniao_api_at.c index ea58f1794..3c73c4962 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/leiniao_api_at.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/leiniao_api_at.c @@ -639,6 +639,7 @@ static uint32_t ln_ota_get_task_at(uint8_t *para, uint32_t paraLen, char *strCom VAD_UNUSED(strCommonCmd); printf("[LN][OTA_GET_TASK]\n"); do_ln_http_server_send_data(LN_HTTP_SERVICE_CMD_OTA_GET_TASK, NULL, 0); + return ERRCODE_SUCC; } @@ -935,6 +936,115 @@ static uint32_t ln_factory_at(uint8_t *para, uint32_t paraLen, char *strCommonCm printf("[LN][FACTORY] ok\n"); return ERRCODE_SUCC; } + +/** + * @brief 推送OTA升级状态AT命令 + * @param para 参数字符串 + * @param paraLen 参数长度 + * @param strCommonCmd 命令字符串 + * @return 错误码 + * + * 用法: AT^LN_UI_OTA_STATUS=0 (设置OTA状态为0) + * AT^LN_UI_OTA_STATUS=1 (设置OTA状态为1) + * AT^LN_UI_OTA_STATUS=2 (设置OTA状态为2) + * AT^LN_UI_OTA_STATUS=3 (设置OTA状态为3) + * AT^LN_UI_OTA_STATUS=4 (设置OTA状态为4) + * AT^LN_UI_OTA_STATUS? (查询当前OTA状态) + */ +static uint32_t ln_ui_ota_status_at(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + VAD_UNUSED(strCommonCmd); + + uint8_t argv[LN_MAX_ARGC][LN_MAX_ARGV_LEN] = {0}; + uint32_t argc = 0; + + // 解析参数 + if (ConvertCmdToParam(para, paraLen, argv, &argc) != VAD_SUCCESS) { + printf("ERROR: Failed to parse parameters\n"); + return ERRCODE_FAIL; + } + + // 查询模式(无参数或参数为"?") + if (argc == 0 || (argc == 1 && strcmp((char*)argv[0], "?") == 0)) { + // 这里可以添加获取当前OTA状态的逻辑 + printf("+LN_UI_OTA_STATUS: \n"); + return ERRCODE_SUCC; + } + + if (argc < 1) { + printf("ERROR: Missing parameter\n"); + printf("Usage: AT^LN_UI_OTA_STATUS=0/1/2/3/4 or AT^LN_UI_OTA_STATUS?\n"); + return ERRCODE_FAIL; + } + + // 设置模式 + int status = atoi((char*)argv[0]); + if (status < 0 || status > 4) { + printf("ERROR: Invalid status value. Must be 0, 1, 2, 3, or 4\n"); + printf("Usage: AT^LN_UI_OTA_STATUS=0/1/2/3/4\n"); + return ERRCODE_FAIL; + } + + printf("[LN][UI_OTA_STATUS] Setting status to: %d\n", status); + push_ota_status(status); + printf("+LN_UI_OTA_STATUS: %d\n", status); + + return ERRCODE_SUCC; +} + +/** + * @brief 推送OTA升级进度AT命令 + * @param para 参数字符串 + * @param paraLen 参数长度 + * @param strCommonCmd 命令字符串 + * @return 错误码 + * + * 用法: AT^LN_UI_OTA_PROGRESS=0 (设置OTA进度为0%) + * AT^LN_UI_OTA_PROGRESS=50 (设置OTA进度为50%) + * AT^LN_UI_OTA_PROGRESS=100 (设置OTA进度为100%) + * AT^LN_UI_OTA_PROGRESS? (查询当前OTA进度) + */ +static uint32_t ln_ui_ota_progress_at(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + VAD_UNUSED(strCommonCmd); + + uint8_t argv[LN_MAX_ARGC][LN_MAX_ARGV_LEN] = {0}; + uint32_t argc = 0; + + // 解析参数 + if (ConvertCmdToParam(para, paraLen, argv, &argc) != VAD_SUCCESS) { + printf("ERROR: Failed to parse parameters\n"); + return ERRCODE_FAIL; + } + + // 查询模式(无参数或参数为"?") + if (argc == 0 || (argc == 1 && strcmp((char*)argv[0], "?") == 0)) { + // 这里可以添加获取当前OTA进度的逻辑 + printf("+LN_UI_OTA_PROGRESS: \n"); + return ERRCODE_SUCC; + } + + if (argc < 1) { + printf("ERROR: Missing parameter\n"); + printf("Usage: AT^LN_UI_OTA_PROGRESS=0-100 or AT^LN_UI_OTA_PROGRESS?\n"); + return ERRCODE_FAIL; + } + + // 设置模式 + int progress = atoi((char*)argv[0]); + if (progress < 0 || progress > 100) { + printf("ERROR: Invalid progress value. Must be 0-100\n"); + printf("Usage: AT^LN_UI_OTA_PROGRESS=0-100\n"); + return ERRCODE_FAIL; + } + + printf("[LN][UI_OTA_PROGRESS] Setting progress to: %d%%\n", progress); + push_ota_progress(progress); + printf("+LN_UI_OTA_PROGRESS: %d\n", progress); + + return ERRCODE_SUCC; +} + static const at_cmd_table_t g_ln_api_cmd[] = { /* ----------------------------------- VAD ---------------------------------- */ {(char *)"AT^VAD_INIT", vad_init, (char *)"初始化 VAD"}, @@ -982,6 +1092,9 @@ static const at_cmd_table_t g_ln_api_cmd[] = { //恢复出厂设置 {(char *)"AT^LN_FACTORY", ln_factory_at, (char *)"恢复出厂设置: AT^LN_FACTORY"}, + /* UI相关at */ + {(char *)"AT^LN_UI_OTA_STATUS", ln_ui_ota_status_at, (char *)"推送OTA升级状态: AT^LN_UI_OTA_STATUS=0、1、2、3、4"}, + {(char *)"AT^LN_UI_OTA_PROGRESS", ln_ui_ota_progress_at, (char *)"推送OTA升级进度: AT^LN_UI_OTA_PROGRESS=100"}, }; diff --git a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c index 92d25ffc1..fcce80a25 100644 --- a/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c +++ b/code/sdk/zhihui/leiniao/imsl_ln/ln_api.c @@ -62,6 +62,7 @@ char *uapi_ln_get_device_model(void) /* 获取设备固件版本version */ char *uapi_ln_get_device_version(void) { + return "V1.0.0_20250920"; char version_buf[128] = {0}; uint32_t version_len = sizeof(version_buf) - 1; // 预留1字节给字符串结束符 uapi_get_buildversion((uint8_t *)version_buf, version_len); diff --git a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp index 575e40c8a..f0d126f53 100644 --- a/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp +++ b/code/sdk/zhihui/leiniao/ln_api_cpp/ln_api_interface.cpp @@ -1,5 +1,7 @@ #include "ln_api_interface.h" #include "thunderbird/include/ThunderBirdModel.h" +#include "ota/include/OtaModel.h" +//#include "ota/include/OtaUpdatingView.h" #include "uiservice/ui_service.h" #ifdef __cplusplus @@ -48,7 +50,9 @@ void push_ota_status(int status) // 获取OTA升级进度 void push_ota_progress(int progress) { - OHOS::ThunderBirdModel::GetInstance()->UpdateOtaProgress(progress); + if (OHOS::OtaModel::GetInstance()) { + OHOS::OtaModel::GetInstance()-> UpdateOtaProgress(progress); + } } // 恢复出厂设置 -- 2.17.1