From 74488803dfddb6532599cf60296b60e6812d6b77 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Thu, 28 Aug 2025 20:26:13 +0800 Subject: [PATCH 1/2] =?UTF-8?q?stop=E6=8E=A5=E5=8F=A3=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: gaoqiang_strong --- .../include/authentication_v2/dm_auth_state_machine.h | 4 ++++ .../implementation/src/authentication_v2/auth_manager.cpp | 6 ++++++ .../src/authentication_v2/dm_auth_state_machine.cpp | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/services/implementation/include/authentication_v2/dm_auth_state_machine.h b/services/implementation/include/authentication_v2/dm_auth_state_machine.h index 48288a3a3..0a5ef25cb 100644 --- a/services/implementation/include/authentication_v2/dm_auth_state_machine.h +++ b/services/implementation/include/authentication_v2/dm_auth_state_machine.h @@ -74,6 +74,8 @@ public: // Stop the thread void Stop(); + bool IsWaitEvent(); + private: // Loop to wait for state transitions and execute actions void Run(std::shared_ptr context); @@ -123,6 +125,8 @@ private: // Thread for state machine execution std::thread thread_; + + std::atomic isWait_ = false; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/implementation/src/authentication_v2/auth_manager.cpp b/services/implementation/src/authentication_v2/auth_manager.cpp index 4b85bd8fa..edf6452a9 100644 --- a/services/implementation/src/authentication_v2/auth_manager.cpp +++ b/services/implementation/src/authentication_v2/auth_manager.cpp @@ -246,11 +246,17 @@ int32_t AuthManager::StopAuthenticateDevice(const std::string &pkgName) LOGI("AuthManager::StopAuthenticateDevice start"); context_->reason = STOP_BIND; + if (context_->authStateMachine->IsWaitEvent()) { + context_->authStateMachine->NotifyEventFinish(DmEventType::ON_FAIL); + return DM_OK; + } + if (context_->direction == DM_AUTH_SOURCE) { context_->authStateMachine->TransitionTo(std::make_shared()); } else { context_->authStateMachine->TransitionTo(std::make_shared()); } + context_->authStateMachine->NotifyEventFinish(DmEventType::ON_FAIL); return DM_OK; } diff --git a/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp b/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp index 106a7f8c2..e5e72bb7c 100644 --- a/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp +++ b/services/implementation/src/authentication_v2/dm_auth_state_machine.cpp @@ -287,9 +287,11 @@ DmEventType DmAuthStateMachine::WaitExpectEvent(DmEventType eventType) std::unique_lock lock(eventMutex_); auto startTime = std::chrono::high_resolution_clock::now(); while (running_.load()) { + isWait_.store(true); eventCv_.wait(lock, [&] { return !running_.load() || !eventQueue_.empty(); }); + isWait_.store(false); if (!running_.load()) { return DmEventType::ON_FAIL; } @@ -404,6 +406,11 @@ void DmAuthStateMachine::Stop() } } +bool DmAuthStateMachine::IsWaitEvent() +{ + return isWait_.load(); +} + void DmAuthStateMachine::SetCurState(DmAuthStateType state) { LOGI("DmAuthStateMachine::SetCurState state: %{public}d", state); -- Gitee From b5e694461411531d02452600e99b72903bc872d6 Mon Sep 17 00:00:00 2001 From: gaoqiang_strong Date: Fri, 29 Aug 2025 16:46:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: gaoqiang_strong --- .../src/authentication/auth_ui_state_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/implementation/src/authentication/auth_ui_state_manager.cpp b/services/implementation/src/authentication/auth_ui_state_manager.cpp index f23423794..e04098aec 100644 --- a/services/implementation/src/authentication/auth_ui_state_manager.cpp +++ b/services/implementation/src/authentication/auth_ui_state_manager.cpp @@ -67,8 +67,8 @@ void AuthUiStateManager::UpdateUiState(const DmUiStateMsg msg) std::lock_guard lock(pkgSetMutex_); if (pkgSet_.empty()) { LOGW("pkgSet_ is empty"); - if (msg == MSG_CANCEL_CONFIRM_SHOW) { - LOGW("cancel confirm dialog"); + if (msg == MSG_CANCEL_CONFIRM_SHOW || msg == MSG_CANCEL_PIN_CODE_INPUT || msg == MSG_CANCEL_PIN_CODE_SHOW) { + LOGW("cancel confirm or input pin code dialog"); DmDialogManager::GetInstance().CloseDialog(); return; } -- Gitee