【关机重启】UI
authorCaisking <Casiking@zhihuishixun.com>
Mon, 28 Apr 2025 09:59:33 +0000 (17:59 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Mon, 28 Apr 2025 09:59:33 +0000 (17:59 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/FactoryResetView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownModelC.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/FactoryResetView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp [new file with mode: 0644]
code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp [new file with mode: 0644]

diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/FactoryResetView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/FactoryResetView.h
new file mode 100644 (file)
index 0000000..1caabfc
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-20 14:12:16
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-10-26 14:51:09
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/FactoryResetVIew.h
+ * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
+ */
+
+#ifndef FACTORY_RESET_VIEW_H
+#define FACTORY_RESET_VIEW_H
+
+
+#include "View.h"
+
+#include "components/ui_image_view.h"
+#include "components/ui_button.h"
+#include "components/ui_view_group.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_scroll_view.h"
+namespace OHOS
+{
+    static constexpr const char *FACTORY_RESET_GROUPVIEW = "FactoryResetGroupView";
+    static constexpr const char *FACTORY_RESET_BUTTON_CHECK_ON = "FactoryResetButtonCheckOn";   /*确认恢复出厂设置*/
+    static constexpr const char *FACTORY_RESET_BUTTON_CHECK_OFF = "FactoryResetButtonCheckOff"; /*取消*/
+    class FactoryResetView
+    {
+
+    public:
+        FactoryResetView();
+        virtual ~FactoryResetView();
+        static FactoryResetView *GetInstance(void);
+
+        UIViewGroup *FactoryResetViewInit(void);
+        UIViewGroup *FactoryResetViewInit(UIView::OnClickListener *FactoryResetButtonCheckOnClick,UIView::OnDragListener *dragListener);
+        void ClearAll(void);
+
+    private:
+        UIViewGroup *group{nullptr};
+        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/rebootandshutdown/include/RebootAndShutdownModel.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h
new file mode 100644 (file)
index 0000000..acd86ab
--- /dev/null
@@ -0,0 +1,48 @@
+/***
+ * @Date: 2024-07-24 09:43:53
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-09-09 10:45:53
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h
+ */
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-18 14:55:21
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-10-03 19:59:14
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownModel.h
+ */
+
+#ifndef REBOOT_AND_SHUTDOWN_H
+#define REBOOT_AND_SHUTDOWN_H
+
+namespace OHOS
+{
+    class RebootAndShutdownModel
+    {
+    public:
+        static RebootAndShutdownModel &GetInstance(void);
+        void HandFirstTimeStartJumpToMainView(void);
+        void RegisterAllKeyEvents(void);
+        bool GetPowerKey();
+        void SetPowerKey(bool state);
+
+    private:
+        RebootAndShutdownModel();
+        ~RebootAndShutdownModel();
+        RebootAndShutdownModel(const RebootAndShutdownModel &) = delete;
+        RebootAndShutdownModel &operator=(const RebootAndShutdownModel &) = delete;
+
+        bool RegisterPowerKeyLongPressEvent(void);
+        bool RegisterPowerKeyDoubleClickEvent(void);
+        bool RegisterFuncKeyPressEvent(void);
+        bool RegisterFuncKeyLongPressEvent(void);
+        bool RegisterFuncKeyClickEvent(void);
+        bool RegisterFuncKeyDoubleClickEvent(void);
+        bool RegisterPowerAndFuncKeyPressEvent(void);
+        bool RegisterFuncKeyOtherOnClickEvent(void);
+        bool powerKeyPressed{false};
+        bool funcKeyPressed{false};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownModelC.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownModelC.h
new file mode 100644 (file)
index 0000000..53d8e48
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef REBOOT_AND_SHUTDOWN_C_H
+#define REBOOT_AND_SHUTDOWN_C_H
+
+#ifdef __cplusplus
+#if __cplusplus
+extern "C"
+{
+#endif
+#endif
+
+#define IS_SUPPORT_BIND_VOTE 1
+
+void uapi_add_bind_vote(void);
+void uapi_remove_bind_vote(void);
+
+#ifdef __cplusplus
+#if __cplusplus
+}
+#endif
+#endif
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h
new file mode 100644 (file)
index 0000000..913f1c2
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-18 14:26:31
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-08-29 17:05:11
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h
+ */
+
+#ifndef REBOOT_AND_SHUTDOWN_PRESENTER_H
+#define REBOOT_AND_SHUTDOWN_PRESENTER_H
+
+#include "Presenter.h"
+#include "View.h"
+#include "components/ui_slider.h"
+#include "components/ui_image_animator.h"
+
+namespace OHOS
+{
+    class RebootAndShutdownView;
+    class RebootAndShutdownModel;
+    class RebootAndShutdownPresenter : public Presenter<RebootAndShutdownView>,
+                                       public UIView::OnClickListener,
+                                       public UIView::OnDragListener,
+                                       public UISlider::UISliderEventListener,
+                                       public UIImageAnimatorView::AnimatorStopListener,
+                                       public RootView::OnKeyActListener
+    {
+    public:
+        RebootAndShutdownPresenter();
+        virtual ~RebootAndShutdownPresenter();
+        static RebootAndShutdownPresenter *GetInstance();
+
+        void OnStart() override;
+        void OnResume() override;
+        void OnPause() override;
+        void OnStop() override;
+
+    private:
+        void handleSlider(UISlider *slider, bool isShutdown);
+
+    private:
+        bool OnClick(UIView &view, const ClickEvent &event) override;
+        bool OnDrag(UIView &view, const DragEvent &event) override;
+        bool OnDragEnd(UIView &view, const DragEvent &event) override;
+        void OnAnimatorStop(UIView &view) override;
+        void OnChange(int32_t value) override;
+        void OnRelease(int32_t value) override;
+        bool OnKeyAct(UIView &view, const KeyEvent &event) override; // 增加按键事件
+
+        RebootAndShutdownModel *model;
+        bool X_DRAG_FLAG{false};
+        bool isShutDownOperation{false};
+        bool isShutDownImageAnimatorStart{false};
+    };
+}
+
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/RebootAndShutdownView.h
new file mode 100644 (file)
index 0000000..3185663
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-18 14:25:53
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-08-29 17:11:51
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownView.h
+ */
+#ifndef REBOOT_AND_SHUTDOWN_VIEW_H
+#define REBOOT_AND_SHUTDOWN_VIEW_H
+
+
+#include "View.h"
+#include "components/ui_scroll_view.h"
+#include "components/ui_label_ext.h"
+#include "components/ui_slider.h"
+#include "components/ui_view_group.h"
+#include "rebootandshutdown/include/ShutDownImageAnimatorView.h"
+#include "rebootandshutdown/include/FactoryResetView.h"
+#define IS_SLIDER_TO_SHUTDOWN 0
+namespace OHOS
+{
+    typedef enum : uint8_t
+    {
+        REBOOTANDSHUTDOWN = 0, // 关机和SOS(Slice)
+        SHUTDOWNANIMATOR,      // 关机动画视图(subview)
+        SHUTDOWNTIPVIEW,       // 关机提示视图(subview)
+        FACTORYRESET,          // 恢复出厂设置视图(subview)
+        REBOOTANDSHUTDOWN_MAX,
+    } REBOOTANDSHUTDOWNVIEWID;
+
+    static constexpr const char *SHUTDOWN_BUTTON_VIEWID = "shutdown_button_viewid";
+    static constexpr const char *SOS_BUTTON_VIEWID = "sos_button_viewid";
+    static constexpr const char *FACTORYRESET_LABEL_VIEWID = "factoryreset_label_viewid";
+    static constexpr const char *REBOOT_AND_SHUTDOWN_GROUPVIEW = "reboot_and_shutdown_groupview";
+
+    class RebootAndShutdownPresenter;
+    class RebootAndShutdownView : public View<RebootAndShutdownPresenter>
+    {
+
+    public:
+        RebootAndShutdownView();
+        ~RebootAndShutdownView();
+        static RebootAndShutdownView *GetInstance(void);
+        UIButton *GetButtonEnsure();
+        UIButton *GetButtonCancel();
+        UIScrollView *GetSystemShutdownScrollView(void);
+
+        bool ChangeToRebootAndShutdownView(int16_t thisView);
+        bool ChangeToShutdownTipView(int16_t thisView);
+        bool ChangeToShutDownAnimatorView(int16_t thisView);
+        bool ChangeToFactoryResetView(int16_t thisView);
+        void ChangeView(int16_t hideView, int16_t showView);
+
+        void OnStart() override;
+      
+
+        struct LabelConfig
+        {
+            int16_t left;
+            int16_t top;
+            int16_t width;
+            int16_t height;
+            int16_t fontSize;
+            int16_t lineHeigh;
+            uint16_t textId;
+            const char *text;
+            uint8_t lineBreakMode;
+        };
+
+    private:
+        bool CheckViewParam(int16_t hideView, int16_t showView);
+        bool ClickFunc(int16_t interface);
+
+        ShutDownImageAnimatorView *shutDownImageAnimatorView{nullptr};
+        FactoryResetView *factoryResetView{nullptr};
+
+    private:
+        UILabelExt *RebootAndShutdownLabelInit(LabelConfig &labelconfig);
+
+        bool CreateRebootAndShutdownLabel(void);
+        bool CreateRebootAndShutdownSlider(void);
+        bool CreateRebootAndShutdownScrollView(void);
+        bool CreateRebootAndShutdownGroupView(void);
+        bool CreateRebootAndShutdownButton(void);
+        void CreateRebootAndShutdownView(void);
+        void ClearAll(void);
+
+        UIViewGroup *rebootAndShutdownGroupView[REBOOTANDSHUTDOWN_MAX]{nullptr};
+
+        UILabelExt *title{nullptr};
+        UILabelExt *factoryResetLabel{nullptr}; /*恢复出厂设置*/
+
+#if IS_SLIDER_TO_SHUTDOWN
+        /*关机*/
+        UILabelExt *shutdownLabel{nullptr};
+        UISlider *shutdownSlider{nullptr};
+        UIScrollView *shutdownScrollView{nullptr};
+
+        /*重启*/
+        UILabelExt *rebootLabel{nullptr};
+        UISlider *rebootSlider{nullptr};
+        UIScrollView *rebootScrollView{nullptr};
+#else
+        // 关机
+        UILabelExt *shutdownLabel{nullptr};
+        UIButton *shutdownButton{nullptr};
+        /* -------------------------------------------------------------------------- */
+        UIScrollView *SystemShutdownScrollView = nullptr;
+        UILabelExt *shutdowntitle{nullptr};
+        UILabelExt *note{nullptr};
+        UIImageView *image = nullptr;
+        UIButton *button_ensure = nullptr;
+        UIButton *button_cancel = nullptr;
+        UIViewGroup *ShutdownViewInit(void);
+        void ClearAllShutdownView(void);
+        /* -------------------------------------------------------------------------- */
+
+        // SOS
+        UILabelExt *sosLabel{nullptr};
+        UIButton *sosButton{nullptr};
+#endif
+        bool viewInitStatus{false};
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h
new file mode 100644 (file)
index 0000000..c57f524
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-20 11:05:46
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-10-12 14:29:17
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h
+ */
+
+#ifndef __SHUTDOWN_IMAGE_ANIMATOR_VIEW_H__
+#define __SHUTDOWN_IMAGE_ANIMATOR_VIEW_H__
+
+#include "components/ui_view_group.h"
+#include "components/ui_image_animator.h"
+
+namespace OHOS
+{
+    static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_X = 0;
+    static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y = 0;
+    static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_W = 466;
+    static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_H = 466;
+    static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 30;                // 图片帧数
+    static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_TIME = 150;                          // 图片更新间隔
+    static constexpr const char *ShutDownPaths = "/user/res/RebootAndShutDown/ShutDown/"; // 关机图片路径
+
+    class ShutDownImageAnimatorView : public UIImageAnimatorView::AnimatorStopListener
+    {
+    public:
+        ShutDownImageAnimatorView();
+        ~ShutDownImageAnimatorView();
+        static ShutDownImageAnimatorView *GetInstance();
+        UIViewGroup *ShutDownAnimatorViewInit(void);
+        UIImageAnimatorView *GeShutDownImageAnimatorView(void);
+        void ShutDownImageAnimator_Start(int type);
+        bool GetShutDownImageAnimatorIsStart(void);
+
+    private:
+        void OnAnimatorStop(UIView &view) override;
+        void ClearAll(void);
+        bool ShowUpShutDownAnimatorView();
+
+        UIViewGroup *group{nullptr};
+        UIImageAnimatorView *shutDownImageAnimatorView{nullptr};                      // 关机动画
+        ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息
+        const char **ShutDownPathsArray{nullptr};
+        // const ImageInfo **ShutDownPathsArray{nullptr};                               // 关机图片路径数组
+        int OperationType;
+        bool isShutDownImageAnimatorStart{false};
+    };
+}
+#endif
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/FactoryResetView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/FactoryResetView.cpp
new file mode 100644 (file)
index 0000000..db48569
--- /dev/null
@@ -0,0 +1,358 @@
+#include "rebootandshutdown/include/FactoryResetView.h"
+#include "rebootandshutdown/include/RebootAndShutdownPresenter.h"
+#include "wearable_log.h"
+#include "UiConfig.h"
+#include "ui_resource_string.h"
+
+namespace OHOS
+{
+
+    static FactoryResetView *g_pFactoryResetView{nullptr};
+
+    FactoryResetView::FactoryResetView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::FactoryResetView");
+        g_pFactoryResetView = this;
+    }
+
+    FactoryResetView::~FactoryResetView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::~FactoryResetView");
+        ClearAll();
+        g_pFactoryResetView = nullptr;
+    }
+
+    FactoryResetView *FactoryResetView::GetInstance()
+    {
+        return g_pFactoryResetView;
+    }
+
+    void FactoryResetView::ClearAll()
+    {
+        if (initViewStatus == true)
+        {
+            if (scrollView != nullptr)
+            {
+                scrollView->RemoveAll();
+                if (Title != nullptr)
+                {
+                    delete Title;
+                    Title = nullptr;
+                }
+
+                if (FactoryResetImage != nullptr)
+                {
+                    delete FactoryResetImage;
+                    FactoryResetImage = nullptr;
+                }
+
+                if (FactoryResetNote != nullptr)
+                {
+                    delete FactoryResetNote;
+                    FactoryResetNote = nullptr;
+                }
+
+                if (FactoryResetButtonCheckOn != nullptr)
+                {
+                    delete FactoryResetButtonCheckOn;
+                    FactoryResetButtonCheckOn = nullptr;
+                }
+                if (FactoryResetButtonCheckOff != nullptr)
+                {
+                    delete FactoryResetButtonCheckOff;
+                    FactoryResetButtonCheckOff = nullptr;
+                }
+                if (temp != nullptr)
+                {
+                    delete temp;
+                    temp = nullptr;
+                }
+                group->Remove(scrollView);
+                delete scrollView;
+                scrollView = nullptr;
+            }
+            delete group;
+            group = nullptr;
+        }
+    }
+
+    UIViewGroup *FactoryResetView::FactoryResetViewInit(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FactoryResetView::FactoryResetViewInit");
+        if (group == nullptr)
+        {
+            group = new UIViewGroup();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new group fail!");
+                return nullptr;
+            }
+            group->SetViewId(FACTORY_RESET_GROUPVIEW);
+            group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+            group->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            group->SetStyle(STYLE_BORDER_RADIUS, 100);
+            group->SetTouchable(true);
+            group->SetDraggable(true);
+            UIView::OnDragListener *dragListener = static_cast<UIView::OnDragListener *>(RebootAndShutdownPresenter::GetInstance());
+            if (dragListener == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::GetInstance fail!!");
+                return nullptr;
+            }
+            group->SetOnDragListener(dragListener);
+            /* ------------------------------- scrollView ------------------------------- */
+            scrollView = new UIScrollView();
+            if (scrollView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::scrollView new fail!");
+                return nullptr;
+            }
+            scrollView->SetPosition(0, 0, 466, 466);
+            scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            // scrollView->SetScrollBlankSize(30);
+            // scrollView->SetReboundSize(30);
+            scrollView->SetMaxScrollDistance(1000);
+            scrollView->SetThrowDrag(true);
+            scrollView->RequestFocus();
+            scrollView->SetRotateFactor(2);
+            /* ---------------------------------- Title --------------------------------- */
+            Title = new UILabelExt();
+            if (Title == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new Title fail!");
+                return nullptr;
+            }
+            Title->SetPosition(83, 50, 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, "FactoryResetView::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, "FactoryResetView::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, "FactoryResetView::new FactoryResetButtonCheckOff fail!");
+                return nullptr;
+            }
+            FactoryResetButtonCheckOff->SetPosition(97, FactoryResetNote->GetTextHeight() + FactoryResetNote->GetY() + 30, 130, 130);
+            FactoryResetButtonCheckOff->SetViewId(FACTORY_RESET_BUTTON_CHECK_OFF);
+            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<UIView::OnClickListener *>(RebootAndShutdownPresenter::GetInstance());
+            if (FactoryResetButtonCheckOffClick == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::RebootAndShutdownPresenter::GetInstance fail!!");
+                return nullptr;
+            }
+            FactoryResetButtonCheckOff->SetOnClickListener(FactoryResetButtonCheckOffClick);
+            /* ------------------------ FactoryResetButtonCheckOn ----------------------- */
+            FactoryResetButtonCheckOn = new UIButton();
+            if (FactoryResetButtonCheckOn == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new FactoryResetButtonCheckOn fail!");
+                return nullptr;
+            }
+            FactoryResetButtonCheckOn->SetPosition(240, FactoryResetButtonCheckOff->GetY(), 130, 130);
+            FactoryResetButtonCheckOn->SetViewId(FACTORY_RESET_BUTTON_CHECK_ON);
+            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<UIView::OnClickListener *>(RebootAndShutdownPresenter::GetInstance());
+            if (FactoryResetButtonCheckOnClick == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::RebootAndShutdownPresenter::GetInstance fail!!");
+                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);
+            group->Add(scrollView);
+
+            initViewStatus = true;
+        }
+        return group;
+    }
+
+    UIViewGroup *FactoryResetView::FactoryResetViewInit(UIView::OnClickListener *FactoryResetButtonCheckOnClick,UIView::OnDragListener *dragListener)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FactoryResetView::FactoryResetViewInit");
+        if (group == nullptr)
+        {
+            group = new UIViewGroup();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new group fail!");
+                return nullptr;
+            }
+            group->SetViewId("FACTORY_RESET_GROUPVIEW");
+            group->SetPosition(0, 0, Screen::GetInstance().GetWidth(), Screen::GetInstance().GetHeight());
+            group->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            group->SetStyle(STYLE_BORDER_RADIUS, 100);
+            group->SetTouchable(true);
+            group->SetDraggable(true);
+          
+            group->SetOnDragListener(dragListener);
+            /* ------------------------------- scrollView ------------------------------- */
+            // scrollView = new UIScrollView();
+            // if (scrollView == nullptr)
+            // {
+            //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::scrollView new fail!");
+            //     return nullptr;
+            // }
+            // scrollView->SetPosition(0, 0, 466, 466);
+            // scrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            // scrollView->SetScrollBlankSize(50);
+            // scrollView->SetReboundSize(35);
+            // scrollView->SetMaxScrollDistance(1000);
+            // scrollView->SetThrowDrag(true);
+            // scrollView->RequestFocus();
+            // scrollView->SetRotateFactor(2);
+            /* ---------------------------------- Title --------------------------------- */
+            Title = new UILabelExt();
+            if (Title == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new Title fail!");
+                return nullptr;
+            }
+            Title->SetPosition(83, 50, 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, "FactoryResetView::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, "FactoryResetView::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, "FactoryResetView::new FactoryResetButtonCheckOff fail!");
+                return nullptr;
+            }
+            FactoryResetButtonCheckOff->SetPosition(97, FactoryResetNote->GetTextHeight() + FactoryResetNote->GetY() + 30, 130, 130);
+            FactoryResetButtonCheckOff->SetViewId("FACTORY_RESET_BUTTON_CHECK_OFF");
+            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);
+         
+            FactoryResetButtonCheckOff->SetOnClickListener((UIView::OnClickListener *)FactoryResetButtonCheckOnClick);
+            /* ------------------------ FactoryResetButtonCheckOn ----------------------- */
+            FactoryResetButtonCheckOn = new UIButton();
+            if (FactoryResetButtonCheckOn == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::new FactoryResetButtonCheckOn fail!");
+                return nullptr;
+            }
+            FactoryResetButtonCheckOn->SetPosition(240, FactoryResetButtonCheckOff->GetY(), 130, 130);
+            FactoryResetButtonCheckOn->SetViewId("FACTORY_RESET_BUTTON_CHECK_ON");
+            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<UIView::OnClickListener *>(RebootAndShutdownPresenter::GetInstance());
+            // if (FactoryResetButtonCheckOnClick == nullptr)
+            // {
+            //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FactoryResetView::RebootAndShutdownPresenter::GetInstance fail!!");
+            //     return nullptr;
+            // }
+            FactoryResetButtonCheckOn->SetOnClickListener((UIView::OnClickListener *)FactoryResetButtonCheckOnClick);
+
+            /* ----------------------------- Add to scroView ---------------------------- */
+            group->Add(Title);
+            group->Add(FactoryResetImage);
+            group->Add(FactoryResetNote);
+            group->Add(FactoryResetButtonCheckOff);
+            group->Add(FactoryResetButtonCheckOn);
+            //group->Add(scrollView);
+            group->SetVisible(false);
+            initViewStatus = true;
+        }
+        return group;
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp
new file mode 100644 (file)
index 0000000..65fabbb
--- /dev/null
@@ -0,0 +1,648 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-18 14:55:27
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-12-24 18:54:47
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp
+ */
+
+#include "rebootandshutdown/include/RebootAndShutdownModel.h"
+#include "rebootandshutdown/include/RebootAndShutdownModelC.h"
+#include "rebootandshutdown/include/ShutDownImageAnimatorView.h"
+#include "wearable_log.h"
+#include "ConfigModel.h"
+#include "NativeAbility.h"
+#include <AppViewIDs.h>
+#include "settings/include/SettingModel.h"
+#include <custom_utils.h>
+#include "themestyle/include/ThemeStyleModel.h"
+#include "aivoice/include/AiVoiceModel.h"
+#include "graphic_service.h"
+#ifdef SUPPORT_BLE_SERVICE
+#include <bleEvent.h>
+#include "bleService.h"
+#endif
+#include "ui_service.h"
+
+#ifdef FD230_650
+#include "dial_sos_c.h"
+#endif
+
+#include "broadcast_feature.h"
+#include "notification_manager.h"
+#define SAVEMODE 0
+#define DEBUGOUTPUT 1
+
+extern "C" uint8_t uapi_dev_runtime_get_lock_status(void);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "pm.h"
+#include "pm_veto.h"
+
+void uapi_add_bind_vote(void)
+{
+  uint8_t res = pm_veto_get_id_cnt(PM_ID_JPEG);
+  if (res == 0) {
+    uapi_pm_add_sleep_veto(PM_ID_JPEG);
+  } else {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,
+                  "uapi_add_bind_vote error");
+  }
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,
+                "投票成功,res:%d",res);
+}
+void uapi_remove_bind_vote(void)
+{
+  uint8_t res = pm_veto_get_id_cnt(PM_ID_JPEG);
+  if (res == 1) {
+    uapi_pm_remove_sleep_veto(PM_ID_JPEG);
+  } else {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,
+                  "uapi_remove_bind_vote error");
+  }
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_MAIN_SERVICE,
+                "移除投票成功 success,res:%d",res);
+}
+#ifdef __cplusplus
+}
+#endif
+namespace OHOS
+{
+    static uint16_t intercept_slice_ids[] = {
+        VIEW_INVALID,
+        VIEW_SAVEBAT,      // 省电模式界面
+        VIEW_BLOOD_CHECK,  // 血氧检测界面
+        VIEW_HEART_CHECK,  // 心率检测界面
+        VIEW_TRAININGCRAD, // 训练控制卡片
+        VIEW_INCOMING_CALL,// 来电界面
+        VIEW_TEST,         // 产测测试界面
+    };
+    #define VOLUME_50 50
+    #define VOLUME_100 100
+
+    //处理闹钟或者查找手表通知
+    static bool HandleAlarmOrFindWatchNotify()
+    {
+        uint16_t notifyId = NotificationManager::GetInstance()->GetShowingNotifyId();
+        if (NotificationManager::GetInstance()->HasNotifyShowing() && (notifyId == TOPIC_EVENT_ALARM_RING || notifyId == TOPIC_EVENT_FIND_WATCH))
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleAlarmOrFindWatchNotify:notifyId = %d", notifyId);
+            return true;
+        }
+        return false;
+    }
+
+    RebootAndShutdownModel::RebootAndShutdownModel() {}
+
+    RebootAndShutdownModel::~RebootAndShutdownModel() {}
+
+    RebootAndShutdownModel &RebootAndShutdownModel::GetInstance()
+    {
+        static RebootAndShutdownModel instance;
+        return instance;
+    }
+
+    /*处理恢复出厂设置后第一次跳转主界面*/
+    void RebootAndShutdownModel::HandFirstTimeStartJumpToMainView(void)
+    {
+        if (ConfigModel::GetInstance()->GetisFirstTimeStart() == true)
+        {
+            uapi_set_screen_on_api();
+        #if IS_SUPPORT_BIND_VOTE
+            uapi_add_bind_vote();//绑定的时候投票防止系统进入深睡,导致绑定成功后进入视频表盘死机
+            // ConfigModel::GetInstance()->SetisFirstTimeStart(false);
+        #else 
+            ConfigModel::GetInstance()->SetisFirstTimeStart(false);
+        #endif
+            uapi_systemVolumeSet(VOLUME_50);//恢复出厂设置系统音量要设置50%
+            uapi_callVolumeSet(VOLUME_100);//恢复出厂设置通话音量要设置100%
+            NativeAbility::GetInstance().SetDefaultSliceId(VIEW_MAIN);
+            NativeAbility::GetInstance().ChangeSlice(VIEW_MAIN);
+        }
+    }
+
+#ifdef __cplusplus
+    extern "C"
+    {
+#endif
+
+#include "input_app.h"
+#ifdef __cplusplus
+    }
+#endif
+#include <power_display_service.h>
+
+    static void PowerKeyLongPressCallBack(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PowerKeyLongPressCallBack");
+
+        ShutDownImageAnimatorView *shutDownImageAnimatorView = ShutDownImageAnimatorView::GetInstance();
+        if (shutDownImageAnimatorView != nullptr && true == shutDownImageAnimatorView->GetShutDownImageAnimatorIsStart())
+        {
+            return;
+        }
+
+        const power_display_svr_api_t *display_api = power_display_svr_get_api();
+        if (!display_api)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr");
+            return;
+        }
+
+        if (display_api->get_screen_state() != SCREEN_ON)
+        {
+            display_api->turn_on_screen();
+        }
+
+        // 切换到关机/重启卡片
+        NativeAbility::GetInstance().EnterSlice(VIEW_REBOOTANDSHUTDOWN);
+    }
+
+    static void HandlePowerKeyLongPress(void)
+    {
+        if (HandleAlarmOrFindWatchNotify())
+            return;
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(PowerKeyLongPressCallBack));
+    }
+
+    /*注册电源键的长按事件*/
+    bool RebootAndShutdownModel::RegisterPowerKeyLongPressEvent(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterPowerKeyLongPressEvent");
+        int32_t ret = uapi_button_register_event_cb(HandlePowerKeyLongPress, BUTTON_PWR_LONGPRESS_3S);
+        if (ret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey LongPress Event error, ret = %d", ret);
+            return false;
+        }
+        return true;
+    }
+
+    static void PowerKeyDoubleClickCallBack(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PowerKeyDoubleClickCallBack");
+
+        ShutDownImageAnimatorView *shutDownImageAnimatorView = ShutDownImageAnimatorView::GetInstance();
+        if (shutDownImageAnimatorView != nullptr && true == shutDownImageAnimatorView->GetShutDownImageAnimatorIsStart())
+        {
+            return;
+        }
+
+        const power_display_svr_api_t *display_api = power_display_svr_get_api();
+        if (!display_api)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr");
+            return;
+        }
+
+        if (display_api->get_screen_state() == SCREEN_ON)
+        {
+            uint16_t cursliceId = NativeAbility::GetInstance().GetCurSliceId();
+            if (cursliceId == VIEW_APPLIST)
+            {
+                ThemeStyleModel &themeStyleModel = ThemeStyleModel::GetInstance();
+                ThemeStyle style = themeStyleModel.GetAppListDisplayStyle();
+                themeStyleModel.SetPreApplistStyle(style);
+                themeStyleModel.SetTheSameSliceChangeFlag(true);
+                themeStyleModel.SwitchApplistStyleOnPowerClick(); // 切换样式
+                NativeAbility::GetInstance().ChangeSlice(VIEW_APPLIST);
+            }
+        }
+        else
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is not on, skipping applist style change");
+        }
+    }
+
+    static void HandlePowerKeyDoubleClick(void)
+    {
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(PowerKeyDoubleClickCallBack));
+    }
+
+    /*注册电源键的双击事件*/
+    bool RebootAndShutdownModel::RegisterPowerKeyDoubleClickEvent(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterPowerKeyDoubleClickEvent");
+        // Register PowerKey DoubleClick event here
+        int32_t ret = uapi_button_register_event_cb(HandlePowerKeyDoubleClick, BUTTON_PWR_CLICKUP_2);
+        if (ret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey DoubleClick Event error, ret = %d", ret);
+            return false;
+        }
+        return true;
+    }
+
+    static void FuncKeyOnPressCallBack(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::FuncKeyOnPressCallBack");
+
+        ShutDownImageAnimatorView *shutDownImageAnimatorView = ShutDownImageAnimatorView::GetInstance();
+        if (shutDownImageAnimatorView != nullptr && true == shutDownImageAnimatorView->GetShutDownImageAnimatorIsStart())
+        {
+            return;
+        }
+
+        const power_display_svr_api_t *display_api = power_display_svr_get_api();
+        if (!display_api)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr");
+            return;
+        }
+        /* -------------------------------------------------------------------------- */
+        display_api->turn_on_screen();
+        /* -------------------------------------------------------------------------- */
+        if (display_api->get_screen_state() == SCREEN_ON)
+        {
+            uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+            if (curSliceId == VIEW_AI_VOICE) // 如果当前已在ai语音界面就切换模型
+            {
+                AiVoiceModel::GetInstance().FunctionKeyOnClickToChangeAIModel();
+            }
+        }
+
+        return;
+    }
+
+    static void HandFuncKeyOnPress(void)
+    {
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(FuncKeyOnPressCallBack));
+    }
+
+    /*注册功能键的按下事件*/
+    bool RebootAndShutdownModel::RegisterFuncKeyPressEvent(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyPressEvent");
+        // Register FuncKey Press event here
+        int32_t ret = uapi_button_register_event_cb(HandFuncKeyOnPress, BUTTON1_PRESS);
+        if (ret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey Press Event error, ret = %d", ret);
+            return false;
+        }
+        return true;
+    }
+
+    static void FuncKeyOnLongPressCallBack(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FuncKeyOnLongPressCallBack");
+
+        ShutDownImageAnimatorView *shutDownImageAnimatorView = ShutDownImageAnimatorView::GetInstance();
+        if (shutDownImageAnimatorView != nullptr && true == shutDownImageAnimatorView->GetShutDownImageAnimatorIsStart())
+        {
+            return;
+        }
+
+        if (true == ConfigModel::GetInstance()->GetisFirstTimeStart())
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FuncKeyOnLongPressCallBack: first time power on");
+            return;
+        }
+
+        const power_display_svr_api_t *display_api = power_display_svr_get_api();
+        if (!display_api)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr");
+            return;
+        }
+
+        if (display_api->get_screen_state() == SCREEN_ON)
+        {
+            uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+            /*处于主界面 或者密码锁界面*/
+            if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK)
+            {
+                /*被锁*/
+                if (uapi_dev_runtime_get_lock_status())
+                {
+                    if (curSliceId != VIEW_CODED_LOCK)
+                    {
+                        NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK);
+                    }
+                    return;
+                }
+            }
+            if (curSliceId == VIEW_AI_VOICE) // 如果当前已在ai语音界面不做切换
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "VIEW_AI_VOICE is not switched");
+                return;
+            }
+            // 全局切换到Ai语音界面
+            NativeAbility::GetInstance().EnterSlice(VIEW_AI_VOICE);
+        }
+        else
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is not on, skipping AI voice change");
+        }
+    }
+
+    static void SOSKeyLongPress(void)
+    {
+        #ifdef FD230_650
+        start_SOS_phone_dail();
+        #endif
+    }
+
+    static void HandFuncKeyOnLongPress(void)
+    {
+        if (HandleAlarmOrFindWatchNotify())
+            return;
+        // GraphicService::GetInstance()->PostGraphicEvent(std::bind(SOSKeyLongPress));
+        SOSKeyLongPress();
+    }
+
+    /*注册功能键的长按事件*/
+    bool RebootAndShutdownModel::RegisterFuncKeyLongPressEvent(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyLongPressEvent");
+        int32_t ret = uapi_button_register_event_cb(HandFuncKeyOnLongPress, BUTTON1_LONGPRESS_2S);
+        if (ret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register PowerKey LongPress Event error, ret = %d", ret);
+            return false;
+        }
+        return true;
+    }
+
+    static void FuncKeyOnClickCallBack(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "FuncKeyOnClickCallBack");
+
+        ShutDownImageAnimatorView *shutDownImageAnimatorView = ShutDownImageAnimatorView::GetInstance();
+        if (shutDownImageAnimatorView != nullptr && true == shutDownImageAnimatorView->GetShutDownImageAnimatorIsStart())
+        {
+            return;
+        }
+
+        if (true == ConfigModel::GetInstance()->GetisFirstTimeStart())
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FuncKeyOnClickCallBack: first time power on");
+            return;
+        }
+
+        const power_display_svr_api_t *display_api = power_display_svr_get_api();
+        if (!display_api)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr");
+            return;
+        }
+
+        if (display_api->get_screen_state() == SCREEN_ON)
+        {
+            uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+            /*处于主界面 或者密码锁界面*/
+            if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK)
+            {
+                /*被锁*/
+                if (uapi_dev_runtime_get_lock_status())
+                {
+                    if (curSliceId != VIEW_CODED_LOCK)
+                    {
+                        NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK);
+                    }
+                    return;
+                }
+            }
+            if (curSliceId == VIEW_AI_VOICE) // 如果当前已在ai语音界面单击切换模型
+            {
+                AiVoiceModel::GetInstance().FunctionKeyOnClickToChangeAIModel();
+                return;
+            }
+            else
+            {
+                NativeAbility::GetInstance().EnterSlice(VIEW_AI_VOICE); // 切换到Ai语音界面
+            }
+        }
+        else
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is not on, skipping AI model change");
+        }
+    }
+
+    static void HandleFuncKeyOnClick(void)
+    {
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(FuncKeyOnClickCallBack));
+    }
+
+    /*注册功能键的单击事件*/
+    bool RebootAndShutdownModel::RegisterFuncKeyClickEvent(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyClickEvent");
+        int32_t ret = uapi_button_register_event_cb(HandleFuncKeyOnClick, BUTTON1_CLICKUP);
+        if (ret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey Click Event error, ret = %d", ret);
+            return false;
+        }
+        return true;
+    }
+
+    static void FuncKeyDoubleClickCallBack(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FuncKeyDoubleClickCallBack");
+
+        ShutDownImageAnimatorView *shutDownImageAnimatorView = ShutDownImageAnimatorView::GetInstance();
+        if (shutDownImageAnimatorView != nullptr && true == shutDownImageAnimatorView->GetShutDownImageAnimatorIsStart())
+        {
+            return;
+        }
+
+        if (true == ConfigModel::GetInstance()->GetisFirstTimeStart())
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "FuncKeyDoubleClickCallBack: first time power on");
+            return;
+        }
+
+        uint16_t current_slice_id = OHOS::NativeAbility::GetInstance().GetCurSliceId();
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "current_slice_id = %d", current_slice_id);
+        for (uint16_t i = 0; i < sizeof(intercept_slice_ids) / sizeof(intercept_slice_ids[0]); i++)
+        {
+            if (intercept_slice_ids[i] == current_slice_id)
+            {
+                return;
+            }
+        }
+        const power_display_svr_api_t *display_api = power_display_svr_get_api();
+        if (!display_api)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr");
+            return;
+        }
+        if (display_api->get_screen_state() == SCREEN_ON)
+        {
+            uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+            /*处于主界面 或者密码锁界面*/
+            if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK)
+            {
+                /*被锁*/
+                if (uapi_dev_runtime_get_lock_status())
+                {
+                    if (curSliceId != VIEW_CODED_LOCK)
+                    {
+                        NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK);
+                    }
+                    return;
+                }
+            }
+            if (curSliceId != VIEW_AI_VOICE)
+            {
+                NativeAbility::GetInstance().EnterSlice(VIEW_AI_VOICE);
+            }
+        }
+        else
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is not on, skipping Slice change");
+        }
+    }
+
+    static void HandleFuncKeyDoubleClick(void)
+    {
+        if (HandleAlarmOrFindWatchNotify())
+            return;
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(FuncKeyDoubleClickCallBack));
+    }
+
+    /*注册功能键双击事件*/
+    bool RebootAndShutdownModel::RegisterFuncKeyDoubleClickEvent(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyDoubleClickEvent");
+        int32_t ret = uapi_button_register_event_cb(HandleFuncKeyDoubleClick, BUTTON1_CLICKUP_2);
+        if (ret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey DoubleClick Event error, ret = %d", ret);
+            return false;
+        }
+        return true;
+    }
+    bool RebootAndShutdownModel::GetPowerKey()
+    {
+        return powerKeyPressed;
+    }
+    void RebootAndShutdownModel::SetPowerKey(bool state)
+    {
+        powerKeyPressed = state;
+    }
+    static void PowerAndFuncKeyPressCallBack(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PowerAndFuncKeyPressCallBack");
+        /*关闭动画*/
+        ShutDownImageAnimatorView *shutDownImageAnimatorView = ShutDownImageAnimatorView::GetInstance();
+        if (shutDownImageAnimatorView != nullptr && true == shutDownImageAnimatorView->GetShutDownImageAnimatorIsStart())
+        {
+            return;
+        }
+        /*第一次启动*/
+        if (true == ConfigModel::GetInstance()->GetisFirstTimeStart())
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "PowerAndFuncKeyPressCallBack: first time power on");
+            return;
+        }
+        /*是否亮屏*/
+        const power_display_svr_api_t *display_api = power_display_svr_get_api();
+        if (!display_api)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "power_display_svr_get_api returned nullptr");
+            return;
+        }
+        if (display_api->get_screen_state() == SCREEN_ON)
+        {
+            uint16_t curSliceId = NativeAbility::GetInstance().GetCurSliceId();
+            /*处于主界面锁屏 或者密码锁界面*/
+            if (curSliceId == VIEW_MAIN || curSliceId == VIEW_CODED_LOCK)
+            {
+                /*被锁*/
+                if (uapi_dev_runtime_get_lock_status())
+                {
+                    if (curSliceId != VIEW_CODED_LOCK)
+                    {
+                        NativeAbility::GetInstance().EnterSlice(VIEW_CODED_LOCK);
+                    }
+                    return;
+                }
+            }
+            // 全局切换安全模式界面
+            NativeAbility::GetInstance().EnterSlice(VIEW_SAFE_MODE);
+        }
+    }
+
+    // 处理同时按下电源键和功能键的事件
+    static void HandlePowerAndFuncKeySetPress(void)
+    {
+        RebootAndShutdownModel::GetInstance().SetPowerKey(true);
+    }
+    static void HandlePowerAndFuncKeyPress(void)
+    {
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(PowerAndFuncKeyPressCallBack));
+    }
+    // 注册同时按下电源键和功能键的事件
+    bool RebootAndShutdownModel::RegisterPowerAndFuncKeyPressEvent(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterPowerAndFuncKeyPressEvent");
+#if 0
+        int32_t ret = uapi_button_register_double_event_cb(HandlePowerAndFuncKeyPress, BUTTON_PWR_PRESS, BUTTON1_PRESS);
+        if (ret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Register FuncKey or Power Click Event error, ret = %d", ret);
+            return false;
+        }   
+
+        int32_t funcret = uapi_button_register_event_cb(HandlePowerAndFuncKeyPress, BUTTON1_PRESS);
+        if (funcret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to register Function Button Press Event, ret = %d", funcret);
+            return false;
+        }
+#endif
+        // 注册按键按下事件 2秒
+        int32_t powerret = uapi_button_register_event_cb(HandlePowerAndFuncKeyPress, BUTTON_PWR_LONGPRESS_2S);
+        if (powerret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to register Power Button Press Event, ret = %d", powerret);
+            return false;
+        }
+
+        return true;
+    }
+
+    static void FuncKeyOtherOnClickEventCallBack(void)
+    {
+        CustomEventPublish(TOPIC_EVENT_DEBUGOUTPUT, NULL, 0);
+        return;
+    }
+    static void HandFuncKeyOtherOnClickEvent(void)
+    {
+        GraphicService::GetInstance()->PostGraphicEvent(std::bind(FuncKeyOtherOnClickEventCallBack));
+    }
+
+    bool RebootAndShutdownModel::RegisterFuncKeyOtherOnClickEvent(void)
+    {
+        // 注册按键按下8次事件
+        int32_t powerret = uapi_button_register_event_cb(HandFuncKeyOtherOnClickEvent, BUTTON1_CLICKUP_8);
+        if (powerret != ERRCODE_SUCC)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to register Power Button Press Event, ret = %d", powerret);
+            return false;
+        }
+
+        return true;
+    }
+
+    /*注册所有按键事件*/
+    void RebootAndShutdownModel::RegisterAllKeyEvents(void)
+    {
+        // RegisterPowerKeyDoubleClickEvent();
+        RegisterPowerKeyLongPressEvent();
+        RegisterFuncKeyPressEvent();
+        RegisterFuncKeyLongPressEvent();
+        // RegisterFuncKeyClickEvent();
+        RegisterFuncKeyDoubleClickEvent();
+#if DEBUGOUTPUT
+        RegisterFuncKeyOtherOnClickEvent();
+#endif
+#if SAVEMODE
+        RegisterPowerAndFuncKeyPressEvent();
+#endif
+    }
+}
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp
new file mode 100644 (file)
index 0000000..89bbe82
--- /dev/null
@@ -0,0 +1,241 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-06-20 15:11:17
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-10-24 20:17:39
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/RebootAndShutdownPresenter.cpp
+ */
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include "common/key_code.h"
+#include <custom_utils.h>
+#include "UiConfig.h"
+#include "rebootandshutdown/include/RebootAndShutdownPresenter.h"
+#include "rebootandshutdown/include/RebootAndShutdownView.h"
+#include "rebootandshutdown/include/RebootAndShutdownModel.h"
+
+#ifdef FD230_650
+#include "dial_sos_c.h"
+#endif
+
+
+#include "vibrator_service.h"
+
+#include "NativeRegisterManager.h"
+
+namespace OHOS
+{
+    REGIST_SLICE(VIEW_REBOOTANDSHUTDOWN, RebootAndShutdownView, RebootAndShutdownPresenter);
+
+
+    
+    static constexpr const int SLIDER_VALUE_MAX = 88;
+    static constexpr const int SLIDER_VALUE_MIN = 12;
+    // 当前Presenter属性实例化的内存指针
+    static RebootAndShutdownPresenter *g_pRebootAndShutdownPresenter = nullptr;
+
+    RebootAndShutdownPresenter::RebootAndShutdownPresenter()
+    {
+        model = &RebootAndShutdownModel::GetInstance();
+        g_pRebootAndShutdownPresenter = this;
+    }
+
+    RebootAndShutdownPresenter::~RebootAndShutdownPresenter()
+    {
+        g_pRebootAndShutdownPresenter = nullptr;
+    }
+
+    RebootAndShutdownPresenter *RebootAndShutdownPresenter::GetInstance()
+    {
+        return g_pRebootAndShutdownPresenter;
+    }
+
+    // 启动时执行的逻辑
+    void RebootAndShutdownPresenter::OnStart()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnStart");
+        Presenter<RebootAndShutdownView>::OnStart();
+    }
+
+    // 页面已经展示后的调用逻辑
+    void RebootAndShutdownPresenter::OnResume(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnResume");
+        Presenter<RebootAndShutdownView>::OnResume();
+        if (view_ == nullptr)
+        {
+            return;
+        }
+    }
+
+    // 页面准备切换到后台前执行的逻辑
+    void RebootAndShutdownPresenter::OnPause(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnPause");
+        Presenter<RebootAndShutdownView>::OnPause();
+    }
+
+    // 页面完全置于后台时的逻辑。
+    void RebootAndShutdownPresenter::OnStop(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnStop");
+        Presenter<RebootAndShutdownView>::OnStop();
+    }
+
+    bool RebootAndShutdownPresenter::OnClick(UIView &view, const ClickEvent &event)
+    {
+        UNUSED(event);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnClick");
+        if (strcmp(view.GetViewId(), FACTORYRESET_LABEL_VIEWID) == 0) // 进入出厂设置界面
+        {
+            view_->ChangeView(REBOOTANDSHUTDOWN, FACTORYRESET);
+            return true;
+        }
+        else if (strcmp(view.GetViewId(), FACTORY_RESET_BUTTON_CHECK_ON) == 0) // 恢复出厂设置确认
+        {
+            ui_api_vibrate_once_func(); //恢复出厂增加震动
+            view_->ChangeView(FACTORYRESET, SHUTDOWNANIMATOR);
+            ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(2);
+            isShutDownImageAnimatorStart = true;
+            return true;
+        }
+        else if (strcmp(view.GetViewId(), FACTORY_RESET_BUTTON_CHECK_OFF) == 0) // 恢复出厂设置取消
+        {
+            view_->ChangeView(FACTORYRESET, REBOOTANDSHUTDOWN);
+        }
+        else if (strcmp(view.GetViewId(), SHUTDOWN_BUTTON_VIEWID) == 0) // 进入关机提示视图
+        {
+            view_->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNTIPVIEW);
+        }
+        else if (&view == view_->GetButtonEnsure()) // 关机确认
+        {
+            view_->ChangeView(SHUTDOWNTIPVIEW, SHUTDOWNANIMATOR);
+          
+
+            ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(0);
+            isShutDownImageAnimatorStart = true;
+        }
+        else if (&view == view_->GetButtonCancel()) // 关机取消
+        {
+            view_->ChangeView(SHUTDOWNTIPVIEW, REBOOTANDSHUTDOWN);
+        }
+        else if (strcmp(view.GetViewId(), SOS_BUTTON_VIEWID) == 0)
+        {
+            #ifdef FD230_650
+            start_SOS_phone_dail();
+            #endif
+        }
+
+        return true;
+    }
+
+    bool RebootAndShutdownPresenter::OnDrag(UIView &view, const DragEvent &event)
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnDrag");
+        if ((event.GetDeltaX() > X_DRAG_OFFSET) && (event.GetDeltaX() > (DOUBLES * MATH_ABS(event.GetDeltaY())))) // 拖动过程中判断是否是水平滑动
+        {
+            RebootAndShutdownPresenter::X_DRAG_FLAG = true;
+        }
+        return true;
+    }
+
+    bool RebootAndShutdownPresenter::OnDragEnd(UIView &view, const DragEvent &event)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnDragEnd");
+        if (event.GetDragDirection() == DragEvent::DIRECTION_LEFT_TO_RIGHT && RebootAndShutdownPresenter::X_DRAG_FLAG)
+        {
+            if (strcmp(view.GetViewId(), REBOOT_AND_SHUTDOWN_GROUPVIEW) == 0)
+            {
+                NativeAbility::GetInstance().Back();
+            }
+            else if (strcmp(view.GetViewId(), FACTORY_RESET_GROUPVIEW) == 0)
+            {
+                view_->ChangeView(FACTORYRESET, REBOOTANDSHUTDOWN);
+            }
+            else if (&view == view_->GetSystemShutdownScrollView())
+            {
+                view_->ChangeView(SHUTDOWNTIPVIEW, REBOOTANDSHUTDOWN);
+            }
+            RebootAndShutdownPresenter::X_DRAG_FLAG = false;
+            return true;
+        }
+        return false;
+    }
+
+    void RebootAndShutdownPresenter::OnAnimatorStop(UIView &view)
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnAnimatorStop");
+        if (isShutDownOperation == true)
+        {
+            // uapi_poweroff_device(); // 关机
+            shutdown_reboot_prejobs(SHUTDOWN_TYPE);
+        }
+        else
+        {
+           shutdown_reboot_prejobs(REBOOT_TYPE);
+        }
+        
+    }
+
+    void RebootAndShutdownPresenter::OnChange(int32_t value)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnChange");
+    }
+
+    void RebootAndShutdownPresenter::OnRelease(int32_t value)
+    {
+        // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnRelease,value = %d", value);
+        // auto shutdownSlider = view_->GetShutdownSlider();
+        // auto rebootSlider = view_->GetRebootSlider();
+
+        // handleSlider(shutdownSlider, true);
+        // handleSlider(rebootSlider, false);
+    }
+
+    void RebootAndShutdownPresenter::handleSlider(UISlider *slider, bool isShutdown)
+    {
+        // if (!slider)
+        // {
+        //     return;
+        // }
+
+        // if (slider->GetValue() < SLIDER_VALUE_MAX)
+        // {
+        //     slider->SetValue(SLIDER_VALUE_MIN);
+        // }
+        // else
+        // {
+        //     slider->SetValue(SLIDER_VALUE_MAX);
+        //     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "%s!!", isShutdown ? "关机" : "重启");
+        //     view_->ChangeView(REBOOTANDSHUTDOWN, SHUTDOWNANIMATOR);
+        //     start_shutdown_or_reboot();
+        //     shutdown_reboot_prejobs();
+
+        //     if (ShutDownImageAnimatorView::GetInstance() != nullptr && ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView() != nullptr)
+        //     {
+        //         ShutDownImageAnimatorView::GetInstance()->GeShutDownImageAnimatorView()->Start();
+        //         isShutDownImageAnimatorStart = true;
+        //     }
+        //     isShutDownOperation = isShutdown;
+        // }
+    }
+
+    bool RebootAndShutdownPresenter::OnKeyAct(UIView &view, const KeyEvent &event) // 增加按键事件
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnKeyAct");
+        uint16_t keyID = event.GetKeyId();
+        uint16_t keyState = event.GetState();
+        // 如果是power键,且是亮屏状态,按键释放就返回上一级
+        if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
+        {
+            if (!isShutDownImageAnimatorStart)
+            {
+                NativeAbility::GetInstance().Back();
+            }
+        }
+        return true;
+    }
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp
new file mode 100644 (file)
index 0000000..ee24848
--- /dev/null
@@ -0,0 +1,682 @@
+/*
+ * @Author: luozheng 1732036298@qq.com
+ * @Date: 2024-07-18 14:26:08
+ * @LastEditors: luozheng 1732036298@qq.com
+ * @LastEditTime: 2024-10-05 10:43:59
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownView.cpp
+ */
+
+#include "rebootandshutdown/include/RebootAndShutdownPresenter.h"
+#include "rebootandshutdown/include/RebootAndShutdownView.h"
+#include "ConfigModel.h"
+#include "wearable_log.h"
+#include "ui_resource_string.h"
+#include "UiConfig.h"
+namespace OHOS
+{
+
+    static RebootAndShutdownView *g_pRebootAndShutdownView{nullptr};
+
+    RebootAndShutdownView::RebootAndShutdownView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::RebootAndShutdownView");
+        g_pRebootAndShutdownView = this;
+    }
+
+    RebootAndShutdownView::~RebootAndShutdownView()
+    {
+        ClearAll();
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::~RebootAndShutdownView");
+        g_pRebootAndShutdownView = nullptr;
+    }
+
+    RebootAndShutdownView *RebootAndShutdownView::GetInstance()
+    {
+        return g_pRebootAndShutdownView;
+    }
+
+    void RebootAndShutdownView::ClearAll(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ClearAll");
+        if (viewInitStatus)
+        {
+    
+            if (rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] != nullptr)
+            {
+                rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->RemoveAll();
+                if (title != nullptr)
+                {
+                    delete title;
+                    title = nullptr;
+                }
+                if (factoryResetLabel != nullptr)
+                {
+                    delete factoryResetLabel;
+                    factoryResetLabel = nullptr;
+                }
+                if (shutdownLabel)
+                {
+                    delete shutdownLabel;
+                    shutdownLabel = nullptr;
+                }
+                if (shutdownButton)
+                {
+                    delete shutdownButton;
+                    shutdownButton = nullptr;
+                }
+                if (sosLabel)
+                {
+                    delete sosLabel;
+                    sosLabel = nullptr;
+                }
+                if (sosButton)
+                {
+                    delete sosButton;
+                    sosButton = nullptr;
+                }
+                delete rebootAndShutdownGroupView[REBOOTANDSHUTDOWN];
+                rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] = nullptr;
+            }
+            ClearAllShutdownView();
+            if (shutDownImageAnimatorView != nullptr)
+            {
+                delete shutDownImageAnimatorView;
+                shutDownImageAnimatorView = nullptr;
+            }
+            if (factoryResetView != nullptr)
+            {
+                delete factoryResetView;
+                factoryResetView = nullptr;
+            }
+            for (int i = REBOOTANDSHUTDOWN; i < REBOOTANDSHUTDOWN_MAX; i++)
+            {
+                rebootAndShutdownGroupView[i] = nullptr;
+            }
+        }
+    }
+
+    UILabelExt *RebootAndShutdownView::RebootAndShutdownLabelInit(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->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+        label->SetRollSpeed(23);
+        label->SetFont(DEFAULT_VECTOR_FONT_FILENAME, labelconfig.fontSize);
+        return label;
+    }
+
+    bool RebootAndShutdownView::CreateRebootAndShutdownLabel(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownLabel");
+        LabelConfig labelConfig = {
+            .left = 83,
+            .top = 50,
+            .width = 300,
+            .height = 35,
+            .fontSize = 30,
+            .lineHeigh = 35,
+            .textId = STR_SYSTEM, /*系统*/
+            .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
+        };
+        title = RebootAndShutdownLabelInit(labelConfig);
+        if (title == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "title new fail!");
+            return false;
+        }
+        /* -------------------------------------------------------------------------- */
+        labelConfig = {
+            .left = 113,
+            .top = 271,
+            .width = 60,
+            .height = 35,
+            .fontSize = 30,
+            .lineHeigh = 35,
+            .textId = STR_SHUTDOWN, /*关机*/
+            .text = "shutdown",
+            .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
+        };
+        shutdownLabel = RebootAndShutdownLabelInit(labelConfig);
+        if (shutdownLabel == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutdownLabel new fail!");
+            return false;
+        }
+        shutdownLabel->SetAlign(TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTER);
+        shutdownLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));
+        /* -------------------------------------------------------------------------- */
+        sosLabel = new UILabelExt();
+        if (sosLabel == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sosLabel new fail!");
+            return false;
+        }
+        sosLabel->SetPosition(294, 271, 58, 35);
+        sosLabel->SetStyle(STYLE_TEXT_FONT, 30);
+        sosLabel->SetStyle(STYLE_LINE_HEIGHT, 35);
+        sosLabel->SetText("SOS");
+        sosLabel->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+        sosLabel->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+        sosLabel->SetRollSpeed(23);
+        sosLabel->SetFont(DEFAULT_VECTOR_FONT_FILENAME_EN, 30);
+        sosLabel->SetTextColor(Color::GetColorFromRGBA(0x66, 0x66, 0x66, 0xff));
+        /* -------------------------------------------------------------------------- */
+        labelConfig = {
+            .left = 83,
+            .top = 370,
+            .width = 300,
+            .height = 70,
+            .fontSize = 30,
+            .lineHeigh = 35,
+            .textId = STR_FACTORY_RESET, /*恢复出厂*/
+            .lineBreakMode = UILabel::LINE_BREAK_OSCILLATION,
+        };
+        factoryResetLabel = RebootAndShutdownLabelInit(labelConfig);
+        if (factoryResetLabel == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "factoryResetLabel new fail!");
+            return false;
+        }
+        factoryResetLabel->SetViewId(FACTORYRESET_LABEL_VIEWID);
+        factoryResetLabel->SetTouchable((ConfigModel::GetInstance()->GetisFirstTimeStart() && ConfigModel::GetInstance()->GetLanguage() == -1) ? false : true);
+        factoryResetLabel->SetTextColor(Color::GetColorFromRGBA(0x35, 0x49, 0xff, 0xff));
+        factoryResetLabel->SetOnClickListener(presenter_);
+
+        return true;
+    }
+
+    bool RebootAndShutdownView::CreateRebootAndShutdownSlider(void)
+    {
+#if IS_SLIDER_TO_SHUTDOWN
+        if (shutdownSlider == nullptr)
+        {
+            shutdownSlider = new UISlider();
+            if (shutdownSlider == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutdownSlider new fail!");
+                return false;
+            }
+            shutdownSlider->SetPosition(10, 10, 360, 80);
+            shutdownSlider->SetViewId(SHUTDOWN_SLIDER_VIEWID);
+            shutdownSlider->SetStyle(STYLE_BORDER_RADIUS, 100);
+            shutdownSlider->SetRange(100, 0);
+            shutdownSlider->SetValidWidth(360);
+            shutdownSlider->SetValidHeight(80);
+            shutdownSlider->SetSliderColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff), Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff));
+            shutdownSlider->SetKnobWidth(80);
+            shutdownSlider->SetKnobStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+            shutdownSlider->SetKnobRadius(100);
+            shutdownSlider->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00);
+            // shutdownSlider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff);
+            shutdownSlider->SetKnobImage(PNG_SETTINGS_SETTTING_SHUTDOWN);
+            shutdownSlider->SetValue(12);
+            shutdownSlider->SetCapType(CapType::CAP_ROUND);
+        }
+        /* -------------------------------------------------------------------------- */
+        if (rebootSlider == nullptr)
+        {
+            rebootSlider = new UISlider();
+            if (rebootSlider == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootSlider new fail!");
+                return false;
+            }
+            rebootSlider->SetPosition(10, 10, 360, 80);
+            rebootSlider->SetViewId(REBOOT_SLIDER_VIEWID);
+            rebootSlider->SetStyle(STYLE_BORDER_RADIUS, 100);
+            rebootSlider->SetRange(100, 0);
+            rebootSlider->SetValidWidth(360);
+            rebootSlider->SetValidHeight(80);
+            rebootSlider->SetSliderColor(Color::GetColorFromRGBA(0xff, 0xff, 0xff, 0xff), Color::GetColorFromRGBA(0x19, 0x19, 0x19, 0xff));
+            rebootSlider->SetKnobWidth(80);
+            rebootSlider->SetKnobStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+            rebootSlider->SetKnobRadius(100);
+            rebootSlider->SetBackgroundStyle(STYLE_BACKGROUND_OPA, 0x00);
+            // rebootSlider->SetForegroundStyle(STYLE_BACKGROUND_OPA, 0xff);
+            rebootSlider->SetKnobImage(PNG_SETTINGS_SETTTING_REBOOT);
+            rebootSlider->SetValue(12);
+            rebootSlider->SetCapType(CapType::CAP_ROUND);
+        }
+        shutdownSlider->SetOnClickListener(presenter_);
+        shutdownSlider->SetOnDragListener(presenter_);
+        shutdownSlider->SetSliderEventListener(presenter_);
+
+        rebootSlider->SetOnClickListener(presenter_);
+        rebootSlider->SetOnDragListener(presenter_);
+        rebootSlider->SetSliderEventListener(presenter_);
+#endif
+        return true;
+    }
+
+    bool RebootAndShutdownView::CreateRebootAndShutdownScrollView(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownScrollView");
+#if IS_SLIDER_TO_SHUTDOWN
+        if (shutdownScrollView == nullptr)
+        {
+            shutdownScrollView = new UIScrollView();
+            if (shutdownScrollView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutdownScrollView new fail!");
+                return false;
+            }
+            shutdownScrollView->SetPosition(43, 120, 380, 100);
+            shutdownScrollView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+            shutdownScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            shutdownScrollView->SetStyle(STYLE_BORDER_RADIUS, 100);
+            shutdownScrollView->SetTouchable(true);
+            shutdownScrollView->SetDraggable(true);
+            shutdownScrollView->SetIntercept(true);
+        }
+
+        /* -------------------------------------------------------------------------- */
+        if (rebootScrollView == nullptr)
+        {
+            rebootScrollView = new UIScrollView();
+            if (rebootScrollView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootScrollView new fail!");
+                return false;
+            }
+            rebootScrollView->SetPosition(43, 240, 380, 100);
+            rebootScrollView->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+            rebootScrollView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            rebootScrollView->SetStyle(STYLE_BORDER_RADIUS, 100);
+            rebootScrollView->SetTouchable(true);
+            rebootScrollView->SetDraggable(true);
+            rebootScrollView->SetIntercept(true);
+        }
+#endif
+        return true;
+    }
+
+    bool RebootAndShutdownView::CreateRebootAndShutdownButton(void)
+    {
+        if (shutdownButton == nullptr)
+        {
+            shutdownButton = new UIButton();
+            if (shutdownButton == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] is new fail!!");
+                return false;
+            }
+            shutdownButton->SetPosition(93, 160);
+            shutdownButton->Resize(100, 100);
+            shutdownButton->SetViewId(SHUTDOWN_BUTTON_VIEWID);
+            shutdownButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+            shutdownButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+            shutdownButton->SetImageSrc(PNG_SETTINGS_SETTTING_SHUTDOWN_1, PNG_SETTINGS_SETTTING_SHUTDOWN_1);
+            shutdownButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+            shutdownButton->SetOnClickListener(presenter_);
+        }
+        if (sosButton == nullptr)
+        {
+            sosButton = new UIButton();
+            if (sosButton == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] is new fail!!");
+                return false;
+            }
+            sosButton->SetPosition(273, 160);
+            sosButton->Resize(100, 100);
+            sosButton->SetViewId(SOS_BUTTON_VIEWID);
+            sosButton->SetStyle(STYLE_BACKGROUND_COLOR, 0xff191919);
+            sosButton->SetStyle(STYLE_BACKGROUND_OPA, 0x00);
+            sosButton->SetImageSrc(PNG_SETTINGS_SETTTING_SOS, PNG_SETTINGS_SETTTING_SOS);
+            sosButton->SetStyleForState(STYLE_BACKGROUND_OPA, 0x00, UIButton::PRESSED);
+            sosButton->SetOnClickListener(presenter_);
+        }
+        return true;
+    }
+
+    bool RebootAndShutdownView::CreateRebootAndShutdownGroupView(void)
+    {
+        if (rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] == nullptr)
+        {
+            rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] = new UIViewGroup();
+            if (rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "rebootAndShutdownGroupView[REBOOTANDSHUTDOWN] is new fail!!");
+                return false;
+            }
+            rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetPosition(0, 0, 466, 466);
+            rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetViewId(REBOOT_AND_SHUTDOWN_GROUPVIEW);
+            rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetStyle(STYLE_BACKGROUND_OPA, 0);
+            rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetTouchable(true);
+            rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetDraggable(true);
+            rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->SetOnDragListener(presenter_);
+        }
+
+        return true;
+    }
+
+    void RebootAndShutdownView::CreateRebootAndShutdownView(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownView");
+        if (!CreateRebootAndShutdownGroupView() || !CreateRebootAndShutdownButton() || !CreateRebootAndShutdownLabel())
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CreateRebootAndShutdownView fail!");
+            return;
+        }
+        rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(title);
+        rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(shutdownButton);
+        rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(shutdownLabel);
+        rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(sosButton);
+        rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(sosLabel);
+        rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]->Add(factoryResetLabel);
+        AddViewToRootContainer(rebootAndShutdownGroupView[REBOOTANDSHUTDOWN]);
+    }
+
+    void RebootAndShutdownView::OnStart()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::OnStart");
+
+        if (!viewInitStatus)
+        {
+            CreateRebootAndShutdownView();
+            viewInitStatus = true;
+        }
+
+        //RootView::GetInstance()->SetOnKeyActListener(presenter_);
+        return;
+    }
+  
+ 
+
+    bool RebootAndShutdownView::ChangeToRebootAndShutdownView(int16_t thisView)
+    {
+        if (rebootAndShutdownGroupView[thisView] == nullptr)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ChangeToRebootAndShutdownView");
+            AddViewToRootContainer(rebootAndShutdownGroupView[thisView]);
+        }
+        return true;
+    }
+
+    // 切换到关机提示视图
+    bool RebootAndShutdownView::ChangeToShutdownTipView(int16_t thisView)
+    {
+        if (rebootAndShutdownGroupView[thisView] == nullptr)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ChangeToShutdownTipView");
+            UIViewGroup *group = ShutdownViewInit();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail");
+                return false;
+            }
+            rebootAndShutdownGroupView[thisView] = group;
+            AddViewToRootContainer(rebootAndShutdownGroupView[thisView]);
+        }
+        return true;
+    }
+
+    // 切换到关机动画视图
+    bool RebootAndShutdownView::ChangeToShutDownAnimatorView(int16_t thisView)
+    {
+        if (rebootAndShutdownGroupView[thisView] == nullptr)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ChangeToShutDownAnimatorView");
+            shutDownImageAnimatorView = new ShutDownImageAnimatorView();
+            if (shutDownImageAnimatorView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "shutDownImageAnimatorView new fail");
+                return false;
+            }
+            UIViewGroup *group = shutDownImageAnimatorView->ShutDownAnimatorViewInit();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail");
+                return false;
+            }
+            rebootAndShutdownGroupView[thisView] = group;
+            AddViewToRootContainer(rebootAndShutdownGroupView[thisView]);
+        }
+        return true;
+    }
+
+    // 切换到恢复出厂设置视图
+    bool RebootAndShutdownView::ChangeToFactoryResetView(int16_t thisView)
+    {
+        if (rebootAndShutdownGroupView[thisView] == nullptr)
+        {
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ChangeToFactoryResetView");
+            factoryResetView = new FactoryResetView();
+            if (factoryResetView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "factoryResetView new fail");
+                return false;
+            }
+            UIViewGroup *group = factoryResetView->FactoryResetViewInit();
+            if (group == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group nullptr fail");
+                return false;
+            }
+            rebootAndShutdownGroupView[thisView] = group;
+            AddViewToRootContainer(rebootAndShutdownGroupView[thisView]);
+        }
+
+        return true;
+    }
+
+    struct RebootAndShutdownViewMapper
+    {
+        const int16_t viewId;
+        bool (RebootAndShutdownView::*func)(int16_t thisView);
+    };
+
+    static const RebootAndShutdownViewMapper ViewMapper[] = {
+        {REBOOTANDSHUTDOWN, &RebootAndShutdownView::ChangeToRebootAndShutdownView},
+        {SHUTDOWNTIPVIEW, &RebootAndShutdownView::ChangeToShutdownTipView},
+        {SHUTDOWNANIMATOR, &RebootAndShutdownView::ChangeToShutDownAnimatorView},
+        {FACTORYRESET, &RebootAndShutdownView::ChangeToFactoryResetView},
+    };
+
+    bool RebootAndShutdownView::ClickFunc(int16_t interface)
+    {
+        int funcSize = sizeof(ViewMapper) / sizeof(ViewMapper[0]);
+        for (int i = 0; i < funcSize; i++)
+        {
+            if (interface == ViewMapper[i].viewId)
+            {
+                bool jug = (this->*(ViewMapper[i].func))(interface);
+                if (jug == false)
+                {
+                    return false;
+                }
+                return true;
+            }
+        }
+        return false;
+    }
+
+    bool RebootAndShutdownView::CheckViewParam(int16_t hideView, int16_t showView)
+    {
+        if (showView < 0 || showView >= REBOOTANDSHUTDOWN_MAX)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CheckViewParam showView err.");
+            return false;
+        }
+
+        if (hideView < 0 || hideView > REBOOTANDSHUTDOWN_MAX)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CheckViewParam hideView err.");
+            return false;
+        }
+
+        return true;
+    }
+
+    void RebootAndShutdownView::ChangeView(int16_t hideView, int16_t showView)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::ChangeView %d, %d", hideView, showView);
+
+        if (!CheckViewParam(hideView, showView))
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownView::CheckViewParam failed.");
+            return;
+        }
+
+        rebootAndShutdownGroupView[hideView]->SetVisible(false);
+        ClickFunc(showView);
+        rebootAndShutdownGroupView[showView]->SetVisible(true);
+        Draw();
+    }
+
+    UIButton *RebootAndShutdownView::GetButtonEnsure()
+    {
+        return button_ensure;
+    }
+    UIButton *RebootAndShutdownView::GetButtonCancel()
+    {
+        return button_cancel;
+    }
+    UIScrollView *RebootAndShutdownView::GetSystemShutdownScrollView(void)
+    {
+        return SystemShutdownScrollView;
+    }
+
+    UIViewGroup *RebootAndShutdownView::ShutdownViewInit(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);
+            SystemShutdownScrollView->SetOnDragListener(presenter_);
+            SystemShutdownScrollView->SetTouchable(true);
+            SystemShutdownScrollView->SetDraggable(true);
+            /* -------------------------------------------------------------------------- */
+            if (shutdowntitle == nullptr)
+            {
+                shutdowntitle = new UILabelExt();
+                if (shutdowntitle == nullptr)
+                {
+                    return nullptr;
+                }
+                shutdowntitle->SetPosition(83, 50, 300, 35);    // 位置
+                shutdowntitle->SetStyle(STYLE_TEXT_FONT, 30);   // 字体大小
+                shutdowntitle->SetStyle(STYLE_LINE_HEIGHT, 35); // 字体行高
+                shutdowntitle->SetTextId(STR_SHUTDOWN);         // 内容
+                shutdowntitle->SetLineBreakMode(UILabel::LINE_BREAK_OSCILLATION);
+                shutdowntitle->SetAlign(TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_CENTER);
+                shutdowntitle->SetRollSpeed(23);
+                shutdowntitle->SetFont(DEFAULT_VECTOR_FONT_FILENAME, 30);
+                SystemShutdownScrollView->Add(shutdowntitle);
+            }
+            /* -------------------------------------------------------------------------- */
+            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->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->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);
+            button_cancel->SetOnClickListener(presenter_);
+            button_ensure->SetOnClickListener(presenter_);
+        }
+        return SystemShutdownScrollView;
+    }
+
+    void RebootAndShutdownView::ClearAllShutdownView(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;
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp
new file mode 100644 (file)
index 0000000..cf9c397
--- /dev/null
@@ -0,0 +1,182 @@
+/***
+ * @Date: 2024-08-29 11:02:07
+ * @LastEditors: Caisking 3449750381@qq.com
+ * @LastEditTime: 2024-08-30 19:24:04
+ * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp
+ */
+#include "rebootandshutdown/include/ShutDownImageAnimatorView.h"
+#include "rebootandshutdown/include/RebootAndShutdownPresenter.h"
+#include "wearable_log.h"
+#include <custom_utils.h>
+#include "uicomponents/UIComponents.h"
+#include "vibrator_service.h"
+#ifdef SUPPORT_BLE_SERVICE
+#include <bleEvent.h>
+#include "bleService.h"
+#endif
+
+#include "AppViewIDs.h"
+#include "NativeAbility.h"
+#include <custom_runtime.h>
+#include "uiservice/include/ui_service.h"
+namespace OHOS
+{
+
+    static ShutDownImageAnimatorView *g_pShutDownAnimatorView = nullptr;
+    ShutDownImageAnimatorView::ShutDownImageAnimatorView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorView::ShutDownImageAnimatorView");
+        g_pShutDownAnimatorView = this;
+    }
+    ShutDownImageAnimatorView::~ShutDownImageAnimatorView()
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorView::~ShutDownImageAnimatorView");
+        ClearAll();
+        g_pShutDownAnimatorView = nullptr;
+    }
+    ShutDownImageAnimatorView *ShutDownImageAnimatorView::GetInstance()
+    {
+        return g_pShutDownAnimatorView;
+    }
+
+    void ShutDownImageAnimatorView::ClearAll(void)
+    {
+        if (group != nullptr)
+        {
+            group->RemoveAll();
+            if (shutDownImageAnimatorView != nullptr)
+            {
+                delete shutDownImageAnimatorView;
+                shutDownImageAnimatorView = nullptr;
+            }
+            FreeImagePathsArray(ShutDownPathsArray, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+            // FreeImageInfoArray(ShutDownPathsArray,ShutDownPaths,SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+            delete group;
+            group = nullptr;
+        }
+    }
+
+    void ShutDownImageAnimatorView::OnAnimatorStop(UIView &view)
+    {
+        UNUSED(view);
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnAnimatorStop");
+        switch (OperationType)
+        {
+        case 0:
+            // uapi_poweroff_device(); // 关机
+             shutdown_reboot_prejobs(SHUTDOWN_TYPE);
+            break;
+        case 1:
+            // uapi_reboot_device(); // 重启
+             shutdown_reboot_prejobs(REBOOT_TYPE);
+            break;
+        case 2:
+            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING, NULL, 0);
+            break;
+        case 3:
+#ifdef SUPPORT_BLE_SERVICE
+            cleanUnbindInfor(1);
+#endif
+        default:
+            break;
+        }
+    }
+
+    UIImageAnimatorView *ShutDownImageAnimatorView::GeShutDownImageAnimatorView(void)
+    {
+        return shutDownImageAnimatorView;
+    }
+
+    //  0 关机 1 重启 2 恢复出厂 3解绑恢复出厂
+    void ShutDownImageAnimatorView::ShutDownImageAnimator_Start(int type)
+    {
+        OperationType = type; // 保存操作类型:0 关机 1 重启 2 恢复出厂 3解绑恢复出厂
+        
+        shutDownImageAnimatorView->Start(); // 开始播放关机动画
+
+        uapi_dev_runtime_set_shutting_down_status(1);//设置关机状态runtime值
+
+        ScreenOffEnable(false);
+        uapi_set_screen_on_api();
+        // ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 关机动画已经开始了不能息屏
+
+        uapi_take_to_wake(0); // 关闭抬腕亮屏,和息屏
+
+        NativeAbility::GetInstance().SetCurSlicePriority(0); // 设置Slice优先级为最高,防止弹窗出现
+
+        // 关机增加震动
+        ui_api_vibrate_once_func();
+    }
+
+    // 获取开机动画是否已经开始
+    bool ShutDownImageAnimatorView::GetShutDownImageAnimatorIsStart(void)
+    {
+        if (uapi_dev_runtime_get_shutting_down_status() == 1)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "正在进行关机动画");
+            isShutDownImageAnimatorStart = true;
+        }
+        else
+        {
+            isShutDownImageAnimatorStart = false;
+        }
+        return isShutDownImageAnimatorStart;
+    }
+
+    bool ShutDownImageAnimatorView::ShowUpShutDownAnimatorView()
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorView::ShowUpShutDownAnimatorView");
+        ShutDownPathsArray = CreateImagePathsArray(ShutDownPaths, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+        // ShutDownPathsArray = CreateImageInfoArray(ShutDownPaths, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+
+        if (shutDownImageAnimatorView == nullptr)
+        {
+            shutDownImageAnimatorView = new UIImageAnimatorView();
+            if (shutDownImageAnimatorView == nullptr)
+            {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView new ShutDownImageAnimatorView fail");
+                return false;
+            }
+            for (uint8_t i = 0; i < SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)
+            {
+                ShutDownImageInfo[i].imagePath = (ShutDownPathsArray[i]);
+                ShutDownImageInfo[i].imageType = IMG_SRC_FILE_PATH;
+                // ShutDownImageInfo[i].imageInfo = (ShutDownPathsArray[i]);
+                // ShutDownImageInfo[i].imageType = IMG_SRC_IMAGE_INFO;
+                ShutDownImageInfo[i].pos.x = SHUTDOWN_IMAGE_ANIMATOR_VIEW_X;
+                ShutDownImageInfo[i].pos.y = SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y;
+                ShutDownImageInfo[i].width = SHUTDOWN_IMAGE_ANIMATOR_VIEW_W;
+                ShutDownImageInfo[i].height = SHUTDOWN_IMAGE_ANIMATOR_VIEW_H;
+            }
+            shutDownImageAnimatorView->SetPosition(SHUTDOWN_IMAGE_ANIMATOR_VIEW_X, SHUTDOWN_IMAGE_ANIMATOR_VIEW_Y, SHUTDOWN_IMAGE_ANIMATOR_VIEW_W, SHUTDOWN_IMAGE_ANIMATOR_VIEW_H);
+            shutDownImageAnimatorView->SetStyle(STYLE_BACKGROUND_COLOR, 0xffffffff);
+            shutDownImageAnimatorView->SetStyle(STYLE_BACKGROUND_OPA, 0xff);
+            shutDownImageAnimatorView->SetImageAnimatorSrc(ShutDownImageInfo, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, 100);
+            shutDownImageAnimatorView->SetRepeat(false);
+            shutDownImageAnimatorView->SetRepeatTimes(1);
+            shutDownImageAnimatorView->SetAnimatorStopListener(this);
+        }
+
+        return true;
+    }
+
+    UIViewGroup *ShutDownImageAnimatorView::ShutDownAnimatorViewInit(void)
+    {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorView::InitShowUpView");
+        bool ret;
+        group = new UIViewGroup();
+        if (group == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");
+            return nullptr;
+        }
+        group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+        ret = ShowUpShutDownAnimatorView();
+        if (ret == false)
+        {
+            return nullptr;
+        }
+        group->Add(shutDownImageAnimatorView);
+        return group;
+    }
+}
\ No newline at end of file