n9解决蓝牙ai不可用问题 2500/1
authorluozheng <1732036298@qq.com>
Tue, 14 Oct 2025 03:37:30 +0000 (11:37 +0800)
committerluozheng <1732036298@qq.com>
Tue, 14 Oct 2025 03:37:30 +0000 (11:37 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceModel.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoicePresenter.cpp
code/sdk/application/wearable/fd230/nativeapp/nativeui/aivoice/src/AiVoiceView.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/aivoice/src/AiVoiceModel.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/aivoice/src/AiVoiceView.cpp

index e80c804..b5e2123 100644 (file)
@@ -192,7 +192,7 @@ namespace OHOS
             else if (GetSelect4gorbt() == AI_SELECT_BT)
             {
 #ifdef SUPPORT_BLE_SERVICE
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "蓝牙:查询Ai是否就绪");
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "蓝牙:查询Ai是否就绪:%d",it->second.second);
                 inquire_AI_is_ready(it->second.second);
 #endif
             }
index c6a9110..d0bc2dc 100644 (file)
@@ -45,7 +45,6 @@ namespace OHOS
 #include <asm/delay.h>
 #include <aivoice/include/AiVoiceModelC.h>
 #include <los_base.h>
-        extern void set_need_tts_reconnect(uint8_t flag);
 
         void remove_4GAI_vote(void)
         {
@@ -98,7 +97,6 @@ namespace OHOS
     void AiVoicePresenter::OnStart()
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnStart");
-        Presenter<AiVoiceView>::OnStart();
         ScreenAlwaysOnCtr(OPEN_SCREEN_ALWAYS_ON);
         // 开启一个60s取消长亮屏timer
         model->ai_start_screen60s_timer();
@@ -113,7 +111,6 @@ namespace OHOS
     void AiVoicePresenter::OnStop(void)
     {
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnStop start");
-        Presenter<AiVoiceView>::OnStop();
         ScreenAlwaysOnCtr(CANCEL_SCREEN_ALWAYS_ON);
         model->StatusResume();
         model->AIVoice_StopTimer();
@@ -130,9 +127,6 @@ namespace OHOS
         uapi_stop_all_websocket_servers();
         uapi_destroy_all_websocket_servers();
 #endif
-        
-        // dinit_ai_task();
-        // ai_cleanup_resources();
 
         uapi_ble_connect_param_update(BLE_CONNECT_INTERVAL_SLOW);
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::OnStop end");
@@ -341,7 +335,6 @@ namespace OHOS
             break;
 
         case AIVOICE_RETURN_RESULT_TEXT_VIEWID:
-            // set_need_tts_reconnect(0);                                 // 停止tts重连
             AiVoiceModel::GetInstance().ClearQuestionAndAiAnswerStr(); // 清空上次用户问题和Ai回答字符串
             AiVoiceModel::GetInstance().SetIsClickable(false);
             AiVoiceModel::GetInstance().SetIsLimitDisplayed(false);
@@ -365,10 +358,8 @@ namespace OHOS
             AiVoiceModel::GetInstance().start_ai_isready_timer();
             break;
         case AIVOICE_RETURN_RESULT_TEXT_VIEWID:
-            // set_need_tts_reconnect(1); // 开始tts重连
             break;
         case AIVOICE_LISTENING_VIEWID:
-            // set_stop_send_ai_flag(0); // 开始发送AI数据
             AiVoiceModel::GetInstance().StartListenAndRecordingUserQuestion();
             AiVoiceModel::GetInstance().start_listening_timer();
             break;
index 7f5ea7c..820f351 100644 (file)
@@ -487,7 +487,7 @@ namespace OHOS
             VolumeProcess->SetKnobStyle(StyleDefault::GetSliderKnobStyle());
             VolumeProcess->RequestFocus();
             VolumeProcess->SetRotateFactor(5.0);
-            // VolumeProcess->SetVisible(false);
+            VolumeProcess->SetVisible(false);
             VolumeProcess->SetOnRotateListener(presenter_);
             AddViewToRootContainer(VolumeProcess);
         }
@@ -498,7 +498,7 @@ namespace OHOS
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView");
         if (!CreateAiVoiceScrollView() || !CreateAiVoiceViewImageView() || !CreateAiVoiceViewPicker() ||
-            !CreateAiVoiceViewLabel() || !CreateAiVoiceViewButton() || !CreateAiVoiceVoiceView())
+            !CreateAiVoiceViewLabel() || !CreateAiVoiceViewButton())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView fail!");
             return nullptr;
