diff --git a/services/bundlemgr/include/base_bundle_installer.h b/services/bundlemgr/include/base_bundle_installer.h index ecc0ca054..d82083b17 100644 --- a/services/bundlemgr/include/base_bundle_installer.h +++ b/services/bundlemgr/include/base_bundle_installer.h @@ -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. diff --git a/services/bundlemgr/include/bundle_installer.h b/services/bundlemgr/include/bundle_installer.h index da7b5c2af..ad800e92e 100644 --- a/services/bundlemgr/include/bundle_installer.h +++ b/services/bundlemgr/include/bundle_installer.h @@ -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 statusReceiver_; diff --git a/services/bundlemgr/src/base_bundle_installer.cpp b/services/bundlemgr/src/base_bundle_installer.cpp index a206afa43..638072d0b 100644 --- a/services/bundlemgr/src/base_bundle_installer.cpp +++ b/services/bundlemgr/src/base_bundle_installer.cpp @@ -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::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 diff --git a/services/bundlemgr/src/bundle_installer.cpp b/services/bundlemgr/src/bundle_installer.cpp index dbcdf5416..65f2cbcb0 100644 --- a/services/bundlemgr/src/bundle_installer.cpp +++ b/services/bundlemgr/src/bundle_installer.cpp @@ -276,29 +276,6 @@ void BundleInstaller::RecoverDriverForAllUsers(const std::string &bundleName, co } } -bool BundleInstaller::HasDriverExtensionAbility(const std::string &bundleName) -{ - auto dataMgr = DelayedSingleton::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;