From: Caisking Date: Mon, 28 Apr 2025 09:31:29 +0000 (+0800) Subject: 【系统】UI X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~338 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=e1b3ac6dbb5be45dc1985a874a9062085cfd381b;p=mirrors%2FFD230.git 【系统】UI --- diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemAboutTheWatchView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemAboutTheWatchView.h new file mode 100644 index 000000000..1f943bdb5 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemAboutTheWatchView.h @@ -0,0 +1,74 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-30 09:14:38 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-10-10 14:48:08 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemAboutTheWatchView.h + */ +#ifndef SYSTEM_ABOUT_VIEW_H +#define SYSTEM_ABOUT_VIEW_H + + +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include +namespace OHOS +{ + static constexpr const char *SYSTEMABOUTTHEWATCHVIEWID = "SystemAboutTheWatchView"; // 关于手表 + class SystemAboutTheWatchView + { + + public: + SystemAboutTheWatchView(); + virtual ~SystemAboutTheWatchView(); + static SystemAboutTheWatchView *GetInstance(void); + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + std::string text; // 文本 + uint16_t textId; + uint8_t lineBreakMode; // 断行模式。 + }; + UIScrollView *SystemAbouTheWatchtInitIView(void); + void ClearAll(void); + UILabelExt *InitLabel_Ext(LabelConfig &labelConfig); + UILabel *InitLabel(LabelConfig &labelConfig); + + private: + bool SetSystemAboutTheWatchScrollView(void); + UIScrollView *SystemAboutTheWatchScrollView{nullptr}; + UILabelExt *SystemAboutTheWatchTitle{nullptr}; // "关于" + UILabelExt *WatchNameTitle{nullptr}; // "手表名称Title" + UILabel *WatchName{nullptr}; // "手表名称" + UILabelExt *FirmwareVersionTitle{nullptr}; // "固件版本Title" + UILabel *FirmwareVersion{nullptr}; // "固件版本" + UILabelExt *BluetoothNameTitle{nullptr}; // "蓝牙名称Title" + UILabel *BluetoothName{nullptr}; // "蓝牙名称" + UILabelExt *BluetoothAddressTitle{nullptr}; // "蓝牙地址Title" + UILabel *BluetoothAddress{nullptr}; // "蓝牙地址" + UILabel *Network4GTitle{nullptr}; // "4G ModemTitle" + UILabel *Network4G{nullptr}; // "4G Modem" + UILabel *PyVerTitle{nullptr}; // "pyVerTitle" + UILabel *PyVer{nullptr}; // "pyVer" + UILabel *IMELTitle{nullptr}; // "IMELTitle" + UILabel *IMEL{nullptr}; // "IMELTitle" + UILabel *FONTTitle = nullptr; + UILabel *FONT = nullptr; + UILabel *HWVERTitle = nullptr; + UILabel *HWVER = nullptr; + UILabel *CyweeVersionTitle = nullptr; + UILabel *CyweeVersion = nullptr; + UILabel *APNprotocolTitle = nullptr; //APN协议 + UILabel * APNprotocol = nullptr; + bool initViewStatus{false}; + }; +} +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemFactoryResetView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemFactoryResetView.h new file mode 100644 index 000000000..071d2710b --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemFactoryResetView.h @@ -0,0 +1,42 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-01-29 15:37:44 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-10-26 11:47:49 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemFactoryResetView.h + */ +#ifndef SYSTEM_FACTORYRESET_VIEW_H +#define SYSTEM_FACTORYRESET_VIEW_H + + +#include "View.h" + +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label_ext.h" +namespace OHOS +{ + class SystemFactoryResetView + { + + public: + SystemFactoryResetView(); + virtual ~SystemFactoryResetView(); + static SystemFactoryResetView *GetInstance(void); + + UIScrollView *SystemFactoryResetViewInit(void); + void ClearAll(void); + + private: + UIScrollView *scrollView{nullptr}; + UILabelExt *Title{nullptr}; + UIImageView *FactoryResetImage{nullptr}; + UILabelExt *FactoryResetNote{nullptr}; + UIButton *FactoryResetButtonCheckOn{nullptr}; // 重置确认 + UIButton *FactoryResetButtonCheckOff{nullptr}; // 重置否定 + UIImageView *temp{nullptr}; + bool initViewStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemLogModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemLogModel.h new file mode 100644 index 000000000..0368b7faa --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemLogModel.h @@ -0,0 +1,132 @@ +#ifndef SYSTEM_LOG_MODEL_H +#define SYSTEM_LOG_MODEL_H + +#include +#include +#include +#include +#include + +#define TOTAL_MUSIC_SPACE (53 * 1024 * 1024) // 53M +#define TOTAL_MUSIC_SPACE_PATH "/user/music/user_music" + +#define TOTAL_RECORDING_SPACE (10 * 1024 * 1024) // 10M +#define TOTAL_RECORDING_SPACE_PATH "/user/music/recording" + +#define TOTAL_RING_SPACE (2 * 1024 * 1024) // 2M +#define TOTAL_RING_SPACE_PATH "/user/music/ring" + +#define TOTAL_DIAL_SPACE (5 * 1024 * 1024) // 5M +#define TOTAL_DIAL_SPACE_PATH "/user/dial/offline_dial" + +#define TOTAL_RES_DIAL_SPACE (5 * 1024 * 1024) // 5M +#define TOTAL_RES_DIAL_SPACE_PATH "/user/dial/res_dial" + +#define TOTAL_CUSTOM_DAIL_SPACE (1 * 1024 * 1024) // 1M +#define TOTAL_CUSTOM_DAIL_SPACE_PATH "/user/dial/custom_dial" + +#define TOTAL_SYSTEM_SPACE (5 * 1024 * 1024) // 5M +#define TOTAL_SYSTEM_SPACE_PATH "/user/system" + +#define TOTAL_RES_SPACE (40 * 1024 * 1024) // 40M +#define TOTAL_RES_SPACE_PATH "/user/user/res" + +#define TOTAL_USERDATA_SPACE (5 * 1024 * 1024) // 5M +#define TOTAL_USERDATA_SPACE_PATH "/user/user/userdata" + +#define TOTAL_UPDATE_SPACE (15 * 1024 * 1024) // 15M +#define TOTAL_UPDATE_SPACE_PATH "/user/update" + +#define TOTAL_SPACE_SIZE (TOTAL_MUSIC_SPACE + TOTAL_RECORDING_SPACE + TOTAL_RING_SPACE + TOTAL_DIAL_SPACE + TOTAL_RES_DIAL_SPACE + TOTAL_CUSTOM_DAIL_SPACE + TOTAL_SYSTEM_SPACE + TOTAL_RES_SPACE + TOTAL_USERDATA_SPACE + TOTAL_UPDATE_SPACE) // 总空间大小 + +#define TOTAL_SYSTEM_SIZE (128 * 1024 * 1024) // 系统空间大小 + +namespace OHOS { + +enum class SystemLogType { + POWER_ON = 0, // 开机 + POWER_OFF, // 关机 + RESTART, // 重启 + FACTORY_RESET, // 恢复出厂设置 + SOFTWARE_UPDATE, // 更新 +}; + +struct SystemLogData { + SystemLogType type; // 日志类型 + uint32_t timestamp; // 时间戳 +}; + +enum class nextday_type { + NEXTDAY_BEGAN = 0, + NEXTDAY_END, +}; + +struct nextday_log_data { + nextday_type type; + uint32_t timestamp; +}; + +enum class popup_windows_type // 弹窗类型 +{ + MOTION_RECOGNITION = 0, // 运动识别 + DRINK_WATER_REMINDER, // 喝水提醒 + SEDENTARY_REMINDER, // 久坐提醒 +}; + +struct popup_windows_log_data { + popup_windows_type type; // 弹窗类型 + uint32_t timestamp; // 时间戳 +}; +class SystemLogModel { +public: + // 获取单例实例 + static SystemLogModel *GetInstance(void); + + /* ---------------------------------- 系统日志 ---------------------------------- */ + bool saveLog(SystemLogData data); // 保存日志 + bool loadLog(); // 加载日志 + const std::deque &getLogData() const; // 获取日志记录(常量引用) + size_t getLogSize() const; // 获取日志数量 + uint32_t GetCurrentTime(); // 获取当前时间 + /* ---------------------------------- 系统内存 ---------------------------------- */ + std::string get_system_mem_info(); // 获取系统内存信息 + long long getFolderSize(const char* folderPath); + bool canSyncFile(std::string path,uint32_t path_max_size,uint32_t download_size); // 获取文件占用空间大小 + long long getResRealSize(void) + { + return getFolderSize(TOTAL_RES_SPACE_PATH); + } + /* ------------------------------- nextday日志记录 ------------------------------ */ + bool save_nextday_log(nextday_log_data data); // 保存nextday日志 + bool load_nextday_log(); // 加载nextday日志 + const std::deque &get_nextday_log() const; // 获取nextday日志记录(常量引用) + size_t get_nextday_log_size() const;//获取日志大小 + /* ------------------------------ popup_windows 日志记录----------------------------- */ + bool save_popup_windows_log(popup_windows_log_data data); // 保存popup_windows日志 + void save_popup_windows_log_type(int type); // 保存popup_windows日志 + bool load_popup_windows_log(); // 加载popup_windows日志 + const std::deque &get_popup_windows_log() const; // 获取popup_windows日志记录(常量引用) + size_t get_popup_windows_log_size() const; // 获取日志大小 + void clear_popup_windows_log(); // 清空popup_windows日志记录 + /* ---------------------------------- 串口控制 ---------------------------------- */ + void init_uart(); + void set_uart_status(bool status); + bool get_uart_status(); + +private: + SystemLogModel() = default; // 私有构造函数 + ~SystemLogModel() = default; // 默认析构函数 + + // 禁止拷贝和赋值 + SystemLogModel(const SystemLogModel &) = delete; + SystemLogModel &operator=(const SystemLogModel &) = delete; + + std::deque logData; // 存储日志数据 + std::deque nextday_log; // 存储nextday时间戳 + std::deque popup_windows_log; // 存储popup_windows时间戳 + + bool uart_status{false}; +}; +} // namespace OHOS + +#endif // SYSTEM_LOG_MODEL_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemLogModelC.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemLogModelC.h new file mode 100644 index 000000000..cbcbc4bb2 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemLogModelC.h @@ -0,0 +1,26 @@ +#ifndef SYSTEMLOGC_H +#define SYSTEMLOGC_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif +#endif + +void start_report_log(void); +void stop_report_log(void); +void resume_report_log(void); +void update_version_report_log(void); +void start_report_nextday_log_start(void); +void start_report_nextday_log_end(void); +void nextday_clear_popup_windows_log(void); +void save_popup_windows_log_c(int type); +void system_init_uart(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemModel.h new file mode 100644 index 000000000..0ef20beb4 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemModel.h @@ -0,0 +1,22 @@ + +#ifndef SYSTEM_MODEL_H +#define SYSTEM_MODEL_H + +namespace OHOS +{ + int start_report_timer(void); + class SystemModel + { + public: + static SystemModel *GetInstance(void); + + private: + SystemModel() = default; + ~SystemModel(){} + SystemModel(const SystemModel &) = delete; + SystemModel &operator=(const SystemModel &) = delete; + + }; +} + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemPresenter.h new file mode 100644 index 000000000..e628ae34c --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemPresenter.h @@ -0,0 +1,59 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-30 18:29:43 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-28 19:55:18 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h + */ + +#ifndef SYSTEM_PRESENTER_H +#define SYSTEM_PRESENTER_H + +#include "Presenter.h" +#include "SystemView.h" +#include "system/include/SystemModel.h" +#include "components/ui_radio_button.h" +#include "KeyInputListener.h" + #include "cat1_ctl.h" + +namespace OHOS +{ + + /* ---------------------------- 恢复出厂设置界面按钮的VIEWID --------------------------- */ + static const char *FACTORYRESET_CHECKON = "factoryresetButtonCheckOn"; // 确认 + static const char *FACTORYRESET_CHECKOFF = "factoryresetButtonCheckOff"; // 取消 + + class SystemView; + class SystemPresenter : public Presenter, + public UIView::OnClickListener, + public RootView::OnKeyActListener, + public UIView::OnDragListener, + public UIView::OnTouchListener + { + public: + SystemPresenter(); + virtual ~SystemPresenter(); + + void OnStart() override; + void OnPause() override; + void OnResume() override; + void OnStop() override; + + static SystemPresenter *GetInstance(); + + private: + // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承; + bool OnClick(UIView &view, const ClickEvent &event) override; + bool OnDrag(UIView &view, const DragEvent &event) override; + bool OnDragEnd(UIView &view, const DragEvent &event) override; + bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件 + bool OnPress(UIView &view, const PressEvent &event) override; + + private: + SystemModel *systemModel; + bool X_DRAG_FLAG{false}; + bool isShutDownImageAnimatorStart{false}; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemPresenterC.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemPresenterC.h new file mode 100644 index 000000000..d48a446f0 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemPresenterC.h @@ -0,0 +1,27 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-06-07 11:18:25 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-07-02 11:07:00 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenterC.h + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + */ +#ifndef SYSTEM_PRESENTER_H +#define SYSTEM_PRESENTER_H + +#ifdef __cplusplus +#if __cplusplus +extern "C" +{ +#endif +#endif + void factorytest_enter_test_view(int cmd); + +#ifdef __cplusplus +#if __cplusplus +} +#endif +#endif +#endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemRestart.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemRestart.h new file mode 100644 index 000000000..2b66ade4d --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemRestart.h @@ -0,0 +1,37 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-08-28 17:29:39 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-28 19:09:57 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemRestart.h + */ +#ifndef _RESTARTVIEW_VIEW_H_ +#define _RESTARTVIEW_VIEW_H_ + +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +#include "components/ui_scroll_view.h" +namespace OHOS +{ + static const char *RESTARTVIEW_CHECKON = "RestartButtonCheckOn"; // 确认 + static const char *RESTARTVIEW_CHECKOFF = "RestartButtonCheckOff"; // 取消 + class SystemRestart + { + public: + SystemRestart(); + ~SystemRestart(); + UIScrollView *SystemRestartViewInit(void); + + private: + void ClearAll(void); + UIScrollView *SystemRestartScrollView = nullptr; + UILabelExt *title{nullptr}; + UILabelExt *note{nullptr}; + UIImageView *image = nullptr; + UIButton *button_ensure = nullptr; + UIButton *button_cancel = nullptr; + }; + +} +#endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemShutdown.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemShutdown.h new file mode 100644 index 000000000..45fb2dc40 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemShutdown.h @@ -0,0 +1,37 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-08-28 17:29:39 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-28 18:08:10 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemShutdown.h + */ +#ifndef _SHUTDOWN_VIEW_H_ +#define _SHUTDOWN_VIEW_H_ + +#include "components/ui_label_ext.h" +#include "components/ui_button.h" +#include "components/ui_image_view.h" +#include "components/ui_scroll_view.h" +namespace OHOS +{ + static const char *SHUTDOWN_CHECKON = "ShoutDownButtonCheckOn"; // 确认 + static const char *SHUTDOWN_CHECKOFF = "ShoutDownButtonCheckOff"; // 取消 + class SystemShutdown + { + public: + SystemShutdown(); + ~SystemShutdown(); + UIScrollView *SystemShutdownViewInit(void); + + private: + void ClearAll(void); + UIScrollView *SystemShutdownScrollView = nullptr; + UILabelExt *title{nullptr}; + UILabelExt *note{nullptr}; + UIImageView *image = nullptr; + UIButton *button_ensure = nullptr; + UIButton *button_cancel = nullptr; + }; + +} +#endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemSuperviseView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemSuperviseView.h new file mode 100644 index 000000000..30e6b703d --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemSuperviseView.h @@ -0,0 +1,32 @@ +#ifndef SYSTEM_SUPERVISE_VIEW_H +#define SYSTEM_SUPERVISE_VIEW_H + + +#include "View.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +namespace OHOS +{ + + class SystemSuperviseView + { + public: + SystemSuperviseView(); + virtual ~SystemSuperviseView(); + static SystemSuperviseView *GetInstance(void); + UILabel *InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize, int fontlineHeigh, uint16_t speed); + UIScrollView *SystemSuperviseViewInit(void); + void ClearAll(void); + + private: + UIScrollView *SystemSuperviseViewScrollView = nullptr; + UILabel *Title = nullptr; + UILabel *ProductModel = nullptr; + UILabel *ProductModelName = nullptr; + UILabel *CMIT = nullptr; + UILabel *CMITName = nullptr; + bool initViewStatus{false}; + }; +} // namespace OHOS +#endif // SLEEPDETAIL_PRESENTER_H \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemView.h new file mode 100644 index 000000000..93a73cae8 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/SystemView.h @@ -0,0 +1,123 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-03-30 18:29:39 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-11-14 18:32:02 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h + */ +#ifndef SYSTEM_VIEW_H +#define SYSTEM_VIEW_H + + +#include "View.h" + +#include "components/ui_view_group.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label_ext.h" +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_label_button_ext.h" +#include "system/include/SystemAboutTheWatchView.h" +// #include "system/include/SystemSuperviseView.h" +#include "system/include/SystemFactoryResetView.h" +// #include "system/include/Systemupgrade.h" +#include "components/ui_toggle_button.h" +#include "system/include/SystemShutdown.h" +#include "system/include/SystemRestart.h" +#include "rebootandshutdown/include/ShutDownImageAnimatorView.h" +namespace OHOS +{ + static constexpr const char *ABOUT_THE_WATCH = "AboutTheWatchButton"; // 关于手表 + static constexpr const char *SYSTEM_UPGRADE = "SystemUpgradeButtonExt"; // 系统升级 + static constexpr const char *SYSTEM_UPGRADE_t = "SystemUpgradeButtonExt_t"; // 点击系统升级 + static constexpr const char *WATCH_QR_CODE = "WatchqrcodeButton"; // 手表二维码 + static constexpr const char *SYSTEM_LANGUAGE = "SystemLanguageButton"; // 系统语言 + static constexpr const char *RESTART = "RestartButton"; // 重启 + static constexpr const char *SHUTDOWN = "ShutdownButton"; // 关机 + static constexpr const char *FACTORY_RESET = "FactoryResetButton"; // 恢复出厂设置 + static constexpr const char *SET_TIME_FORMAT = "SetTimeFormatButton"; // 设置时间格式 + + typedef enum + { + SYSTEMVIEW = 0, // 系统视图(slice) + ABOUTTHEWATCHVIEW, // 关于手表视图(subView) + RESTARTVIEW, // 重启视图(subView) + SHUTDOWNVIEW, // 关机视图(subView) + FACTORYRESETVIEW, // 恢复出厂设置视图(subView) + SHUTDOWNANIMATIONVIEW, // 关机动画(subView) + MAX_SYSTEMVIEWID, + } SYSTEMVIEWID; + + class SystemPresenter; + class SystemView : public View + { + + public: + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; + int16_t lineHeigh; + uint16_t textId; + uint8_t lineBreakMode; + }; + + SystemView(); + ~SystemView(); + static SystemView *GetInstance(void); + + void OnStart() override; + + + struct ButtonConfig + { + int16_t x; + int16_t y; + int16_t w; + int16_t h; + const char *viewId; + }; + + bool ChangeToSystemView(int16_t thisView); + bool ChangeToSystemAboutView(int16_t thisView); + bool ChangeToSystemFactoryResetView(int16_t thisView); + bool ChangeToSystemRestartView(int16_t thisView); + bool ChangeToSystemShutdownView(int16_t thisView); + bool ChangeToSystemShutdownAnimatorView(int16_t thisView); + bool ClickFunc(int16_t interface); + bool CheckViewParam(int16_t hideView, int16_t showView); + void ChangeView(int16_t hideView, int16_t showView); + UIScrollView *GetSystemScrollView(int ViewId); + + private: + SystemAboutTheWatchView *p_SystemAboutTheWatchView{nullptr}; // 关于手表 + SystemFactoryResetView *p_SystemFactoryResetView{nullptr}; // 恢复出厂设置 + SystemRestart *p_SystemRestart{nullptr}; // 重启 + SystemShutdown *p_SystemShutdown{nullptr}; // 关机 + ShutDownImageAnimatorView *p_ShutDownImageAnimatorView{nullptr}; // 关机动画 + + private: + UILabelButtonExt *SystemViewLabelButtonInit(ButtonConfig &buttonconfig); + UILabelExt *SystemViewLabelInit(LabelConfig &labelconfig); + bool CreateSystemViewLabel(void); + bool CreateSystemViewLabelButton(void); + bool CreateSystemScrollView(void); + void CreateSystemView(void); + void ClearAll(void); + void NeedToUpdateImageinit(void); + UILabelExt *Title{nullptr}; // 标题 + UIScrollView *SystemScrollView[MAX_SYSTEMVIEWID]{nullptr}; + UILabelButtonExt *SystemViewLabelButton[10]{nullptr}; + UILabelExt *SystemViewLabel[10]{nullptr}; + int SystemViewLabelNum{0}; + int SystemViewButtonNum{0}; + UIImageView *NeedToUpdateImage{nullptr}; // 提示需要系统更新的icon图片 + UIImageView *temp{nullptr}; + bool viewInitStatus{false}; + }; +} // namespace OHOS + +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/Systemupgrade.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/Systemupgrade.h new file mode 100644 index 000000000..b476a30d6 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/include/Systemupgrade.h @@ -0,0 +1,135 @@ +#ifndef SYSTEM_UPGRADE_VIEW_H +#define SYSTEM_UPGRADE_VIEW_H + + +#include "View.h" + +#include "components/ui_image_view.h" +#include "components/ui_button.h" +#include "components/ui_scroll_view.h" +#include "components/ui_label.h" +#include "components/ui_label_ext.h" +#include "components/ui_label_button_ext.h" +#include "cat1_ctl.h" +#include "upg_common_porting.h" + +#if USE_THISIOT +#define HTTP_JSON_SERVER_NAME "test.iot.api.thisiot.com"//"test.app.api.thisiot.com"//获取升级服务器 +#define HTTP_FWPGK_SERVER_NAME "r-oss.thisiot.com"//"//升级包服务器 +#define PORT (80)//(443)//http端口号 +#define POST_URL "http://test.iot.api.thisiot.com/ota/update-result"//上报url +#define JSON_URL "http://test.iot.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s"//获取升级url +#else + +/** + * http://icfota.snicker.com.cn:8089/fd230ota.jsp?product=FD230&pkgver=V1.1_20240316_115535&imei=864430010001091 +查看 返回的"UptoDate" == False,即可根据"url"地址下载,文件校验可以后面再加。 +{ "UptoDate": false , + + "OtaPackageVersion" : "V1.1_20240316_130929", +"SystemVersion" : "V1.1_20240316_115535", +"description" : " update to checkota version 3 ", + "md5sum" : "f51486072dc3d81f30610d6d5a58d717", +"AutoUpdate" : true } +*/ +#define HTTP_JSON_SERVER_NAME "snicker.com.cn"//"test.app.api.thisiot.com"//获取升级服务器 +#define HTTP_FWPGK_SERVER_NAME "snicker.com.cn"//"//升级包服务器 +#define PORT (8089)//(443)//http端口号 +#define POST_URL "http://snicker.com.cn:8089"//上报url +#define JSON_URL "http://snicker.com.cn:8089/fd230otanew.jsp?product=FD230&imei=%s&pkgver=%s"//获取升级url +#endif + +#ifdef SINGLE_USER_PARTITION + +#define UPDATAJSONPATH "/user/update/ota_start_.json"//获取升级的得到的json +#define UPDATAREPORT "/user/update/ota_start_reported_.json"//点升级后保存下来的json +#define UPDATAFWPKGPATH UPG_FILE_NAME //升级包 +#define UPDATAREPORT_ "/user/update/ota_report_.json"//上报升级得到的json + +#else + +#define UPDATAJSONPATH "/update/ota_start_.json"//获取升级的得到的json +#define UPDATAREPORT "/update/ota_start_reported_.json"//点升级后保存下来的json +#define UPDATAFWPKGPATH UPG_FILE_NAME //升级包 +#define UPDATAREPORT_ "/update/ota_report_.json"//上报升级得到的json + +#endif + +namespace OHOS +{ + // typedef enum { + // IOT_CODE_0, + // IOT_CODE_IS_NEW=20006,//已是最新版本 + // IOT_CODE_SUCCESS=20007,//有新版本,唯一成功id,不是这个都表示没有升级版本data为NULL + // IOT_CODE_FAIL_1=50000,//设备源版本不能为空 + // IOT_CODE_FAIL_2=50012,//设备未注册 + // } iot_code; + + + class SystemupgradeView + { + + public: + SystemupgradeView(); + virtual ~SystemupgradeView(); + static SystemupgradeView *GetInstance(void); + + UIScrollView *SystemupgradeViewInit(void); + void ClearAll(void); + void set_string_value(char *str,bool); + void cat1_up_success(void); + struct LabelConfig + { + int16_t left; + int16_t top; + int16_t width; + int16_t height; + int16_t fontSize; // 字体大小 + int16_t lineHeigh; // 行高 + char *text; // 文本 + uint8_t lineBreakMode; // 断行模式。 + }; + UILabel *InitLabel(LabelConfig &labelConfig); + + UILabel *newVersionTitle{nullptr}; // "最新软件版本" + UILabel *newVersion{nullptr}; + + void detection_update(void); + + void statr_down_fwpkg(void); + + void statr_upgrade(void); + + UILabel *FirmwareVersionTitle{nullptr}; // "固件版本" + UILabel *FirmwareVersion{nullptr}; + UILabel *new_label{nullptr}; + + UILabel *cat1Version{nullptr}; + UILabel *cat1label{nullptr}; + + void init_fail(uint8_t); + private: + UIScrollView *scrollView{nullptr}; + //UIImageView *FactoryResetImage{nullptr}; // 恢复出厂设置背景图片 + //UIButton *FactoryResetButtonCheckOn{nullptr}; // 重置确认 + // UIButton *FactoryResetButtonCheckOff{nullptr}; // 重置否定 + UILabelButtonExt * SystemUpgradeButton_; + UILabel *systemupgrade{nullptr}; // "固件版本" + UILabel *label_updating{nullptr}; + UILabel *label1_fail{nullptr}; + + UIViewGroup *container_updating{nullptr}; + UIViewGroup *container_fail{nullptr}; + UILabelButtonExt *labelButton1_exit=NULL; + void init_updating(); + + bool is_new_version=false; + bool is_new_cat1_version=false; + + bool is_fwpkg_ready=false; + + + bool initViewStatus{false}; + }; +} // namespace OHOS +#endif \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemAboutTheWatchView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemAboutTheWatchView.cpp new file mode 100644 index 000000000..a90eb168f --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemAboutTheWatchView.cpp @@ -0,0 +1,682 @@ +#include "system/include/SystemAboutTheWatchView.h" +#include "system/include/SystemPresenter.h" +#include "wearable_log.h" +#include "custom_utils.h" +#include "ConfigModel.h" +#include "ui_resource_string.h" + +#define WATCH_ABOUT_TITLE_HEIGHT 50 +#define WATCH_ABOUT_VALUE_HEIGHT 80 +#define WATCH_NAME_POS_TOP 140 +#define WATCH_NAME_VALUE_POS_TOP (WATCH_NAME_POS_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_FIRMWARE_POS_TOP (WATCH_NAME_VALUE_POS_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_FIRMWARE_VALUE_POS_TOP (WATCH_FIRMWARE_POS_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_HWVER_TOP (WATCH_FIRMWARE_VALUE_POS_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_HWVER_VALUE_TOP (WATCH_HWVER_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_BT_NAME_TOP (WATCH_HWVER_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_BT_NAME_VALUE_TOP (WATCH_BT_NAME_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_BT_ADDR_TOP (WATCH_BT_NAME_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_BT_ADDR_VALUE_TOP (WATCH_BT_ADDR_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_MODEM_VERSION_TOP (WATCH_BT_ADDR_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_MODEM_VERSION_VALUE_TOP (WATCH_MODEM_VERSION_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_MODEM_APP_VERSION_TOP (WATCH_MODEM_VERSION_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_MODEM_APP_VERSION_VALUE_TOP (WATCH_MODEM_APP_VERSION_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_APN_PROTOCOL_TOP (WATCH_MODEM_APP_VERSION_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_APN_PROTOCOL_VALUE_TOP (WATCH_APN_PROTOCOL_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_IMEI_TOP (WATCH_APN_PROTOCOL_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_IMEI_VALUE_TOP (WATCH_IMEI_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_FONT_TOP (WATCH_IMEI_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_FONT_VALUE_TOP (WATCH_FONT_TOP + WATCH_ABOUT_TITLE_HEIGHT) +#define WATCH_CYWEEVER_TOP (WATCH_FONT_VALUE_TOP + WATCH_ABOUT_VALUE_HEIGHT) +#define WATCH_CYWEEVER_TOP_VALUE_TOP (WATCH_CYWEEVER_TOP + WATCH_ABOUT_TITLE_HEIGHT) + +namespace OHOS +{ + static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_X = 83; + static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_Y = 50; + static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_W = 300; + static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_H = 35; + static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_FONTSIZE = 30; + static constexpr uint16_t SYSTEM_ABOUT_THEWATCH_TITLE_LINEHEIGHT = 35; + + static constexpr uint16_t TITLE_LABEL_X = 53; + static constexpr uint16_t TITLE_LABEL_W = 360; + static constexpr uint16_t TITLE_LABEL_H = 35; + static constexpr uint16_t TITLE_LABEL_FONTSIZE = 30; + static constexpr uint16_t TITLE_LABEL_LINEHEIGHT = 35; + + static constexpr uint16_t LABEL_X = 33; + static constexpr uint16_t LABEL_W = 400; + static constexpr uint16_t LABEL_H = 35; + static constexpr uint16_t LABEL_FONTSIZE = 30; + static constexpr uint16_t LABEL_LINEHEIGHT = 35; + + static SystemAboutTheWatchView *g_pSystemAboutTheWatchView{nullptr}; + + SystemAboutTheWatchView::SystemAboutTheWatchView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchView"); + g_pSystemAboutTheWatchView = this; + } + + SystemAboutTheWatchView::~SystemAboutTheWatchView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::~SystemAboutTheWatchView"); + ClearAll(); + g_pSystemAboutTheWatchView = nullptr; + } + + SystemAboutTheWatchView *SystemAboutTheWatchView::GetInstance() + { + return g_pSystemAboutTheWatchView; + } + + void SystemAboutTheWatchView::ClearAll() + { + if (initViewStatus == true) + { + SystemAboutTheWatchScrollView->RemoveAll(); + + delete SystemAboutTheWatchTitle; + SystemAboutTheWatchTitle = nullptr; + + delete WatchNameTitle; + WatchNameTitle = nullptr; + delete WatchName; + WatchName = nullptr; + + delete FirmwareVersionTitle; + FirmwareVersionTitle = nullptr; + delete FirmwareVersion; + FirmwareVersion = nullptr; + + delete BluetoothNameTitle; + BluetoothNameTitle = nullptr; + delete BluetoothName; + BluetoothName = nullptr; + + delete BluetoothAddressTitle; + BluetoothAddressTitle = nullptr; + delete BluetoothAddress; + BluetoothAddress = nullptr; + + delete Network4GTitle; + Network4GTitle = nullptr; + delete Network4G; + Network4G = nullptr; + + delete PyVerTitle; + PyVerTitle = nullptr; + delete PyVer; + PyVer = nullptr; + + delete IMELTitle; + IMELTitle = nullptr; + delete IMEL; + IMEL = nullptr; + + delete FONTTitle; + FONTTitle = nullptr; + delete FONT; + FONT = nullptr; + + delete HWVERTitle; + HWVERTitle = nullptr; + delete HWVER; + HWVER = nullptr; + + delete CyweeVersionTitle; + CyweeVersionTitle = nullptr; + delete CyweeVersion; + CyweeVersion = nullptr; + + delete APNprotocolTitle; + APNprotocolTitle = nullptr; + delete APNprotocol; + APNprotocol = nullptr; + + FocusManager::GetInstance()->ClearFocus(); + delete SystemAboutTheWatchScrollView; + SystemAboutTheWatchScrollView = nullptr; + } + } + + UILabelExt *SystemAboutTheWatchView::InitLabel_Ext(LabelConfig &labelConfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高 + // label->SetText(labelConfig.text.c_str()); // 内容 + label->SetTextId(labelConfig.textId); + label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); + return label; + } + + UILabel *SystemAboutTheWatchView::InitLabel(LabelConfig &labelConfig) + { + UILabel *label = new UILabel(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高 + label->SetText(labelConfig.text.c_str()); // 内容 + label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, labelConfig.fontSize); + return label; + } + + bool SystemAboutTheWatchView::SetSystemAboutTheWatchScrollView(void) + { + SystemAboutTheWatchScrollView = new UIScrollView(); + if (SystemAboutTheWatchScrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchScrollView new fail!"); + return false; + } + SystemAboutTheWatchScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemAboutTheWatchScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemAboutTheWatchScrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + SystemAboutTheWatchScrollView->SetScrollBlankSize(30); + SystemAboutTheWatchScrollView->SetReboundSize(30); + SystemAboutTheWatchScrollView->SetDirection(1); + SystemAboutTheWatchScrollView->SetThrowDrag(true); + SystemAboutTheWatchScrollView->SetMaxScrollDistance(1000); + SystemAboutTheWatchScrollView->SetSwipeACCLevel(200); /*设置手指抬起屏幕后的补偿距离。*/ + FocusManager::GetInstance()->RequestFocus(SystemAboutTheWatchScrollView); + FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP); + SystemAboutTheWatchScrollView->SetRotateFactor(1.0); + UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); + if (draglistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::draglistener can not be nullptr!"); + return false; + } + SystemAboutTheWatchScrollView->SetOnDragListener(draglistener); + + SystemAboutTheWatchScrollView->SetTouchable(true); + SystemAboutTheWatchScrollView->SetDraggable(true); + + SystemAboutTheWatchScrollView->SetViewId(SYSTEMABOUTTHEWATCHVIEWID); + UIView::OnClickListener *touch = static_cast(SystemPresenter::GetInstance()); + SystemAboutTheWatchScrollView->SetOnClickListener(touch); + return true; + } + + UIScrollView *SystemAboutTheWatchView::SystemAbouTheWatchtInitIView() + { + if (!SetSystemAboutTheWatchScrollView()) + { + return nullptr; + } + /* -------------------------------------------------------------------------- */ + LabelConfig Config = { + .left = SYSTEM_ABOUT_THEWATCH_TITLE_X, + .top = SYSTEM_ABOUT_THEWATCH_TITLE_Y, + .width = SYSTEM_ABOUT_THEWATCH_TITLE_W, + .height = SYSTEM_ABOUT_THEWATCH_TITLE_H, + .fontSize = SYSTEM_ABOUT_THEWATCH_TITLE_FONTSIZE, + .lineHeigh = SYSTEM_ABOUT_THEWATCH_TITLE_LINEHEIGHT, + .text = "关于手表", + .textId = STR_ABOUT_WATCH, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + SystemAboutTheWatchTitle = InitLabel_Ext(Config); + if (SystemAboutTheWatchTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::SystemAboutTheWatchTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(SystemAboutTheWatchTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_NAME_POS_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "手表名称", + .textId = STR_WATCH_NAME, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + WatchNameTitle = InitLabel_Ext(Config); + if (WatchNameTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::WatchNameTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(WatchNameTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = LABEL_X, + .top = WATCH_NAME_VALUE_POS_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE, + .lineHeigh = LABEL_LINEHEIGHT, + #ifdef CUSTOM_Z1 + .text = "Z1", + #else + .text = "Watch Soar", + #endif + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + WatchName = InitLabel(Config); + if (WatchName == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::WatchName new fail!"); + return nullptr; + } + WatchName->SetTextColor(Color::GetColorFromRGBA(0x88, 0x88, 0x88, 0xff)); + SystemAboutTheWatchScrollView->Add(WatchName); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_FIRMWARE_POS_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "固件版本", + .textId = STR_FIRMWARE_VERSION, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + FirmwareVersionTitle = InitLabel_Ext(Config); + if (FirmwareVersionTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::FirmwareVersionTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(FirmwareVersionTitle); + /* -------------------------------------------------------------------------- */ + char version_buf[128] = {0}; + uint32_t version_len = 128; + uapi_get_buildversion((uint8_t *)version_buf, version_len); + Config = { + .left = LABEL_X, + .top = WATCH_FIRMWARE_VALUE_POS_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE, + .lineHeigh = LABEL_LINEHEIGHT, + #if defined(SUPPORT_CHINA_MOBILE_DMP) || defined(SUPPORT_TELECOM_DMP) //移动、电信入库软件要求 版本号固定 + .text = "Watch Soar V1.0", + #else + .text = (char *)version_buf, + #endif + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + FirmwareVersion = InitLabel(Config); + if (FirmwareVersion == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::FirmwareVersion new fail!"); + return nullptr; + } + FirmwareVersion->SetTextColor(Color::GetColorFromRGBA(0x88, 0x88, 0x88, 0xff)); + SystemAboutTheWatchScrollView->Add(FirmwareVersion); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_BT_NAME_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "蓝牙名称", + .textId = STR_BLUETOOTH_NAME, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + BluetoothNameTitle = InitLabel_Ext(Config); + if (BluetoothNameTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::BluetoothNameTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(BluetoothNameTitle); + /* -------------------------------------------------------------------------- */ + uint8_t ble_name[LABEL_FONTSIZE] = {0}; + uint32_t ble_name_len = sizeof(ble_name); + errcode_t ret = uapi_get_nv_btname(ble_name, &ble_name_len); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "get btname %s ,ret 0x%X\n", ble_name, ret); + + Config = { + .left = LABEL_X, + .top = WATCH_BT_NAME_VALUE_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE, + .lineHeigh = LABEL_LINEHEIGHT, + .text = (char *)ble_name, + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + BluetoothName = InitLabel(Config); + if (BluetoothName == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::BluetoothName new fail!"); + return nullptr; + } + BluetoothName->SetTextColor(Color::GetColorFromRGBA(0x88, 0x88, 0x88, 0xff)); + SystemAboutTheWatchScrollView->Add(BluetoothName); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_BT_ADDR_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "蓝牙地址", + .textId = STR_BLUETOOTH_ADDRESS, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + BluetoothAddressTitle = InitLabel_Ext(Config); + if (BluetoothAddressTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::BluetoothAddressTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(BluetoothAddressTitle); + /* -------------------------------------------------------------------------- */ + uint8_t btaddr[6] = {0}; + uint8_t btaddr_str[64] = {0}; + uint32_t len = 6; + ret = uapi_get_nv_btaddr((uint8_t *)btaddr, &len); + sprintf((char *)btaddr_str, "%02X:%02X:%02X:%02X:%02X:%02X", btaddr[0], btaddr[1], btaddr[2], btaddr[3], btaddr[4], btaddr[5]); + + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "get btaddr %s , ret 0x%X\n", btaddr_str, ret); + Config = { + .left = LABEL_X, + .top = WATCH_BT_ADDR_VALUE_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE, + .lineHeigh = LABEL_LINEHEIGHT, + .text = (char *)btaddr_str, + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + BluetoothAddress = InitLabel(Config); + if (BluetoothAddress == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::BluetoothAddress new fail!"); + return nullptr; + } + BluetoothAddress->SetTextColor(Color::GetColorFromRGBA(0x88, 0x88, 0x88, 0xff)); + SystemAboutTheWatchScrollView->Add(BluetoothAddress); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_MODEM_VERSION_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "4G Modem", + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + Network4GTitle = InitLabel(Config); + if (Network4GTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::Network4GTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(Network4GTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = LABEL_X, + .top = WATCH_MODEM_VERSION_VALUE_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE - 2, + .lineHeigh = LABEL_LINEHEIGHT, + .text = ConfigModel::GetInstance()->GetmoderVer(), + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + Network4G = InitLabel(Config); + if (Network4G == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::Network4G new fail!"); + return nullptr; + } + Network4G->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(Network4G); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_MODEM_APP_VERSION_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "pyVer", + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + PyVerTitle = InitLabel(Config); + if (PyVerTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::PyVerTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(PyVerTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = LABEL_X, + .top = WATCH_MODEM_APP_VERSION_VALUE_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE, + .lineHeigh = LABEL_LINEHEIGHT, + .text = ConfigModel::GetInstance()->GetpyVer(), + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + PyVer = InitLabel(Config); + if (PyVer == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::PyVer new fail!"); + return nullptr; + } + PyVer->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(PyVer); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_APN_PROTOCOL_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "APN protocol", + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + APNprotocolTitle = InitLabel(Config); + if (APNprotocolTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::APNprotocolTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(APNprotocolTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = LABEL_X, + .top = WATCH_APN_PROTOCOL_VALUE_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "IPV4/IPV6", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + APNprotocol = InitLabel(Config); + if (APNprotocol == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::APNprotocol new fail!"); + return nullptr; + } + APNprotocol->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(APNprotocol); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_IMEI_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "IMEI", + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + IMELTitle = InitLabel(Config); + if (IMELTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::IMELTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(IMELTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = LABEL_X, + .top = WATCH_IMEI_VALUE_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = ConfigModel::GetInstance()->Getimei(), + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + IMEL = InitLabel(Config); + if (IMEL == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::IMEL new fail!"); + return nullptr; + } + IMEL->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(IMEL); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_FONT_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "OS Version", + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + FONTTitle = InitLabel(Config); + if (FONTTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::FONTTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(FONTTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = LABEL_X, + .top = WATCH_FONT_VALUE_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE, + .lineHeigh = LABEL_LINEHEIGHT, + .text = "OpenHarmony 3.2 Release", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + FONT = InitLabel(Config); + if (FONT == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::FONT new fail!"); + return nullptr; + } + FONT->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(FONT); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_HWVER_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "HW Version", + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + HWVERTitle = InitLabel(Config); + if (HWVERTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::HWVERTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(HWVERTitle); + /* -------------------------------------------------------------------------- */ + Config = { + .left = LABEL_X, + .top = WATCH_HWVER_VALUE_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE, + .lineHeigh = LABEL_LINEHEIGHT, + .text = "FD230 V1.0", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + HWVER = InitLabel(Config); + if (HWVER == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::HWVER new fail!"); + return nullptr; + } + HWVER->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(HWVER); + /* -------------------------------------------------------------------------- */ + Config = { + .left = TITLE_LABEL_X, + .top = WATCH_CYWEEVER_TOP, + .width = TITLE_LABEL_W, + .height = TITLE_LABEL_H, + .fontSize = TITLE_LABEL_FONTSIZE, + .lineHeigh = TITLE_LABEL_LINEHEIGHT, + .text = "Cywee Version", + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + CyweeVersionTitle = InitLabel(Config); + if (CyweeVersionTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::CyweeVersionTitle new fail!"); + return nullptr; + } + SystemAboutTheWatchScrollView->Add(CyweeVersionTitle); +/* -------------------------------------------------------------------------- */ + char cywee_version[20] = {0}; + uapi_cywee_get_version(cywee_version, sizeof(cywee_version)); + Config = { + .left = LABEL_X, + .top = WATCH_CYWEEVER_TOP_VALUE_TOP, + .width = LABEL_W, + .height = LABEL_H, + .fontSize = LABEL_FONTSIZE, + .lineHeigh = LABEL_LINEHEIGHT, + .text = cywee_version, + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + CyweeVersion = InitLabel(Config); + if (CyweeVersion == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchView::CyweeVersion new fail!"); + return nullptr; + } + CyweeVersion->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemAboutTheWatchScrollView->Add(CyweeVersion); + + /* -------------------------------------------------------------------------- */ + initViewStatus = true; + return SystemAboutTheWatchScrollView; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemFactoryResetView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemFactoryResetView.cpp new file mode 100644 index 000000000..e8553e70a --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemFactoryResetView.cpp @@ -0,0 +1,194 @@ +#include "system/include/SystemFactoryResetView.h" +#include "system/include/SystemPresenter.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "ui_resource_string.h" + +namespace OHOS +{ + + static SystemFactoryResetView *g_pSystemFactoryResetView{nullptr}; + + SystemFactoryResetView::SystemFactoryResetView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::SystemFactoryResetView"); + g_pSystemFactoryResetView = this; + } + + SystemFactoryResetView::~SystemFactoryResetView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::~SystemFactoryResetView"); + ClearAll(); + g_pSystemFactoryResetView = nullptr; + } + + SystemFactoryResetView *SystemFactoryResetView::GetInstance() + { + return g_pSystemFactoryResetView; + } + + void SystemFactoryResetView::ClearAll() + { + if (initViewStatus == true) + { + scrollView->RemoveAll(); + + delete Title; + Title = nullptr; + + delete FactoryResetImage; + FactoryResetImage = nullptr; + + delete FactoryResetNote; + FactoryResetNote = nullptr; + + delete FactoryResetButtonCheckOn; + FactoryResetButtonCheckOn = nullptr; + + delete FactoryResetButtonCheckOff; + FactoryResetButtonCheckOff = nullptr; + + delete temp; + temp = nullptr; + + delete scrollView; + scrollView = nullptr; + } + } + + UIScrollView *SystemFactoryResetView::SystemFactoryResetViewInit(void) + { + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new scrollView fail!"); + return nullptr; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView->SetStyle(STYLE_BORDER_RADIUS, 100); + // scrollView->SetScrollBlankSize(30); + // scrollView->SetReboundSize(30); + scrollView->SetMaxScrollDistance(1000); + scrollView->SetThrowDrag(true); + scrollView->RequestFocus(); + scrollView->SetRotateFactor(2); + UIView::OnDragListener *dragListener = static_cast(SystemPresenter::GetInstance()); + if (dragListener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemPresenter::GetInstance fail!!"); + return nullptr; + } + scrollView->SetOnDragListener(dragListener); + /* ---------------------------------- Title --------------------------------- */ + Title = new UILabelExt(); + if (Title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new Title fail!"); + return nullptr; + } + Title->SetPosition(83, 52, 300, 35); + Title->SetStyle(STYLE_TEXT_FONT, 30); + Title->SetStyle(STYLE_LINE_HEIGHT, 35); + Title->SetTextId(STR_FACTORY_RESET); /*恢复出厂*/ + Title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + Title->SetRollSpeed(23); + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + Title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ---------------------------- FactoryResetImage --------------------------- */ + FactoryResetImage = new UIImageView(); + if (FactoryResetImage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new FactoryResetImage fail!"); + return nullptr; + } + FactoryResetImage->SetPosition(193, 120); + FactoryResetImage->SetSrc(PNG_ATTENTION_IMAGE); + /* ---------------------------- FactoryResetNote ---------------------------- */ + FactoryResetNote = new UILabelExt(); + if (FactoryResetNote == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new FactoryResetNote fail!"); + return nullptr; + } + FactoryResetNote->SetPosition(53, 228, 360, 70); + FactoryResetNote->SetStyle(STYLE_TEXT_FONT, 30); + FactoryResetNote->SetStyle(STYLE_LINE_HEIGHT, 35); + FactoryResetNote->SetTextId(STR_RESET_CONFIRM_NOTE); /*该操作会清空并重置手表数据,是否确认继续?*/ + FactoryResetNote->SetLineBreakMode(UILabel::LINE_BREAK_WRAP); + FactoryResetNote->SetTextColor(Color::GetColorFromRGBA(0xff, 0x8a, 0x36, 0xff)); + FactoryResetNote->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + FactoryResetNote->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + /* ----------------------- FactoryResetButtonCheckOff ----------------------- */ + FactoryResetButtonCheckOff = new UIButton(); + if (FactoryResetButtonCheckOff == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new FactoryResetButtonCheckOff fail!"); + return nullptr; + } + FactoryResetButtonCheckOff->SetPosition(97, FactoryResetNote->GetY() + FactoryResetNote->GetTextHeight() + 30, 130, 130); + FactoryResetButtonCheckOff->SetViewId(FACTORYRESET_CHECKOFF); + FactoryResetButtonCheckOff->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + FactoryResetButtonCheckOff->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + FactoryResetButtonCheckOff->SetImagePosition(15, 15); + FactoryResetButtonCheckOff->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + FactoryResetButtonCheckOff->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + FactoryResetButtonCheckOff->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, PNG_SYSTEM_CHECK_OFF_IMAGE); + UIView::OnClickListener *FactoryResetButtonCheckOffClick = static_cast(SystemPresenter::GetInstance()); + if (FactoryResetButtonCheckOffClick == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::FactoryResetButtonCheckOffClick is nullptr!"); + return nullptr; + } + FactoryResetButtonCheckOff->SetOnClickListener(FactoryResetButtonCheckOffClick); + /* ------------------------ FactoryResetButtonCheckOn ----------------------- */ + FactoryResetButtonCheckOn = new UIButton(); + if (FactoryResetButtonCheckOn == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new FactoryResetButtonCheckOn fail!"); + return nullptr; + } + FactoryResetButtonCheckOn->SetPosition(240, FactoryResetButtonCheckOff->GetY(), 130, 130); + FactoryResetButtonCheckOn->SetViewId(FACTORYRESET_CHECKON); + FactoryResetButtonCheckOn->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + FactoryResetButtonCheckOn->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + FactoryResetButtonCheckOn->SetImagePosition(15, 15); + FactoryResetButtonCheckOn->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + FactoryResetButtonCheckOn->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + FactoryResetButtonCheckOn->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, PNG_SYSTEM_CHECK_ON_IMAGE); + UIView::OnClickListener *FactoryResetButtonCheckOnClick = static_cast(SystemPresenter::GetInstance()); + if (FactoryResetButtonCheckOnClick == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::FactoryResetButtonCheckOnClick is nullptr!"); + return nullptr; + } + FactoryResetButtonCheckOn->SetOnClickListener(FactoryResetButtonCheckOnClick); + /* -------------------------------------------------------------------------- */ + if ((FactoryResetButtonCheckOn->GetY() + FactoryResetButtonCheckOn->GetHeight() > Screen::GetInstance().GetHeight())) + { + if (temp == nullptr) + { + temp = new UIImageView(); + if (temp == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new temp fail!"); + return nullptr; + } + temp->SetPosition(43, FactoryResetButtonCheckOn->GetY() + FactoryResetButtonCheckOn->GetHeight(), 380, 40); + temp->SetVisible(false); + scrollView->Add(temp); + scrollView->SetScrollBlankSize(30); + scrollView->SetReboundSize(30); + } + } + /* ----------------------------- Add to scroView ---------------------------- */ + scrollView->Add(Title); + scrollView->Add(FactoryResetImage); + scrollView->Add(FactoryResetNote); + scrollView->Add(FactoryResetButtonCheckOff); + scrollView->Add(FactoryResetButtonCheckOn); + initViewStatus = true; + return scrollView; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemLogModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemLogModel.cpp new file mode 100644 index 000000000..dcbab5a9d --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemLogModel.cpp @@ -0,0 +1,484 @@ +#include "system/include/SystemLogModel.h" +#include "cmsis_os.h" +#include "custom_utils.h" +#include "graphic_service.h" +#include "iostream" +#include "securec.h" +#include "system/include/SystemLogModelC.h" +#include "uicomponents/UIComponents.h" +#include "wearable_log.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ConfigModel.h" +#include "custom_save_runtime.h" +#define SYSTEM_LOG_PATH "/user/system/" +#define SYSTEM_LOG_FILE_PATH "/user/system/system_log.txt" +#define SYSTEM_LOG_FILE_PATH_NEXTDAY "/user/system/system_log_nextday.txt" +#define SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS "/user/system/popup_windows_log.txt" + +extern "C" { +// 通用日志记录功能 +void report_log(OHOS::SystemLogType type) { + OHOS::SystemLogData systemlog; + systemlog.timestamp = OHOS::SystemLogModel::GetInstance()->GetCurrentTime(); + systemlog.type = type; +#ifdef FD230_650 + uapi_save_runtime_log_Time(); +#endif + + // 存储日志 + OHOS::SystemLogModel::GetInstance()->saveLog(systemlog); +} + +// 关机保存 +void start_report_log(void) { report_log(OHOS::SystemLogType::POWER_OFF); } + +// 重启保存 +void stop_report_log(void) { report_log(OHOS::SystemLogType::RESTART); } + +// 恢复存储保存 +void resume_report_log(void) { report_log(OHOS::SystemLogType::FACTORY_RESET); } + +// 更新版本保存 +void update_version_report_log(void) { + report_log(OHOS::SystemLogType::SOFTWARE_UPDATE); +} + +//保存nextday日志 +void start_report_nextday_log_start(void) { + OHOS::nextday_log_data data; + uint32_t timestamp = OHOS::SystemLogModel::GetInstance()->GetCurrentTime(); + data.type = OHOS::nextday_type::NEXTDAY_BEGAN; + data.timestamp = timestamp; + OHOS::SystemLogModel::GetInstance()->save_nextday_log(data); +} +void start_report_nextday_log_end(void) { + OHOS::nextday_log_data data; + uint32_t timestamp = OHOS::SystemLogModel::GetInstance()->GetCurrentTime(); + data.type = OHOS::nextday_type::NEXTDAY_END; + data.timestamp = timestamp; + OHOS::SystemLogModel::GetInstance()->save_nextday_log(data); +} +// 清空popup_windows日志 +void nextday_clear_popup_windows_log(void) { + // OHOS::SystemLogModel::GetInstance()->clear_popup_windows_log(); +} +void save_popup_windows_log_c(int type) +{ + OHOS::SystemLogModel::GetInstance()->save_popup_windows_log_type(type); +} +//进行开机配置uart +void system_init_uart(void) +{ + OHOS::SystemLogModel::GetInstance()->init_uart(); +} +} + +namespace OHOS { +SystemLogModel *SystemLogModel::GetInstance(void) { + static SystemLogModel instance; + return &instance; +} + +uint32_t SystemLogModel::GetCurrentTime() { + uint32_t time; + if (uapi_get_timestampe_ss(&time) != ERRCODE_SUCC) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to get timestamp"); + return 0; + } + return time; +} + +// 保存日志 +bool SystemLogModel::saveLog(SystemLogData data) { + + //记录开机,关机,重启,ota升级,恢复出厂事件 + switch (data.type) + { + case SystemLogType::POWER_ON: + uapi_save_runtime_log(RUNTIME_LOG_POWER_ON);//TOOD* + break; + case SystemLogType::POWER_OFF: + uapi_save_runtime_log(RUNTIME_LOG_POWER_OFF);//TOOD* + break; + case SystemLogType::RESTART: + uapi_save_runtime_log(RUNTIME_LOG_REBOOT);//TOOD* + break; + case SystemLogType::FACTORY_RESET: + uapi_save_runtime_log(RUNTIME_LOG_FACTORY_RESET);//TOOD* + break; + case SystemLogType::SOFTWARE_UPDATE: + uapi_save_runtime_log(RUNTIME_LOG_OTA);//TOOD* + break; + default: + break; + } + + // 将新日志添加到日志数据 + logData.push_back(data); + + // 如果超过限制,删除最早的日志 + while (logData.size() > 50) { + logData.pop_front(); // 从前端删除最早的日志 + } + + //如果是4分区先创建文件夹 + CreateDirectoryIfNotExists(SYSTEM_LOG_PATH); + + // 将所有日志写入文件 + std::ofstream ofs(SYSTEM_LOG_FILE_PATH, std::ios::trunc); + if (!ofs.is_open()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to open log file for writing"); + return false; + } + + for (const auto &log : logData) { + ofs << static_cast(log.type) << " " << log.timestamp << std::endl; + } + + return true; +} + +// 加载日志 +bool SystemLogModel::loadLog() { + std::ifstream ifs(SYSTEM_LOG_FILE_PATH); + if (!ifs.is_open()) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to open log file for reading"); + return false; + } + + logData.clear(); + SystemLogData data; + int type; + while (ifs >> type >> data.timestamp) { + data.type = static_cast(type); + logData.push_back(data); + } + + // // 如果超过限制,删除最早的日志 + // while (logData.size() > 50) { + // logData.pop_front(); // 从前端删除最早的日志 + // } + + WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "Loaded %d logs from file", + logData.size()); + + return true; +} + +// 获取日志记录,返回deque +const std::deque &SystemLogModel::getLogData() const { + return logData; +} + +// 获取日志大小 +size_t SystemLogModel::getLogSize() const { return logData.size(); } + +long long SystemLogModel::getFolderSize(const char *folderPath) { + DIR *dir; + struct dirent *entry; + struct stat fileStat; + long long totalSize = 0; + + dir = opendir(folderPath); + if (dir == NULL) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error opening directory"); + return 0; + } + + while ((entry = readdir(dir)) != NULL) { + char filePath[1024]; + snprintf(filePath, sizeof(filePath), "%s/%s", folderPath, entry->d_name); + + if (stat(filePath, &fileStat) == -1) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Error getting file status"); + continue; + } + + if (S_ISDIR(fileStat.st_mode)) { + if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) + continue; + totalSize += getFolderSize(filePath); + } else { + totalSize += fileStat.st_size; + } + } + + closedir(dir); + return totalSize; +} + +//获取系统内存 +/* +[FS INFO]total size=12416KB used size=8114KB free size=4302KB +[FS INFO]/update/: +[FS INFO]total size=12416KB used size=552KB free size=11864KB +[FS INFO]/music/: +[FS INFO]total size=12416KB used size=1270KB free size=11146KB +[FS INFO]/user/: +[FS INFO]total size=91264KB used size=64596KB free size=26668KB +*/ +std::string SystemLogModel::get_system_mem_info() { + struct statfs file_buf = {0}; + std::stringstream result; + std::string system_volume_name = "/user/"; + if (statfs(system_volume_name.c_str(), &file_buf) != 0) { + result << "Error retrieving info for " << system_volume_name << std::endl; + } else { + // 计算总大小、已用大小和自由空间 + uint64_t total_size = + static_cast(file_buf.f_blocks) * file_buf.f_bsize; + uint64_t free_size = + static_cast(file_buf.f_bfree) * file_buf.f_bsize; + uint64_t used_size = total_size - free_size; + + // 按照所需格式输出 + result << "[" << system_volume_name << "]" << std::endl; + result << "Total size = " << total_size / 1024 << " KB" << std::endl; + result << "Used size = " << used_size / 1024 << " KB" << std::endl; + result << "Free size = " << free_size / 1024 << " KB" << std::endl; + result << "====================" << std::endl; // 分隔线 + } + + std::vector volume_names = { + "/user/dial/", "/user/music/", "/user/update/", + "/user/res/", "/user/system/", "/user/userdata/", + }; + + // 遍历每个目录,获取文件系统状态 + for (const auto &volume_name : volume_names) { + // 获取文件系统状态 + uint64_t total_size = getFolderSize(volume_name.c_str()); + if (total_size == 0) { + result << "Error retrieving info for " << volume_name << std::endl; + } else { + // 计算总大小 + result << "[" << volume_name << "]" << std::endl; + result << "Total size = " << total_size / 1024 << " KB" << std::endl; + result << "====================" << std::endl; // 分隔线 + } + } + + // 如果没有信息,则返回说明信息 + return result.str().empty() ? "No volumes found or accessible." + : result.str(); +} + +// 检查是否可以同步文件 +bool SystemLogModel::canSyncFile(std::string path, uint32_t path_max_size, + uint32_t download_size) { + // 获取文件夹的大小 + long long usedSpace = getFolderSize(path.c_str()); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "usedSpace = %lld", usedSpace); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "path_max_size = %lld", path_max_size); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "download_size = %lld", download_size); + + return (usedSpace + download_size) <= path_max_size; +} +// nextday相关 + +bool SystemLogModel::save_nextday_log(nextday_log_data data) { + // 检查容量,最多存储7条日志 + if (nextday_log.size() >= 7) { + nextday_log.pop_front(); // 超出限制,删除最旧的日志 + } + + // 保存新日志,将传入的完整日志数据添加到队列 + nextday_log.push_back(data); + + // 将nextday_log写入文件,覆盖写 + std::ofstream outFile(SYSTEM_LOG_FILE_PATH_NEXTDAY, std::ios::trunc); + if (!outFile) { + return false; // 文件打开失败 + } + + // 遍历队列,将每条日志数据(包括类型和时间戳)写入文件 + for (const auto &logData : nextday_log) { + // 将日志类型转换为整数写入 + outFile << static_cast(logData.type) << " "; + outFile << logData.timestamp << std::endl; + } + + outFile.close(); + + return true; +} + +// 加载下一日日志 +bool SystemLogModel::load_nextday_log() { + nextday_log.clear(); // 清空当前的日志 + + std::ifstream inFile(SYSTEM_LOG_FILE_PATH_NEXTDAY); + if (!inFile) { + return false; // 无法打开文件 + } + + std::string line; + while (std::getline(inFile, line)) { + std::istringstream ss(line); + nextday_log_data data; + + // 先读取日志类型(转换为整数读取),再读取时间戳 + int typeValue; + if (ss >> typeValue >> data.timestamp) { + data.type = static_cast(typeValue); + nextday_log.push_back(data); // 读取时间戳并存储完整日志数据 + } + } + + inFile.close(); + + return true; +} + +// 获取下一日日志 +const std::deque &SystemLogModel::get_nextday_log() const { + return nextday_log; // 返回日志记录的常量引用 +} + +// 获取日志大小 +size_t SystemLogModel::get_nextday_log_size() const { + return nextday_log.size(); +} + +// 保存popup_windows日志 +bool SystemLogModel::save_popup_windows_log(popup_windows_log_data data) { + // 保存新日志 + popup_windows_log.push_back(data); + + // 如果超过限制,删除最早的日志 + while (popup_windows_log.size() > 50) { + popup_windows_log.pop_front(); // 从前端删除最早的日志 + } + // 将日志写入文件 + std::ofstream outFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS, std::ios::trunc); + if (!outFile) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to open log file for writing"); + return false; // 文件打开失败 + } + + // 将结构体中的数据转换为字符串格式写入文件 + for (const auto &log : popup_windows_log) { + outFile << static_cast(log.type) << " " << log.timestamp << std::endl; + } + outFile.close(); + return true; +} + +void SystemLogModel::save_popup_windows_log_type(int type) +{ + popup_windows_log_data data; + data.timestamp = GetCurrentTime(); + switch(type) + { + case 0: + data.type = popup_windows_type::MOTION_RECOGNITION; + break; + case 1: + data.type = popup_windows_type::DRINK_WATER_REMINDER; + break; + case 2: + data.type = popup_windows_type::SEDENTARY_REMINDER; + break; + default: + break; + } + save_popup_windows_log(data); +} +bool SystemLogModel::load_popup_windows_log() { + std::ifstream inFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS); + if (!inFile) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to open log file for reading"); + return false; // 无法打开文件 + } + + std::string line; + while (std::getline(inFile, line)) { + std::istringstream ss(line); + popup_windows_log_data data; + int typeInt; + if (ss >> typeInt >> data.timestamp) { + switch(typeInt) + { + case 0: + data.type = popup_windows_type::MOTION_RECOGNITION; + break; + case 1: + data.type = popup_windows_type::DRINK_WATER_REMINDER; + break; + case 2: + data.type = popup_windows_type::SEDENTARY_REMINDER; + break; + default: + break; + } + popup_windows_log.push_back(data); + } + } + + inFile.close(); + return true; +} +// 获取popup_windows日志记录(常量引用) +const std::deque & +SystemLogModel::get_popup_windows_log() const { + return popup_windows_log; +} +// 获取日志大小 +size_t SystemLogModel::get_popup_windows_log_size() const { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"log size:%d",popup_windows_log.size()); + return popup_windows_log.size(); +} + +void SystemLogModel::clear_popup_windows_log() { + // 清空当前的日志 + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "clear_popup_windows_log"); + popup_windows_log.clear(); + + std::ofstream outFile(SYSTEM_LOG_FILE_PATH_POPUP_WINDOWS, std::ios::trunc); + if (!outFile) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, + "Failed to open log file for writing"); + return; + } + outFile << ""; + outFile.close(); +} +/*串口控制*/ +void SystemLogModel::init_uart() { + //读取configmodle + uart_status = ConfigModel::GetInstance()->get_configData_bool( + ConfigModel::CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS); + uapi_custom_set_uart_rx_enable_flag(uart_status); +} +//设置串口状态 +void SystemLogModel::set_uart_status(bool status) { + uart_status = status; + uapi_custom_set_uart_rx_enable_flag(uart_status); + ConfigModel::GetInstance()->set_condigData_Bool( + ConfigModel::CONFIGMODEL_ITEM_URAT_AT_CONTROL_STATUS,uart_status); +} +//获取串口状态 +bool SystemLogModel::get_uart_status() { return uart_status;} +} // namespace OHOS diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemModel.cpp new file mode 100644 index 000000000..dd492488b --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemModel.cpp @@ -0,0 +1,34 @@ + +#include "system/include/SystemModel.h" +#include "system/include/Systemupgrade.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "custom_utils.h" +#include "stdio.h" +#include +#include +#include "cJSON.h" +#include "ConfigModel.h" +#include "lwip/err.h" +#include "power_display_service.h" +#include "cmsis_os2.h" +#include "los_memory.h" +#include "thread_init.h" + #include "lwip/apps/http_client.h" + #include "tcxo.h" + #include "cat1_server.h" + #include "linux/delay.h" + +#define UPDATAREPORT_M UPDATAREPORT + +namespace OHOS +{ + + + SystemModel *SystemModel::GetInstance(void) + { + static SystemModel instance; + return &instance; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemPresenter.cpp new file mode 100644 index 000000000..aaf1c2c51 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemPresenter.cpp @@ -0,0 +1,303 @@ +#include "AppViewIDs.h" +#include "components/ui_label_ext.h" +#include "ui_resource_string.h" +#include "NativeAbility.h" +#include "graphic_math.h" +#include "string.h" +#include "system/include/SystemPresenter.h" +#include "font/font_global_manager.h" +#include "font/ui_font.h" +#include "languagecode/LanguageInit.h" + +#include "common/key_code.h" +#include "custom_utils.h" +#include "languagecode/LanguageInit.h" +#include "ui_resource_string.h" +#include "ConfigModel.h" +#include "vibrator_service.h" +#include "broadcast_feature.h" + +#include "UiConfig.h" + +#include "NativeRegisterManager.h" + +namespace OHOS +{ + REGIST_SLICE(VIEW_SYSTEM, SystemView, SystemPresenter); + + // 当前Presenter属性实例化的内存指针 + static SystemPresenter *g_pSystemPresenter = nullptr; + + SystemPresenter::SystemPresenter() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::SystemPresenter"); + g_pSystemPresenter = this; + systemModel = SystemModel::GetInstance(); + } + + SystemPresenter::~SystemPresenter() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::~SystemPresenter"); + g_pSystemPresenter = nullptr; + } + + SystemPresenter *SystemPresenter::GetInstance() + { + + return g_pSystemPresenter; + } + + void SystemPresenter::OnStart() + { + + Presenter::OnStart(); + } + + void SystemPresenter::OnPause(void) + { + Presenter::OnPause(); + } + + void SystemPresenter::OnResume(void) + { + + Presenter::OnResume(); + } + + void SystemPresenter::OnStop(void) + { + + Presenter::OnStop(); + } + + static uint32_t time = 0; + static uint32_t OnClick_num = 0; + + bool SystemPresenter::OnPress(UIView &view, const PressEvent &event) + { + return true; + } + + bool SystemPresenter::OnDrag(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::OnDrag"); + if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动 + { + SystemPresenter::X_DRAG_FLAG = true; + } + return true; + } + + bool SystemPresenter::OnDragEnd(UIView &view, const DragEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::OnDragEnd"); + SystemView *p_SystemView = SystemView::GetInstance(); + if (p_SystemView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::GetInstance fail!"); + return false; + } + + if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && SystemPresenter::X_DRAG_FLAG) + { + if (&view == p_SystemView->GetSystemScrollView(SYSTEMVIEW)) + { + NativeAbility::GetInstance().Back(); + } + else if (&view == p_SystemView->GetSystemScrollView(ABOUTTHEWATCHVIEW)) + { + p_SystemView->ChangeView(ABOUTTHEWATCHVIEW, SYSTEMVIEW); + } + else if (&view == p_SystemView->GetSystemScrollView(RESTARTVIEW)) + { + p_SystemView->ChangeView(RESTARTVIEW, SYSTEMVIEW); + } + else if (&view == p_SystemView->GetSystemScrollView(SHUTDOWNVIEW)) + { + p_SystemView->ChangeView(SHUTDOWNVIEW, SYSTEMVIEW); + } + else if (&view == p_SystemView->GetSystemScrollView(FACTORYRESETVIEW)) + { + p_SystemView->ChangeView(FACTORYRESETVIEW, SYSTEMVIEW); + } + SystemPresenter::X_DRAG_FLAG = false; + return true; + } + return false; + } + + // 该点击回调主要用于在系统视图界面进行跳转视图 + bool SystemPresenter::OnClick(UIView &view, const ClickEvent &event) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::OnClick"); + SystemView *p_SystemView = SystemView::GetInstance(); + if (p_SystemView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::GetInstance fail!"); + return false; + } + + if (strcmp(view.GetViewId(), SYSTEMABOUTTHEWATCHVIEWID) == 0) // 连续点击进入产测模式 + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemAboutTheWatchTitle"); + if (time == 0) + { + time = event.GetTimeStamp(); + OnClick_num = 1; + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "222 %d", time); + } + else + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "111 %d", event.GetTimeStamp()); + if (event.GetTimeStamp() - time < 2000) + { + OnClick_num++; + + if (OnClick_num > 5) + { + // NativeAbility::GetInstance().ChangeSlice(VIEW_TEST); + CustomEventPublish(TOPIC_EVENT_DEBUGOUTPUT, NULL, 0); + } + } + else + { + time = 0; + } + } + return true; + } + else if (strcmp(view.GetViewId(), ABOUT_THE_WATCH) == 0) // 点击进入关于手表界面 + { + p_SystemView->ChangeView(SYSTEMVIEW, ABOUTTHEWATCHVIEW); + return true; + } + else if (strcmp(view.GetViewId(), SET_TIME_FORMAT) == 0) // 点击进入设置时间格式 + { + NativeAbility::GetInstance().EnterSlice(VIEW_SET_TIME_FORMAT); + return true; + } + else if (strcmp(view.GetViewId(), SYSTEM_UPGRADE) == 0) // 点击进入系统升级视图 + { + NativeAbility::GetInstance().EnterSlice(VIEW_SYSTEM_UPDATE); + return true; + } + else if (strcmp(view.GetViewId(), WATCH_QR_CODE) == 0) // 点击进入手表二维码视图 + { + NativeAbility::GetInstance().EnterSlice(VIEW_WATCH_QR_CODE); + return true; + } + else if (strcmp(view.GetViewId(), SYSTEM_LANGUAGE) == 0) // 点击进入系统语言界面 + { + NativeAbility::GetInstance().EnterSlice(VIEW_LANGUAGE_SWITCH); + return true; + } + else if (strcmp(view.GetViewId(), RESTART) == 0) // 点击进入重启界面 + { + p_SystemView->ChangeView(SYSTEMVIEW, RESTARTVIEW); + return true; + } + else if (strcmp(view.GetViewId(), SHUTDOWN) == 0) // 点击进入关机界面 + { + p_SystemView->ChangeView(SYSTEMVIEW, SHUTDOWNVIEW); + return true; + } + else if (strcmp(view.GetViewId(), FACTORY_RESET) == 0) // 点击进入恢复出厂设置界面 + { + p_SystemView->ChangeView(SYSTEMVIEW, FACTORYRESETVIEW); + return true; + } + else if (strcmp(view.GetViewId(), RESTARTVIEW_CHECKON) == 0) // 重启确认 + { + p_SystemView->ChangeView(RESTARTVIEW, SHUTDOWNANIMATIONVIEW); + + ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(1); + isShutDownImageAnimatorStart = true; + return true; + } + else if (strcmp(view.GetViewId(), RESTARTVIEW_CHECKOFF) == 0) // 重启取消 + { + p_SystemView->ChangeView(RESTARTVIEW, SYSTEMVIEW); + return true; + } + else if (strcmp(view.GetViewId(), SHUTDOWN_CHECKON) == 0) // 关机确认 + { + p_SystemView->ChangeView(SHUTDOWNVIEW, SHUTDOWNANIMATIONVIEW); + + + ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(0); + isShutDownImageAnimatorStart = true; + + return true; + } + else if (strcmp(view.GetViewId(), SHUTDOWN_CHECKOFF) == 0) // 关机取消 + { + p_SystemView->ChangeView(SHUTDOWNVIEW, SYSTEMVIEW); + return true; + } + else if (strcmp(view.GetViewId(), FACTORYRESET_CHECKON) == 0) // 恢复出厂设置确认 + { + ui_api_vibrate_once_func(); //恢复出厂增加震动 + p_SystemView->ChangeView(FACTORYRESETVIEW, SHUTDOWNANIMATIONVIEW); + ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(2); + isShutDownImageAnimatorStart = true; + return true; + } + else if (strcmp(view.GetViewId(), FACTORYRESET_CHECKOFF) == 0) // 恢复出厂设置取消 + { + p_SystemView->ChangeView(FACTORYRESETVIEW, SYSTEMVIEW); + return true; + } + + // if (strcmp(view.GetViewId(), SYSTEM_UPGRADE_t) == 0) //点击是否立即升级 + // { + // SystemupgradeView::GetInstance()->statr_down_fwpkg(); + // } + // if (strcmp(view.GetViewId(), "labelButton1_exit") == 0) //稍后再说 + // { + // NativeAbility::GetInstance().ChangeSlice(VIEW_SETTING); + // } + return true; + } + + bool SystemPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件 + { + UNUSED(view); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemPresenter::OnKeyAct"); + uint16 keyID = event.GetKeyId(); + uint16 keyState = event.GetState(); + // 如果是power键,且是亮屏状态,按键释放就返回上一级 + if (keyID == static_cast(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0) + { + if (!isShutDownImageAnimatorStart) + { + NativeAbility::GetInstance().Back(); + } + } + return true; + } + + // void SystemPresenter::set_key_falg(bool falg) // 增加按键事件 + // { + // isSystemUpgradeState = falg; + // } +#ifdef __cplusplus +#if __cplusplus + extern "C" + { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + + void factorytest_enter_test_view(int cmd) + { + if (cmd == 1) + NativeAbility::GetInstance().ChangeSlice(VIEW_TEST); + else + NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN); + } + +#ifdef __cplusplus +#if __cplusplus + } +#endif /* __cplusplus */ +#endif /* __cplusplus */ +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemRestart.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemRestart.cpp new file mode 100644 index 000000000..4efd295b4 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemRestart.cpp @@ -0,0 +1,168 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-08-28 17:30:10 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-28 19:25:08 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemRestart.cpp + */ +#include "system/include/SystemRestart.h" +#include "system/include/SystemPresenter.h" +#include "ui_resource_string.h" +#include "UiConfig.h" +namespace OHOS +{ + SystemRestart::SystemRestart() + { + } + + SystemRestart::~SystemRestart() + { + ClearAll(); + } + + void SystemRestart::ClearAll(void) + { + if (SystemRestartScrollView) + { + SystemRestartScrollView->RemoveAll(); + + if (title) + { + delete title; + title = nullptr; + } + if (note) + { + delete note; + note = nullptr; + } + if (image) + { + delete image; + image = nullptr; + } + if (button_ensure) + { + delete button_ensure; + button_ensure = nullptr; + } + if (button_cancel) + { + delete button_cancel; + button_cancel = nullptr; + } + delete SystemRestartScrollView; + SystemRestartScrollView = nullptr; + } + } + UIScrollView *SystemRestart::SystemRestartViewInit(void) + { + if (SystemRestartScrollView == nullptr) + { + SystemRestartScrollView = new UIScrollView(); + if (SystemRestartScrollView == nullptr) + { + return nullptr; + } + SystemRestartScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemRestartScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); + if (draglistener == nullptr) + { + return nullptr; + } + SystemRestartScrollView->SetOnDragListener(draglistener); + SystemRestartScrollView->SetTouchable(true); + SystemRestartScrollView->SetDraggable(true); + /* -------------------------------------------------------------------------- */ + if (title == nullptr) + { + title = new UILabelExt(); + if (title == nullptr) + { + return nullptr; + } + title->SetPosition(83, 50, 300, 35); // 位置 + title->SetStyle(STYLE_TEXT_FONT, 30); // 字体大小 + title->SetStyle(STYLE_LINE_HEIGHT, 35); // 字体行高 + title->SetTextId(STR_RESTART); // 内容 + title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + title->SetRollSpeed(23); + title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + SystemRestartScrollView->Add(title); + } + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + return nullptr; + } + image->SetPosition(193, 120, 80, 80); + image->SetSrc("/user/res/settings/SETTTING_REBOOT.bin"); + } + SystemRestartScrollView->Add(image); + /* -------------------------------------------------------------------------- */ + if (note == nullptr) + { + note = new UILabelExt(); + if (note == nullptr) + { + return nullptr; + } + note->SetPosition(53, 232, 360, 35); // 位置 + note->SetStyle(STYLE_TEXT_FONT, 30); // 字体大小 + note->SetStyle(STYLE_LINE_HEIGHT, 35); // 字体行高 + note->SetTextId(STR_RESET_CONFIRM); + note->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + note->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + note->SetRollSpeed(23); + note->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + SystemRestartScrollView->Add(note); + } + /* -------------------------------------------------------------------------- */ + button_cancel = new UIButton(); + if (button_cancel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemRestart::new button_cancel fail!"); + return nullptr; + } + button_cancel->SetPosition(97, 299, 130, 130); + button_cancel->SetViewId(RESTARTVIEW_CHECKOFF); + button_cancel->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button_cancel->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button_cancel->SetImagePosition(15, 15); + button_cancel->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + button_cancel->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button_cancel->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, PNG_SYSTEM_CHECK_OFF_IMAGE); + SystemRestartScrollView->Add(button_cancel); + /* ------------------------ button_ensure ----------------------- */ + button_ensure = new UIButton(); + if (button_ensure == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemRestart::new button_ensure fail!"); + return nullptr; + } + button_ensure->SetPosition(240, 299, 130, 130); + button_ensure->SetViewId(RESTARTVIEW_CHECKON); + button_ensure->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button_ensure->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button_ensure->SetImagePosition(15, 15); + button_ensure->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + button_ensure->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button_ensure->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, PNG_SYSTEM_CHECK_ON_IMAGE); + SystemRestartScrollView->Add(button_ensure); + UIView::OnClickListener *ButtonOnClick = static_cast(SystemPresenter::GetInstance()); + if (ButtonOnClick == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemRestart::ButtonOnClick is nullptr!"); + return nullptr; + } + button_cancel->SetOnClickListener(ButtonOnClick); + button_ensure->SetOnClickListener(ButtonOnClick); + } + return SystemRestartScrollView; + } +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemShutdown.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemShutdown.cpp new file mode 100644 index 000000000..3d407ca48 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemShutdown.cpp @@ -0,0 +1,168 @@ +/* + * @Author: luozheng 1732036298@qq.com + * @Date: 2024-08-28 17:30:10 + * @LastEditors: luozheng 1732036298@qq.com + * @LastEditTime: 2024-08-28 18:49:19 + * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/src/SystemShutdown.cpp + */ +#include "system/include/SystemShutdown.h" +#include "UiConfig.h" +#include "system/include/SystemPresenter.h" +#include "ui_resource_string.h" +namespace OHOS +{ + SystemShutdown::SystemShutdown() + { + } + + SystemShutdown::~SystemShutdown() + { + ClearAll(); + } + + void SystemShutdown::ClearAll(void) + { + if (SystemShutdownScrollView) + { + SystemShutdownScrollView->RemoveAll(); + + if (title) + { + delete title; + title = nullptr; + } + if (note) + { + delete note; + note = nullptr; + } + if (image) + { + delete image; + image = nullptr; + } + if (button_ensure) + { + delete button_ensure; + button_ensure = nullptr; + } + if (button_cancel) + { + delete button_cancel; + button_cancel = nullptr; + } + delete SystemShutdownScrollView; + SystemShutdownScrollView = nullptr; + } + } + UIScrollView *SystemShutdown::SystemShutdownViewInit(void) + { + if (SystemShutdownScrollView == nullptr) + { + SystemShutdownScrollView = new UIScrollView(); + if (SystemShutdownScrollView == nullptr) + { + return nullptr; + } + SystemShutdownScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemShutdownScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); + if (draglistener == nullptr) + { + return nullptr; + } + SystemShutdownScrollView->SetOnDragListener(draglistener); + SystemShutdownScrollView->SetTouchable(true); + SystemShutdownScrollView->SetDraggable(true); + /* -------------------------------------------------------------------------- */ + if (title == nullptr) + { + title = new UILabelExt(); + if (title == nullptr) + { + return nullptr; + } + title->SetPosition(83, 50, 300, 35); // 位置 + title->SetStyle(STYLE_TEXT_FONT, 30); // 字体大小 + title->SetStyle(STYLE_LINE_HEIGHT, 35); // 字体行高 + title->SetTextId(STR_SHUTDOWN); // 内容 + title->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + title->SetRollSpeed(23); + title->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + SystemShutdownScrollView->Add(title); + } + /* -------------------------------------------------------------------------- */ + if (image == nullptr) + { + image = new UIImageView(); + if (image == nullptr) + { + return nullptr; + } + image->SetPosition(196, 120, 74, 80); + image->SetSrc("/user/res/settings/SETTTING_SHUTDOWN.bin"); + } + SystemShutdownScrollView->Add(image); + /* -------------------------------------------------------------------------- */ + if (note == nullptr) + { + note = new UILabelExt(); + if (note == nullptr) + { + return nullptr; + } + note->SetPosition(53, 232, 360, 35); // 位置 + note->SetStyle(STYLE_TEXT_FONT, 30); // 字体大小 + note->SetStyle(STYLE_LINE_HEIGHT, 35); // 字体行高 + note->SetTextId(STR_SHUTDOWN_CONFIRM); + note->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION); + note->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + note->SetRollSpeed(23); + note->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + SystemShutdownScrollView->Add(note); + } + /* -------------------------------------------------------------------------- */ + button_cancel = new UIButton(); + if (button_cancel == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemShutdown::new button_cancel fail!"); + return nullptr; + } + button_cancel->SetPosition(97, 299, 130, 130); + button_cancel->SetViewId(SHUTDOWN_CHECKOFF); + button_cancel->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button_cancel->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button_cancel->SetImagePosition(15, 15); + button_cancel->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + button_cancel->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button_cancel->SetImageSrc(PNG_SYSTEM_CHECK_OFF_IMAGE, PNG_SYSTEM_CHECK_OFF_IMAGE); + SystemShutdownScrollView->Add(button_cancel); + /* ------------------------ button_ensure ----------------------- */ + button_ensure = new UIButton(); + if (button_ensure == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemShutdown::new button_ensure fail!"); + return nullptr; + } + button_ensure->SetPosition(240, 299, 130, 130); + button_ensure->SetViewId(SHUTDOWN_CHECKON); + button_ensure->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff); + button_ensure->SetStyle(STYLE_BACKGROUND_OPA, 0x00); + button_ensure->SetImagePosition(15, 15); + button_ensure->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff191919, UIButton::PRESSED); + button_ensure->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED); + button_ensure->SetImageSrc(PNG_SYSTEM_CHECK_ON_IMAGE, PNG_SYSTEM_CHECK_ON_IMAGE); + SystemShutdownScrollView->Add(button_ensure); + UIView::OnClickListener *ButtonOnClick = static_cast(SystemPresenter::GetInstance()); + if (ButtonOnClick == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemShutdown::ButtonOnClick is nullptr!"); + return nullptr; + } + button_cancel->SetOnClickListener(ButtonOnClick); + button_ensure->SetOnClickListener(ButtonOnClick); + } + return SystemShutdownScrollView; + } +} diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemSuperviseView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemSuperviseView.cpp new file mode 100644 index 000000000..79cbfc0ea --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemSuperviseView.cpp @@ -0,0 +1,137 @@ +#include "system/include/SystemSuperviseView.h" +#include "system/include/SystemPresenter.h" +#include "wearable_log.h" +namespace OHOS +{ + + static SystemSuperviseView *g_pSystemSuperviseView{nullptr}; + + SystemSuperviseView::SystemSuperviseView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemSuperviseView::SystemSuperviseView"); + g_pSystemSuperviseView = this; + } + + SystemSuperviseView::~SystemSuperviseView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemSuperviseView::~SystemSuperviseView"); + ClearAll(); + g_pSystemSuperviseView = nullptr; + } + + SystemSuperviseView *SystemSuperviseView::GetInstance() + { + return g_pSystemSuperviseView; + } + + void SystemSuperviseView::ClearAll() + { + if (initViewStatus == true) + { + SystemSuperviseViewScrollView->RemoveAll(); + delete Title; + Title = nullptr; + delete ProductModel; + ProductModel = nullptr; + delete ProductModelName; + ProductModelName = nullptr; + delete CMIT; + CMIT = nullptr; + delete CMITName; + CMITName = nullptr; + delete SystemSuperviseViewScrollView; + SystemSuperviseViewScrollView = nullptr; + } + } + + UILabel *SystemSuperviseView::InitLabel(int left, int top, int width, int height, const char *text, const char *viewId, int fontSize, int fontlineHeigh, uint16_t speed) + { + UILabel *label = new UILabel(); + label->SetPosition(left, top); // 位置 + label->Resize(width, height); // 大小 + label->SetViewId(viewId); // id + label->SetStyle(STYLE_TEXT_FONT, fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, fontlineHeigh); // 字体行高 + label->SetText(text); // 内容 + label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label->SetRollSpeed(speed); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, fontSize); + + return label; + } + + UIScrollView *SystemSuperviseView::SystemSuperviseViewInit() + { + if (SystemSuperviseViewScrollView == nullptr) + { + SystemSuperviseViewScrollView = new UIScrollView(); + } + SystemSuperviseViewScrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemSuperviseViewScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemSuperviseViewScrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); + if (draglistener == nullptr) + { + return nullptr; + } + SystemSuperviseViewScrollView->SetOnDragListener(draglistener); + SystemSuperviseViewScrollView->SetTouchable(true); + SystemSuperviseViewScrollView->SetDraggable(true); + /* -------------------------------------------------------------------------- */ + if (Title == nullptr) + { + Title = InitLabel(203, 52, 60, 35, "监管", "Title", 30, 35, 6); + } + SystemSuperviseViewScrollView->Add(Title); + /* -------------------------------------------------------------------------- */ + if (ProductModel == nullptr) + { + ProductModel = InitLabel(203, 164, 60, 35, "型号", "ProductModel", 30, 35, 6); + } + SystemSuperviseViewScrollView->Add(ProductModel); + /* -------------------------------------------------------------------------- */ + ProductModelName = new UILabel(); + if (ProductModelName == nullptr) + { + return nullptr; + } + ProductModelName->SetPosition(37, 221, 400, 30); // 位置大小 + ProductModelName->SetStyle(STYLE_TEXT_FONT, 26); // 字体大小 + ProductModelName->SetStyle(STYLE_LINE_HEIGHT, 30); // 字体行高 + #ifdef CUSTOM_Z1 + ProductModelName->SetText("Z1"); // 内容 + #else + ProductModelName->SetText("Watch Soar"); // 内容 + #endif + ProductModelName->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); // 断行模式。 + ProductModelName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + ProductModelName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + ProductModelName->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemSuperviseViewScrollView->Add(ProductModelName); + /* -------------------------------------------------------------------------- */ + if (CMIT == nullptr) + { + CMIT = InitLabel(198, 310, 71, 35, "CMIT", "CMIT", 30, 35, 6); + } + SystemSuperviseViewScrollView->Add(CMIT); + /* -------------------------------------------------------------------------- */ + CMITName = new UILabel(); + if (CMITName == nullptr) + { + return nullptr; + } + CMITName->SetPosition(37, 367, 400, 30); // 位置大小 + CMITName->SetStyle(STYLE_TEXT_FONT, 26); // 字体大小 + CMITName->SetStyle(STYLE_LINE_HEIGHT, 30); // 字体行高 + CMITName->SetText("V1.0"); // 内容 + CMITName->SetLineBreakMode(UILabel::LINE_BREAK_ELLIPSIS); // 断行模式。 + CMITName->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + CMITName->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30); + CMITName->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + SystemSuperviseViewScrollView->Add(CMITName); + initViewStatus = true; + return SystemSuperviseViewScrollView; + } + +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemView.cpp new file mode 100644 index 000000000..779e1dcdd --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/SystemView.cpp @@ -0,0 +1,533 @@ +#include "system/include/SystemView.h" +#include "system/include/SystemPresenter.h" +#include "wearable_log.h" + +#ifdef SUPPORT_BLE_SERVICE +#include +#include "bleService.h" +#endif + +// #include "battery_hal.h" +// extern uint8_t battery_get_voltage(float *voltage); + +#include "UiConfig.h" + + + +#include "ui_resource_string.h" + +#include "systemupdate/include/SystemUpdateModel.h" +namespace OHOS +{ + static SystemView *g_pSystemView{nullptr}; + + SystemView::SystemView() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::SystemView"); + g_pSystemView = this; + } + + SystemView::~SystemView() + { + ClearAll(); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::~SystemView"); + g_pSystemView = nullptr; + } + + SystemView *SystemView::GetInstance() + { + return g_pSystemView; + } + + void SystemView::ClearAll() + { + + + if (viewInitStatus) + { + if (SystemScrollView[SYSTEMVIEW] != nullptr) + { + SystemScrollView[SYSTEMVIEW]->RemoveAll(); + if (Title != nullptr) + { + delete Title; + Title = nullptr; + } + for (int i = 0; i < sizeof(SystemViewLabelButton) / sizeof(SystemViewLabelButton[0]); i++) + { + if (SystemViewLabelButton[i] != nullptr) + { + delete SystemViewLabelButton[i]; + SystemViewLabelButton[i] = nullptr; + } + + if (SystemViewLabel[i] != nullptr) + { + delete SystemViewLabel[i]; + SystemViewLabel[i] = nullptr; + } + } + if (NeedToUpdateImage != nullptr) + { + delete NeedToUpdateImage; + NeedToUpdateImage = nullptr; + } + if (temp != nullptr) + { + delete temp; + temp = nullptr; + } + delete SystemScrollView[SYSTEMVIEW]; + SystemScrollView[SYSTEMVIEW] = nullptr; + } + } + if (p_SystemAboutTheWatchView != nullptr) + { + delete p_SystemAboutTheWatchView; + p_SystemAboutTheWatchView = nullptr; + } + if (p_SystemRestart != nullptr) + { + delete p_SystemRestart; + p_SystemRestart = nullptr; + } + if (p_SystemShutdown != nullptr) + { + delete p_SystemShutdown; + p_SystemShutdown = nullptr; + } + if (p_SystemFactoryResetView != nullptr) + { + delete p_SystemFactoryResetView; + p_SystemFactoryResetView = nullptr; + } + if (p_ShutDownImageAnimatorView != nullptr) + { + delete p_ShutDownImageAnimatorView; + p_ShutDownImageAnimatorView = nullptr; + } + for (int i = SYSTEMVIEW; i < MAX_SYSTEMVIEWID; i++) + { + SystemScrollView[i] = nullptr; + } + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::ClearAll end!!"); + } + + UILabelButtonExt *SystemView::SystemViewLabelButtonInit(ButtonConfig &buttonconfig) + { + UILabelButtonExt *labelButton = new UILabelButtonExt(); + if (labelButton == nullptr) + { + return nullptr; + } + labelButton->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h); + labelButton->SetViewId(buttonconfig.viewId); + labelButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + labelButton->SetImageSrc(PNG_SETTING_NEXT_IMAGE, PNG_SETTING_NEXT_IMAGE); + labelButton->SetImagePosition(326, 37); + labelButton->SetStyleForState(STYLE_BACKGROUND_COLOR, 0xff000000, UIButton::PRESSED); + labelButton->SetOnClickListener(presenter_); + + return labelButton; + } + + UILabelExt *SystemView::SystemViewLabelInit(LabelConfig &labelconfig) + { + UILabelExt *label = new UILabelExt(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelconfig.left, labelconfig.top, labelconfig.width, labelconfig.height); + label->SetStyle(STYLE_TEXT_FONT, labelconfig.fontSize); + label->SetStyle(STYLE_LINE_HEIGHT, labelconfig.lineHeigh); + label->SetTextId(labelconfig.textId); + label->SetLineBreakMode(labelconfig.lineBreakMode); + label->SetRollSpeed(23); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize); + return label; + } + + bool SystemView::CreateSystemViewLabel(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemViewLabel"); + LabelConfig labelConfig = { + .left = 83, + .top = 50, + .width = 300, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_SYSTEM, /*系统*/ + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + Title = SystemViewLabelInit(labelConfig); + if (Title == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::Title"); + return false; + } + Title->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + SystemScrollView[SYSTEMVIEW]->Add(Title); + /* -------------------------------------------------------------------------- */ + struct LabelSetup + { + int16_t y; + const int16_t textId; + }; + + LabelSetup labelSetups[] = { + {153, STR_ABOUT_WATCH}, + // {273, STR_SYSTEM_UPDATE}, + {273, STR_TIME_FORMAT_SET}, + {393, STR_WATCH_QR_CODE}, + {513, STR_SYSTEM_LANGUAGE}, + {633, STR_RESTART}, + {753, STR_SHUTDOWN}, + {873, STR_FACTORY_RESET}, + }; + labelConfig = { + .left = 90, + .top = 153, + .width = 240, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .textId = STR_ABOUT_WATCH, + .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION, + }; + int pos_y = 153; + SystemViewLabelNum = sizeof(labelSetups) / sizeof(labelSetups[0]); + for (int i = 0; i < SystemViewLabelNum; ++i) + { + + labelConfig.top = pos_y + 120*i; + labelConfig.textId = labelSetups[i].textId; + SystemViewLabel[i] = SystemViewLabelInit(labelConfig); + if (SystemViewLabel[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::SystemViewLabel[%d] new fail!", i); + return false; + } + SystemScrollView[SYSTEMVIEW]->Add(SystemViewLabel[i]); + } + + return true; + } + + bool SystemView::CreateSystemViewLabelButton(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemViewLabelButton"); + struct ButtonSetup + { + int y; + const char *viewId; + }; + ButtonSetup buttonSetups[] = { + {120, ABOUT_THE_WATCH}, + // {240, SYSTEM_UPGRADE}, + {300, SET_TIME_FORMAT}, + {360, WATCH_QR_CODE}, + {480, SYSTEM_LANGUAGE}, + {600, RESTART}, + {720, SHUTDOWN}, + {840, FACTORY_RESET}, + }; + + int pos_y = 120; + SystemViewButtonNum = sizeof(buttonSetups) / sizeof(buttonSetups[0]); + for (int i = 0; i < SystemViewButtonNum; ++i) + { + ButtonConfig buttonconfig = { + .x = 43, + // .y = buttonSetups[i].y, + .y = pos_y + 120*i, + .w = 380, + .h = 100, + .viewId = buttonSetups[i].viewId, + }; + SystemViewLabelButton[i] = SystemViewLabelButtonInit(buttonconfig); + if (SystemViewLabelButton[i] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SoundAndVibrationView::Button[%d] new fail!", i); + return false; + } + SystemScrollView[SYSTEMVIEW]->Add(SystemViewLabelButton[i]); + } + + return true; + } + + bool SystemView::CreateSystemScrollView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemScrollView"); + SystemScrollView[SYSTEMVIEW] = new UIScrollView(); + if (SystemScrollView[SYSTEMVIEW] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemScrollView new fail!"); + return false; + } + SystemScrollView[SYSTEMVIEW]->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + SystemScrollView[SYSTEMVIEW]->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + SystemScrollView[SYSTEMVIEW]->SetScrollBlankSize(30); + SystemScrollView[SYSTEMVIEW]->SetReboundSize(30); + SystemScrollView[SYSTEMVIEW]->SetDirection(1); + SystemScrollView[SYSTEMVIEW]->SetThrowDrag(true); // 设置手指抬起屏幕后是否继续滚动。 + SystemScrollView[SYSTEMVIEW]->SetMaxScrollDistance(1000); // 设置手指抬起屏幕后的最大滚动距离。 + SystemScrollView[SYSTEMVIEW]->SetSwipeACCLevel(200); /*设置手指抬起屏幕后的补偿距离。*/ + FocusManager::GetInstance()->RequestFocus(SystemScrollView[SYSTEMVIEW]); + FocusManager::GetInstance()->RequestFocusByDirection(FOCUS_DIRECTION_UP); + SystemScrollView[SYSTEMVIEW]->SetRotateFactor(1.0); + SystemScrollView[SYSTEMVIEW]->SetOnDragListener(presenter_); + SystemScrollView[SYSTEMVIEW]->SetTouchable(true); + SystemScrollView[SYSTEMVIEW]->SetDraggable(true); + + return true; + } + + /*需要更新的红点图片初始化*/ + void SystemView::NeedToUpdateImageinit(void) + { + if (NeedToUpdateImage == nullptr) + { + NeedToUpdateImage = new UIImageView(); + if (NeedToUpdateImage == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemView"); + return; + } + NeedToUpdateImage->SetPosition(323, 280, 20, 20); + NeedToUpdateImage->SetStyle(STYLE_BORDER_RADIUS, 200); + const char *imagesPath = "/user/res/system/SYSTEM_UPDATE_FLAG.bin"; + NeedToUpdateImage->SetSrc(imagesPath); + + SystemScrollView[SYSTEMVIEW]->Add(NeedToUpdateImage); + } + } + + void SystemView::CreateSystemView(void) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemView"); + if (!CreateSystemScrollView() || !CreateSystemViewLabelButton() || !CreateSystemViewLabel()) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::CreateSystemView fail!!"); + return; + } + /* ------------------- 该组件的使用是为了解决不能单独设置滚动视图底部空白大小问题,用一个不可见组件占位置 ------------------ */ + /* ---------------------------- 因为使用SetScrollBlankSize设置过大后,下拉后无法恢复到原位置,有明显的向下偏移 --------------------------- */ + if (temp == nullptr) + { + temp = new UIImageView(); + if (temp == nullptr) + { + return; + } + temp->SetPosition(43, (SystemViewButtonNum + 1) * 120, 380, 40); + temp->SetVisible(false); + SystemScrollView[SYSTEMVIEW]->Add(temp); + } + viewInitStatus = true; + } + + void SystemView::OnStart() + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::OnStart"); + + + if (!viewInitStatus) + { + CreateSystemView(); + } + + RootView::GetInstance()->SetOnKeyActListener(presenter_); + + if (SystemScrollView[SYSTEMVIEW] == nullptr) + { + return; + } + if (SystemUpdateModel::GetInstance().IsLatestVersion() == false) // 如果不是最新系统版本出现小圆点 + { + NeedToUpdateImageinit(); + } + AddViewToRootContainer(SystemScrollView[SYSTEMVIEW]); + } + + + + + // 0.跳转到系统视图,其他视图都市通过这个视图跳转 + bool SystemView::ChangeToSystemView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeToSystemView"); + AddViewToRootContainer(SystemScrollView[thisView]); + } + return true; + } + + // 1.跳转到关于手表 + bool SystemView::ChangeToSystemAboutView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeToSystemAboutView"); + p_SystemAboutTheWatchView = new SystemAboutTheWatchView(); + if (p_SystemAboutTheWatchView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = p_SystemAboutTheWatchView->SystemAbouTheWatchtInitIView(); + AddViewToRootContainer(SystemScrollView[thisView]); + } + return true; + } + + // 3.跳转到恢复出厂设置界面 + bool SystemView::ChangeToSystemFactoryResetView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeToSystemFactoryResetView"); + p_SystemFactoryResetView = new SystemFactoryResetView(); + if (p_SystemFactoryResetView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = p_SystemFactoryResetView->SystemFactoryResetViewInit(); + AddViewToRootContainer(SystemScrollView[thisView]); + } + return true; + } + + // 重启 + bool SystemView::ChangeToSystemRestartView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeToSystemRestartView"); + p_SystemRestart = new SystemRestart(); + if (p_SystemRestart == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = p_SystemRestart->SystemRestartViewInit(); + AddViewToRootContainer(SystemScrollView[thisView]); + } + return true; + } + + // 关机 + bool SystemView::ChangeToSystemShutdownView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeToSystemShutdownView"); + p_SystemShutdown = new SystemShutdown(); + if (p_SystemShutdown == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = p_SystemShutdown->SystemShutdownViewInit(); + AddViewToRootContainer(SystemScrollView[thisView]); + } + return true; + } + + // 关机动画 + bool SystemView::ChangeToSystemShutdownAnimatorView(int16_t thisView) + { + if (SystemScrollView[thisView] == nullptr) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "SystemView::ChangeToSystemShutdownAnimatorView"); + p_ShutDownImageAnimatorView = new ShutDownImageAnimatorView(); + if (p_ShutDownImageAnimatorView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: new scrollView[%d] fail", thisView); + return false; + } + SystemScrollView[thisView] = static_cast(p_ShutDownImageAnimatorView->ShutDownAnimatorViewInit()); + AddViewToRootContainer(SystemScrollView[thisView]); + } + return true; + } + + struct SystemViewMapper + { + const int16_t viewId; + bool (SystemView::*func)(int16_t thisView); + }; + + static const SystemViewMapper ViewMapper[] = { + {SYSTEMVIEW, &SystemView::ChangeToSystemView}, + {ABOUTTHEWATCHVIEW, &SystemView::ChangeToSystemAboutView}, + {FACTORYRESETVIEW, &SystemView::ChangeToSystemFactoryResetView}, + {RESTARTVIEW, &SystemView::ChangeToSystemRestartView}, + {SHUTDOWNVIEW, &SystemView::ChangeToSystemShutdownView}, + {SHUTDOWNANIMATIONVIEW, &SystemView::ChangeToSystemShutdownAnimatorView}, + }; + + // 根据传入的interface参数执行相应视图ID关联的成员函数。 + bool SystemView::ClickFunc(int16_t interface) + { + int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[SYSTEMVIEW]); + 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; + } + + /*检查传入的两个视图参数 hideView 和 showView 的有效性。*/ + bool SystemView::CheckViewParam(int16_t hideView, int16_t showView) + { + if (showView < 0 || showView >= MAX_SYSTEMVIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::CheckViewParam showView err."); + return false; + } + + if (hideView < 0 || hideView > MAX_SYSTEMVIEWID) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::CheckViewParam hideView err."); + return false; + } + + return true; + } + + // 切换视图 + void SystemView::ChangeView(int16_t hideView, int16_t showView) + { + if (!CheckViewParam(hideView, showView)) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::CheckViewParam failed."); + return; + } + SystemScrollView[hideView]->SetVisible(false); + ClickFunc(showView); + SystemScrollView[showView]->SetVisible(true); + Draw(); + } + + UIScrollView *SystemView::GetSystemScrollView(int ViewId) + { + if (SystemScrollView[ViewId] == nullptr) + { + return nullptr; + } + return SystemScrollView[ViewId]; + } +} \ No newline at end of file diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/Systemupgrade.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/Systemupgrade.cpp new file mode 100644 index 000000000..0d3afcc32 --- /dev/null +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/system/src/Systemupgrade.cpp @@ -0,0 +1,952 @@ +#include "system/include/Systemupgrade.h" +#include "system/include/SystemPresenter.h" +#include "wearable_log.h" +#include "UiConfig.h" +#include "custom_utils.h" +#include "stdio.h" +#include +#include +#include "cJSON.h" +#include "ConfigModel.h" +#include "lwip/err.h" +#include "power_display_service.h" +#include "cmsis_os2.h" +#include "los_memory.h" +#include "thread_init.h" + #include "lwip/apps/http_client.h" + #include "tcxo.h" + #include "cat1_server.h" + #include "linux/delay.h" + +//http://r-oss.thisiot.com/device-ota/2024_05_06/1787425705369333762.fwpkg?Expires=1714998097&OSSAccessKeyId=LTAI5tJa2arDBmqSUsSTQJ1T&Signature=eLmtuPN10YXS8pNUtJO2E2vt%2FPM%3D + + +//https://test.app.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion + +//http://test.iot.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion +namespace OHOS +{ + + + static SystemupgradeView *g_pSystemFactoryResetView{nullptr}; + static osThreadId_t g_alipay_task_handle = NULL; + //static char * imei_str="864430010001091"; +// osThreadAttr_t g_alipay_attr = { +// "alipay_task", 0, NULL, 0, NULL, ALIPAT_MSG_STACK_SIZE, TASK_PRIORITY_ALIPAY_APP, 0, 0 +// }; + static char *Path=UPDATAJSONPATH; + static httpc_connection_t settings = {0}; + static uint8_t uri[256] ={0};// (uint8_t*) + //"http://icfota.snicker.com.cn:8089/fd230ota.jsp?product=FD230&pkgver=V1.1_20240316_115535&imei=864430010001091"; + + static char *Path_ota_package= UPDATAFWPKGPATH; + static uint8_t uri_ota_package[256] ={0}; + static const char *imei_str=NULL; + static char *report_jsonString=NULL; + static uint32_t file_total_len = 0; + static err_t httpc_download_headers_done_ui(httpc_state_t *connection, void *arg, struct pbuf *hdr, u16_t hdr_len, u32_t content_len) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_headers_done_ui hdrlen %d, file len %d\r\n",hdr_len,content_len); + file_total_len = content_len; + return 0; + } + static err_t httpc_download_file_recv_ui(httpc_state_t *connection, u32_t rx_len,u32_t rx_total_len) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_file_recv_ui recv %d bytes total received %d filelen %d\r\n",rx_len,rx_total_len,file_total_len); + return 0; + } + + static void httpc_download_result_report_data(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, u32_t srv_res, err_t err) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"httpc_download_result , httpc_result_t %d, rx_content_len %d , srv_res %d, err %d\n", + httpc_result,rx_content_len,srv_res,err); + if(srv_res==200 && err==0) + remove(UPDATAREPORT); + + return ; + } + + + + + // // httpc_get_file( + // const ip_addr_t* server_addr, + // u16_t port, + // const char* uri, + // const httpc_connection_t *settings, + // // // altcp_recv_fn recv_fn, + // void* callback_arg, httpc_state_t **connection) + + static void report_data_by_get_file(char *data,u16_t data_len) + { + settings.use_proxy=0; + + settings.use_post=1; + settings.args=(u8_t*)data; + settings.arglen=data_len; + uint8_t *otadatapath =(uint8_t *)UPDATAREPORT_; + + settings.result_fn=httpc_download_result_report_data; + settings.file_rx_fn = httpc_download_file_recv_ui; + settings.headers_done_fn = httpc_download_headers_done_ui; + + httpc_state_t* connection=NULL; + err_t rett= httpc_get_file_dns_to_disk( + HTTP_JSON_SERVER_NAME, + PORT, + POST_URL, + &settings, + NULL, + (const char*) otadatapath, + &connection); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"custom_start_ota_download %d \r\n",rett); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "use_post_"); + } + //#define UP_TEST + static void upgrade_task(void *arg) + { + + // msleep(3000); + //uapi_tcxo_delay_ms(3000); + + + FILE * fp = fopen(Path,"rb+"); + if(fp==NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "open fail"); + if(SystemupgradeView::GetInstance()) + SystemupgradeView::GetInstance()->set_string_value(NULL,false); + return; + } + char *buf=(char *)malloc(1024); + memset((void*)buf,0,1024); + int ret =fread(buf,1,1024,fp); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui %d %s\r\n",ret,buf); + if(ret==0) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "fread %d",ret); + fclose(fp); + free(buf); + if(SystemupgradeView::GetInstance()) + SystemupgradeView::GetInstance()->set_string_value(NULL,false); + return; + } + + // std::string jsonDataString((std::istreambuf_iterator(inFile)), std::istreambuf_iterator()); + // const char *jsonData = jsonDataString.c_str(); + // char *new_buf=NULL; + // new_buf=strstr(buf,"{\"success\":");//移到json的头的位置 + cJSON *root = cJSON_Parse(buf); + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " %s",new_buf); + free(buf); + if(root==NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui JSON_parse_fail"); + } + else if(root!=NULL) + { + + int code=cJSON_GetObjectItem(root, "code")->valueint; + + //char *uri = cJSON_GetObjectItem(root, "url")->valuestring; + // + //char *OtaPackageVersion = cJSON_GetObjectItem(root, "OtaPackageVersion")->valuestring; + char *msg = cJSON_GetObjectItem(root, "msg")->valuestring; + // if(msg==NULL) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "msg????????????????"); + // } + // else + // //WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",msg); + int success=cJSON_GetObjectItem(root, "success")->valueint; + + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s,%s",uri,OtaPackageVersion); + // //SystemupgradeView::GetInstance()->newVersion->SetText(OtaPackageVersion); + // cJSON_Delete(root); + char msg_buf[256]={0}; + bool falg=false; + + + + sprintf(msg_buf,"%s",msg); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s",msg); + if(SystemupgradeView::GetInstance()) + SystemupgradeView::GetInstance()->set_string_value(msg_buf,falg); + + //RootView::GetInstance()->Invalidate(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui"); + cJSON_Delete(root); + + } + fclose(fp); + + + } + + static void upgrade_task_fwpkg(void *arg) + { + + // msleep(3000); + FILE * fp = fopen(Path_ota_package,"rb"); + if(fp!=NULL) + { + fclose(fp); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file open success fwpkg_is_ready"); + } + errcode_t ret=uaip_cmd_update_request(); + if(ret!=ERRCODE_SUCC) + { + SystemupgradeView::GetInstance()->init_fail(0); + } + + //开始升级 + //********** + + } + + // void create_ppg_queue(void) + // { + // if (osal_msg_queue_create("ppg_service_queue", 10, &g_app_queue, + // 0, sizeof(PPG_CMD_TYPE_T)) != ERRCODE_SUCC) { + // PRINT_ERR("[ppg][service] app create mail fail\n"); + // } + // } + + errcode_t upgrade_service_service_init(void) + { + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_ppg_service_init !\r\n"); + app_task_definition_t taskcfg={0}; + taskcfg.create_queue_handle = NULL; + taskcfg.attr.name="upgrade_service"; + taskcfg.attr.priority = TASK_PRIORITY_APP; + taskcfg.attr.stack_size = 1024*10; + taskcfg.func = upgrade_task; + taskcfg.use_mem = USE_EXTEND_MEM; + + errcode_t ret=uapi_create_osThread_custom(&taskcfg); + if(ret != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"create ppg_service failed %d!\r\n",ret); + return ERRCODE_FAIL; + } + + return ERRCODE_SUCC; + } + + errcode_t upgrade_service_service_init_packpage(void) + { + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"uapi_ppg_service_init !\r\n"); + app_task_definition_t taskcfg={0}; + taskcfg.create_queue_handle = NULL; + taskcfg.attr.name="upgrade_service_ota_fwpkg"; + taskcfg.attr.priority = TASK_PRIORITY_APP; + taskcfg.attr.stack_size = 1024*8; + taskcfg.func = upgrade_task_fwpkg; + taskcfg.use_mem = USE_EXTEND_MEM; + + errcode_t ret=uapi_create_osThread_custom(&taskcfg); + if(ret != ERRCODE_SUCC) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"create ppg_service failed %d!\r\n",ret); + return ERRCODE_FAIL; + } + + return ERRCODE_SUCC; + } + + + + + static void httpc_download_result_ui_packpage(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, u32_t srv_res, err_t err) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"httpc_download_result , httpc_result_t %d, rx_content_len %d , srv_res %d, err %d\n", + httpc_result,rx_content_len,srv_res,err); + cat1_api_keep_wakeup(0); + if(httpc_result!=0) + { + SystemupgradeView::GetInstance()->init_fail(1); + return; + } + + + upgrade_service_service_init_packpage();//线程当timer用 + return ; + } + + + static void httpc_download_result_ui(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, u32_t srv_res, err_t err) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "httpc_download_result_ui"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"httpc_download_result , httpc_result_t %d, rx_content_len %d , srv_res %d, err %d\n", + httpc_result,rx_content_len,srv_res,err); + cat1_api_keep_wakeup(0); + upgrade_service_service_init();//线程当timer用 + + return ; + } + + //static osTimerId_t upgrade_timer=NULL; + + + static uint32_t custom_start_ota_download_ui_1( uint8_t *uri_str,uint8_t *Path,bool falg,const char *server_name) + { + + //(uint8_t*)argv[0]; + uint8_t *otadatapath = (uint8_t*)Path; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"custom_start_ota_download %s to %s\r\n",uri_str,otadatapath); + cat1_api_keep_wakeup(1); + if(falg) + { + settings.result_fn=httpc_download_result_ui; + } + else + { + settings.result_fn=httpc_download_result_ui_packpage; + } + + FILE * fp= fopen((char *)Path,"rb"); + if(fp!=NULL) + { + fclose(fp); + int ret= remove((char *)Path); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "file remove!!!!!!!!!!!!! %d ",ret); + } + + settings.file_rx_fn = httpc_download_file_recv_ui; + settings.headers_done_fn=httpc_download_headers_done_ui; + settings.use_post=0; + httpc_state_t* connection=NULL; + err_t rett = httpc_get_file_dns_to_disk( + server_name, + PORT, + (const char*) uri_str, + (const httpc_connection_t *)&settings, + NULL, + (const char*) otadatapath, + &connection); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"custom_start_ota_download %d \r\n",rett); + if(rett!=0) + { + if(SystemupgradeView::GetInstance()) + SystemupgradeView::GetInstance()->set_string_value(NULL,false); + } + + // SystemupgradeView::GetInstance()->init_fail(0); + return ERRCODE_SUCC; + } + + + + + + + //httpc_result_fn *result_fn; + + + SystemupgradeView::SystemupgradeView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::SystemFactoryResetView"); + g_pSystemFactoryResetView = this; + } + + SystemupgradeView::~SystemupgradeView() + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::~SystemFactoryResetView"); + ClearAll(); + g_pSystemFactoryResetView = nullptr; + } + + SystemupgradeView *SystemupgradeView::GetInstance() + { + return g_pSystemFactoryResetView; + } + + void SystemupgradeView::ClearAll() + { + // if (initViewStatus == true) + // { + if(scrollView) + { + scrollView->RemoveAll(); + if(container_fail) + { + container_fail->RemoveAll(); + if(label1_fail) + { + delete label1_fail; + } + label1_fail=nullptr; + + if(labelButton1_exit) + { + delete labelButton1_exit; + } + labelButton1_exit=nullptr; + + delete container_fail; + container_fail = nullptr; + } + if(container_updating) + { + container_updating->RemoveAll(); + if(label_updating) + { + delete label_updating; + } + label_updating=nullptr; + delete label_updating; + label_updating = nullptr; + } + if(newVersionTitle) + { + delete newVersionTitle; + } + newVersionTitle=nullptr; + + if(newVersion) + { + delete newVersion; + } + newVersion=nullptr; + + if(systemupgrade) + { + delete systemupgrade; + } + systemupgrade=nullptr; + + if(FirmwareVersionTitle) + { + delete FirmwareVersionTitle; + } + FirmwareVersionTitle=nullptr; + + if(FirmwareVersion) + { + delete FirmwareVersion; + } + FirmwareVersion=nullptr; + + if(new_label) + { + delete new_label; + } + new_label=nullptr; + + + if(SystemUpgradeButton_) + { + delete SystemUpgradeButton_; + } + SystemUpgradeButton_=nullptr; + + } + scrollView->RemoveAll(); + delete scrollView; + scrollView = nullptr; + + // const power_display_svr_api_t *display_api = power_display_svr_get_api(); + // if (display_api->get_screen_state() != SCREEN_ON) + // { + // display_api->turn_on_screen(); + // } + // int t=ConfigModel::GetInstance()->GetScreenDuration(); + // display_api->set_screen_set_keepon_timeout(t); + ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON); + // } + } + + + + UILabel *SystemupgradeView::InitLabel(LabelConfig &labelConfig) + { + UILabel *label = new UILabel(); + if (label == nullptr) + { + return nullptr; + } + label->SetPosition(labelConfig.left, labelConfig.top, labelConfig.width, labelConfig.height); // 位置大小 + label->SetStyle(STYLE_TEXT_FONT, labelConfig.fontSize); // 字体大小 + label->SetStyle(STYLE_LINE_HEIGHT, labelConfig.lineHeigh); // 字体行高 + label->SetText(labelConfig.text); // 内容 + label->SetLineBreakMode(labelConfig.lineBreakMode); // 断行模式。 + label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_TOP); + label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelConfig.fontSize); + return label; + } + void SystemupgradeView::statr_down_fwpkg(void) + { + // if(is_new_cat1_version) + // { + // char *imei_str= const_cast(ConfigModel::GetInstance()->Getimei().c_str()); + // char * version_buf=const_cast(ConfigModel::GetInstance()->GetmoderVer().c_str()); + // sprintf((char *)uri,"http://test.iot.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s",imei_str,version_buf); + // cat1_ota_update((char *)"0"); + // container_updating->SetVisible(true); + // scrollView->SetTouchable(false); + // scrollView->SetDraggable(false); + // } + // else + if(is_new_version) + { + //下载差分包 + // // //********** + container_updating->SetVisible(true); + scrollView->SetTouchable(false); + scrollView->SetDraggable(false); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "custom_start_ota_download_ui_1"); + custom_start_ota_download_ui_1(uri_ota_package,(uint8_t*)Path_ota_package,false,HTTP_FWPGK_SERVER_NAME); + if(report_jsonString!=NULL) + { + uint32_t data_len=strlen(report_jsonString); + if(data_len!=0) + { + FILE *FP_= fopen(UPDATAREPORT,"w+"); + printf("升级文件保存\r\n"); + fwrite(report_jsonString,1,data_len,FP_); + fclose(FP_); + printf("data%d %s\r\n",data_len,report_jsonString); + cJSON_free(report_jsonString); + report_jsonString=NULL; + } + + } + + + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, ""); + // upgrade_reported_data(); + } + } + + void SystemupgradeView::cat1_up_success(void) + { + if(is_new_cat1_version) + { + label_updating->SetText(" success"); + container_updating->SetVisible(true); + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + is_new_cat1_version=false; + statr_down_fwpkg(); + } + + } + + + static uint8_t falg_dwon_json=0; + void SystemupgradeView::set_string_value(char *str,bool falg) + { + if(falg_dwon_json==0) + { + if(falg) + { + if(str!=NULL) + { + newVersion->SetText(str); + } + + if(newVersion) + newVersion->SetVisible(true); + + if(newVersionTitle) + { + newVersionTitle->SetText("有最新固件版本"); + newVersionTitle->SetVisible(true); + } + + //new_label->SetVisible(true); + is_new_version=true; + + } + else + { + if(str!=NULL) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "str %s",str); + if(newVersion) + { + newVersion->SetText(str); + newVersion->SetVisible(true); + } + + } + + if(newVersion) + { + newVersionTitle->SetText("获取升级失败"); + newVersionTitle->SetVisible(true); + } + + is_new_version=false; + + } + + // imei_str= const_cast(ConfigModel::GetInstance()->Getimei().c_str()); + // char * version_buf=const_cast(ConfigModel::GetInstance()->GetmoderVer().c_str()); + // sprintf((char *)uri,"https://test.app.api.thisiot.com/ota/task?deviceId=%s&sourceVersion=%s",imei_str,version_buf); + // custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true); + // falg_dwon_json++; + } + else if (falg_dwon_json==1) + { + if(falg) + { + const char *text= newVersion->GetText(); + char buf[256]={0}; + sprintf(buf,"%s\n%s",text,str); + newVersion->SetText(buf); + newVersionTitle->SetText("有最新固件版本"); + newVersion->SetVisible(true); + newVersionTitle->SetVisible(true); + is_new_cat1_version=true; + + } + else + { + if(is_new_version!=true) + { + newVersionTitle->SetText("已是最新固件版本"); + newVersionTitle->SetVisible(true); + is_new_version=false; + is_new_cat1_version=false; + + } + + + } + + UIView::OnDragListener *draglistener = static_cast(SystemPresenter::GetInstance()); + if (draglistener == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::draglistener can not be nullptr!"); + return ; + } + scrollView->SetOnDragListener(draglistener); + falg_dwon_json++; + } + + + + + + RootView::GetInstance()->Invalidate(); + } + + void SystemupgradeView::statr_upgrade(void) + { + if(is_fwpkg_ready) + { + //开始升级 + //********** + statr_down_fwpkg(); + } + } + + void SystemupgradeView::init_updating(void) + { + if (container_updating == nullptr) { + container_updating = new UIViewGroup(); + container_updating->SetPosition(0, 0, 466, 480); + //container_updating->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + if (label_updating == nullptr) { + label_updating = new UILabel(); + } + label_updating->SetPosition(94, 207); // widget's left position and top position + label_updating->Resize(425, 132); // widget's width and height + label_updating->SetViewId("label1");// Set style + label_updating->SetStyle(STYLE_TEXT_FONT, 50); + + // Set additional property + label_updating->SetText("updating....."); + label_updating->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label_updating->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label_updating->SetRollSpeed(0); + label_updating->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50); + + // Add to rootView + container_updating->Add(label_updating); + container_updating->SetVisible(false); + container_updating->SetTouchable(false); + container_updating->SetDraggable(false); + scrollView->Add(container_updating); + + + } + + void SystemupgradeView::init_fail(uint8_t falg) + { + if (container_fail == nullptr) { + container_fail = new UIViewGroup(); + container_fail->SetPosition(0, 0, 466, 480); + // container_fail->SetStyle(STYLE_BACKGROUND_OPA, 0); + } + + if (label1_fail == nullptr) { + label1_fail = new UILabel(); + } + label1_fail->SetPosition(81, 207); // widget's left position and top position + label1_fail->Resize(454, 142); + // label1_fail->SetPosition(197, 207); // widget's left position and top position + // label1_fail->Resize(425, 132); // widget's width and height + label1_fail->SetViewId("label1");// Set style + label1_fail->SetStyle(STYLE_TEXT_FONT, 50); + + // Set additional property + if(falg==0) + { + label1_fail->SetText("updating fail"); + } + else + { + label1_fail->SetText("download fail"); + } + + label1_fail->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT); + label1_fail->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER); + label1_fail->SetRollSpeed(0); + label1_fail->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 50); + + // Add to rootView + container_fail->Add(label1_fail); + label1_fail->SetVisible(true); + + // Add LabelButtonExt to App + if (labelButton1_exit == nullptr) { + labelButton1_exit = new UILabelButtonExt(); + } + labelButton1_exit->SetPosition(156, 326); // widget's left position and top position + labelButton1_exit->Resize(153, 64); // widget's width and height + labelButton1_exit->SetViewId("labelButton1_exit");// Set style + + // Set additional property + labelButton1_exit->SetText("exit"); + labelButton1_exit->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 35); + labelButton1_exit->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + labelButton1_exit->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + UIView::OnClickListener *clickListener = static_cast(SystemPresenter::GetInstance()); + labelButton1_exit->SetOnClickListener(clickListener); + // Add to rootView + container_fail->SetTouchable(true); + container_fail->Add(labelButton1_exit); + container_fail->SetVisible(true); + scrollView->Add(container_fail); + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + RootView::GetInstance()->Invalidate(); + } + + + + + + UIScrollView *SystemupgradeView::SystemupgradeViewInit(void) + { + + scrollView = new UIScrollView(); + if (scrollView == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemFactoryResetView::new scrollView fail!"); + return nullptr; + } + scrollView->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight()); + scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff); + scrollView->SetStyle(STYLE_BORDER_RADIUS, 1294); + scrollView->SetScrollBlankSize(35); + scrollView->SetReboundSize(50); + scrollView->SetDirection(1); + + + scrollView->SetTouchable(true); + scrollView->SetDraggable(true); + + LabelConfig Config = { + .left = 190, + .top = 52, + .width = 60, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "系统升级", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + systemupgrade = InitLabel(Config); + if (systemupgrade == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemAboutTheWatchTitle new fail!"); + return nullptr; + } + scrollView->Add(systemupgrade); + + /* -------------------------------------------------------------------------- */ + Config = { + .left = 168, + .top = 105, + .width = 120, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "当前固件版本", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + FirmwareVersionTitle = InitLabel(Config); + if (FirmwareVersionTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersionTitle new fail!"); + return nullptr; + } + scrollView->Add(FirmwareVersionTitle); + + char version_buf[128]={0}; + uint32_t version_len=128; + uapi_get_buildversion((uint8_t*)version_buf,version_len); + Config = { + .left = 37, + .top = 135, + .width = 400, + .height = 30, + .fontSize = 26, + .lineHeigh = 30, + .text = (char*)version_buf, + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + FirmwareVersion = InitLabel(Config); + if (FirmwareVersion == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersion new fail!"); + return nullptr; + } + FirmwareVersion->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + scrollView->Add(FirmwareVersion); + + Config = { + .left = 140, + .top = 210, + .width = 120, + .height = 35, + .fontSize = 30, + .lineHeigh = 35, + .text = "最新固件版本", + .lineBreakMode = UILabel::LINE_BREAK_ADAPT, + }; + newVersionTitle = InitLabel(Config); + if (newVersionTitle == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersionTitle new fail!"); + return nullptr; + } + newVersionTitle->SetVisible(false); + scrollView->Add(newVersionTitle); + + + + Config = { + .left = 37, + .top = 240, + .width = 400, + .height = 30, + .fontSize = 26, + .lineHeigh = 30, + .text = (char*)"", + .lineBreakMode = UILabel::LINE_BREAK_WRAP, + }; + newVersion = InitLabel(Config); + newVersion->SetTextColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0x87)); + newVersion->SetTouchable(true); + newVersion->SetViewId("newVersion"); + UIView::OnClickListener *clickListener = static_cast(SystemPresenter::GetInstance()); + newVersion->SetOnClickListener(clickListener); + newVersion->SetVisible(false); + scrollView->Add(newVersion); + + // Config = { + // .left = 367, + // .top = 240, + // .width = 45, + // .height = 30, + // .fontSize = 26, + // .lineHeigh = 30, + // .text = "新!", + // .lineBreakMode = UILabel::LINE_BREAK_WRAP, + // }; + // new_label = InitLabel(Config); + // if (FirmwareVersion == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FirmwareVersion new fail!"); + // return nullptr; + // } + // new_label->SetTextColor(Color::GetColorFromRGBA(0xff, 0x00, 0x00, 0x87)); + // new_label->SetVisible(false); + // scrollView->Add(new_label); + /* -------------------------------------------------------------------------- */ + // UILabelButtonExt * SystemUpgradeButton = new UILabelButtonExt(); + // if (SystemUpgradeButton == nullptr) + // { + // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemUpgradeButtonExt new fail!"); + // } + // SystemUpgradeButton->SetPosition(43, 400, 200, 100); + // SystemUpgradeButton->SetViewId(SYSTEM_UPGRADE); + // SystemUpgradeButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + // SystemUpgradeButton->SetText("下载"); + // SystemUpgradeButton->SetAlign(TEXT_ALIGNMENT_LEFT); + // SystemUpgradeButton->SetLabelPosition(45, 0); + // SystemUpgradeButton->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 25); + // SystemUpgradeButton->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + // scrollView->Add(SystemUpgradeButton); + + SystemUpgradeButton_ = new UILabelButtonExt(); + if (SystemUpgradeButton_ == nullptr) + { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemUpgradeButtonExt new fail!"); + } + SystemUpgradeButton_->SetPosition(163, 400, 180, 80); + SystemUpgradeButton_->SetViewId(SYSTEM_UPGRADE_t); + SystemUpgradeButton_->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919); + SystemUpgradeButton_->SetText("确认升级"); + SystemUpgradeButton_->SetAlign(TEXT_ALIGNMENT_LEFT); + SystemUpgradeButton_->SetLabelPosition(45, 0); + SystemUpgradeButton_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 25); + SystemUpgradeButton_->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED); + + + UIView::OnClickListener *Click = static_cast(SystemPresenter::GetInstance()); + SystemUpgradeButton_->SetOnClickListener(Click); + scrollView->Add(SystemUpgradeButton_); + + + init_updating(); + + //init_fail(); + + //SystemUpgradeButton->SetOnClickListener(clickListener); + + //char *Path= "/user/data/ota_start_1.json"; + // const power_display_svr_api_t *display_api = power_display_svr_get_api(); + // if (display_api->get_screen_state() != SCREEN_ON) + // { + // display_api->turn_on_screen(); + // } + // display_api->set_screen_set_keepon_timeout(-1); + ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); + + memset(uri,0,256); + imei_str= const_cast(ConfigModel::GetInstance()->Getimei().c_str());//"864430010001091";//const_cast(ConfigModel::GetInstance()->Getimei().c_str()); + //https://test.app.api.thisiot.com/ota/task?deviceId=deviceId&sourceVersion=sourceVersion + // 860132060347507 + // v1.1_20240419_152549 + // sprintf((char *)uri,JSON_URL,"860132060347507","V1.1_20240422_161728"); + sprintf((char *)uri,JSON_URL,imei_str,version_buf); + custom_start_ota_download_ui_1(uri,(uint8_t*)Path,true,HTTP_JSON_SERVER_NAME); + //report_data_by_get_file(); + falg_dwon_json=0; + //uograde_service_service_init(); + + return scrollView; + } + +} \ No newline at end of file