From bb2378262c95ecdcb2dfd8576fd9689cc9f81c49 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Fri, 7 Mar 2025 10:21:54 +0800 Subject: [PATCH] =?utf8?q?AI=20V2=20=E7=89=88=E6=9C=AC=E9=80=82=E9=85=8D23?= =?utf8?q?0UI=EF=BC=8CSDK=E7=9A=84AI=E5=AF=B9=E8=AF=9D=E9=9C=80=E8=A6=81?= =?utf8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E5=B7=B2=E5=8F=8D=E9=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../include/AivoiceReturnResultTextView.h | 3 ++- .../nativeui/aivoice/src/AiVoiceModel.cpp | 15 ++++++--------- .../nativeui/aivoice/src/AiVoicePresenter.cpp | 15 +++------------ .../nativeui/aivoice/src/AiVoiceView.cpp | 2 +- .../src/AivoiceReturnResultTextView.cpp | 19 ++++++++++++++++++- .../ble_service/bleservice/bleService.c | 5 +++-- 6 files changed, 33 insertions(+), 26 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceReturnResultTextView.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceReturnResultTextView.h index 6e67ed523..27d9e34aa 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceReturnResultTextView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceReturnResultTextView.h @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-22 16:46:26 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-07-31 11:45:08 + * @LastEditTime: 2025-03-07 09:26:23 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceReturnResultTextView.h */ @@ -59,6 +59,7 @@ namespace OHOS AivoiceChatContentListAdapter *GetAivoiceChatContentListAdapter(void); UIList *GetChatContentList(void); void UpdateTitleTextId(int textId); + void IsScrollChatContentList(bool isScroll); private: void ClearAll(void); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp index e89e1aaaa..651ec72f8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:14:50 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2025-02-18 14:48:15 + * @LastEditTime: 2025-03-07 10:14:18 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp */ #include "aivoice/include/AiVoiceModel.h" @@ -32,7 +32,7 @@ namespace OHOS { // 声明定时器变量 static osTimerId_t g_timer = nullptr; - static constexpr uint16_t THIRTY_TIME = 31; + static constexpr uint16_t THIRTY_TIME = 30; static int Time = THIRTY_TIME; static int AiModelConnectTimeout = 5; @@ -490,6 +490,7 @@ namespace OHOS /*清空上次用户问题和Ai回答字符串*/ void AiVoiceModel::ClearQuestionAndAiAnswerStr(void) { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "清空上次用户问题和Ai回答字符串"); userQuestionStr = ""; aiAnswerStr = ""; } @@ -506,7 +507,7 @@ namespace OHOS #endif int32_t AudioCaptureSample(int32_t argc, const char *argv[]); int32_t streamingRecordAndSend_AI(void); - #define IS_SUPPORT_REALTIME_RECORD_SEND_AI 1 + #define IS_SUPPORT_REALTIME_RECORD_SEND_AI 1 //是否支持实时发送录音数据 #ifdef __cplusplus }; #endif @@ -514,7 +515,7 @@ namespace OHOS // 开始聆听并录取用户问题 void AiVoiceModel::StartListenAndRecordingUserQuestion(void) { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::StartListenAndRecordingUserQuestion"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "聆听用户问题并发送录音数据"); AiVoiceView *view_ = AiVoiceView::GetInstance(); if (view_ == nullptr) { @@ -553,7 +554,7 @@ namespace OHOS // 停止聆听用户问题 void AiVoiceModel::StopListenAndRecordingUserQuestion(void) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::StopListenAndRecordingUserQuestion"); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "停止录音"); int32_t argc = 1; uint8_t *argv = (uint8_t *)"stop"; AudioCaptureSample(argc, (const char **)&argv); @@ -626,10 +627,6 @@ namespace OHOS { // 等待AI思考完成的定时器 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AIVoice_TimerCallbackProc,Time = %d", Time); - if (Time == 30) // 等待一秒,确保录音停止,发送录音准备就绪指令 - { - // AiVoiceModel::GetInstance().CheckFileAndSendAIIsReady(); - } if (Time < 0) // 如果思考时间超时30s,进入连接超时界面 { AiVoiceModel::GetInstance().AIVoice_StopTimer(); diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index 0b7d84912..5f3f402f6 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-06-20 15:11:17 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2024-11-19 22:08:14 + * @LastEditTime: 2025-03-06 16:10:32 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp */ #include "AppViewIDs.h" @@ -254,6 +254,7 @@ namespace OHOS break; case AIVOICE_RETURN_RESULT_TEXT_VIEWID: + AiVoiceModel::GetInstance().ClearQuestionAndAiAnswerStr(); // 清空上次用户问题和Ai回答字符串 if (showView == AIVOICE_LISTENING_VIEWID) { model->StartListenAndRecordingUserQuestion(); @@ -268,6 +269,7 @@ namespace OHOS return true; } + // 处理手点击屏幕切换AI模型 bool AiVoicePresenter::OnClick(UIView &view, const ClickEvent &event) { UNUSED(event); @@ -308,7 +310,6 @@ namespace OHOS if (it->first == AIVOICERETURNRESULTTEXT_CONTINUECHAT_BUTTON_VIEW_ID) // 点击继续对话按钮要发取消当前对话指令,避免AI回应中途按继续对话按钮没有取消上一次对话问题 { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "CancelCurAIChat"); - AiVoiceModel::GetInstance().ClearQuestionAndAiAnswerStr(); // 清空上次用户问题和Ai回答字符串 AiVoiceModel::GetInstance().CancelCurAIChat(); PlayersModel::GetInstance()->HandPausePhoneMusic(); // 暂停手机音乐 PlayersModel::GetInstance()->PlayerPause(); // 暂停手机音乐 @@ -316,11 +317,6 @@ namespace OHOS ChangeViewAndLogicOperator(it->second.first, it->second.second); return true; } - else - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Return false if viewId doesn't match any entry in the map"); - return false; - } return true; } @@ -410,11 +406,6 @@ namespace OHOS ChangeViewAndLogicOperator(it->second.first, it->second.second); return true; } - else - { - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Return false if viewId doesn't match any entry in the map"); - return false; - } return true; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp index ebd1cd90e..e61d04856 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2025-02-28 15:44:14 + * @LastEditTime: 2025-03-06 16:07:08 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp */ #include "aivoice/include/AiVoicePresenter.h" diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp index de3c212c0..0d5611b31 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp @@ -2,7 +2,7 @@ * @Author: luozheng 1732036298@qq.com * @Date: 2024-05-07 11:25:58 * @LastEditors: luozheng 1732036298@qq.com - * @LastEditTime: 2025-03-03 11:48:01 + * @LastEditTime: 2025-03-07 09:54:21 * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AivoiceReturnResultTextView.cpp */ #include "aivoice/include/AiVoicePresenter.h" @@ -364,4 +364,21 @@ namespace OHOS } } } + + void AivoiceReturnResultTextView::IsScrollChatContentList(bool isScroll) + { + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AivoiceReturnResultTextView::IsScrollChatContentList"); + if (isScroll) + { + scrollView->RequestFocus(); + chatContentList->SetTouchable(false); + chatContentList->SetDraggable(false); + } + else + { + chatContentList->RequestFocus(); + chatContentList->SetTouchable(true); + chatContentList->SetDraggable(true); + } + } } \ No newline at end of file diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index b8e760e5b..82dfd506e 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -2227,7 +2227,7 @@ static void blesrv_service_check_task(void const *arg) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ble_recv:end\r\n"); } } -#define BLESRV_APP_BOARD_MSG_COUNT 500 +#define BLESRV_APP_BOARD_MSG_COUNT 256 #define BLESRV_APP_BOARD_TASK_SIZE 0x2000 #define BLESRV_BOARD_TASK_PRIO 7 void create_blesrv_queue(void) @@ -2374,7 +2374,8 @@ errcode_t uapi_Ai_send_service_init(void) taskcfg.create_queue_handle = create_Ai_record_queue; taskcfg.attr.name = "Ai_record_queue_service"; taskcfg.attr.priority = osPriorityNormal; - taskcfg.attr.stack_size = BLESRV_APP_BOARD_TASK_SIZE; + // taskcfg.attr.stack_size = BLESRV_APP_BOARD_TASK_SIZE; + taskcfg.attr.stack_size = 0x800; taskcfg.func = blesrvAi_send_service_task; taskcfg.use_mem = USE_EXTEND_MEM; -- 2.17.1