diff --git a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h index b2d6e749bb76995633e832245297905a24846ec5..ae6ba815b4791daa05e02f0a6a59d79cf1f66d7a 100644 --- a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h +++ b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h @@ -147,6 +147,7 @@ enum { ERR_APPEXECFWK_INSTALL_DEBUG_BUNDLE_NOT_ALLOWED = 8519784, ERR_APPEXECFWK_INSTALL_FAILED_CONTROLLED = 8519785, ERR_APPEXECFWK_INSTALL_MULTI_APP_MAX_COUNT_DECREASE = 8519786, + ERR_APPEXECFWK_INSTALL_APP_IN_BLOCKLIST = 8519787, // native bundle ERR_APPEXECFWK_NATIVE_INSTALL_FAILED = 8519790, diff --git a/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h b/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h index 6b6eef345bb72df831bca8c861a09319f84b78cb..ef10c629a98b21ee79a59bcabdfa75d0ee649d51 100644 --- a/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h +++ b/interfaces/inner_api/bundlemgr_extension/include/bms_extension_data_mgr.h @@ -52,6 +52,7 @@ public: ErrCode VerifyActivationLock(bool &res); ErrCode GetBackupUninstallList(int32_t userId, std::set &uninstallBundles); ErrCode ClearBackupUninstallFile(int32_t userId); + bool IsAppInBlocklist(const std::string &bundleName); private: bool OpenHandler(); static BmsExtension bmsExtension_; diff --git a/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h b/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h index 044a471efe449ad0ee9ccc5aae2e091e65edb49e..7ebb0f1f8107e8a274816535bec1690887ce976f 100644 --- a/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h +++ b/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext.h @@ -91,6 +91,10 @@ public: { return ERR_BUNDLE_MANAGER_EXTENSION_DEFAULT_ERR; } + virtual bool IsAppInBlocklist(const std::string &bundleName) + { + return false; + } }; } // AppExecFwk diff --git a/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp b/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp index e643d15aebc62e439215bb4d1499534aa6193ab7..b8346768c65eedb3f88d667c26f6986b779ee87c 100644 --- a/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp +++ b/interfaces/inner_api/bundlemgr_extension/src/bms_extension_data_mgr.cpp @@ -313,5 +313,20 @@ ErrCode BmsExtensionDataMgr::ClearBackupUninstallFile(int32_t userId) } return bundleMgrExtPtr->ClearBackupUninstallFile(userId); } + +bool BmsExtensionDataMgr::IsAppInBlocklist(const std::string &bundleName) +{ + if ((Init() != ERR_OK) || handler_ == nullptr) { + APP_LOGW("link failed"); + return false; + } + auto bundleMgrExtPtr = + BundleMgrExtRegister::GetInstance().GetBundleMgrExt(bmsExtension_.bmsExtensionBundleMgr.extensionName); + if (bundleMgrExtPtr == nullptr) { + APP_LOGW("GetBundleMgrExt failed"); + return false; + } + return bundleMgrExtPtr->IsAppInBlocklist(bundleName); +} } // AppExecFwk } // OHOS diff --git a/interfaces/kits/js/common/common_func.cpp b/interfaces/kits/js/common/common_func.cpp index afaca53a64efb7bcea0538b5bfa7d94d45a5c138..d1b896555bb5d2207b6487531a4e65dd8c7b4856 100644 --- a/interfaces/kits/js/common/common_func.cpp +++ b/interfaces/kits/js/common/common_func.cpp @@ -166,6 +166,7 @@ static std::unordered_map ERR_MAP = { { ERR_APPEXECFWK_CLONE_UNINSTALL_NOT_INSTALLED_AT_SPECIFIED_USERID, ERROR_BUNDLE_NOT_EXIST }, { ERR_APPEXECFWK_CLONE_UNINSTALL_APP_NOT_CLONED, ERROR_INVALID_APPINDEX }, { ERR_APPEXECFWK_INSTALL_FAILED_CONTROLLED, ERROR_INSTALL_FAILED_CONTROLLED }, + { ERR_APPEXECFWK_INSTALL_APP_IN_BLOCKLIST, ERROR_INSTALL_FAILED_CONTROLLED }, { ERR_APPEXECFWK_CLONE_INSTALL_APP_INDEX_EXCEED_MAX_NUMBER, ERROR_INVALID_APPINDEX }, { ERR_APPEXECFWK_SANDBOX_INSTALL_INVALID_APP_INDEX, ERROR_INVALID_APPINDEX }, { ERR_APPEXECFWK_CLONE_INSTALL_APP_NOT_SUPPORTED_MULTI_TYPE, ERROR_APP_NOT_SUPPORTED_MULTI_TYPE }, diff --git a/services/bundlemgr/include/base_bundle_installer.h b/services/bundlemgr/include/base_bundle_installer.h index 22009850af55a26c5333a2a91f0ccb6a3961e6b7..82e0bf09d0eaec18faca172b8362d69393d71583 100644 --- a/services/bundlemgr/include/base_bundle_installer.h +++ b/services/bundlemgr/include/base_bundle_installer.h @@ -710,6 +710,8 @@ private: void SetInstallSourceToAppInfo(std::unordered_map &infos, const InstallParam &installParam) const; bool InitDataMgr(); + bool IsAppInBlocklist(const std::string &bundleName) const; + InstallerState state_ = InstallerState::INSTALL_START; std::shared_ptr dataMgr_ = nullptr; // this pointer will get when public functions called std::string bundleName_; diff --git a/services/bundlemgr/src/base_bundle_installer.cpp b/services/bundlemgr/src/base_bundle_installer.cpp index cc01107fa2a108dc2acc5bd809c33c753c956637..d542cad79e69864172b674fdacd35b78996e41ce 100644 --- a/services/bundlemgr/src/base_bundle_installer.cpp +++ b/services/bundlemgr/src/base_bundle_installer.cpp @@ -1056,10 +1056,15 @@ ErrCode BaseBundleInstaller::ProcessBundleInstall(const std::vector result = ParseHapFiles(bundlePaths, installParam, appType, hapVerifyResults, newInfos); CHECK_RESULT(result, "parse haps file failed %{public}d"); // washing machine judge - for (const auto &infoIter: newInfos) { - if (!infoIter.second.IsSystemApp() && !VerifyActivationLock()) { - result = ERR_APPEXECFWK_INSTALL_FAILED_CONTROLLED; - break; + if (!installParam.isPreInstallApp) { + for (const auto &infoIter: newInfos) { + if (!infoIter.second.IsSystemApp() && !VerifyActivationLock()) { + result = ERR_APPEXECFWK_INSTALL_FAILED_CONTROLLED; + break; + } + } + if (IsAppInBlocklist((newInfos.begin()->second).GetBundleName())) { + result = ERR_APPEXECFWK_INSTALL_APP_IN_BLOCKLIST; } } CHECK_RESULT(result, "check install verifyActivation failed %{public}d"); @@ -5689,5 +5694,16 @@ ErrCode BaseBundleInstaller::RollbackHmpCommonInfo(const std::string &bundleName ClearDomainVerifyStatus(oldInfo.GetAppIdentifier(), oldInfo.GetBundleName()); return ERR_OK; } + +bool BaseBundleInstaller::IsAppInBlocklist(const std::string &bundleName) const +{ + BmsExtensionDataMgr bmsExtensionDataMgr; + bool res = bmsExtensionDataMgr.IsAppInBlocklist(bundleName); + if (res) { + LOG_E(BMS_TAG_INSTALLER, "app %{public}s is in blocklist", bundleName.c_str()); + return true; + } + return false; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/src/status_receiver_proxy.cpp b/services/bundlemgr/src/status_receiver_proxy.cpp index c3fd30339e778c1c99ea3b3319e82ee485580a77..a17da656f4a80874e69665f5046e7bdcad2de19b 100644 --- a/services/bundlemgr/src/status_receiver_proxy.cpp +++ b/services/bundlemgr/src/status_receiver_proxy.cpp @@ -592,6 +592,9 @@ const std::map MAP_RECEIVED_RESULTS { {ERR_APPEXECFWK_INSTALL_MULTI_APP_MAX_COUNT_DECREASE, {IStatusReceiver::ERR_INSTALL_MULTI_APP_MAX_COUNT_DECREASE, MSG_ERR_INSTALL_MULTI_APP_MAX_COUNT_DECREASE}}, + {ERR_APPEXECFWK_INSTALL_APP_IN_BLOCKLIST, + {IStatusReceiver::ERR_INSTALL_CODE_APP_CONTROLLED_FAILED, + MSG_ERR_INSTALL_CODE_APP_CONTROLLED_FAILED}}, }; } // namespace