优化低电量关机 416/2
authorhcj <1224667075@qq.com>
Sat, 29 Jun 2024 06:06:41 +0000 (14:06 +0800)
committerhcj <1224667075@qq.com>
Sat, 29 Jun 2024 06:06:41 +0000 (14:06 +0800)
code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp
code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp

index 146972a..af96aa7 100644 (file)
@@ -386,6 +386,7 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
     else
     {
         //电量过低,直接提醒关机
+        display_api->turn_on_screen(); 
         display_api->set_auto_timeout_function(1000*10);
         set_lowpower_falg(1);
         if (NotificationManager::GetInstance()->HasNotifyShowing())
index deb75d3..5bb1d33 100644 (file)
@@ -9,6 +9,8 @@
 #include "battery_service.h"
 #include "NativeAbility.h"
 #include "custom_utils.h"
+#include "cmsis_os2.h"
+#include "linux/delay.h"
 namespace OHOS
 {
     UIImageView *imageCharge = nullptr;
@@ -19,15 +21,15 @@ namespace OHOS
     UIViewGroup *group=nullptr;
     UIImageAnimatorView *ShutDownImageAnimatorView=nullptr;
     static constexpr char *ShutDownPaths = "/user/res/RebootAndShutDown/ShutDown/"; //关机图片路径
-    static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES = 30; // 图片帧数
-    static constexpr int16_t SHUTDOWN_IMAGE_ANIMATOR_TIME = 150;           // 图片更新间隔
-    ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息
+    #define SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES 30 // 图片帧数
+    static int16_t SHUTDOWN_IMAGE_ANIMATOR_TIME = 130;           // 图片更新间隔
+    
     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;
     const char **ShutDownPathsArray{nullptr};                                     // 关机图片路径数组
-
+    ImageAnimatorInfo ShutDownImageInfo[SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES]; // 关机图像的信息
     #define LOW_POWER_BUTTON "LOW_POWER_BUTTON"
     // UIViewGroup *ChargingStatuShow()
     // {
@@ -97,6 +99,7 @@ namespace OHOS
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView new ShutDownImageAnimatorView fail");
                 return ;
             }
+           
             for (uint8_t i = 0; i < SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)
             {
                 ShutDownImageInfo[i].imagePath = (ShutDownPathsArray[i]);
@@ -109,7 +112,7 @@ namespace OHOS
             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->SetImageAnimatorSrc(ShutDownImageInfo, SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES, SHUTDOWN_IMAGE_ANIMATOR_TIME);
             ShutDownImageAnimatorView->SetRepeat(false);
             ShutDownImageAnimatorView->SetRepeatTimes(1);
            
@@ -159,6 +162,7 @@ namespace OHOS
         if(group)
         {
             group->RemoveAll();
+            ShutDownImageAnimatorView->Stop();
             if(ShutDownImageAnimatorView)
             {
             delete ShutDownImageAnimatorView;
@@ -357,9 +361,9 @@ namespace OHOS
     void lowppowrAnimatorStopListener::OnAnimatorStop(UIView &view)
     {
         //UNUSED(view);
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxxxxxxxxxOnAnimatorStop");
-
         NotificationManager::GetInstance()->StopNotify();
+        msleep(500);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxxxxxxxxxOnAnimatorStop");
 
         if(battery_falg==4)
         uapi_reboot_device();