增加语音助手Slice的相关宏
authorCaisking <Casiking@zhihuishixun.com>
Thu, 28 Aug 2025 06:10:09 +0000 (14:10 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Thu, 28 Aug 2025 06:10:09 +0000 (14:10 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/assistant/src/AssistantModel.cpp
code/sdk/zhihui/utils/custom_runtime.h

index 4d0388c..4f0deee 100644 (file)
@@ -7,11 +7,24 @@
 #include "AppViewIDs.h"
 #include "NativeAbility.h"
 
-// #include "bleEvent.h"
-// #include "cat1_ctl.h"
-// #include "cat1_server.h"
-// #include "http_client.h"
-// #include "vibrator_service.h"
+#ifdef SUPPORT_BLE_SERVICE
+#include <bleEvent.h>
+#include "bleService.h"
+#endif
+
+#ifdef SUPPORT_CAT1_SERVICE
+#include "cat1_ctl.h"
+#include "cat1_server.h"
+#include "http_client.h"
+#include "lwip/err.h"
+#endif
+
+#ifdef SUPPORT_PHONE_SERVICE
+#include "PhoneService.h"
+#include "phoneservice/include/PhoneServiceC.h"
+#endif
+
+#include "vibrator_service.h"
 
 #include "broadcast_feature.h"
 #include "broadcast_service.h"
@@ -36,8 +49,6 @@
 #include <string>
 #include <vector>
 
-// #include "PhoneService.h"
-// #include "phoneservice/include/PhoneServiceC.h"
 
 extern "C" {
 int uapi_open_voice_recognition(void);
@@ -142,35 +153,41 @@ void AssistantModel::Init() {
 
 //获取状态[hfp]
 bool AssistantModel::GetHFPStatus(void) {
-  // if (uapi_hfp_connect_state()) {
-  //   WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "uapi_hfp_connect_state is ok");
-  //   return true;
-  // }
+#ifdef SUPPORT_PHONE_SERVICE
+  if (uapi_hfp_connect_state()) {
+    WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "uapi_hfp_connect_state is ok");
+    return true;
+  }
+#endif
   WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "uapi_hfp_connect_state is failed");
   return false;
 }
 //开启语音助手[soc]
 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;
-  // }
+#ifdef SUPPORT_PHONE_SERVICE
+  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;
+  }
+#endif
   WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
                 "uapi_open_voice_recognition is failed");
   return false;
 }
 //关闭语音助手
 void AssistantModel::StopAssistant(void) {
-  // if (uapi_close_voice_recognition() == 0) {
-  //   WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
-  //                 "uapi_close_voice_recognition is ok");
-  // } else {
-  //   WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
-  //                 "uapi_close_voice_recognition is failed");
-  // }
+#ifdef SUPPORT_PHONE_SERVICE
+  if (uapi_close_voice_recognition() == 0) {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "uapi_close_voice_recognition is ok");
+  } else {
+    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+                  "uapi_close_voice_recognition is failed");
+  }
+#endif
 }
 
 //语音回答界面->主界面
@@ -186,7 +203,7 @@ bool AssistantModel::ChangeToMainView(void) {
       p_AssistantView->GetAssistantScrollView(ASSISTANT_MAIN_VIEW)
               ->IsVisible() == false) {
     //设置退出状态
-    // uapi_dev_runtime_set_voice_status(0);
+    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 a834b4b..a352589 100644 (file)
@@ -279,6 +279,10 @@ 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);
 // 获取被动心率检测状态