优化AI答案更新问题 2010/1 2010/head 2011/target/1
authorluozheng <1732036298@qq.com>
Fri, 25 Jul 2025 01:59:27 +0000 (09:59 +0800)
committerluozheng <1732036298@qq.com>
Fri, 25 Jul 2025 01:59:27 +0000 (09:59 +0800)
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp

index ee4c8c4..12880bd 100644 (file)
@@ -528,7 +528,7 @@ namespace OHOS
     {
         if (GetSelect4gorbt() == AI_SELECT_4G)
         {
-            if(str.empty())
+            if (str.empty())
             {
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "传入的问题为空");
                 return;
@@ -545,18 +545,18 @@ namespace OHOS
         }
         else if (GetSelect4gorbt() == AI_SELECT_BT)
         {
-        if (!entryTextViewState)
-        {
-            SendMsgToUIService(UI_AI_JUMP_TO_RESULT_VIEW, 0, nullptr, 0);
-            entryTextViewState = true; // 进入返回结果界面的标志  避免重复发消息
-            usleep(50000);             // 延时等待创建完成,0.05秒
-        }
-        /* -------------------------------------------------------------------------- */
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "传入的问题:%s", str.c_str());
-        userQuestionStr = str;
-        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "拼接的问题:%s", userQuestionStr.c_str());
-        /* -------------------------------------------------------------------------- */
-        SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0);
+            if (!entryTextViewState)
+            {
+                SendMsgToUIService(UI_AI_JUMP_TO_RESULT_VIEW, 0, nullptr, 0);
+                entryTextViewState = true; // 进入返回结果界面的标志  避免重复发消息
+                usleep(50000);             // 延时等待创建完成,0.05秒
+            }
+            /* -------------------------------------------------------------------------- */
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "传入的问题:%s", str.c_str());
+            userQuestionStr = str;
+            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "拼接的问题:%s", userQuestionStr.c_str());
+            /* -------------------------------------------------------------------------- */
+            SendMsgToUIService(UI_UPDATE_USER_QUESTION_STR, 0, nullptr, 0);
         }
     }
 
@@ -895,21 +895,20 @@ namespace OHOS
         AiVoiceView *view_ = AiVoiceView::GetInstance();
         if (GetSelect4gorbt() == AI_SELECT_4G) // 4G
         {
+            if (!OHOS::AiVoiceModel::GetInstance().GetIsLimitDisplayed()) // 如果ai答案没有显示到极限了,就更新ai答案字符串
+            {
+                aiAnswerStr += str;
+                /* -------------------------------------------------------------------------- */
+                // 累积接收到的文本
+                accumulatedText += str;
+                /* -------------------------------------------------------------------------- */
+                WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "接受字的符串:%s", aiAnswerStr.c_str());
+            }
             if (view_ != nullptr)
             {
                 if (view_->GetAiVoiceScrollView(AIVOICE_RETURN_RESULT_TEXT_VIEWID) && view_->GetAiVoiceScrollView(AIVOICE_RETURN_RESULT_TEXT_VIEWID)->IsVisible())
                 {
-                    start_ai4g_tts_play_timer();                                  // 开启一个定时器,用于播放tts音频
-                    if (!OHOS::AiVoiceModel::GetInstance().GetIsLimitDisplayed()) // 如果ai答案没有显示到极限了,就更新ai答案字符串
-                    {
-                        aiAnswerStr += str;
-                        /* -------------------------------------------------------------------------- */
-                        // 累积接收到的文本
-                        accumulatedText += str;
-                        /* -------------------------------------------------------------------------- */
-                        WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "接受字的符串:%s", aiAnswerStr.c_str());
-                        // SendMsgToUIService(UI_UPDATE_AI_ANSWER_STR, 0, nullptr, 0);
-                    }
+                    start_ai4g_tts_play_timer(); // 开启一个定时器,用于播放tts音频
                     start_update_ai_answer_timer();
                 }
             }