From fbe332fcc26ce93f81ec9e568199763ad50d1d31 Mon Sep 17 00:00:00 2001 From: Caisking Date: Wed, 31 Dec 2025 17:49:43 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E7=94=B5=E6=B1=A0=E6=9B=B4?= =?utf8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/notify/charge_notification.cpp | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) 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) -- 2.17.1