From: xue <2144439972@qq.com> Date: Tue, 23 Dec 2025 13:13:35 +0000 (+0800) Subject: 对话模式切换中防重入 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=f740f8275fcde5265da063229cd71751e0c3b010;p=mirrors%2FFD230.git 对话模式切换中防重入 --- diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h index e677029f7..99fea8bb9 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/include/ThunderBirdPresenter.h @@ -36,6 +36,7 @@ namespace OHOS void timer_callback_toui_proc(); bool isDialogueing{false};//是否进入对话模式 + bool dialogueTransitioning{false}; // 对话模式切换中防重入 bool powerKeyPressed{false};//电源键按下标志位,防止重复触发 bool screenOnFromOff{false};//从息屏状态亮屏的标志位,防止松开时立即息屏 bool pendingDialogueJump{false};//等待音频初始化完成后跳转对话界面的标志位 diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index 4184678ec..1f6bc61f9 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -2112,7 +2112,7 @@ extern "C" { m_cat1PowerStatus = uapi_dev_runtime_get_cat1_powerstat(); // CAT1电源状态 m_signalStrength = cat1_api_runtime_get_cat1_signal_bars(); // 信号强度 (旧接口,保留兼容性) m_networkStatus = uapi_dev_runtime_get_cat1_networkstat(); // 网络连接状态 - // m_networkType = cat1_api_runtime_get_cat1_networktype(); // 网络类型 + m_networkType = cat1_api_runtime_get_cat1_networktype(); // 网络类型 // 更新网络连接标志位:m_networkStatus == 1表示有网络连接 m_hasNetwork = (m_networkStatus == 1); diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp index cc7828451..308fc5f71 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp @@ -1106,6 +1106,11 @@ namespace OHOS // cat1_gettime(); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdPresenter::HandleFuncKeyLongPress - FUNC key long press detected"); + if (dialogueTransitioning) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "HandleFuncKeyLongPress: dialogue transition in progress, skip"); + return; + } + dialogueTransitioning = true; // 长按FUNC键2秒的处理逻辑 // 触发对话模式切换 if (ThunderBirdMainView::GetInstance()) { @@ -1150,6 +1155,7 @@ namespace OHOS networkCount = 0; } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "WebSocket未连接,不进入对话模式"); + dialogueTransitioning = false; return; // 不满足条件,不进入对话模式 } else if(vadAuthSuccess == false) @@ -1172,6 +1178,7 @@ namespace OHOS vadAuthCount = 0; } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "vad认证不成功,不进入对话模式"); + dialogueTransitioning = false; return; } do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_AUDIO_INIT_VAD_ENABLE, NULL, 0); @@ -1211,8 +1218,7 @@ namespace OHOS // 音频已在按键按下时初始化,这里直接开始对话 // 初始化音频聊天上下文,确保可以接收服务器消息 ln_ws_start_audio_chat(LN_AUDIO_CHAT_VOICE_CHAT_REQUEST);//开始对话 - - + dialogueTransitioning = false; } else if(currentView == THUNDERBIRD_DIALOGUEVIEW) { @@ -1303,6 +1309,7 @@ namespace OHOS } } + dialogueTransitioning = false; } void ThunderBirdPresenter::SetDialogueing(bool dialogueing)