From 6f1f3d126f701a72406c14fe58fa4fb1ded39a8f Mon Sep 17 00:00:00 2001 From: Caisking Date: Tue, 24 Feb 2026 10:56:35 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E7=9B=AE=E6=A0=87=E8=BE=BE?= =?utf8?q?=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../msg_center/src/msg_center_customer.cpp | 100 ++++++++---------- 1 file changed, 46 insertions(+), 54 deletions(-) diff --git a/code/sdk/application/wearable/fd272/service/msg_center/src/msg_center_customer.cpp b/code/sdk/application/wearable/fd272/service/msg_center/src/msg_center_customer.cpp index d5b30108e..cd5c49a70 100644 --- a/code/sdk/application/wearable/fd272/service/msg_center/src/msg_center_customer.cpp +++ b/code/sdk/application/wearable/fd272/service/msg_center/src/msg_center_customer.cpp @@ -77,9 +77,9 @@ #include "sleep/include/SleepModel.h" #include "health/health_service/health_service.h" #include "player/include/PlayersModelC.h" - #include "system/include/SystemLogModelC.h" - - #include "bloodoxygen/include/BloodOxygenModel.h" +#include "system/include/SystemLogModelC.h" + +#include "bloodoxygen/include/BloodOxygenModel.h" #include "heartrate/include/HeartModel.h" #include "saveele/include/SaveEleModel.h" #include "respiratorytraining/include/RespiratoryTrainingModel.h" @@ -1041,7 +1041,7 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req) static uint8_t goal_type=0; void MsgCenterNotifystepProc(const Topic topic, Request* req) { - //unused(req); + (void)topic; if (req->msgId == TOPIC_EVENT_STEPDATA_UPDATE) { @@ -1050,7 +1050,6 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req) return; } // 计步数据累加 - OHOS::GoalModel::GetInstance().show_data_step_refresh(); OHOS::GoalModel::GetInstance().show_data_calories_refresh(); OHOS::GoalModel::GetInstance().show_data_distance_refresh(); @@ -1059,75 +1058,63 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req) { GraphicService::GetInstance()->PostGraphicEvent( std::bind(&OHOS::GoalView::GoalViewrefresh, OHOS::GoalView::GetInstance() )); - - // OHOS::GoalView::GetInstance()->GoalViewrefresh(); } if(OHOS::GoalotherView::GetInstance()) { - //OHOS::GoalotherView::GetInstance()->GoalViewrefresh(); GraphicService::GetInstance()->PostGraphicEvent( std::bind(&OHOS::GoalotherView::GoalViewrefresh, OHOS::GoalotherView::GetInstance() )); } - if(OHOS::GoalModel::GetInstance().getstepvalue()>=100) - { + /* 运动过程中不弹目标达成,避免打扰用户;使用 runtime 训练状态(0 未训练/结束,1 训练中) */ + if (uapi_dev_runtime_get_train_status() != 0) { + return; + } - goal_type=GOAL_STEP; - if(get_Is_show_flag(goal_type)) - { - if(OHOS::GoalModel::GetInstance().get_step_goal_show()) - { - CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1); - } + /* 同时只弹一个:本轮只发布第一个达成的目标,顺序:步数 -> 距离 -> 燃脂 -> 站立 -> 卡路里 */ + bool published = false; + if (!published && OHOS::GoalModel::GetInstance().getstepvalue() >= 100) + { + goal_type = GOAL_STEP; + if (get_Is_show_flag(goal_type) && OHOS::GoalModel::GetInstance().get_step_goal_show()) + { + CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW, (uint8_t *)&goal_type, 1); + published = true; } } - - if(OHOS::GoalModel::GetInstance().is_goal_DISTANCE_done()) + if (!published && OHOS::GoalModel::GetInstance().is_goal_DISTANCE_done()) { - goal_type=GOAL_DISTANCE; - if(get_Is_show_flag(goal_type)) - { - if(OHOS::GoalModel::GetInstance().get_other_goal_show()) - { - CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1); - } - + goal_type = GOAL_DISTANCE; + if (get_Is_show_flag(goal_type) && OHOS::GoalModel::GetInstance().get_other_goal_show()) + { + CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW, (uint8_t *)&goal_type, 1); + published = true; } } - - if(OHOS::GoalModel::GetInstance().is_goal_fatburning_done()) + if (!published && OHOS::GoalModel::GetInstance().is_goal_fatburning_done()) { - goal_type=GOAL_FAT; - if(get_Is_show_flag(goal_type)) - { - if(OHOS::GoalModel::GetInstance().get_other_goal_show()) - { - CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1); - } + goal_type = GOAL_FAT; + if (get_Is_show_flag(goal_type) && OHOS::GoalModel::GetInstance().get_other_goal_show()) + { + CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW, (uint8_t *)&goal_type, 1); + published = true; } } - - if(OHOS::GoalModel::GetInstance().is_goal_stand_done()) + if (!published && OHOS::GoalModel::GetInstance().is_goal_stand_done()) { - goal_type=GOAL_STAND; - if(get_Is_show_flag(goal_type)) - { - if(OHOS::GoalModel::GetInstance().get_other_goal_show()) - { - CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1); - } + goal_type = GOAL_STAND; + if (get_Is_show_flag(goal_type) && OHOS::GoalModel::GetInstance().get_other_goal_show()) + { + CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW, (uint8_t *)&goal_type, 1); + published = true; } } - - if(OHOS::GoalModel::GetInstance().is_goal_calories_done()) + if (!published && OHOS::GoalModel::GetInstance().is_goal_calories_done()) { - goal_type=GOAL_CALOREIE; - if(get_Is_show_flag(goal_type)) - { - if(OHOS::GoalModel::GetInstance().get_other_goal_show()) - { - CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW,(uint8_t *)&goal_type,1); - } + goal_type = GOAL_CALOREIE; + if (get_Is_show_flag(goal_type) && OHOS::GoalModel::GetInstance().get_other_goal_show()) + { + CustomEventPublish(TOPIC_EVENT_GOAL_SHOW_VIEW, (uint8_t *)&goal_type, 1); + published = true; } } #endif @@ -1329,6 +1316,11 @@ void MsgCenterNotifyLowPowerAlarmProc(const Topic topic, Request* req) void MsgCenterNotifyGoalShowViewProc(const Topic topic, Request* req) { unused(req); + /* 同时只弹一个:若当前已在显示目标达成弹窗,则不再叠加 */ + if (NotificationManager::GetInstance()->GetShowingNotifyId() == static_cast(TOPIC_EVENT_GOAL_SHOW_VIEW)) + { + return; + } WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "MsgCenterNotifyGoalShowViewProc目标达成 !"); if (CheckPriority(topic)) { -- 2.17.1