From 39b30ee6fe2a76c3c39bb166c5a6fab5843dffee Mon Sep 17 00:00:00 2001 From: fengyang Date: Sun, 29 Sep 2024 10:10:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=94=81=E5=B1=8F=E8=A7=A3?= =?UTF-8?q?=E9=94=81=E4=BA=8B=E4=BB=B6=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fengyang --- services/common/include/bundle_active_core.h | 2 ++ services/common/src/bundle_active_core.cpp | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/services/common/include/bundle_active_core.h b/services/common/include/bundle_active_core.h index 081d854..9c7a78a 100644 --- a/services/common/include/bundle_active_core.h +++ b/services/common/include/bundle_active_core.h @@ -262,7 +262,9 @@ private: std::recursive_mutex callbackMutex_; std::map> userStatServices_; void RegisterSubscriber(); + void SubscriberLockScreenCommonEvent(); std::shared_ptr commonEventSubscriber_; + std::shared_ptr lockScreenSubscriber_; void RestoreAllData(); std::map> groupChangeObservers_; std::map, sptr> recipientMap_; diff --git a/services/common/src/bundle_active_core.cpp b/services/common/src/bundle_active_core.cpp index e0b80b3..649e5b5 100644 --- a/services/common/src/bundle_active_core.cpp +++ b/services/common/src/bundle_active_core.cpp @@ -23,6 +23,7 @@ #include "bundle_active_group_common.h" #include "bundle_active_bundle_mgr_helper.h" #include "bundle_active_constant.h" +#include "bundle_constants.h" namespace OHOS { namespace DeviceUsageStats { @@ -154,18 +155,30 @@ void BundleActiveCore::RegisterSubscriber() matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED); matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_BUNDLE_REMOVED); matchingSkills.AddEvent(CommonEventSupport::COMMON_EVENT_PACKAGE_FULLY_REMOVED); - matchingSkills.AddEvent(COMMON_EVENT_UNLOCK_SCREEN); - matchingSkills.AddEvent(COMMON_EVENT_LOCK_SCREEN); CommonEventSubscribeInfo subscriberInfo(matchingSkills); commonEventSubscriber_ = std::make_shared(subscriberInfo, bundleGroupController_, handler_); + SubscriberLockScreenCommonEvent(); bool subscribeResult = CommonEventManager::SubscribeCommonEvent(commonEventSubscriber_); BUNDLE_ACTIVE_LOGD("Register for events result is %{public}d", subscribeResult); } +void BundleActiveCore::SubscriberLockScreenCommonEvent() +{ + MatchingSkills matchingSkills; + matchingSkills.AddEvent(COMMON_EVENT_UNLOCK_SCREEN); + matchingSkills.AddEvent(COMMON_EVENT_LOCK_SCREEN); + CommonEventSubscribeInfo subscriberInfo(matchingSkills); + subscriberInfo.SetPublisherBundleName(AppExecFwk::Constants::SCENE_BOARD_BUNDLE_NAME); + lockScreenSubscriber_ = std::make_shared(subscriberInfo, + bundleGroupController_, handler_); + CommonEventManager::SubscribeCommonEvent(lockScreenSubscriber_); +} + void BundleActiveCore::UnRegisterSubscriber() { CommonEventManager::UnSubscribeCommonEvent(commonEventSubscriber_); + CommonEventManager::UnSubscribeCommonEvent(lockScreenSubscriber_); } void BundleActiveCore::Init() -- Gitee