低电量修改
authorhcj <1224667075@qq.com>
Sat, 29 Jun 2024 03:30:15 +0000 (11:30 +0800)
committerhcj <1224667075@qq.com>
Sat, 29 Jun 2024 03:30:15 +0000 (11:30 +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 9525552..146972a 100644 (file)
@@ -366,8 +366,8 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
     if (display_api->get_screen_state() != SCREEN_ON)
     {   
         display_api->turn_on_screen();  
-    }  
-    display_api->set_screen_set_keepon_timeout(1000*5);
+    }
+    display_api->set_auto_timeout_function(1000*5);
     if(*x==3)
     {
         //倒计时结束后,直接执行关机动画
@@ -377,17 +377,20 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req)
     {
         //提醒低电充电
         set_lowpower_falg(0);
-        // if (NotificationManager::GetInstance()->HasNotifyShowing())
-        //     NotificationManager::GetInstance()->StopNotify();
-        NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
+        NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_TWO);
+
+        if (NotificationManager::GetInstance()->HasNotifyShowing())
+        return;
         NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
     }
     else
     {
         //电量过低,直接提醒关机
+        display_api->set_auto_timeout_function(1000*10);
         set_lowpower_falg(1);
-        // if (NotificationManager::GetInstance()->HasNotifyShowing())
-        //     NotificationManager::GetInstance()->StopNotify();
+        if (NotificationManager::GetInstance()->HasNotifyShowing())
+        NotificationManager::GetInstance()->StopNotify();
+
         NotificationManager::GetInstance()->SetNotifyPriority(PRIORITY_ONE);
         NotificationManager::GetInstance()->ShowNotify(showlowpowerNotify, (uint16_t)topic, true);
 
index 5fe4335..deb75d3 100644 (file)
@@ -52,6 +52,17 @@ namespace OHOS
     //         imageCharge->SetVisible(true);
     //     }
     // }
+
+    static void FreeImagePathsArray(const char **imagePaths, const int numImages)
+    {
+        for (int i = 0; i < numImages; i++)
+        {
+            // ImageCacheManager::GetInstance().UnloadSingleRes(imagePaths[i]);
+            delete imagePaths[i];
+            imagePaths[i] = nullptr;
+        }
+    }
+
     static const char ** CreateImagePathsArray(const char *basePath, const char *fileExtension, int numImages)
     {
         const char **imagePaths = new const char *[numImages];
@@ -65,15 +76,15 @@ namespace OHOS
         return imagePaths;
     }
 
-    UIViewGroup * ShowUpShutDownAnimatorView()
+    void ShowUpShutDownAnimatorView()
     {
         group = new UIViewGroup();
         if (group == nullptr)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "group new fail");
-            return nullptr;
+            return ;
         }
-        group->SetPosition(0, 0, HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
+        group->SetPosition(0, 0, 466, 466);
 
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ShutDownAnimatorView::ShowUpShutDownAnimatorView");
         ShutDownPathsArray = CreateImagePathsArray(ShutDownPaths, "bin", SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
@@ -84,7 +95,7 @@ namespace OHOS
             if (ShutDownImageAnimatorView == nullptr)
             {
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "BluetoothEarPhoneView new ShutDownImageAnimatorView fail");
-                return NULL;
+                return ;
             }
             for (uint8_t i = 0; i < SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES; i++)
             {
@@ -103,11 +114,19 @@ namespace OHOS
             ShutDownImageAnimatorView->SetRepeatTimes(1);
            
         }
+        UIImageAnimatorView::AnimatorStopListener *stoplistener =  static_cast<UIImageAnimatorView::AnimatorStopListener *>(lowppowrAnimatorStopListener::GetInstance());
+        ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener);
+        if (stoplistener == nullptr)
+        {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!");
+            return;
+        }
+
         ShutDownImageAnimatorView->SetVisible(true);
         //ShutDownImageAnimatorView->Start();
         group->SetVisible(false);
         group->Add(ShutDownImageAnimatorView);
-        return group;
+        return ;
     }
 
     static uint8_t battery_falg=0;
@@ -149,6 +168,7 @@ namespace OHOS
             group = nullptr;
 
         }
+        FreeImagePathsArray(ShutDownPathsArray,SHUTDOWN_IMAGE_ANIMATOR_VIEW_NUM_FRAMES);
       
         RootView::GetInstance()->Remove(UIViewGroup_lowpower);
         delete UIViewGroup_lowpower;
@@ -292,13 +312,6 @@ namespace OHOS
         if(battery_falg>=3)
         {
             group->SetVisible(true);
-            UIImageAnimatorView::AnimatorStopListener *stoplistener =  static_cast<UIImageAnimatorView::AnimatorStopListener *>(lowppowrAnimatorStopListener::GetInstance());
-            ShutDownImageAnimatorView->SetAnimatorStopListener(stoplistener);
-            if (stoplistener == nullptr)
-            {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Failed to Create stoplistener!!");
-                return NULL;
-            }
             ShutDownImageAnimatorView->Start();
         }
         return UIViewGroup_lowpower;
@@ -345,10 +358,16 @@ namespace OHOS
     {
         //UNUSED(view);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "xxxxxxxxxxxxxxxxxxxxOnAnimatorStop");
+
+        NotificationManager::GetInstance()->StopNotify();
+
         if(battery_falg==4)
         uapi_reboot_device();
         else
         uapi_poweroff_device(); // 关机 
+
+       
+
         //NotificationManager::GetInstance()->StopNotify();
         //
         // if(strcmp(view.GetViewId(),LOW_POWER_BUTTON)!=0)