1.将ConfigModel.json文件从/user/userdata移动到/system/分区,需要重新烧录json文件
authorluozheng <1732036298@qq.com>
Tue, 2 Apr 2024 08:28:25 +0000 (16:28 +0800)
committerluozheng <1732036298@qq.com>
Tue, 2 Apr 2024 08:28:25 +0000 (16:28 +0800)
2.将显示与亮度视图中4G能力开关恢复为抬腕亮屏,并在系统视图中添加4g能力按钮,通过button能够开启按钮
3.解决ConfigModel.h文件中WriteJsonToFile函数写完json字符串数据没有释放内存问题

code/sdk/application/wearable/fd230app/nativeui/config/ConfigModel.json
code/sdk/application/wearable/fd230app/nativeui/config/include/ConfigModel.h
code/sdk/application/wearable/fd230app/nativeui/config/src/ConfigModel.cpp
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessModel.cpp
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessPresent.cpp
code/sdk/application/wearable/fd230app/nativeui/displaybrightness/src/DisplayBrightnessView.cpp
code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h
code/sdk/application/wearable/fd230app/nativeui/system/include/SystemView.h
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemView.cpp
code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/system/ConfigModel.json [moved from code/sdk/build/config/target_config/brandy/mk_fs_image/fd230/fs/user/userdata/ConfigModel.json with 87% similarity]

index 55a811f..03fdb65 100644 (file)
@@ -9,5 +9,6 @@
     "Language_Id": 0,
     "Language_Code": "zh",
     "VibrationReminder":false,
-    "SilentMode":false
+    "SilentMode":false,
+    "Cat1_4Gability": false
 }
\ No newline at end of file
index efbd9af..48693bd 100644 (file)
@@ -51,7 +51,7 @@ namespace OHOS
         void WriteJsonData_VectorDouble(cJSON *json_obj, const char *field_name, const std::vector<double> &data);
         void WriteJsonData_VectorString(cJSON *json_obj, const char *field_name, const std::vector<std::string> &data);
 
-        void WriteJsonToFile(const char *json_string, const char *file_path);
+        void WriteJsonToFile(char *json_string, const char *file_path);
         /* -------------------------------------------------------------------------- */
         void ShowReadJsonData(void);
         void Init(void);
@@ -82,6 +82,8 @@ namespace OHOS
         bool GetVibrationReminder(void);
         void SetSilentMode(bool state);
         bool GetSilentMode(void);
+        void SetCat1_4Gability(bool state);
+        bool GetCat1_4Gability();
         // -------------------------------------------------------------------------- */
     private:
         ConfigModel();                                        // 私有构造函数,确保无法在外部实例化
@@ -90,7 +92,7 @@ namespace OHOS
         ~ConfigModel();
 
     private:
-        const std::string filePath = "/user/userdata/ConfigModel.json";
+        const std::string filePath = "/system/ConfigModel.json";
         cJSON *cjson_json{nullptr};
         /* ------------------------------- json中要读取的键 ------------------------------- */
         bool RaiseToBrightnessCheckBoxButtonState{false};    // 抬腕按钮状态 ,默认补选中
@@ -107,6 +109,7 @@ namespace OHOS
         std::string LanguageCode = "zh";
         bool VibrationReminder{false}; // 震动提醒
         bool SilentMode{false};        // 静音模式
+        bool Cat1_4Gability{false};    // 4G能力开关
         cat1_msg_config cat1_msg_config_t;
         /* -------------------------------------------------------------------------- */
     };
index 1203c03..cd4903b 100644 (file)
@@ -87,7 +87,7 @@ namespace OHOS
      * @param {char*} 字段名
      * @return {int} 读取到的数字
      */
-    int  ConfigModel::ReadJsonData_Int(const cJSON *json_obj, const char *field_name)
+    int ConfigModel::ReadJsonData_Int(const cJSON *json_obj, const char *field_name)
     {
         const cJSON *field_item = cJSON_GetObjectItem(json_obj, field_name);
         if (field_item != NULL && cJSON_IsNumber(field_item))
@@ -313,7 +313,7 @@ namespace OHOS
      * @param {char} json字符串
      * @param {char} json文件路径
      */
-    void ConfigModel::WriteJsonToFile(const char *json_string, const char *file_path)
+    void ConfigModel::WriteJsonToFile(char *json_string, const char *file_path)
     {
         if (json_string == NULL || file_path == NULL)
         {
@@ -328,9 +328,16 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to open file: %s", file_path);
             return;
         }
+        else
+        {
+            if (fputs(json_string, fp) != EOF)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WriteJsonData to file success\n");
+            }
+            fclose(fp);
+            free(json_string);
+        }
 
-        fputs(json_string, fp);
-        fclose(fp);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "JSON data written to file: %s", file_path);
     }
 
