解决关机动画被打断导致不能关机或者重启。 619/2 619/head
authorluozheng <1732036298@qq.com>
Wed, 31 Jul 2024 02:57:57 +0000 (10:57 +0800)
committerluozheng <1732036298@qq.com>
Wed, 31 Jul 2024 02:57:57 +0000 (10:57 +0800)
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp
code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownPresenter.cpp

index 9b3df54..69347ce 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-07-18 14:26:31
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-30 10:25:25
+ * @LastEditTime: 2024-07-31 10:43:04
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/include/RebootAndShutdownPresenter.h
  */
 
@@ -29,6 +29,7 @@ namespace OHOS
         RebootAndShutdownPresenter();
         virtual ~RebootAndShutdownPresenter();
         static RebootAndShutdownPresenter *GetInstance();
+        bool GetIsShutDownImageAnimator(void);
 
         void OnStart() override;
         void OnResume() override;
index 0d08dea..f653658 100644 (file)
@@ -2,11 +2,12 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-07-18 14:55:27
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-07-27 18:27:16
+ * @LastEditTime: 2024-07-31 10:49:15
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/rebootandshutdown/src/RebootAndShutdownModel.cpp
  */
 
 #include "rebootandshutdown/include/RebootAndShutdownModel.h"
+#include "rebootandshutdown/include/RebootAndShutdownPresenter.h"
 #include "wearable_log.h"
 #include "ConfigModel.h"
 #include "NativeAbility.h"
@@ -55,6 +56,13 @@ namespace OHOS
     static void HandlePowerKeyLongPress(void)
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandlePowerKeyLongPress");
+
+        RebootAndShutdownPresenter *rebootAndShutdownPresenter = RebootAndShutdownPresenter::GetInstance();
+        if (rebootAndShutdownPresenter != nullptr && true == rebootAndShutdownPresenter->GetIsShutDownImageAnimator())
+        {
+            return;
+        }
+
         const power_display_svr_api_t *display_api = power_display_svr_get_api();
         if (!display_api)
         {
@@ -86,8 +94,14 @@ namespace OHOS
 
     static void HandlePowerKeyDoubleClick(void)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandlePowerKeyDoubleClick");
-        // Handle PowerKey DoubleClick logic here
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandlePowerKeyDoubleClick");
+
+        RebootAndShutdownPresenter *rebootAndShutdownPresenter = RebootAndShutdownPresenter::GetInstance();
+        if (rebootAndShutdownPresenter != nullptr && true == rebootAndShutdownPresenter->GetIsShutDownImageAnimator())
+        {
+            return;
+        }
+
         const power_display_svr_api_t *display_api = power_display_svr_get_api();
         if (!display_api)
         {
@@ -117,7 +131,7 @@ namespace OHOS
     /*注册电源键的双击事件*/
     bool RebootAndShutdownModel::RegisterPowerKeyDoubleClickEvent(void)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterPowerKeyDoubleClickEvent");
+        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)
@@ -130,6 +144,14 @@ namespace OHOS
 
     static void HandFuncKeyOnPress(void)
     {
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::HandFuncKeyOnPress");
+
+        RebootAndShutdownPresenter *rebootAndShutdownPresenter = RebootAndShutdownPresenter::GetInstance();
+        if (rebootAndShutdownPresenter != nullptr && true == rebootAndShutdownPresenter->GetIsShutDownImageAnimator())
+        {
+            return;
+        }
+
         const power_display_svr_api_t *display_api = power_display_svr_get_api();
         if (!display_api)
         {
@@ -137,21 +159,13 @@ namespace OHOS
             return;
         }
         display_api->turn_on_screen();
-        // if (display_api->get_screen_state() == SCREEN_OFF) /*处于灭屏状态才亮屏*/
-        // {
-
-        // }
-        // else
-        // {
-        //     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Screen is on not to turn_on_screen");
-        // }
         return;
     }
 
     /*注册功能键的按下事件*/
     bool RebootAndShutdownModel::RegisterFuncKeyPressEvent(void)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyPressEvent");
+        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)
@@ -166,7 +180,13 @@ namespace OHOS
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandFuncKeyOnLongPress");
 
-        if(true == ConfigModel::GetInstance()->GetisFirstTimeStart())
+        RebootAndShutdownPresenter *rebootAndShutdownPresenter = RebootAndShutdownPresenter::GetInstance();
+        if (rebootAndShutdownPresenter != nullptr && true == rebootAndShutdownPresenter->GetIsShutDownImageAnimator())
+        {
+            return;
+        }
+
+        if (true == ConfigModel::GetInstance()->GetisFirstTimeStart())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandFuncKeyOnLongPress: first time power on");
             return;
@@ -213,7 +233,13 @@ namespace OHOS
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleFuncKeyOnClick");
 
-        if(true == ConfigModel::GetInstance()->GetisFirstTimeStart())
+        RebootAndShutdownPresenter *rebootAndShutdownPresenter = RebootAndShutdownPresenter::GetInstance();
+        if (rebootAndShutdownPresenter != nullptr && true == rebootAndShutdownPresenter->GetIsShutDownImageAnimator())
+        {
+            return;
+        }
+
+        if (true == ConfigModel::GetInstance()->GetisFirstTimeStart())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleFuncKeyOnClick: first time power on");
             return;
@@ -243,7 +269,7 @@ namespace OHOS
     /*注册功能键的单击事件*/
     bool RebootAndShutdownModel::RegisterFuncKeyClickEvent(void)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyClickEvent");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyClickEvent");
         int32_t ret = uapi_button_register_event_cb(HandleFuncKeyOnClick, BUTTON1_CLICKUP);
         if (ret != ERRCODE_SUCC)
         {
@@ -255,9 +281,15 @@ namespace OHOS
 
     static void HandleFuncKeyDoubleClick(void)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleFuncKeyDoubleClick");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HandleFuncKeyDoubleClick");
+
+        RebootAndShutdownPresenter *rebootAndShutdownPresenter = RebootAndShutdownPresenter::GetInstance();
+        if (rebootAndShutdownPresenter != nullptr && true == rebootAndShutdownPresenter->GetIsShutDownImageAnimator())
+        {
+            return;
+        }
 
-        if(true == ConfigModel::GetInstance()->GetisFirstTimeStart())
+        if (true == ConfigModel::GetInstance()->GetisFirstTimeStart())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleFuncKeyDoubleClick: first time power on");
             return;
@@ -283,7 +315,7 @@ namespace OHOS
     /*注册功能键双击事件*/
     bool RebootAndShutdownModel::RegisterFuncKeyDoubleClickEvent(void)
     {
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyDoubleClickEvent");
+        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "RebootAndShutdownModel::RegisterFuncKeyDoubleClickEvent");
         int32_t ret = uapi_button_register_event_cb(HandleFuncKeyDoubleClick, BUTTON1_CLICKUP_2);
         if (ret != ERRCODE_SUCC)
         {
index 8bbf6e0..460f98e 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-07-30 10:23:45
+ * @LastEditTime: 2024-07-31 10:43:30
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/RebootAndShutdownPresenter.cpp
  */
 #include "AppViewIDs.h"
@@ -221,4 +221,9 @@ namespace OHOS
         }
         return true;
     }
+
+    bool RebootAndShutdownPresenter::GetIsShutDownImageAnimator(void)
+    {
+        return isShutDownImageAnimatorStart;
+    }
 }
\ No newline at end of file