解决,#878,手表,恢复出厂设置时,频繁点击按钮会持续震动bug
authorluozheng <1732036298@qq.com>
Sun, 29 Sep 2024 10:38:52 +0000 (18:38 +0800)
committerluozheng <1732036298@qq.com>
Sun, 29 Sep 2024 10:38:52 +0000 (18:38 +0800)
恢复出厂添加关机动画

code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/ShutDownImageAnimatorView.cpp
code/sdk/application/wearable/fd230app/nativeui/system/src/SystemPresenter.cpp

index 89cc1e5..653ffb8 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-07-20 11:05:46
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-28 20:21:31
+ * @LastEditTime: 2024-09-29 18:03:03
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/ShutDownImageAnimatorView.h
  */
 
@@ -30,7 +30,7 @@ namespace OHOS
         static ShutDownImageAnimatorView *GetInstance();
         UIViewGroup *ShutDownAnimatorViewInit(void);
         UIImageAnimatorView *GeShutDownImageAnimatorView(void);
-        void ShutDownImageAnimator_Start(bool state);
+        void ShutDownImageAnimator_Start(int type);
         bool GetShutDownImageAnimatorIsStart(void);
 
     private:
@@ -42,7 +42,7 @@ namespace OHOS
         UIImageAnimatorView *shutDownImageAnimatorView{nullptr};                      // 关机动画
         ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息
         const char **ShutDownPathsArray{nullptr};                                     // 关机图片路径数组
-        bool isShutDownOperation;
+        int OperationType;
         bool isShutDownImageAnimatorStart{false};
     };
 }
index 90d00fa..362a826 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-20 15:11:17
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-09-19 14:21:00
+ * @LastEditTime: 2024-09-29 18:14:14
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/RebootAndShutdownPresenter.cpp
  */
 #include "AppViewIDs.h"
@@ -83,7 +83,9 @@ namespace OHOS
         else if (strcmp(view.GetViewId(), FACTORY_RESET_BUTTON_CHECK_ON) == 0) // 恢复出厂设置确认
         {
             ui_api_vibrate_once_func(); //恢复出厂增加震动
-            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING, NULL, 0);
+            view_->ChangeView(FACTORYRESET, SHUTDOWNANIMATOR);
+            ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(2);
+            isShutDownImageAnimatorStart = true;
             return true;
         }
         else if (strcmp(view.GetViewId(), FACTORY_RESET_BUTTON_CHECK_OFF) == 0) // 恢复出厂设置取消
@@ -100,7 +102,7 @@ namespace OHOS
             start_shutdown_or_reboot();
             shutdown_reboot_prejobs();
 
-            ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(true);
+            ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(0);
             isShutDownImageAnimatorStart = true;
         }
         else if (&view == view_->GetButtonCancel()) // 关机取消
index 60db0d2..7cf2bed 100644 (file)
@@ -50,13 +50,19 @@ namespace OHOS
     {
         UNUSED(view);
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownPresenter::OnAnimatorStop");
-        if (isShutDownOperation == true)
+        switch (OperationType)
         {
+        case 0:
             uapi_poweroff_device(); // 关机
-        }
-        else
-        {
+            break;
+        case 1:
             uapi_reboot_device(); // 重启
+            break;
+        case 2:
+            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING, NULL, 0);
+            break;
+        default:
+            break;
         }
     }
 
@@ -65,15 +71,15 @@ namespace OHOS
         return shutDownImageAnimatorView;
     }
 
-    // true 关机 false 重启
-    void ShutDownImageAnimatorView::ShutDownImageAnimator_Start(bool state)
+    //  0 关机 1 重启 2 恢复出厂
+    void ShutDownImageAnimatorView::ShutDownImageAnimator_Start(int type)
     {
-        isShutDownOperation = state;
+        OperationType = type;
         shutDownImageAnimatorView->Start();
         isShutDownImageAnimatorStart = true;
-        ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);//关机动画已经开始了不能息屏
+        ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON); // 关机动画已经开始了不能息屏
 
-        //关机增加震动
+        // 关机增加震动
         ui_api_vibrate_once_func();
     }
 
@@ -86,7 +92,7 @@ namespace OHOS
     bool ShutDownImageAnimatorView::ShowUpShutDownAnimatorView()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ShutDownImageAnimatorView::ShowUpShutDownAnimatorView");
-        ShutDownPathsArray = CreateImagePathsArray(ShutDownPaths,  SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
+        ShutDownPathsArray = CreateImagePathsArray(ShutDownPaths, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
 
         if (shutDownImageAnimatorView == nullptr)
         {
index 8daedb0..25111ea 100644 (file)
@@ -199,7 +199,7 @@ namespace OHOS
             start_shutdown_or_reboot();\r
             shutdown_reboot_prejobs();\r
 \r
-            ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(false);\r
+            ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(1);\r
             isShutDownImageAnimatorStart = true;\r
             return true;\r
         }\r
@@ -214,7 +214,7 @@ namespace OHOS
             start_shutdown_or_reboot();\r
             shutdown_reboot_prejobs();\r
 \r
-            ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(true);\r
+            ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(0);\r
             isShutDownImageAnimatorStart = true;\r
             return true;\r
         }\r
@@ -226,7 +226,9 @@ namespace OHOS
         else if (strcmp(view.GetViewId(), FACTORYRESET_CHECKON) == 0) // 恢复出厂设置确认\r
         {\r
             ui_api_vibrate_once_func(); //恢复出厂增加震动\r
-            do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING, NULL, 0);\r
+            p_SystemView->ChangeView(FACTORYRESETVIEW, SHUTDOWNANIMATIONVIEW);\r
+            ShutDownImageAnimatorView::GetInstance()->ShutDownImageAnimator_Start(2);\r
+            isShutDownImageAnimatorStart = true;\r
             return true;\r
         }\r
         else if (strcmp(view.GetViewId(), FACTORYRESET_CHECKOFF) == 0) // 恢复出厂设置取消\r