From: Caisking Date: Wed, 31 Dec 2025 09:49:43 +0000 (+0800) Subject: 修复电池更新 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=fbe332fcc26ce93f81ec9e568199763ad50d1d31;p=mirrors%2FFD230.git 修复电池更新 --- diff --git a/code/sdk/application/wearable/fd272/service/msg_center/src/notify/charge_notification.cpp b/code/sdk/application/wearable/fd272/service/msg_center/src/notify/charge_notification.cpp index f79291eeb..8208824ea 100644 --- a/code/sdk/application/wearable/fd272/service/msg_center/src/notify/charge_notification.cpp +++ b/code/sdk/application/wearable/fd272/service/msg_center/src/notify/charge_notification.cpp @@ -17,6 +17,7 @@ #include "components/ui_circle_progress.h" #include "uicomponents/UIComponents.h" #include "charge_notification.h" +#include //#include "ui_resource_string.h" @@ -71,11 +72,13 @@ namespace OHOS osTimerId_t Chargeing_timer= NULL; - // 刷新回调 - void Chargeing_Timer_CallBack(int data) { - if (UIViewGroup_charge == nullptr || UILabel_Chargeing == nullptr || - UILabel_power == nullptr || UILabel_time == nullptr || - batteryprogress== nullptr) { + // 实际的UI更新逻辑(在图形线程中执行) + static void Chargeing_Timer_CallBackProc(int data) { + // 检查必要的UI组件是否存在(batteryprogress可能为nullptr,不影响更新) + if (UIViewGroup_charge == nullptr || + UILabel_power == nullptr || + UILabel_time == nullptr) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Chargeing_Timer_CallBackProc: UI组件为空,跳过更新"); return; } @@ -110,6 +113,18 @@ namespace OHOS UILabel_power->Invalidate(); } + // 如果batteryprogress存在,也更新它的值 + if (batteryprogress != nullptr) { + batteryprogress->SetValue(power); + batteryprogress->Invalidate(); + } + + } + + // 定时器回调函数(通过PostGraphicEvent投递到图形线程) + void Chargeing_Timer_CallBack(int data) { + GraphicService::GetInstance()->PostGraphicEvent( + std::bind(Chargeing_Timer_CallBackProc, data)); } bool is_UIViewGroup_charge(void)