@@ -571,6 +578,26 @@ namespace OHOS
         return SilentMode;
     }
 
+    /*
+     * @brief 设置4G能力是否开启
+     * @param {bool} state
+     */
+    void ConfigModel::SetCat1_4Gability(bool state)
+    {
+        Cat1_4Gability = state;
+        WriteJsonData_Bool(GetcJSON(), "Cat1_4Gability", Cat1_4Gability); // 应该放到开机时候读
+    }
+
+    /*
+     * @brief  获取4G能力是否开启
+     * @return {bool} true 开启 false 关闭
+     */
+    bool ConfigModel::GetCat1_4Gability()
+    {
+        Cat1_4Gability = ReadJsonData_Bool(GetcJSON(), "Cat1_4Gability"); // 应该放到关机机时候写
+        return Cat1_4Gability;
+    }
+
     /* ------------------------------ ImageAnimator ----------------------------- */
 
     ImageAnimator::ImageAnimator()
index 85c09a4..a154155 100644 (file)
@@ -2,7 +2,7 @@
 #include "displaybrightness/include/DisplayBrightnessPresenter.h"
 #include "wearable_log.h"
 #include "cat1_ctl.h"
-#include "../../../../../../drivers/peripheral/slip/cat1Service/cat1_ctl.h"
+
 namespace OHOS
 {
 
@@ -40,7 +40,7 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "DisplayBrightnessViewAndSubViewComponentsStatusInit DisplayBrightnessPresenter GetInstance fail");
             return false;
         }
-        displayBrightnessPresent->SetRaiseToBrightnessState(uapi_cat1_get_power_stat()); // 抬腕按钮的状态
+        displayBrightnessPresent->SetRaiseToBrightnessState(RaiseToBrightnessCheckBoxButtonState); // 抬腕按钮的状态
         return true;
     }
 
index e7b06f4..624dc53 100644 (file)
@@ -1,6 +1,6 @@
 #include "AppViewIDs.h"\r
 #include "components/ui_label_ext.h"\r
-#include"language/font/ui_resource_string.h"\r
+#include "language/font/ui_resource_string.h"\r
 #include "NativeAbility.h"\r
 #include "graphic_math.h"\r
 #include "string.h"\r
@@ -163,49 +163,15 @@ namespace OHOS
         return false;\r
     }\r
 \r
-    extern "C"\r
-    {\r
-        uint32_t uapi_cat1_power_on(uint32_t pwron);\r
-        uint32_t uapi_cat1_reset(uint32_t pwron);\r
-\r
-        void power_on_cat1(void)\r
-        {\r
-            uapi_cat1_power_on(1);\r
-            uapi_cat1_reset(0);\r
-        }\r
-\r
-        void power_off_cat1(void)\r
-        {\r
-            uapi_cat1_reset(1);\r
-            uapi_cat1_power_on(0);\r
-        }\r
-    }\r
-\r
     bool DisplayBrightnessPresenter::OnChange(UICheckBox::UICheckBoxState state)\r
     {\r
-#if 0\r
-        switch (state)\r
-        {\r
-        case UICheckBox::SELECTED:\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RaiseToBrightnessCheckBoxButton switched on!");\r
-            break;\r
-        case UICheckBox::UNSELECTED:\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RaiseToBrightnessCheckBoxButton switched off!");\r
-            break;\r
-        default:\r
-            break;\r
-        }\r
-        return true;\r
-#endif\r
         switch (state)\r
         {\r
         case UICheckBox::SELECTED:\r
-            power_on_cat1();\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4g Capability Is Enabled");\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Raise to Wake switched on!");\r
             break;\r
         case UICheckBox::UNSELECTED:\r
-            power_off_cat1();\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4g Capability Is Disabled");\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Raise to Wake switched off!");\r
             break;\r
         default:\r
             break;\r
index 617122e..c7dcd05 100644 (file)
@@ -237,8 +237,8 @@ namespace OHOS
         }\r
         /* -------------------------------------------------------------------------- */\r
         labelconfig.top = 393;\r
