From d2b7f95362dc5977691f67b3d8dc8f885d7493ed Mon Sep 17 00:00:00 2001 From: Caisking Date: Fri, 26 Dec 2025 18:59:05 +0800 Subject: [PATCH] =?utf8?q?GPS=E7=9A=84=E5=BC=80=E5=85=B3=E4=BD=BF=E7=94=A8?= =?utf8?q?=E5=BC=82=E6=AD=A5=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/traing/src/TraingModel.cpp | 30 +++++++++++-------- .../traing/src/TraingNomalPresenter.cpp | 5 ++++ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingModel.cpp index 699bd3995..07fb8565c 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingModel.cpp @@ -3104,12 +3104,15 @@ void TraingModel::stop_heart_gps() { if (gpsopen == true) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开始关闭GPS定位服务..."); - // 关闭gps - #if defined(SUPPORT_GNSS) - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "调用gnss_stop()关闭GPS服务"); - gnss_stop(); - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gnss_stop()调用完成"); - #endif + // 关闭gps +#if defined(SUPPORT_GNSS) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "调用gnss_stop()关闭GPS服务"); + GraphicService::GetInstance()->PostGraphicEvent([]() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "异步执行gnss_stop()"); + gnss_stop(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "gnss_stop()调用完成"); + }); +#endif //关闭心率检测 #ifdef SUPPORT_PPG_SERVICE @@ -3144,12 +3147,15 @@ if (gps_timer_count < 2) { return; } - if (gps_timer_count == 2) { - #if defined(SUPPORT_GNSS) - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开启gps"); - gnss_start(); - #endif - } + if (gps_timer_count == 2) { +#if defined(SUPPORT_GNSS) + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开启gps"); + GraphicService::GetInstance()->PostGraphicEvent([]() { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "异步执行gnss_start()"); + gnss_start(); + }); +#endif + } #if defined(SUPPORT_GNSS) gps_data_t send_gps_data = {0}; gps_data_t *gps_data = getPGPSGlobaldata(); diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingNomalPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingNomalPresenter.cpp index f02755c57..527a405e0 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingNomalPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/traing/src/TraingNomalPresenter.cpp @@ -8,6 +8,7 @@ #include "custom_utils.h" #include "common/key_code.h" +#include #include #include #include @@ -159,6 +160,10 @@ namespace OHOS //修改为秒级定时器更新GPS定位状态 void TraingNomalPresenter::OnTickEvent() { + if(TraingNomalView::GetInstance() == nullptr) + { + return; + } /*判断是否需要GPS*/ if(TraingModel::GetInstance()->IsNeedGPS(TraingModel::GetInstance()->GetSportEvent()) == false) { -- 2.17.1