diff --git a/services/bundlemgr/include/bundle_mgr_service.h b/services/bundlemgr/include/bundle_mgr_service.h index 76f0f3a1..57d2367a 100644 --- a/services/bundlemgr/include/bundle_mgr_service.h +++ b/services/bundlemgr/include/bundle_mgr_service.h @@ -94,6 +94,10 @@ public: * @brief register bms sa to samgr */ void RegisterService(); + /** + * @brief send bundle scan finished common event + */ + void NotifyBundleScanStatus(); /** * @brief Process hidump. * @param args Indicates the args. diff --git a/services/bundlemgr/src/bundle_mgr_service.cpp b/services/bundlemgr/src/bundle_mgr_service.cpp index f5c193e6..21dfe854 100644 --- a/services/bundlemgr/src/bundle_mgr_service.cpp +++ b/services/bundlemgr/src/bundle_mgr_service.cpp @@ -15,6 +15,8 @@ #include "bundle_mgr_service.h" +#include "ohos/aafwk/content/want.h" + #include "account_helper.h" #include "app_log_wrapper.h" #include "bundle_constants.h" @@ -317,6 +319,19 @@ void BundleMgrService::RegisterService() AfterRegisterToService(); } +void BundleMgrService::NotifyBundleScanStatus() +{ + APP_LOGD("PublishCommonEvent for bundle scan finished"); + AAFwk::Want want; + want.SetAction(EventFwk::CommonEventSupport::COMMON_EVENT_BUNDLE_SCAN_FINISHED); + EventFwk::CommonEventData commonEventData { want }; + if (!EventFwk::CommonEventManager::PublishCommonEvent(commonEventData)) { + 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) { diff --git a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp index 5b189330..d4041bda 100644 --- a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp +++ b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp @@ -71,6 +71,7 @@ void BMSEventHandler::ProcessEvent(const InnerEvent::Pointer &event) OnRebootStartScanning(); SetAllInstallFlag(); DelayedSingleton::GetInstance()->RegisterService(); + DelayedSingleton::GetInstance()->NotifyBundleScanStatus(); break; } default: diff --git a/services/bundlemgr/src/bundle_user_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_user_mgr_host_impl.cpp index 23fe43d0..20ee1433 100644 --- a/services/bundlemgr/src/bundle_user_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_user_mgr_host_impl.cpp @@ -100,6 +100,9 @@ void BundleUserMgrHostImpl::CreateNewUser(int32_t userId) if (static_cast(g_installedHapNum) < totalHapNum) { bundlePromise->WaitForAllTasksExecute(); } + if (userId == Constants::START_USERID) { + DelayedSingleton::GetInstance()->NotifyBundleScanStatus(); + } APP_LOGD("CreateNewUser end userId: (%{public}d)", userId); }