-        // labelconfig.text = "抬腕亮屏";\r
-        labelconfig.text = "4G能力开关";\r
+        labelconfig.text = "抬腕亮屏";\r
+        //labelconfig.text = "4G能力开关";\r
         RaiseToBrightnessLabel = SetUpLabel(labelconfig);\r
         if (RaiseToBrightnessLabel == nullptr)\r
         {\r
index 01c151e..6c05a16 100644 (file)
@@ -1,3 +1,10 @@
+/*\r
+ * @Author: luozheng 1732036298@qq.com\r
+ * @Date: 2024-03-30 18:29:43\r
+ * @LastEditors: luozheng 1732036298@qq.com\r
+ * @LastEditTime: 2024-04-02 16:00:14\r
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/system/include/SystemPresenter.h\r
+ */\r
 \r
 #ifndef SYSTEM_PRESENTER_H\r
 #define SYSTEM_PRESENTER_H\r
@@ -7,6 +14,7 @@
 #include "system/include/SystemModel.h"\r
 #include "components/ui_radio_button.h"\r
 #include "KeyInputListener.h"\r
+#include "../../../../../../drivers/peripheral/slip/cat1Service/cat1_ctl.h"\r
 \r
 namespace OHOS\r
 {\r
@@ -60,6 +68,7 @@ namespace OHOS
                             public UIView::OnClickListener,\r
                             public RootView::OnKeyActListener,\r
                             public UIView::OnDragListener, \r
+                            public UICheckBox::OnChangeListener,\r
                             public UIView::OnTouchListener\r
     {\r
     public:\r
@@ -79,7 +88,8 @@ namespace OHOS
         bool OnDrag(UIView &view, const DragEvent &event) override;\r
         bool OnDragEnd(UIView &view, const DragEvent &event) override;\r
         bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件\r
-        bool OnPress(UIView &view, const PressEvent &event);\r
+        bool OnPress(UIView &view, const PressEvent &event) override;\r
+        bool OnChange(UICheckBox::UICheckBoxState state) override;\r
 \r
     private:\r
         SystemModel *systemModel;\r
index 89c7df9..c129f25 100644 (file)
@@ -6,7 +6,6 @@
 \r
 #include "components/ui_view_group.h"\r
 #include "components/ui_scroll_view.h"\r
-#include "components/ui_label.h"\r
 #include "components/ui_label_ext.h"\r
 #include "components/ui_image_view.h"\r
 #include "components/ui_button.h"\r
@@ -16,6 +15,8 @@
 #include "system/include/SystemLanguageView.h"\r
 #include "system/include/SystemFactoryResetView.h"\r
 #include "system/include/Systemupgrade.h"\r
+#include "components/ui_toggle_button.h"\r
+\r
 namespace OHOS\r
 {\r
     static const char *ABOUT_THE_WATCH = "AboutTheWatchButton";   // 关于手表\r
@@ -59,14 +60,13 @@ namespace OHOS
             const char *ViewId;\r
             const char *ImageSrc;\r
 \r
-            //label\r
+            // label\r
             int label_x;\r
             int label_y;\r
             uint8_t ALIGN;\r
-            int  Fontsize;\r
-        \r
+            int Fontsize;\r
         };\r
-        \r
+\r
         bool ChangeSystemView(int16_t thisView);\r
         bool ChangeSystemAboutView(int16_t thisView);\r
         bool ChangeSystemSuperviseView(int16_t thisView);\r
@@ -78,26 +78,23 @@ namespace OHOS
         UIScrollView *GetSystemScrollView(int ViewId);\r
 \r
     private:\r
-        void InitIView(void);\r
-        void initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc);\r
+        void initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc);\r
         void ClearAll(void);\r
         bool SetTheSystemScrollView(void);\r
         bool SetTheTitle(void);\r
-        UIButton *SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener);\r
+        bool Cat1_4GabilityButtonViewInit();\r
         UILabelButtonExt *SetTheButton_ext(ButtonConfig_ext_t &ButtonConfig_ext, UIView::OnClickListener *clickListener);\r
         SystemAboutTheWatchView *p_SystemAboutTheWatchView{nullptr};\r
         SystemSuperviseView *p_SystemSuperviseView{nullptr};\r
         SystemLanguageView *p_SystemLanguageView{nullptr};\r
         SystemFactoryResetView *p_SystemFactoryResetView{nullptr};\r
         SystemupgradeView *p_SystemupgradeView{nullptr};\r
-\r
         UIScrollView *SystemScrollView[10]{nullptr};\r
