优化对话 2575/target/2 2577/1 2577/head
authorxue <2144439972@qq.com>
Tue, 21 Oct 2025 07:47:51 +0000 (15:47 +0800)
committerxue <2144439972@qq.com>
Tue, 21 Oct 2025 07:47:51 +0000 (15:47 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp
code/sdk/zhihui/utils/custom_cmd_service.c
code/sdk/zhihui/utils/custom_utils.h

index c9de571..2949e9b 100644 (file)
     }
      void ThunderBirdModel::StopCountUpTimer(void)
      {
-         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "StopCountUpTimer");
+         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "StopCountUpTimer");
          
          // 停止计数定时器
          m_countUpActive = false;
          m_countUpValue = 0;
          m_countUpTarget = 0;
          
-         WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Count up timer stopped");
+         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Count up timer stopped");
      }
      int ThunderBirdModel::GetCountUpValue() const
      {
         // 恢复到进入对话模式前记录的表情
         if (!m_currentExpression.empty()) {
             SetCurrentExpression(m_currentExpression);
-            SetCurrentExpressionAndStatus();
+            //SetCurrentExpressionAndStatus();
         }
     }
     
         if(currentView == THUNDERBIRD_DIALOGUEVIEW && currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW)
         {
             ThunderBirdDialogueView::GetInstance()->UpdateDialogueText(m_currentStatusText.c_str());
-        }
+        
         //切换表情
         //不为屏保模式
         std::string expressionPath;
             }
             
         }
+   
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::SetCurrentExpressionAndStatus: expression=%s, statusText=%s", 
             expressionPath.c_str(), m_currentStatusText.c_str());
+        }
     }
     
     // 获取当前表情状态
index 1edbc4e..4a7d6d1 100644 (file)
@@ -348,8 +348,14 @@ namespace OHOS
         // {
         //     return;
         // }
-
-        if (currentView == THUNDERBIRD_DIALOGUEVIEW && currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING) {
+        /*if(DialogueingFlag == false)
+        {
+            ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
+            ThunderBirdDialogueView::GetInstance()->UpdateDialogueText("超认真聆听中");
+            ln_ws_start_audio_chat(LN_AUDIO_CHAT_VOICE_CHAT_REQUEST);
+            DialogueingFlag = true;
+        }
+        else*/if (currentView == THUNDERBIRD_DIALOGUEVIEW && currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING ) {
             // 停止录音并发送
             // 停止聆听超时定时器
             ThunderBirdModel::GetInstance()->StopCountUpTimer();
@@ -360,6 +366,7 @@ namespace OHOS
         } else {
             // 开始录音
             ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
+            ThunderBirdDialogueView::GetInstance()->UpdateDialogueText("超认真聆听中");
             ln_ws_start_audio_chat(LN_AUDIO_CHAT_VOICE_CHAT_REQUEST);
         }
     }
@@ -660,10 +667,11 @@ namespace OHOS
                 isDialogueing = true;
                 // 进入对话模式时记录当前表情
                 ThunderBirdModel::GetInstance()->OnEnterDialogueMode();
-                ln_ws_audio_init();//功耗优化
-                //do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_AUDIO_INIT, NULL, 0);
+                //ThunderBirdDialogueView::GetInstance()->UpdateDialogueText("点击开始对话");
+                //DialogueingFlag = true;
+                //ln_ws_audio_init();//功耗优化
+                do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_AUDIO_INIT, NULL, 0);
                 ln_ws_start_audio_chat(LN_AUDIO_CHAT_VOICE_CHAT_REQUEST);//开始对话
-                
             }
             else if(currentView == THUNDERBIRD_DIALOGUEVIEW)
             {
@@ -671,20 +679,25 @@ namespace OHOS
                 // 停止实际的音频播放
                 // ai_media_play_stop();
                 // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdDialogueView::AudioPlaybackEnd: Stopped audio playback");
+                //
                 ln_ws_end_audio_chat();//结束对话
                 
                 // 退出对话模式时恢复表情
                 AI_ForceInterrupt();
                 ln_ws_send_voice_chat_interrupt("退出对话");
-                ln_ws_audio_deinit();//功耗优化
-                //do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_AUDIO_DEINIT, NULL, 0);
-                isDialogueing = false;
-                ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW);
+
+                //ln_ws_audio_deinit();//功耗优化
+               
+                do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_AUDIO_DEINIT, NULL, 0);
+                 isDialogueing = false;
+                // DialogueingFlag = false;
+                 ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_STATUS_SHOW);
                 if(currentSubView == ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING)
                 {
                     ThunderBirdModel::GetInstance()->StopCountUpTimer();
                 }
-                ThunderBirdModel::GetInstance()->OnExitDialogueMode();
+                 ThunderBirdModel::GetInstance()->OnExitDialogueMode();
+                
             }
             //当为故事模式
             else if(currentView == THUNDERBIRD_LULLABYVIEW && currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4)
index 8cdedd3..06303ac 100644 (file)
@@ -466,6 +466,16 @@ case CUSTOM_CMD_MSG_START_AI_ASR:
 #endif
             break;
 
+        case CUSTOM_CMD_MSG_AUDIO_INIT:
+            PRINT("Audio init via custom cmd\n");
+            //osDelay(1000);
+            ln_ws_audio_init();
+            break;
+        case CUSTOM_CMD_MSG_AUDIO_DEINIT:
+            PRINT("Audio deinit via custom cmd\n");
+            ln_ws_audio_deinit();
+            break;
+
         default:
             PRINT("Unknown CUSTOM_CMD_MSG cmd 0x%02X \r\n", mail.cmd);
             break;
index bd3d634..1fe7b61 100644 (file)
@@ -257,6 +257,10 @@ uint32_t uapi_calendar_store_date(void);
 
 #define CUSTOM_CMD_MSG_DESTROY_ALL_WEBSOCKET_SERVERS 0x25
 
+#define CUSTOM_CMD_MSG_AUDIO_DEINIT 0x26
+
+#define CUSTOM_CMD_MSG_AUDIO_INIT 0x27
+
 typedef enum {
     BR_HFP_CONNECT=1,
     BR_HFP_DISCONNECT,