diff --git a/services/bundlemgr/include/bundle_mgr_service.h b/services/bundlemgr/include/bundle_mgr_service.h index ca0668cc..7fce494c 100644 --- a/services/bundlemgr/include/bundle_mgr_service.h +++ b/services/bundlemgr/include/bundle_mgr_service.h @@ -132,6 +132,7 @@ private: bool ready_ = false; bool registerToService_ = false; bool needToScan_ = false; + bool notifyBundleScanStatus = false; std::shared_ptr runner_; std::shared_ptr handler_; std::shared_ptr dataMgr_; diff --git a/services/bundlemgr/src/bundle_mgr_service.cpp b/services/bundlemgr/src/bundle_mgr_service.cpp index 39dbb82d..69a2c297 100644 --- a/services/bundlemgr/src/bundle_mgr_service.cpp +++ b/services/bundlemgr/src/bundle_mgr_service.cpp @@ -80,6 +80,7 @@ void BundleMgrService::OnStart() if (!needToScan_) { PerfProfile::GetInstance().Dump(); } + AddSystemAbilityListener(COMMON_EVENT_SERVICE_ID); #ifdef DEVICE_MANAGER_ENABLE AddSystemAbilityListener(DISTRIBUTED_HARDWARE_DEVICEMANAGER_SA_ID); AddSystemAbilityListener(DISTRIBUTED_BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); @@ -316,29 +317,35 @@ void BundleMgrService::NotifyBundleScanStatus() want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_BUNDLE_SCAN_FINISHED); EventFwk::CommonEventData commonEventData { want }; if (!EventFwk::CommonEventManager::PublishCommonEvent(commonEventData)) { + notifyBundleScanStatus = true; APP_LOGE("PublishCommonEvent for bundle scan finished failed."); } else { APP_LOGD("PublishCommonEvent for bundle scan finished succeed."); } } -#ifdef DEVICE_MANAGER_ENABLE void BundleMgrService::OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) { APP_LOGD("OnAddSystemAbility systemAbilityId:%{public}d added!", systemAbilityId); +#ifdef DEVICE_MANAGER_ENABLE if (deviceManager_) { deviceManager_->OnAddSystemAbility(systemAbilityId, deviceId); } +#endif + if (COMMON_EVENT_SERVICE_ID == systemAbilityId && notifyBundleScanStatus) { + NotifyBundleScanStatus(); + } } void BundleMgrService::OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) { APP_LOGD("OnRemoveSystemAbility systemAbilityId:%{public}d removed!", systemAbilityId); +#ifdef DEVICE_MANAGER_ENABLE if (deviceManager_) { deviceManager_->OnRemoveSystemAbility(systemAbilityId, deviceId); } -} #endif +} bool BundleMgrService::Hidump(const std::vector &args, std::string& result) const {