-        UILabel *SystemLabel{nullptr}; // 标题\r
-        UIButton *AboutTheWatchButton{nullptr};\r
-        UIButton *SuperviseButton = {nullptr};\r
-        UIButton *SystemLanguageButton = {nullptr};\r
-        UIButton *FactoryResetButton{nullptr};\r
-        UILabelButtonExt *SystemUpgradeButtonExt{nullptr};\r
+        UILabelExt *SystemLabel{nullptr}; // 标题\r
+\r
+        UILabelExt *Cat1_4Gability_Label{nullptr};\r
+        UIImageView *Cat1_4Gability_ImageView{nullptr};\r
+        UIToggleButton *Cat1_4Gability_ToggleButton{nullptr};\r
         bool initViewStatus{false};\r
     };\r
 } // namespace OHOS\r
index e5c31ad..23ac865 100644 (file)
@@ -13,6 +13,7 @@
 #include "custom_utils.h"\r
 #include "language/LanguageInit.h"\r
 #include "language/font/ui_resource_string.h"\r
+#include "config/include/ConfigModel.h"\r
 namespace OHOS\r
 {\r
 \r
@@ -64,6 +65,18 @@ namespace OHOS
         Presenter<SystemView>::OnPause();\r
     }\r
 \r
+    void SystemPresenter::OnResume(void)\r
+    {\r
+\r
+        Presenter<SystemView>::OnResume();\r
+    }\r
+\r
+    void SystemPresenter::OnStop(void)\r
+    {\r
+\r
+        Presenter<SystemView>::OnStop();\r
+    }\r
+\r
     static uint32_t time = 0;\r
     static uint32_t OnClick_num = 0;\r
 \r
@@ -72,16 +85,42 @@ namespace OHOS
         return true;\r
     }\r
 \r
-    void SystemPresenter::OnResume(void)\r
+    extern "C"\r
     {\r
+        uint32_t uapi_cat1_power_on(uint32_t pwron);\r
+        uint32_t uapi_cat1_reset(uint32_t pwron);\r
 \r
-        Presenter<SystemView>::OnResume();\r
-    }\r
+        void power_on_cat1(void)\r
+        {\r
+            uapi_cat1_power_on(1);\r
+            uapi_cat1_reset(0);\r
+        }\r
 \r
-    void SystemPresenter::OnStop(void)\r
+        void power_off_cat1(void)\r
+        {\r
+            uapi_cat1_reset(1);\r
+            uapi_cat1_power_on(0);\r
+        }\r
+    }\r
+    \r
+    bool SystemPresenter::OnChange(UICheckBox::UICheckBoxState state)\r
     {\r
-\r
-        Presenter<SystemView>::OnStop();\r
+        switch (state)\r
+        {\r
+        case UICheckBox::SELECTED:\r
+            power_on_cat1();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4g Capability Is Enabled");\r
+            ConfigModel::GetInstance()->SetCat1_4Gability(uapi_cat1_get_power_stat());\r
+            break;\r
+        case UICheckBox::UNSELECTED:\r
+            power_off_cat1();\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "4g Capability Is Disabled");\r
+            ConfigModel::GetInstance()->SetCat1_4Gability(uapi_cat1_get_power_stat());\r
+            break;\r
+        default:\r
+            break;\r
+        }\r
+        return true;\r
     }\r
 \r
     bool SystemPresenter::OnDrag(UIView &view, const DragEvent &event)\r
index f8fdfa3..6bae158 100644 (file)
@@ -12,27 +12,21 @@ namespace OHOS
 \r
     struct SystemViewMapper_ext\r
     {\r
-            const int16_t viewId;\r
-            char *viewid_str;\r
-            char *Labe_str;\r
-            bool (SystemView::*func)(int16_t thisView);\r
+        const int16_t viewId;\r
+        const char *viewid_str;\r
+        const char *Labe_str;\r
+        bool (SystemView::*func)(int16_t thisView);\r
     };\r
