diff --git a/services/key_enable/utils/include/unlock_event_helper.h b/services/key_enable/utils/include/unlock_event_helper.h index ddc245c295588cb191422b4e4842c6dd0581f421..99c872ab5b95b3da11812dbd31278856db141b5c 100644 --- a/services/key_enable/utils/include/unlock_event_helper.h +++ b/services/key_enable/utils/include/unlock_event_helper.h @@ -57,6 +57,7 @@ private: bool hasRegistered_ = false; bool hasInited_ = false; bool hasUnLocked_ = false; + std::atomic recvEvent_ {false}; std::mutex unlockMutex_; std::condition_variable unlockConVar_; std::shared_ptr unlockEventSubscriber_; diff --git a/services/key_enable/utils/src/unlock_event_helper.cpp b/services/key_enable/utils/src/unlock_event_helper.cpp index b57e9864671ed06342b0ec740ca35f183e1ae196..33a5cad5c6655e385bf425bc9ee5ecf4033167be 100644 --- a/services/key_enable/utils/src/unlock_event_helper.cpp +++ b/services/key_enable/utils/src/unlock_event_helper.cpp @@ -37,6 +37,10 @@ void UnlockEventHelper::UnlockEventSubscriber::OnReceiveEvent(const EventFwk::Co const auto action = want.GetAction(); if (action == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED) { LOG_INFO(LABEL, "receive unlocked event"); + // exchange return old value + if (UnlockEventHelper::GetInstance().recvEvent_.exchange(true)) { + return; + } UnlockEventHelper::GetInstance().FinishWaiting(); return; } @@ -108,6 +112,7 @@ void UnlockEventHelper::UnregisterEvent() return; } hasRegistered_ = false; + LOG_INFO(LABEL, "UnregisterEvent end"); } bool UnlockEventHelper::WaitForCommonEventManager()