From a952f9124d5d79e46aa6b407bcc43d29194e0059 Mon Sep 17 00:00:00 2001 From: luozheng <1732036298@qq.com> Date: Tue, 22 Jul 2025 18:04:18 +0800 Subject: [PATCH] =?utf8?q?=E8=A7=A3=E5=86=B34GAI=E4=B8=AD=E6=96=AD?= =?utf8?q?=E5=AF=B9=E8=AF=9D=E4=BC=9A=E6=AD=BB=E6=9C=BA=E9=97=AE=E9=A2=98?= =?utf8?q?=EF=BC=8C@=E8=96=9B=E6=96=87=E5=BC=BA=E6=B5=8B=E8=AF=95=E6=AC=A1?= =?utf8?q?=E6=95=B0=E8=B6=85=E8=BF=87100=E6=AC=A1=EF=BC=8C=E6=9C=AA?= =?utf8?q?=E5=87=BA=E7=8E=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/aivoice/include/AiVoicePresenter.h | 3 +++ .../nativeui/aivoice/src/AiVoicePresenter.cpp | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h index 257255bd2..2967eb596 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoicePresenter.h @@ -14,6 +14,7 @@ #include "components/ui_time_picker.h" #include "components/ui_slider.h" #include "ModelListenerSample.h" +#include namespace OHOS { class AiVoiceView; @@ -74,6 +75,8 @@ namespace OHOS int preHeight{0}; bool isScroll{false}; + + std::mutex m_mutex; // 添加互斥锁 }; } diff --git a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp index 2d30825d0..fdaeaecce 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp @@ -27,7 +27,7 @@ #include "aivoice/include/AiVoiceSelectView.h" #include "cat1_ws.h" - +#include namespace OHOS { #ifdef __cplusplus @@ -146,7 +146,8 @@ namespace OHOS if (model->GetSelect4gorbt() == AI_SELECT_4G) { preHeight = 0; - ChangeViewAndLogicOperator(model->GetCurView(), AIVOICE_RETURN_RESULT_TEXT_VIEWID); + if (model->GetCurView() == AIVOICE_LISTENING_VIEWID || model->GetCurView() == AIVOICE_THINKING_VIEWID) + ChangeViewAndLogicOperator(model->GetCurView(), AIVOICE_RETURN_RESULT_TEXT_VIEWID); } else if (model->GetSelect4gorbt() == AI_SELECT_BT) { @@ -285,6 +286,10 @@ namespace OHOS bool AiVoicePresenter::ChangeViewAndLogicOperator(int16_t hideView, int16_t showView) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AiVoicePresenter::ChangeViewOperator"); + + // 加锁,作用域结束时自动释放锁 + std::lock_guard lock(m_mutex); + bool isSameView = (hideView == showView); if (isSameView) { @@ -591,6 +596,14 @@ namespace OHOS auto it = viewIdMap.find(viewId); if (it != viewIdMap.end()) { + if (it->first != ALERT_APPBLUETOOTH_AND_4GNETWORK_ENSURE_BUTTON_VIEW_ID) + { + if (model->GetSelect4gorbt() == AI_SELECT_4G) + { + dinit_ai_task(); + LOS_Msleep(50); + } + } ChangeViewAndLogicOperator(it->second.first, it->second.second); return true; } -- 2.17.1