-    static UILabelButtonExt *button[10]={NULL};\r
-\r
-    // 2.ViewMapper[] 是一个静态的视图映射数组,将视图ID与MainStopWatchView类中的特定成员函数指针进行了绑定。\r
-        SystemViewMapper_ext ViewMapper_t[] = {\r
-        {ABOUTTHEWATCHVIEW,"AboutTheWatchButton","关于手表",&SystemView::ChangeSystemAboutView},\r
-        {SUPERVISEVIEW,"SuperviseButton","监管模式",&SystemView::ChangeSystemSuperviseView},\r
-        {SYSTEMLANGUAGEVIEW,"SystemLanguageButton","切换语言", &SystemView::ChangeSystemLanguageView},\r
-        {FACTORYRESETVIEW,"FactoryResetButton","恢复出厂", &SystemView::ChangeSystemFactoryResetView},\r
-        {SYSTEMLUPGRADE,"systemupgread","系统升级",&SystemView::ChangeSystemupgradeView},\r
-        \r
-        // {ABOUTTHEWATCHVIEW, &SystemView::ChangeSystemAboutView},\r
-        // {SUPERVISEVIEW, &SystemView::ChangeSystemSuperviseView},\r
-        // {SYSTEMLANGUAGEVIEW, &SystemView::ChangeSystemLanguageView},\r
-        // {FACTORYRESETVIEW, &SystemView::ChangeSystemFactoryResetView},\r
+    static UILabelButtonExt *button[10] = {NULL};\r
+\r
+    SystemViewMapper_ext ViewMapper_t[] = {\r
+        {ABOUTTHEWATCHVIEW, "AboutTheWatchButton", "关于手表", &SystemView::ChangeSystemAboutView},\r
+        {SUPERVISEVIEW, "SuperviseButton", "监管模式", &SystemView::ChangeSystemSuperviseView},\r
+        {SYSTEMLANGUAGEVIEW, "SystemLanguageButton", "切换语言", &SystemView::ChangeSystemLanguageView},\r
+        {FACTORYRESETVIEW, "FactoryResetButton", "恢复出厂", &SystemView::ChangeSystemFactoryResetView},\r
+        {SYSTEMLUPGRADE, "systemupgread", "系统升级", &SystemView::ChangeSystemupgradeView},\r
     };\r
-    \r
+\r
     SystemView::SystemView()\r
     {\r
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemView");\r
@@ -62,24 +56,53 @@ namespace OHOS
                 delete draglistener;\r
                 draglistener = nullptr;\r
             }\r
-            delete p_SystemAboutTheWatchView;\r
-            p_SystemAboutTheWatchView = nullptr;\r
-            delete p_SystemSuperviseView;\r
-            p_SystemSuperviseView = nullptr;\r
-            delete p_SystemLanguageView;\r
-            p_SystemLanguageView = nullptr;\r
-            delete p_SystemFactoryResetView;\r
-            p_SystemFactoryResetView = nullptr;\r
-            delete SystemLabel;\r
-            SystemLabel = nullptr;\r
-            delete AboutTheWatchButton;\r
-            AboutTheWatchButton = nullptr;\r
-            delete SuperviseButton;\r
-            SuperviseButton = nullptr;\r
-            delete SystemLanguageButton;\r
-            SystemLanguageButton = nullptr;\r
-            delete FactoryResetButton;\r
-            FactoryResetButton = nullptr;\r
+\r
+            if (p_SystemAboutTheWatchView != nullptr)\r
+            {\r
+                delete p_SystemAboutTheWatchView;\r
+                p_SystemAboutTheWatchView = nullptr;\r
+            }\r
+            if (p_SystemSuperviseView != nullptr)\r
+            {\r
+                delete p_SystemSuperviseView;\r
+                p_SystemSuperviseView = nullptr;\r
+            }\r
+\r
+            if (p_SystemLanguageView != nullptr)\r
+            {\r
+                delete p_SystemLanguageView;\r
+                p_SystemLanguageView = nullptr;\r
+            }\r
+\r
+            if (p_SystemFactoryResetView != nullptr)\r
+            {\r
+                delete p_SystemFactoryResetView;\r
+                p_SystemFactoryResetView = nullptr;\r
+            }\r
+\r
+            if (SystemLabel != nullptr)\r
+            {\r
+                delete SystemLabel;\r
+                SystemLabel = nullptr;\r
+            }\r
+\r
+            if (Cat1_4Gability_Label != nullptr)\r
+            {\r
+                delete Cat1_4Gability_Label;\r
+                Cat1_4Gability_Label = nullptr;\r
+            }\r
+\r
+            if (Cat1_4Gability_ImageView != nullptr)\r
+            {\r
+                delete Cat1_4Gability_ImageView;\r
+                Cat1_4Gability_ImageView = nullptr;\r
+            }\r
+\r
+            if (Cat1_4Gability_ToggleButton != nullptr)\r
+            {\r
+                delete Cat1_4Gability_ToggleButton;\r
+                Cat1_4Gability_ToggleButton = nullptr;\r
+            }\r
 \r
             delete SystemScrollView[SYSTEMVIEW];\r
             SystemScrollView[SYSTEMVIEW] = nullptr;\r
@@ -119,7 +142,7 @@ namespace OHOS
     /// @return true 设置成功,false 失败\r
     bool SystemView::SetTheTitle(void)\r
     {\r
-        SystemLabel = new UILabel();\r
+        SystemLabel = new UILabelExt();\r
         if (SystemLabel == nullptr)\r
         {\r
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemLabel new fail!");\r
@@ -137,25 +160,51 @@ namespace OHOS
         return true;\r
     }\r
 \r
-    /// @brief 设置按钮\r
-    /// @param button\r
-    /// @return true 设置成功,false 失败\r
-    UIButton *SystemView::SetTheButton(ButtonConfig &buttonconfig, UIView::OnClickListener *clickListener)\r
+    /*Cat14G能力开关视图初始化*/\r
+    bool SystemView::Cat1_4GabilityButtonViewInit()\r
     {\r
-        UIButton *button = new UIButton();\r
-        if (button == nullptr)\r
+        Cat1_4Gability_Label = new UILabelExt();\r
+        if (Cat1_4Gability_Label == nullptr)\r
         {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " SystemView::SetTheButton: button new  fail!");\r
-            return nullptr;\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Cat1_4Gability_Label new  fail!!");\r
+            return false;\r
         }\r
-        button->SetPosition(buttonconfig.x, buttonconfig.y, buttonconfig.w, buttonconfig.h);\r
-        button->SetViewId(buttonconfig.ViewId);\r
-        button->SetStyle(STYLE_BACKGROUND_COLOR, 0xff000000);\r
-        button->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
-        button->SetImageSrc(buttonconfig.ImageSrc, buttonconfig.ImageSrc);\r
-        button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-        button->SetOnClickListener(clickListener);\r
-        return button;\r
+        Cat1_4Gability_Label->SetPosition(83, 150, 200, 40);\r
+        Cat1_4Gability_Label->SetStyle(STYLE_TEXT_FONT, 30);\r
+        Cat1_4Gability_Label->SetStyle(STYLE_LINE_HEIGHT, 35);\r
+        Cat1_4Gability_Label->SetText("4G能力");\r
+        Cat1_4Gability_Label->SetLineBreakMode(UILabel::LINE_BREAK_ADAPT);\r
+        Cat1_4Gability_Label->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);\r
+        Cat1_4Gability_Label->SetRollSpeed(0);\r
+        Cat1_4Gability_Label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
+        /* -------------------------------------------------------------------------- */\r
+        Cat1_4Gability_ImageView = new UIImageView();\r
+        if (Cat1_4Gability_ImageView == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " Cat1_4Gability_ImageView new  fail!!");\r
+            return false;\r
+        }\r
+        Cat1_4Gability_ImageView->SetPosition(43, 120, 380, 100);\r
+        Cat1_4Gability_ImageView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
+        Cat1_4Gability_ImageView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);\r
+        Cat1_4Gability_ImageView->SetStyle(STYLE_BORDER_RADIUS, 100);\r
+        /* -------------------------------------------------------------------------- */\r
+        Cat1_4Gability_ToggleButton = new UIToggleButton();\r
+        if (Cat1_4Gability_ToggleButton == nullptr)\r
+        {\r
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Cat1_4Gability_ToggleButton new fail!!");\r
+            return false;\r
+        }\r
+        Cat1_4Gability_ToggleButton->SetState(uapi_cat1_get_power_stat());\r
+        Cat1_4Gability_ToggleButton->SetPosition(298, 145, 100, 50);\r
+        Cat1_4Gability_ToggleButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);\r
+        Cat1_4Gability_ToggleButton->SetStyle(STYLE_BORDER_RADIUS, 50);\r
+        const char *toggleButtonselectedImg = "/user/res/TOGGLEBUTTON_ON.bin";\r
+        const char *toggleButtonunSelectedImg = "/user/res/TOGGLEBUTTON_OFF.bin";\r
+        Cat1_4Gability_ToggleButton->SetImages(toggleButtonselectedImg, toggleButtonunSelectedImg);\r
+        UICheckBox::OnChangeListener *listener = static_cast<UICheckBox::OnChangeListener *>(SystemPresenter::GetInstance());\r
+        Cat1_4Gability_ToggleButton->SetOnChangeListener(listener);\r
+        return true;\r
     }\r
 \r
     UILabelButtonExt *SystemView::SetTheButton_ext(ButtonConfig_ext_t &buttonconfig, UIView::OnClickListener *clickListener)\r
