移除训练的uapi_add_sport_vote()修改运动结束逻辑
authorCaisking <3449750381@qq.com>
Tue, 24 Sep 2024 12:34:01 +0000 (20:34 +0800)
committerCaisking <3449750381@qq.com>
Tue, 24 Sep 2024 12:34:01 +0000 (20:34 +0800)
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp

index 982df61..dc2b49d 100644 (file)
@@ -428,18 +428,10 @@ namespace OHOS
         if (state != ExerciseState::General)
         {
             /*运动开始并且是app发起的运动*/
-            if (Openingway == true)
+            if (Openingway == true && state != ExerciseState::End)
             {
                 sendtraningstatedata(static_cast<uint8_t>(state), sportdata->duration);
             }
-            else
-            {
-                /*手表发起并且是结束状态*/
-                if (state == ExerciseState::End)
-                {
-                    sendtraningstateend();
-                }
-            }
         }
         sportState_ = state;
     }
@@ -713,6 +705,16 @@ namespace OHOS
             sportTag_ = 0;
             sportTagType_ = ExerciseTag::UNKNOW;
 #endif
+            /*运动结束并且是手表发起的运动*/
+            if (Openingway == false)
+            {
+                sendtraningstateend();
+            }
+            /*运动结束并且是app发起的运动*/
+            else
+            {
+                sendtraningstatedata(0, sportdata->duration);
+            }
 
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "结束运动");
         }
index 29a583e..f5d312a 100644 (file)
@@ -74,7 +74,7 @@ TraingCardView::TraingCardView() {
   TraingModel::GetInstance()->SetSportState(\r
       ExerciseState::Start); // 设置运动状态为开始\r
   TraingModel::GetInstance()->SetTimestamp();\r
-  uapi_add_sport_vote(); // 保护进程\r
+  // uapi_add_sport_vote(); // 保护进程\r
   g_pTraingCardView = this;\r
 }\r
 \r
@@ -87,7 +87,7 @@ TraingCardView::~TraingCardView() {
   g_pTraingCardView = nullptr;\r
   DisableTimer(); // 关闭计时器\r
   TraingModel::GetInstance()->SetTimestamp();\r
-  uapi_remove_sport_vote(); // 移除\r
+  // uapi_remove_sport_vote(); // 移除\r
 }\r
 \r
 TraingCardView *TraingCardView::GetInstance() { return g_pTraingCardView; }\r