AI V2 版本适配230UI,SDK的AI对话需要优化,已反馈 1689/1
authorluozheng <1732036298@qq.com>
Fri, 7 Mar 2025 02:21:54 +0000 (10:21 +0800)
committerluozheng <1732036298@qq.com>
Fri, 7 Mar 2025 02:21:54 +0000 (10:21 +0800)
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AivoiceReturnResultTextView.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AivoiceReturnResultTextView.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleService.c

index 6e67ed5..27d9e34 100644 (file)
@@ -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);
index e89e1aa..651ec72 100644 (file)
@@ -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();
index 0b7d849..5f3f402 100644 (file)
@@ -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;
     }
 
index ebd1cd9..e61d048 100644 (file)
@@ -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"
index de3c212..0d5611b 100644 (file)
@@ -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
index b8e760e..82dfd50 100644 (file)
@@ -2227,7 +2227,7 @@ static void blesrv_service_check_task(void const *arg)
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ble_recv:end\r\n");\r
     }\r
 }\r
-#define BLESRV_APP_BOARD_MSG_COUNT 500\r
+#define BLESRV_APP_BOARD_MSG_COUNT 256\r
 #define BLESRV_APP_BOARD_TASK_SIZE 0x2000\r
 #define BLESRV_BOARD_TASK_PRIO 7\r
 void create_blesrv_queue(void)\r
@@ -2374,7 +2374,8 @@ errcode_t uapi_Ai_send_service_init(void)
     taskcfg.create_queue_handle = create_Ai_record_queue;\r
     taskcfg.attr.name = "Ai_record_queue_service";\r
     taskcfg.attr.priority = osPriorityNormal;\r
-    taskcfg.attr.stack_size = BLESRV_APP_BOARD_TASK_SIZE;\r
+    // taskcfg.attr.stack_size = BLESRV_APP_BOARD_TASK_SIZE;\r
+    taskcfg.attr.stack_size = 0x800;\r
     taskcfg.func = blesrvAi_send_service_task;\r
     taskcfg.use_mem = USE_EXTEND_MEM;\r
 \r