@@ -175,17 +224,15 @@ namespace OHOS
 \r
         button->SetText(buttonconfig.str);\r
         button->SetAlign(TEXT_ALIGNMENT_LEFT);\r
-        button->SetLabelPosition(buttonconfig.label_x,buttonconfig.label_y );\r
+        button->SetLabelPosition(buttonconfig.label_x, buttonconfig.label_y);\r
         button->SetFont(DEFAULT_VECTOR_FONT_FILENAME, buttonconfig.Fontsize);\r
-        //button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
+        // button->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
 \r
         button->SetImagePosition(326, 37);\r
         return button;\r
     }\r
 \r
-    \r
-\r
-    void SystemView::initView_ext(int x,int y,int w,int h,int interval,const char *imagsrc)\r
+    void SystemView::initView_ext(int x, int y, int w, int h, int interval, const char *imagsrc)\r
     {\r
         if (!SetTheSystemScrollView())\r
         {\r
@@ -206,100 +253,21 @@ namespace OHOS
         buttonconfig.w = w;\r
         buttonconfig.h = h;\r
 \r
-        int len =sizeof(ViewMapper_t)/sizeof(SystemViewMapper_ext);\r
+        int len = sizeof(ViewMapper_t) / sizeof(SystemViewMapper_ext);\r
 \r
-        for(int i=0;i<len;i++)\r
+        for (int i = 0; i < len; i++)\r
         {\r
-            buttonconfig.str=ViewMapper_t[i].Labe_str;\r
+            buttonconfig.str = ViewMapper_t[i].Labe_str;\r
             buttonconfig.ViewId = ViewMapper_t[i].viewid_str;\r
             buttonconfig.ImageSrc = imagsrc;\r
-            buttonconfig.label_x=40;\r
-            buttonconfig.label_y=0;\r
-            buttonconfig.Fontsize=30;\r
-            buttonconfig.ALIGN=TEXT_ALIGNMENT_LEFT;\r
+            buttonconfig.label_x = 40;\r
+            buttonconfig.label_y = 0;\r
+            buttonconfig.Fontsize = 30;\r
+            buttonconfig.ALIGN = TEXT_ALIGNMENT_LEFT;\r
             button[i] = SetTheButton_ext(buttonconfig, clickListener);\r
-            buttonconfig.y+=interval;\r
-\r
-        }\r
-        /* -------------------------------------------------------------------------- */\r
-       \r
-    }\r
-\r
-    void SystemView::InitIView(void)\r
-    {\r
-        if (!SetTheSystemScrollView())\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheSystemScrollView() fail!");\r
-            return;\r
-        }\r
-        if (!SetTheTitle())\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SetTheTitle() fail!");\r
-            return;\r
-        }\r
-        /* -------------------------------------------------------------------------- */\r
-        UIView::OnClickListener *clickListener = static_cast<UIView::OnClickListener *>(SystemPresenter::GetInstance());\r
-        /* -------------------------------------------------------------------------- */\r
-        ButtonConfig buttonconfig;\r
-        buttonconfig.x = 43;\r
-        buttonconfig.y = 120;\r
-        buttonconfig.w = 380;\r
-        buttonconfig.h = 100;\r
-        buttonconfig.ViewId = ABOUT_THE_WATCH;\r
-        buttonconfig.ImageSrc = ABOUT_THE_WATCH_IMAGESRC;\r
-        AboutTheWatchButton = SetTheButton(buttonconfig, clickListener);\r
-        if (nullptr == AboutTheWatchButton)\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::AboutTheWatchButton new fail!");\r
-            return;\r
-        }\r
-        /* -------------------------------------------------------------------------- */\r
-        buttonconfig.y = 240;\r
-        buttonconfig.ViewId = SUPERVISE;\r
-        buttonconfig.ImageSrc = SUPERVISE_IMAGESRC;\r
-        SuperviseButton = SetTheButton(buttonconfig, clickListener);\r
-        if (nullptr == SuperviseButton)\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SuperviseButton new fail!");\r
-        }\r
-        /* -------------------------------------------------------------------------- */\r
-        buttonconfig.y = 360;\r
-        buttonconfig.ViewId = SYSTEM_LANGUAGE;\r
-        buttonconfig.ImageSrc = SYSTEM_LANGUAGE_IMAGESRC;\r
-        SystemLanguageButton = SetTheButton(buttonconfig, clickListener);\r
-        if (nullptr == SystemLanguageButton)\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemLanguageButton fail!");\r
-            return;\r
-        }\r
-        /* -------------------------------------------------------------------------- */\r
-        buttonconfig.y = 480;\r
-        buttonconfig.ViewId = FACTORY_RESET;\r
-        buttonconfig.ImageSrc = FACTORY_RESET_LANGUAGE_IMAGESRC;\r
-        FactoryResetButton = SetTheButton(buttonconfig, clickListener);\r
-        if (nullptr == FactoryResetButton)\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::FactoryResetButton fail!");\r
-            return;\r
+            buttonconfig.y += interval;\r
         }\r
         /* -------------------------------------------------------------------------- */\r
