修复多用户安装驱动连续发送广播的问题

Signed-off-by: Zhou Shihui <zhoushihui4@huawei.com>
This commit is contained in:
Zhou Shihui 2024-09-19 19:50:40 +08:00
parent 83a1063fae
commit c21cc1713d
4 changed files with 26 additions and 26 deletions

View File

@ -186,6 +186,8 @@ protected:
ErrCode RollbackHmpCommonInfo(const std::string &bundleName);
bool HasDriverExtensionAbility(const std::string &bundleName);
private:
/**
* @brief The real procedure for system and normal bundle install.

View File

@ -113,8 +113,6 @@ private:
void RecoverDriverForAllUsers(const std::string &bundleName, const InstallParam &installParam);
bool HasDriverExtensionAbility(const std::string &bundleName);
private:
const int64_t installerId_ = 0;
const sptr<IStatusReceiver> statusReceiver_;

View File

@ -212,7 +212,7 @@ ErrCode BaseBundleInstaller::InstallBundle(
.abilityName = mainAbility_,
.appDistributionType = appDistributionType_,
};
if (installParam.allUser) {
if (installParam.allUser || HasDriverExtensionAbility(bundleName_)) {
AddBundleStatus(installRes);
} else if (NotifyBundleStatus(installRes) != ERR_OK) {
LOG_W(BMS_TAG_INSTALLER, "notify status failed for installation");
@ -6119,5 +6119,28 @@ void BaseBundleInstaller::MarkInstallFinish()
LOG_W(BMS_TAG_INSTALLER, "save mark failed");
}
}
bool BaseBundleInstaller::HasDriverExtensionAbility(const std::string &bundleName)
{
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (dataMgr == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return false;
}
InnerBundleInfo info;
bool isAppExist = dataMgr->FetchInnerBundleInfo(bundleName, info);
if (isAppExist) {
const auto extensions = info.GetInnerExtensionInfos();
for (const auto &item : extensions) {
if (item.second.type == ExtensionAbilityType::DRIVER) {
APP_LOGI("find driver extension ability, bundleName: %{public}s, moduleName: %{public}s",
item.second.bundleName.c_str(), item.second.moduleName.c_str());
return true;
}
}
}
return false;
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -276,29 +276,6 @@ void BundleInstaller::RecoverDriverForAllUsers(const std::string &bundleName, co
}
}
bool BundleInstaller::HasDriverExtensionAbility(const std::string &bundleName)
{
auto dataMgr = DelayedSingleton<BundleMgrService>::GetInstance()->GetDataMgr();
if (dataMgr == nullptr) {
APP_LOGE("Get dataMgr shared_ptr nullptr");
return false;
}
InnerBundleInfo info;
bool isAppExist = dataMgr->FetchInnerBundleInfo(bundleName, info);
if (isAppExist) {
const auto extensions = info.GetInnerExtensionInfos();
for (const auto &item : extensions) {
if (item.second.type == ExtensionAbilityType::DRIVER) {
APP_LOGI("find driver extension ability, bundleName: %{public}s, moduleName: %{public}s",
item.second.bundleName.c_str(), item.second.moduleName.c_str());
return true;
}
}
}
return false;
}
void BundleInstaller::UninstallAndRecover(const std::string &bundleName, const InstallParam &installParam)
{
ErrCode resultCode = ERR_OK;