!1378 重启扫描完成广播发送失败修复

Merge pull request !1378 from wanghang/master
This commit is contained in:
openharmony_ci
2022-05-11 10:14:15 +00:00
committed by Gitee
2 changed files with 10 additions and 2 deletions
@@ -132,6 +132,7 @@ private:
bool ready_ = false;
bool registerToService_ = false;
bool needToScan_ = false;
bool notifyBundleScanStatus = false;
std::shared_ptr<EventRunner> runner_;
std::shared_ptr<BMSEventHandler> handler_;
std::shared_ptr<BundleDataMgr> dataMgr_;
@@ -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<std::string> &args, std::string& result) const
{