-        SystemUpgradeButtonExt = new UILabelButtonExt();\r
-        if (SystemUpgradeButtonExt == nullptr)\r
-        {\r
-            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView::SystemUpgradeButtonExt new fail!");\r
-        }\r
-        SystemUpgradeButtonExt->SetPosition(43, 600, 380, 100);\r
-        SystemUpgradeButtonExt->SetViewId(SYSTEM_UPGRADE);\r
-        SystemUpgradeButtonExt->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);\r
-        SystemUpgradeButtonExt->SetImagePosition(326, 37);\r
-        SystemUpgradeButtonExt->SetImageSrc("/user/res/SETTING_NEXT.bin", "/user/res/SETTING_NEXT.bin");\r
-        SystemUpgradeButtonExt->SetText("系统升级");\r
-        SystemUpgradeButtonExt->SetAlign(TEXT_ALIGNMENT_LEFT);\r
-        SystemUpgradeButtonExt->SetLabelPosition(45, 0);\r
-        SystemUpgradeButtonExt->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);\r
-        SystemUpgradeButtonExt->SetStyleForState(STYLE_BORDER_COLOR, 0xff0b1928, UIButton::PRESSED);\r
-        SystemUpgradeButtonExt->SetOnClickListener(clickListener);\r
-\r
         initViewStatus = true;\r
     }\r
 \r
