From b32275facf55862f2951cc13506cf77faa44e795 Mon Sep 17 00:00:00 2001 From: hcj <1224667075@qq.com> Date: Sat, 29 Jun 2024 11:30:15 +0800 Subject: [PATCH] =?utf8?q?=E4=BD=8E=E7=94=B5=E9=87=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../msg_center/src/msg_center_customer.cpp | 17 +++++--- .../src/notify/charge_notification.cpp | 43 +++++++++++++------ 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp index 952555216..146972a6b 100644 --- a/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/msg_center_customer.cpp @@ -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); diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp index 5fe43358b..deb75d3a1 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/charge_notification.cpp @@ -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(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(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) -- 2.17.1