diff --git a/services/common/include/bundle_active_core.h b/services/common/include/bundle_active_core.h index 081d854d6b3eda926cbd63b1820ac3eff4aa6fb4..9c7a78aef03467c3a42a90c602b1970f9839c2e0 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 e0b80b3591f5cd3f88d76b5cb60ec6c070f79e0d..649e5b539c1427bb528125dc3113defeb13eff33 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()