@@ -370,10 +338,6 @@ namespace OHOS
         return true;\r
     }\r
 \r
-   \r
-\r
-    \r
-\r
     // 4.跳转到恢复出厂设置界面\r
     bool SystemView::ChangeSystemFactoryResetView(int16_t thisView)\r
     {\r
@@ -392,6 +356,7 @@ namespace OHOS
         return true;\r
     }\r
 \r
+    // 5.跳转到系统升级界面\r
     bool SystemView::ChangeSystemupgradeView(int16_t thisView)\r
     {\r
         if (SystemScrollView[thisView] == nullptr)\r
@@ -409,7 +374,6 @@ namespace OHOS
         return true;\r
     }\r
 \r
-\r
     UIScrollView *SystemView::GetSystemScrollView(int ViewId)\r
     {\r
         if (SystemScrollView[ViewId] == nullptr)\r
@@ -473,9 +437,8 @@ namespace OHOS
     void SystemView::OnStart()\r
     {\r
         View<SystemPresenter>::OnStart();\r
-        //InitIView();\r
-        initView_ext(43,120,380,100,120,"/user/res/SETTING_NEXT.bin");\r
-        \r
+        initView_ext(43, 240, 380, 100, 120, "/user/res/SETTING_NEXT.bin");\r
+        Cat1_4GabilityButtonViewInit();\r
         RootView::OnKeyActListener *keyactListener = (RootView::OnKeyActListener *)OHOS::SystemPresenter::GetInstance();\r
         RootView::GetInstance()->SetOnKeyActListener(keyactListener);\r
     }\r
@@ -488,20 +451,18 @@ namespace OHOS
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "SystemView:: OnSetUpView  has nullptr");\r
             return;\r
         }\r
-        \r
+\r
         SystemScrollView[SYSTEMVIEW]->Add(SystemLabel);\r
+        SystemScrollView[SYSTEMVIEW]->Add(Cat1_4Gability_ImageView);\r
+        SystemScrollView[SYSTEMVIEW]->Add(Cat1_4Gability_Label);\r
+        SystemScrollView[SYSTEMVIEW]->Add(Cat1_4Gability_ToggleButton);\r
 \r
-        int len =sizeof(ViewMapper_t)/sizeof(SystemViewMapper_ext);\r
+        int len = sizeof(ViewMapper_t) / sizeof(SystemViewMapper_ext);\r
 \r
-        for(int i=0;i<len;i++)\r
+        for (int i = 0; i < len; i++)\r
         {\r
-         SystemScrollView[SYSTEMVIEW]->Add(button[i]);\r
+            SystemScrollView[SYSTEMVIEW]->Add(button[i]);\r
         }\r
-        // SystemScrollView[SYSTEMVIEW]->Add(SuperviseButton);\r
-        // SystemScrollView[SYSTEMVIEW]->Add(SystemLanguageButton);\r
-        // SystemScrollView[SYSTEMVIEW]->Add(FactoryResetButton);\r
-        // SystemScrollView[SYSTEMVIEW]->Add(SystemUpgradeButtonExt);\r
-\r
         RootView::GetInstance()->Add(SystemScrollView[SYSTEMVIEW]);\r
         Draw();\r
     }\r