Merge #1636 into sdk602patch0911 from refs/changes/1636/head 1639/target/1
author袁清梦 <3449750381@qq.com>
Sat, 18 Jan 2025 08:16:29 +0000 (08:16 +0000)
committer袁清梦 <3449750381@qq.com>
Sat, 18 Jan 2025 08:16:29 +0000 (08:16 +0000)
Code review from 袁清梦

* refs/changes/1636/head: (9 commits squashed)

  - #1272 运动记录详情页面启动语音助手再退出,运动记录详情页面不能退出

  - 运动:过滤运动平均配速为0;最高最低配速为0的数据

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

  - 修复运动卡片内存泄漏

  - 语音助手:增加使用语音助手的情况下不进行弹窗

  - 训练:增加训练配速相关日志

  - Merge branch &#39;sdk602patch0911&#39; of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911

Signed-off-by: Caisking <3449750381@qq.com>
Reviewed-by: Caisking <3449750381@qq.com>
Reviewed-by: 罗正 <1732036298@qq.com>
Reviewed-by: aliyun8003852482 <1224667075@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Reviewed-by: aliyun6865282430 <1624952103@qq.com>
Merged-by: Caisking <3449750381@qq.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1636
code/sdk/application/wearable/fd230app/nativeui/assistant/src/AssistantModel.cpp
code/sdk/application/wearable/fd230app/nativeui/message/src/MessageModel.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingDataAllView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingControlView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDataView.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TrainingDetailView.cpp
code/sdk/drivers/peripheral/utils/custom_runtime.c
code/sdk/drivers/peripheral/utils/custom_runtime.h

