From 5062c7ba95fbc5fa5840c783c5085fa83b8f7181 Mon Sep 17 00:00:00 2001 From: Caisking Date: Thu, 28 Aug 2025 14:10:09 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E8=AF=AD=E9=9F=B3=E5=8A=A9?= =?utf8?q?=E6=89=8BSlice=E7=9A=84=E7=9B=B8=E5=85=B3=E5=AE=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/assistant/src/AssistantModel.cpp | 69 ++++++++++++------- code/sdk/zhihui/utils/custom_runtime.h | 4 ++ 2 files changed, 47 insertions(+), 26 deletions(-) diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/assistant/src/AssistantModel.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/assistant/src/AssistantModel.cpp index 4d0388c09..4f0deeedf 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/assistant/src/AssistantModel.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/assistant/src/AssistantModel.cpp @@ -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 +#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 #include -// #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"); } diff --git a/code/sdk/zhihui/utils/custom_runtime.h b/code/sdk/zhihui/utils/custom_runtime.h index a834b4b63..a352589a4 100644 --- a/code/sdk/zhihui/utils/custom_runtime.h +++ b/code/sdk/zhihui/utils/custom_runtime.h @@ -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); // 获取被动心率检测状态 -- 2.17.1