@@ -730,6 +730,13 @@ namespace OHOS
         {
             SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0);
         }
+        if(AiVoiceModel::GetInstance().GetSelect4gorbt() == AI_SELECT_4G)
+        {
+            if (VolumeProcess)
+            {
+                VolumeProcess->SetVisible(true);
+            }
+        }
         return true;
     }
 
@@ -1086,7 +1093,7 @@ namespace OHOS
 
     void AiVoiceView::ChangeView(int16_t hideView, int16_t showView)
     {
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeView hideView:%d, showView:%d", hideView, showView);
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::ChangeView hideView:%d, showView:%d", hideView, showView);
         if (!CheckViewParam(hideView, showView))
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CheckViewParam failed.");
index 8931f30..cdfc8d7 100644 (file)
@@ -867,7 +867,6 @@ namespace OHOS
             }
             else if (AiVoiceModel::AI_RESPONSE_END) // 如果是AI 回应结束
             {
-                return;
                 if (errnote.empty()) // 如果没有回应数据
                 {
                     WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceModel::GetErrnote is empty!!");
@@ -884,7 +883,7 @@ namespace OHOS
                     if (!OHOS::AiVoiceModel::GetInstance().GetIsLimitDisplayed()) // 如果ai答案没有显示到极限了,就更新ai答案字符串
                     {
                         aiAnswerStr += str;
-                        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "接受字的符串:%s", aiAnswerStr.c_str());
+                        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "接受字的符串:%s", aiAnswerStr.c_str());
                         SendMsgToUIService(UI_UPDATE_AI_ANSWER_STR, 0, nullptr, 0);
                     }
                 }
index 85a668a..a0a8fd7 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * @Author: luozheng 1732036298@qq.com
- * @Date: 2024-05-07 11:25:58
- * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2025-03-06 16:07:08
- * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp
- */
+* @Author: luozheng 1732036298@qq.com
+* @Date: 2024-05-07 11:25:58
+* @LastEditors: luozheng 1732036298@qq.com
+* @LastEditTime: 2025-03-06 16:07:08
+* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp
+*/
 #include "aivoice/include/AiVoicePresenter.h"
 #include "aivoice/include/AiVoiceView.h"
 #include "aivoice/include/AiVoiceModel.h"
@@ -487,7 +487,7 @@ namespace OHOS
             VolumeProcess->SetKnobStyle(StyleDefault::GetSliderKnobStyle());
             VolumeProcess->RequestFocus();
             VolumeProcess->SetRotateFactor(5.0);
-            // VolumeProcess->SetVisible(false);
+            VolumeProcess->SetVisible(false);
             VolumeProcess->SetOnRotateListener(presenter_);
             AddViewToRootContainer(VolumeProcess);
         }
@@ -498,7 +498,7 @@ namespace OHOS
     {
         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView");
         if (!CreateAiVoiceScrollView() || !CreateAiVoiceViewImageView() || !CreateAiVoiceViewPicker() ||
-            !CreateAiVoiceViewLabel() || !CreateAiVoiceViewButton() || !CreateAiVoiceVoiceView())
+            !CreateAiVoiceViewLabel() || !CreateAiVoiceViewButton())
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AiVoiceView::CreateAiVoiceView fail!");
             return nullptr;
@@ -730,6 +730,13 @@ namespace OHOS
         {
             SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0);
         }
+        if(AiVoiceModel::GetInstance().GetSelect4gorbt() == AI_SELECT_4G)
+        {
+            if (VolumeProcess)
+            {
+                VolumeProcess->SetVisible(true);
+            }
+        }
         return true;
     }