From ff29c49134803cb90f9d457e5d4d70500ad339ea Mon Sep 17 00:00:00 2001 From: h60047265 Date: Fri, 20 Dec 2024 14:34:15 +0800 Subject: [PATCH] =?UTF-8?q?=E2=80=9D=E8=A7=A3=E5=86=B3=E5=9B=A0=E6=BC=8F?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E5=85=AC=E5=85=B1=E4=BA=8B=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4SA=E4=B8=8D=E8=83=BD=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E6=8B=89=E8=B5=B7=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: h60047265 --- .../source/collect/common_event_collect.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/services/samgr/native/source/collect/common_event_collect.cpp b/services/samgr/native/source/collect/common_event_collect.cpp index 305f9d59..41594bcc 100644 --- a/services/samgr/native/source/collect/common_event_collect.cpp +++ b/services/samgr/native/source/collect/common_event_collect.cpp @@ -178,24 +178,25 @@ bool CommonEventCollect::CreateCommonEventSubscriber() bool CommonEventCollect::CreateCommonEventSubscriberLocked() { int64_t begin = GetTickCount(); - if (commonEventSubscriber_ != nullptr) { + EventFwk::MatchingSkills skill = EventFwk::MatchingSkills(); + AddSkillsEvent(skill); + EventFwk::CommonEventSubscribeInfo info(skill); + std::shared_ptr comEvtScrb = commonEventSubscriber_; + commonEventSubscriber_ = std::make_shared(info, this); + bool ret = EventFwk::CommonEventManager::SubscribeCommonEvent(commonEventSubscriber_); + HILOGI("SubsComEvt %{public}" PRId64 "ms %{public}s", (GetTickCount() - begin), ret ? "suc" : "fail"); + if (comEvtScrb != nullptr) { HILOGI("UnSubsComEvt start"); { SamgrXCollie samgrXCollie("samgr--UnSubscribeCommonEvent"); - bool isUnsubscribe = EventFwk::CommonEventManager::UnSubscribeCommonEvent(commonEventSubscriber_); + bool isUnsubscribe = EventFwk::CommonEventManager::UnSubscribeCommonEvent(comEvtScrb); if (!isUnsubscribe) { HILOGE("CreateCommonEventSubscriberLocked isUnsubscribe failed!"); return false; } } - commonEventSubscriber_.reset(); + comEvtScrb.reset(); } - EventFwk::MatchingSkills skill = EventFwk::MatchingSkills(); - AddSkillsEvent(skill); - EventFwk::CommonEventSubscribeInfo info(skill); - commonEventSubscriber_ = std::make_shared(info, this); - bool ret = EventFwk::CommonEventManager::SubscribeCommonEvent(commonEventSubscriber_); - HILOGI("SubsComEvt %{public}" PRId64 "ms %{public}s", (GetTickCount() - begin), ret ? "suc" : "fail"); return ret; } -- Gitee