index 75ccc7e..a9bd880 100644 (file)
@@ -145,6 +145,8 @@ bool AssistantModel::GetHFPStatus(void) {
 bool AssistantModel::StartAssistant(void) {
   if (uapi_open_voice_recognition() == 0) {
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "uapi_open_voice_recognition is ok");
+    //成功开启语音助手
+    uapi_dev_runtime_set_voice_status(1);
     return true;
   }
   WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
@@ -153,7 +155,6 @@ bool AssistantModel::StartAssistant(void) {
 }
 //关闭语音助手
 void AssistantModel::StopAssistant(void) {
-
   if (uapi_close_voice_recognition() == 0) {
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
                   "uapi_close_voice_recognition is ok");
@@ -175,6 +176,8 @@ bool AssistantModel::ChangeToMainView(void) {
               ->IsVisible() == true &&
       p_AssistantView->GetAssistantScrollView(ASSISTANT_MAIN_VIEW)
               ->IsVisible() == false) {
+    //设置退出状态
+    uapi_dev_runtime_set_voice_status(0);
     p_AssistantView->ChangeView(ASSISTANT_ANSWER_VIEW, ASSISTANT_MAIN_VIEW);
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "退出语音助手成功\r\n");
   }
index 83d0423..9566ae1 100644 (file)
@@ -207,9 +207,17 @@ static void Notify(void *args, const Topic topic, Request *request) {
 
     messageTimestamp = currentTimestamp;
 
+    /*
+      以下状态不进行消息弹窗
+      -训练中
+      -省电模式
+      -呼吸训练中
+      -使用语音助手
+    */
     if (uapi_dev_runtime_get_train_status() ||
         uapi_dev_runtime_get_saveele_status() ||
-        uapi_dev_runtime_get_respiratory_training_status()) {
+        uapi_dev_runtime_get_respiratory_training_status() ||
+        uapi_dev_runtime_get_voice_status()) {
 
       free(messageInfo_.title);
       free(messageInfo_.msg);
@@ -533,8 +541,6 @@ void MessageModel::AddMessageData(ancs_data_info_t *messageInfo) {
   WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "messageInfo add is ok");
 }
 
-
-
 // 获取目前的项
 MessageData *MessageModel::GetCurrentMessageData() {
   if (currentIndex_ < MessageVector.size()) {
index 30a9efa..88851ef 100644 (file)
@@ -547,18 +547,23 @@ void TraingModel::AnalysisData(cywee_activity_result_t *cyweeInfo) {
 /*分析activity extra info数据*/
 void TraingModel::AnalysisExtraData(
     cywee_activity_result_extre_info_t *cyweeInfo) {
-  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "extra data %d %d %d %d",
+
+  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[apc:%d fpc:%d cdc:%d std:%d]",
                 cyweeInfo->avg_pace, cyweeInfo->max_pace,
                 cyweeInfo->avg_step_freq, cyweeInfo->avg_step_len);
+  //平均配速
   if (cyweeInfo->avg_pace != 0) {
     sportdata->apc = cyweeInfo->avg_pace;
   }
+  //最快配速
   if (cyweeInfo->max_pace != 0) {
-    sportdata->fpc = cyweeInfo->max_pace;
+    sportdata->fpc =cyweeInfo->max_pace;
   }
+  //平均步频
   if (cyweeInfo->avg_step_freq != 0) {
     sportdata->cdc = cyweeInfo->avg_step_freq;
   }
+  //平均步长
   if (cyweeInfo->avg_step_len != 0) {
     sportdata->std = cyweeInfo->avg_step_len * 100; // 前者cm 后者m
   }
@@ -1755,7 +1760,7 @@ void TraingModel::SendLiveDataIfNecessary() {
   }
 }
 
-// 每10秒进行配速和心率数据存储
+// 每5秒进行配速和心率数据存储
 void TraingModel::StoreDataIfMinutePassed() {
   if (sportdata->duration % 5 == 0) {
     uint32_t timestamp;
index 51c7982..f7ac60c 100644 (file)
@@ -495,7 +495,9 @@ void TraingCardPresenter::handleEndState() {
   ControlSensor(ExerciseState::End);\r
   uapi_set_screen_on_api(); // 亮屏\r
 #if DATATEST\r
-  NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA);\r
+  // NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGENDDATA);\r
+  // 回退\r
+  NativeAbility::GetInstance().ChangeSlice(VIEW_TRAININGNOMAL);\r
   return;\r
 #endif\r
   // 是否达到训练目标\r
index d61e7ca..ca2ebc0 100644 (file)
@@ -20,7 +20,6 @@
 #include "traing/include/TraingModel.h"\r
 #include "uicomponents/UIComponents.h"\r
 \r
-\r
 extern "C" {\r
 void StartTimer();\r
 void StopAndResetTimer();\r
@@ -634,6 +633,7 @@ void TraingCardView::DeInit() {
   endView->RemoveAll();\r
   getView->RemoveAll();\r
   heartView->RemoveAll();\r
+  DetailView->RemoveAll();\r
 \r
   /*标签*/\r
   delete endtitle;\r
@@ -644,6 +644,7 @@ void TraingCardView::DeInit() {
   endnotelabel = nullptr;\r
   delete endnote;\r
   endnote = nullptr;\r
+\r
   delete labeltitle;\r
   labeltitle = nullptr;\r
   delete labeltag;\r
@@ -652,6 +653,7 @@ void TraingCardView::DeInit() {
   labelgettag = nullptr;\r
   delete labelpre;\r
   labelpre = nullptr;\r
+\r
   delete hearttitle;\r
   hearttitle = nullptr;\r
   delete labelnote;\r
@@ -684,6 +686,8 @@ void TraingCardView::DeInit() {
   dataallview_ = nullptr;\r
   delete musicview_;\r
   musicview_ = nullptr;\r
+  delete DetailView; //删除屏蔽卡片\r
+  DetailView = nullptr;\r
 \r
   /*弹窗*/\r
   delete endView;\r
@@ -1031,7 +1035,11 @@ void TraingCardView::OnTearDownView() {
 \r
 void TraingCardView::OnStop() {\r
   View<TraingCardPresenter>::OnStop();\r
-  container_ = nullptr;\r
+  // if (container_ != nullptr) {\r
+  //   container_->RemoveAll();\r
+  //   delete container_;\r
+  //   container_ = nullptr;\r
+  // }\r
   RootView::GetInstance()->RemoveAll();\r
   return;\r
 }\r
index 1579cf2..1c92c91 100644 (file)
@@ -42,6 +42,12 @@ void TraingDataAllView::ClearAll(void) {
 
   delete trainingDetailView;
   trainingDetailView = nullptr;
+
+  delete trainingDataAllView;
+  trainingDataAllView = nullptr;
+
+  delete traingDataAllPageView;
+  traingDataAllPageView = nullptr;
 }
 
 UISwipeView *TraingDataAllView::TraingDataAllViewInit(void) {
index 1ddd7d6..1ca79f2 100644 (file)
@@ -93,6 +93,7 @@ UIButton *TrainingControlView::GetButton() { return buttonStop; }
 void TrainingControlView::DeInit() {
   RemoveAll();
   if (labeltitle != nullptr) {
+    delete labeltitle;
     labeltitle = nullptr;
   }
   if (labeltimer != nullptr) {
index 416024c..be8bfee 100644 (file)
 #include "common/image_cache_manager.h"
 #include "components/ui_button.h"
 #include "components/ui_label_ext.h"
+#include "custom_runtime.h"
 #include "traing/Training_UiConfig.h"
 #include "traing/include/TraingModel.h"
 #include "ui_resource_image.h"
 #include "ui_resource_string.h"
 #include "uicomponents/UIComponents.h"
 #include <ui_scroll_view.h>
-#include "custom_runtime.h"
 
 namespace OHOS {
 
@@ -31,7 +31,6 @@ TrainingDataView::TrainingDataView() {
 }
 
 TrainingDataView::~TrainingDataView() {
-  RemoveAll();
   DeInit();
   g_pTrainingDataView = nullptr;
 }
@@ -77,7 +76,6 @@ bool TrainingDataView ::InitPage() {
   InitLabelExt(sportlabel, 83, 120, 300, 35, "label2", sport_id,
                DEFAULT_VECTOR_FONT_FILENAME, 30);
   sportlabel->SetTextColor(Color::Gray());
-
   //数字统一使用DEFAULT_VECTOR_FONT_FILENAME_EN
   InitLabel(curtimelabel, 155, 60, 150, 50, "label1", "23:54",
             DEFAULT_VECTOR_FONT_FILENAME_EN, 40);
@@ -85,7 +83,6 @@ bool TrainingDataView ::InitPage() {
             DEFAULT_VECTOR_FONT_FILENAME_EN, 80);
   InitLabel(heartlabel, 85, 284, 230, 80, "label4", "--",
             DEFAULT_VECTOR_FONT_FILENAME_EN, 60);
-  
   InitLabel(ubpmlabel, 218, 284, 230, 80, "label5", "bpm",
             DEFAULT_VECTOR_FONT_FILENAME, 60);
   ubpmlabel->SetTextColor(Color::Gray());
@@ -98,12 +95,12 @@ bool TrainingDataView ::InitPage() {
   return true;
 
 #if 0
-        //  初始化Button
-        InitButton(buttonNote, 275, 350, 26, 26, BUTTONNOTE);
-        // Set additional property
-        buttonNote->SetImageSrc(NOTE_IMAGE, NOTE_IMAGE);
-        buttonNote->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingCardPresenter::GetInstance()));
-        Add(buttonNote);
+  //  初始化Button
+  InitButton(buttonNote, 275, 350, 26, 26, BUTTONNOTE);
+  // Set additional property
+  buttonNote->SetImageSrc(NOTE_IMAGE, NOTE_IMAGE);
+  buttonNote->SetOnClickListener(static_cast<UIView::OnClickListener *>(TraingCardPresenter::GetInstance()));
+  Add(buttonNote);
 #endif
   // 增加上拉卡片
   // SetCoverable(true);
@@ -113,6 +110,7 @@ bool TrainingDataView ::InitPage() {
 void TrainingDataView::DeInit() {
   RemoveAll();
   if (curtimelabel != nullptr) {
+    delete curtimelabel;
     curtimelabel = nullptr;
   }
   if (sportlabel != nullptr) {
@@ -131,6 +129,7 @@ void TrainingDataView::DeInit() {
     delete ubpmlabel;
     ubpmlabel = nullptr;
   }
+
   // 删除button
   if (buttonNote != nullptr) {
     delete buttonNote;
@@ -138,10 +137,6 @@ void TrainingDataView::DeInit() {
   }
 
   // 删除Image
-  if (image_lowIntensity != nullptr) {
-    delete image_lowIntensity;
-    image_lowIntensity = nullptr;
-  }
   if (image_iconup != nullptr) {
     delete image_iconup;
     image_iconup = nullptr;
@@ -150,6 +145,16 @@ void TrainingDataView::DeInit() {
     delete image_iconpoint;
     image_iconpoint = nullptr;
   }
+  if (image_heart != nullptr) {
+    delete image_heart;
+    image_heart = nullptr;
+  }
+  if (image_progress != nullptr) {
+    delete image_progress;
+    image_progress = nullptr;
+  }
+
+  //删除进度条圆圈
   if (circleProgress != nullptr) {
     delete circleProgress;
     circleProgress = nullptr;
@@ -173,12 +178,11 @@ void TrainingDataView::UpdataTime() {
   // 解析时间
   int hour = pTM.tm_hour;
   //需要判断显示的格式
-  if (uapi_dev_runtime_get_time_hour_show_model() ==  12)
-  {
-      if (pTM.tm_hour > 12)
-          hour = pTM.tm_hour - 12 ;
+  if (uapi_dev_runtime_get_time_hour_show_model() == 12) {
+    if (pTM.tm_hour > 12)
+      hour = pTM.tm_hour - 12;
   }
-  
+
   int minute = pTM.tm_min;
 
   // 将时间和日期转换为字符串
index 50ffe5e..1fce82c 100644 (file)
@@ -25,7 +25,6 @@ TrainingDetailView::TrainingDetailView() {
   g_pTrainingDetailView = this;
 }
 TrainingDetailView::~TrainingDetailView() {
-  RemoveAll();
   DeInit();
   g_pTrainingDetailView = nullptr;
 }
index 04e1656..c316da0 100644 (file)
@@ -106,6 +106,7 @@ typedef struct
     uint8_t transmitting_status;//是否处于ble传输状态
 
     uint8_t atuoota_status;//是否处于自动ota状态
+    uint8_t voice_status;//是否处于使用语音助手
 } runtime_status_t;
 
 
@@ -609,6 +610,15 @@ uint8_t uapi_dev_runtime_get_heartrate_detect_status(void)
 {
     return g_runtime.heartrate_detect_status;
 }
+//设置是否在使用语音助手功能
+void uapi_dev_runtime_set_voice_status(uint8_t status)
+{
+    g_runtime.voice_status = status;
+}
+uint8_t uapi_dev_runtime_get_voice_status(void)
+{
+    return g_runtime.voice_status;
+}
 // 设置是否为指南针页面状态
 void uapi_dev_runtime_set_mmc_status(uint8_t status)
 {
index 147df7a..1f414c9 100644 (file)
@@ -285,6 +285,9 @@ void uapi_dev_runtime_set_safemode_flag(uint8_t status);
 // 安全模式
 uint8_t uapi_dev_runtime_get_safemode_flag(void);
 
+//是否使用语音助手状态
+void uapi_dev_runtime_set_voice_status(uint8_t status);
+uint8_t uapi_dev_runtime_get_voice_status(void);
 
 void uapi_dev_runtime_set_hrs_passivity(uint8_t status);
 // 获取被动心率检测状态