修复角色说话完毕导致的判断错误
authorxue <2144439972@qq.com>
Mon, 1 Dec 2025 10:01:29 +0000 (18:01 +0800)
committerxue <2144439972@qq.com>
Mon, 1 Dec 2025 10:01:29 +0000 (18:01 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp

index 0e58d99..726ed6b 100644 (file)
@@ -2747,6 +2747,8 @@ extern "C" {
            if(is_intention_result == 0)
            {
               WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleSleepModeStart: 非意图识别结果,跳转到4");
+                // 重置故事模式finished标志,确保每次进入故事模式时标志位是干净的
+                m_storyModeFinished = false;
                 ThunderBirdMainView::GetInstance()->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4);
                 //清空文本队列
                 ClearAudioTextQueue();
@@ -2802,10 +2804,28 @@ extern "C" {
     {
         if (finished) {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleStoryResponseFinished: 收到故事模式finished=true");
+            
+            // 检查当前文本是否为"正在准备故事...",只有不是默认文本时才认为是真正的finished
+            ThunderBirdLullabyView *lullabyView = ThunderBirdLullabyView::GetInstance();
+            if (lullabyView != nullptr) {
+                std::string currentText = lullabyView->GetCurrentText();
+                if (currentText == "正在准备故事...") {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleStoryResponseFinished: 当前文本为'正在准备故事...',忽略finished信号");
+                    return; // 忽略这个finished信号
+                }
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleStoryResponseFinished: 当前文本为'%s',确认为真正的finished", currentText.c_str());
+            }
+            
             m_storyModeFinished = true;
         }
     }
     
+    void ThunderBirdModel::ResetStoryModeFinished(void)
+    {
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::ResetStoryModeFinished: 重置故事模式finished标志");
+        m_storyModeFinished = false;
+    }
+    
     void ThunderBirdModel::HandleDialogueResponseFinished(bool finished)
     {
         if (finished) {
@@ -2992,6 +3012,8 @@ extern "C" {
         }
         
         // 检查是否是故事模式且已finished
+        // 注意:m_storyModeFinished在HandleStoryResponseFinished中已经通过了文本检查(不是"正在准备故事..."),
+        // 所以这里不需要再次检查文本,直接结束故事模式即可
         if (currentView == THUNDERBIRD_LULLABYVIEW &&
             currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4 &&
             m_storyModeFinished)
@@ -3026,10 +3048,14 @@ extern "C" {
             int16_t currentView = view->GetCurrentView();
             int16_t currentSubView = view->GetCurrentSubView();
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleAudioRecordingStart: currentView=%d, currentSubView=%d", currentView, currentSubView);
-            // 如果当前在对话界面,且不在聆听状态,则跳转到聆听状态
-            //如果是哄睡界面,则不进行处理
-            if(currentView == THUNDERBIRD_LULLABYVIEW && currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3)
+            // 如果当前在哄睡界面(包括故事选择界面和故事模式),则不进行处理
+            // THUNDERBIRD_LULLABYVIEW_3: 故事选择界面(VAD已关闭)
+            // THUNDERBIRD_LULLABYVIEW_4: 故事模式(VAD已关闭)
+            if(currentView == THUNDERBIRD_LULLABYVIEW && 
+               (currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3 ||
+                currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4))
             {
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleAudioRecordingStart: 在哄睡界面(故事模式),忽略录音开始事件");
                 return;
             }
             if ((currentView == THUNDERBIRD_DIALOGUEVIEW && 
@@ -3070,9 +3096,11 @@ extern "C" {
                 view->ChangeView(currentView, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_SPEAKING);
             }
             else if (currentView == THUNDERBIRD_LULLABYVIEW && 
-                currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3) {
-                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "录音结束,跳转到故事选择界面");
-                view->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4);
+                currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_3 ||
+                currentSubView == ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4) {
+                // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "录音结束,跳转到故事选择界面");
+                // view->ChangeView(currentView, THUNDERBIRD_LULLABYVIEW, ThunderBirdLullabyView::THUNDERBIRD_LULLABYVIEW_4);
+                return;
             }
             else{
                 WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleAudioRecordingEnd: 不满足推送条件 ");