From 4041a6133eb67fb1b2ff2d402291e2cca430cb58 Mon Sep 17 00:00:00 2001 From: small_leek Date: Fri, 12 Sep 2025 15:55:24 +0800 Subject: [PATCH] split errcode for 8519694/8519690 Signed-off-by: small_leek --- .../include/appexecfwk_errors.h | 17 + .../bundle_status_callback_proxy.cpp | 28 + .../include/bundle_mgr_ext_register.h | 5 +- .../src/bundle_mgr_ext_register.cpp | 8 +- .../bundle_manager/clean_cache_callback.cpp | 2 +- .../js/bundle_manager/clean_cache_callback.h | 3 +- interfaces/kits/js/common/common_func.cpp | 18 +- .../bundlemgr/include/aging/aging_request.h | 5 +- .../include/aging/bundle_aging_mgr.h | 4 +- services/bundlemgr/include/bundle_data_mgr.h | 32 +- .../bundlemgr/include/bundle_mgr_service.h | 3 +- services/bundlemgr/include/bundle_promise.h | 9 +- services/bundlemgr/include/bundle_util.h | 12 +- .../bundle_distributed_manager.h | 3 +- .../free_install/bundle_connect_ability_mgr.h | 11 +- .../free_install/service_center_connection.h | 5 +- .../bundlemgr/include/rdb/rdb_data_manager.h | 9 +- .../bundlemgr/src/aging/aging_request.cpp | 8 +- .../bundlemgr/src/aging/bundle_aging_mgr.cpp | 6 +- .../recently_unused_bundle_aging_handler.cpp | 9 +- .../bundlemgr/src/base_bundle_installer.cpp | 15 +- .../bundlemgr/src/bundle_common_event_mgr.cpp | 3 +- services/bundlemgr/src/bundle_data_mgr.cpp | 487 +++++++++--------- .../bundlemgr/src/bundle_install_checker.cpp | 3 +- services/bundlemgr/src/bundle_mgr_service.cpp | 8 +- .../src/bundle_multiuser_installer.cpp | 5 +- services/bundlemgr/src/bundle_util.cpp | 49 +- .../bundle_distributed_manager.cpp | 8 +- .../bundle_connect_ability_mgr.cpp | 34 +- .../bundlemgr/src/rdb/rdb_data_manager.cpp | 14 +- .../shared/inner_shared_bundle_installer.cpp | 24 +- .../bundlemgr/src/status_receiver_proxy.cpp | 28 + .../bundlemgr/test/mock/src/bundle_util.cpp | 24 +- .../bms_bundle_app_provision_info_test.cpp | 8 +- .../bms_bundle_free_install_test.cpp | 20 +- ...bms_bundle_shared_library_install_test.cpp | 6 +- .../bms_bundle_app_service_fwk_installer.cpp | 2 +- .../bms_bundle_installer_test.cpp | 37 +- .../bms_bundle_data_mgr_test.cpp | 4 +- .../bms_data_mgr_test/bms_data_mgr_test.cpp | 18 +- .../bmsfreeinstall_fuzzer003.cpp | 2 +- .../servicecenterconnection_fuzzer.cpp | 2 +- 42 files changed, 545 insertions(+), 453 deletions(-) diff --git a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h index 1b2ddddd01..43b278e1b7 100644 --- a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h +++ b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h @@ -145,6 +145,8 @@ enum { ERR_APPEXECFWK_INSTALL_FAILED_CONTROLLED = 8519785, ERR_APPEXECFWK_INSTALL_FAILED_ACCOUNT_CONSTRAINT = 8519786, ERR_APPEXECFWK_INSTALL_APP_IN_BLOCKLIST = 8519787, + ERR_APPEXECFWK_INSTALL_BUNDLENAME_IS_EMPTY = 8519788, + ERR_APPEXECFWK_INSTALL_BUNDLEID_EXCEED_MAX_NUMBER = 8519789, // native bundle ERR_APPEXECFWK_NATIVE_INSTALL_FAILED = 8519790, ERR_APPEXECFWK_NATIVE_UNINSTALL_FAILED = 8519791, @@ -598,6 +600,21 @@ enum { ERR_APPEXECFWK_IDL_GET_RESULT_ERROR = 8522610, // control not dynamic atomicService ERR_APPEXECFWK_INSTALL_NOT_SUPPORT_STATIC_ATOMIC_SERVICE = 8522630, + + // check file path err + ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY = 8522640, + ERR_APPEXECFWK_INSTALL_INVALID_FILE_NAME_SIZE = 8522641, + ERR_APPEXECFWK_INSTALL_FILE_PATH_IS_NOT_REAL = 8522642, + ERR_APPEXECFWK_INSTALL_ACCESS_FILE_FAILED = 8522643, + ERR_APPEXECFWK_INSTALL_STAT_FILE_FAILED = 8522644, + ERR_APPEXECFWK_INSTALL_OPENDIR_FAILED = 8522645, + ERR_APPEXECFWK_INSTALL_HAP_NUMBER_EXCEED_MAX_NUMBER = 8522646, + ERR_APPEXECFWK_INSTALL_HSP_NUMBER_EXCEED_MAX_NUMBER = 8522647, + ERR_APPEXECFWK_INSTALL_RENAME_INSTALL_FILE_PATH_NOT_START_WITH_APP_INSTALL_SANDBOX = 8522648, + ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR = 8522649, + ERR_APPEXECFWK_INSTALL_ONLY_ONE_HSP_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR = 8522650, + ERR_APPEXECFWK_INSTALL_ONLY_ONE_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR = 8522651, + }; // Error code for Hidump diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_status_callback_proxy.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_status_callback_proxy.cpp index 5316e56ec9..0d1c23df78 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_status_callback_proxy.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_status_callback_proxy.cpp @@ -163,6 +163,34 @@ void BundleStatusCallbackProxy::InitResultMap() "ERR_APP_DISTRIBUTION_TYPE_NOT_ALLOW_INSTALL"}, {ERR_APPEXECFWK_INSTALL_FAILED_AND_RESTORE_TO_PREINSTALLED, "ERR_APPEXECFWK_INSTALL_FAILED_AND_RESTORE_TO_PREINSTALLED"}, + {ERR_APPEXECFWK_INSTALL_BUNDLENAME_IS_EMPTY, + "ERR_APPEXECFWK_INSTALL_BUNDLENAME_IS_EMPTY"}, + {ERR_APPEXECFWK_INSTALL_BUNDLEID_EXCEED_MAX_NUMBER, + "ERR_APPEXECFWK_INSTALL_BUNDLEID_EXCEED_MAX_NUMBER"}, + {ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY, + "ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY"}, + {ERR_APPEXECFWK_INSTALL_INVALID_FILE_NAME_SIZE, + "ERR_APPEXECFWK_INSTALL_INVALID_FILE_NAME_SIZE"}, + {ERR_APPEXECFWK_INSTALL_FILE_PATH_IS_NOT_REAL, + "ERR_APPEXECFWK_INSTALL_FILE_PATH_IS_NOT_REAL"}, + {ERR_APPEXECFWK_INSTALL_ACCESS_FILE_FAILED, + "ERR_APPEXECFWK_INSTALL_ACCESS_FILE_FAILED"}, + {ERR_APPEXECFWK_INSTALL_STAT_FILE_FAILED, + "ERR_APPEXECFWK_INSTALL_STAT_FILE_FAILED"}, + {ERR_APPEXECFWK_INSTALL_OPENDIR_FAILED, + "ERR_APPEXECFWK_INSTALL_OPENDIR_FAILED"}, + {ERR_APPEXECFWK_INSTALL_HAP_NUMBER_EXCEED_MAX_NUMBER, + "ERR_APPEXECFWK_INSTALL_HAP_NUMBER_EXCEED_MAX_NUMBER"}, + {ERR_APPEXECFWK_INSTALL_HSP_NUMBER_EXCEED_MAX_NUMBER, + "ERR_APPEXECFWK_INSTALL_HSP_NUMBER_EXCEED_MAX_NUMBER"}, + {ERR_APPEXECFWK_INSTALL_RENAME_INSTALL_FILE_PATH_NOT_START_WITH_APP_INSTALL_SANDBOX, + "ERR_APPEXECFWK_INSTALL_RENAME_INSTALL_FILE_PATH_NOT_START_WITH_APP_INSTALL_SANDBOX"} + {ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR, + "ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR"}, + {ERR_APPEXECFWK_INSTALL_ONLY_ONE_HSP_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR, + "ERR_APPEXECFWK_INSTALL_ONLY_ONE_HSP_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR"}, + {ERR_APPEXECFWK_INSTALL_ONLY_ONE_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR, + "ERR_APPEXECFWK_INSTALL_ONLY_ONE_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR"}, }; } diff --git a/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext_register.h b/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext_register.h index 5fa6a93961..bc9e05725e 100644 --- a/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext_register.h +++ b/interfaces/inner_api/bundlemgr_extension/include/bundle_mgr_ext_register.h @@ -22,7 +22,6 @@ #include #include "bundle_mgr_ext.h" -#include "ffrt.h" #include "nocopyable.h" namespace OHOS { @@ -37,8 +36,8 @@ public: void RegisterBundleMgrExt(const std::string& bundleExtName, const CreateFunc& createFunc); std::shared_ptr GetBundleMgrExt(const std::string &bundleExtName); private: - static ffrt::mutex mutex_; - mutable ffrt::mutex BundleMgrExtMutex_; + static std::mutex mutex_; + mutable std::mutex BundleMgrExtMutex_; BundleMgrExtRegister() = default; std::unordered_map bundleMgrExts_; diff --git a/interfaces/inner_api/bundlemgr_extension/src/bundle_mgr_ext_register.cpp b/interfaces/inner_api/bundlemgr_extension/src/bundle_mgr_ext_register.cpp index fab1650b77..452f44e637 100644 --- a/interfaces/inner_api/bundlemgr_extension/src/bundle_mgr_ext_register.cpp +++ b/interfaces/inner_api/bundlemgr_extension/src/bundle_mgr_ext_register.cpp @@ -18,23 +18,23 @@ namespace OHOS { namespace AppExecFwk { -ffrt::mutex BundleMgrExtRegister::mutex_; +std::mutex BundleMgrExtRegister::mutex_; BundleMgrExtRegister &BundleMgrExtRegister::GetInstance() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); static BundleMgrExtRegister bundleMgrExt; return bundleMgrExt; } void BundleMgrExtRegister::RegisterBundleMgrExt(const std::string& bundleExtName, const CreateFunc& createFunc) { - std::lock_guard lock(BundleMgrExtMutex_); + std::lock_guard lock(BundleMgrExtMutex_); bundleMgrExts_.emplace(bundleExtName, createFunc); } std::shared_ptr BundleMgrExtRegister::GetBundleMgrExt(const std::string &bundleExtName) { - std::lock_guard lock(BundleMgrExtMutex_); + std::lock_guard lock(BundleMgrExtMutex_); auto it = bundleMgrExts_.find(bundleExtName); if (it == bundleMgrExts_.end()) { return nullptr; diff --git a/interfaces/kits/js/bundle_manager/clean_cache_callback.cpp b/interfaces/kits/js/bundle_manager/clean_cache_callback.cpp index c96e7c4914..33e753edb1 100644 --- a/interfaces/kits/js/bundle_manager/clean_cache_callback.cpp +++ b/interfaces/kits/js/bundle_manager/clean_cache_callback.cpp @@ -30,7 +30,7 @@ CleanCacheCallback::~CleanCacheCallback() {} void CleanCacheCallback::OnCleanCacheFinished(bool err) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!complete_) { complete_ = true; err_ = err; diff --git a/interfaces/kits/js/bundle_manager/clean_cache_callback.h b/interfaces/kits/js/bundle_manager/clean_cache_callback.h index bc4ea81f83..8c4086519a 100644 --- a/interfaces/kits/js/bundle_manager/clean_cache_callback.h +++ b/interfaces/kits/js/bundle_manager/clean_cache_callback.h @@ -16,7 +16,6 @@ #ifndef BUNDLE_FRAMEWORK_INTERFACES_KITS_JS_BUNDLE_MANAGER_CLEAN_CACHE_CALLBACK_H #define BUNDLE_FRAMEWORK_INTERFACES_KITS_JS_BUNDLE_MANAGER_CLEAN_CACHE_CALLBACK_H -#include "ffrt.h" #include #include @@ -43,7 +42,7 @@ public: private: bool err_ = false; - ffrt::mutex mutex_; + std::mutex mutex_; bool complete_ = false; std::promise promise_; std::future future_ = promise_.get_future(); diff --git a/interfaces/kits/js/common/common_func.cpp b/interfaces/kits/js/common/common_func.cpp index 388356a7b8..c2df32021c 100644 --- a/interfaces/kits/js/common/common_func.cpp +++ b/interfaces/kits/js/common/common_func.cpp @@ -225,7 +225,23 @@ static std::unordered_map ERR_MAP = { { ERR_APPEXECFWK_PLUGIN_NOT_FOUND, ERROR_PLUGIN_NOT_FOUND }, { ERR_APPEXECFWK_PLUGIN_INSTALL_SAME_BUNDLE_NAME, ERROR_PLUGIN_SAME_BUNDLE_NAME }, { ERR_APPEXECFWK_PLUGIN_INSTALL_NOT_ALLOW, ERROR_INSTALL_PARSE_FAILED }, - { ERR_APPEXECFWK_INSTALL_DISK_MEM_INSUFFICIENT, ERROR_INSTALL_NO_DISK_SPACE_LEFT } + { ERR_APPEXECFWK_INSTALL_DISK_MEM_INSUFFICIENT, ERROR_INSTALL_NO_DISK_SPACE_LEFT }, + { ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY, ERROR_INSTALL_HAP_FILEPATH_INVALID }, + { ERR_APPEXECFWK_INSTALL_INVALID_FILE_NAME_SIZE, ERROR_INSTALL_HAP_FILEPATH_INVALID }, + { ERR_APPEXECFWK_INSTALL_FILE_PATH_IS_NOT_REAL, ERROR_INSTALL_HAP_FILEPATH_INVALID }, + { ERR_APPEXECFWK_INSTALL_ACCESS_FILE_FAILED, ERROR_INSTALL_HAP_FILEPATH_INVALID }, + { ERR_APPEXECFWK_INSTALL_STAT_FILE_FAILED, ERROR_INSTALL_HAP_FILEPATH_INVALID }, + { ERR_APPEXECFWK_INSTALL_HAP_NUMBER_EXCEED_MAX_NUMBER, ERROR_INSTALL_HAP_FILEPATH_INVALID }, + { ERR_APPEXECFWK_INSTALL_HSP_NUMBER_EXCEED_MAX_NUMBER, ERROR_INSTALL_HAP_FILEPATH_INVALID }, + { ERR_APPEXECFWK_INSTALL_RENAME_INSTALL_FILE_PATH_NOT_START_WITH_APP_INSTALL_SANDBOX, + ERROR_INSTALL_HAP_FILEPATH_INVALID }, + { ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR, + ERROR_INSTALL_HAP_FILEPATH_INVALID }, + { ERR_APPEXECFWK_INSTALL_ONLY_ONE_HSP_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR, + ERROR_INSTALL_HAP_FILEPATH_INVALID }, + { ERR_APPEXECFWK_INSTALL_ONLY_ONE_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR, + ERROR_INSTALL_HAP_FILEPATH_INVALID }, + }; } using Want = OHOS::AAFwk::Want; diff --git a/services/bundlemgr/include/aging/aging_request.h b/services/bundlemgr/include/aging/aging_request.h index 98935a1fd0..45dd51af00 100644 --- a/services/bundlemgr/include/aging/aging_request.h +++ b/services/bundlemgr/include/aging/aging_request.h @@ -21,7 +21,6 @@ #include "aging_bundle_info.h" #include "aging_util.h" -#include "ffrt.h" namespace OHOS { namespace AppExecFwk { @@ -42,7 +41,7 @@ public: const std::vector GetAgingBundles() const { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return agingBundles_; }; @@ -91,7 +90,7 @@ private: static int64_t totalDataBytesThreshold_; static int64_t oneDayTimeMs_; - mutable ffrt::mutex mutex_; + mutable std::mutex mutex_; std::vector agingBundles_; }; } // namespace AppExecFwk diff --git a/services/bundlemgr/include/aging/bundle_aging_mgr.h b/services/bundlemgr/include/aging/bundle_aging_mgr.h index 126dbb6a3c..3809136974 100644 --- a/services/bundlemgr/include/aging/bundle_aging_mgr.h +++ b/services/bundlemgr/include/aging/bundle_aging_mgr.h @@ -23,8 +23,6 @@ #include "aging/aging_handler_chain.h" #include "aging/aging_request.h" #include "bundle_active_client.h" -#include "bundle_data_mgr.h" -#include "ffrt.h" #include "singleton.h" namespace OHOS { @@ -62,7 +60,7 @@ private: static const uint32_t EVENT_AGING_NOW = 1; int64_t agingTimerInterval_ = AgingConstants::DEFAULT_AGING_TIMER_INTERVAL; int64_t agingBatteryThresold_ = AgingConstants::DEFAULT_AGING_BATTERY_THRESHOLD; - ffrt::mutex mutex_; + std::mutex mutex_; AgingHandlerChain chain_; AgingRequest request_; }; diff --git a/services/bundlemgr/include/bundle_data_mgr.h b/services/bundlemgr/include/bundle_data_mgr.h index ca3a6466c7..9e360f6e44 100644 --- a/services/bundlemgr/include/bundle_data_mgr.h +++ b/services/bundlemgr/include/bundle_data_mgr.h @@ -150,7 +150,7 @@ public: * @param innerBundleUserInfo Indicates the InnerBundleUserInfo object. * @return Returns true if this function is successfully called; returns false otherwise. */ - bool GenerateUidAndGid(InnerBundleUserInfo &innerBundleUserInfo); + ErrCode GenerateUidAndGid(InnerBundleUserInfo &innerBundleUserInfo); /** * @brief Recycle uid and gid . * @param info Indicates the InnerBundleInfo object. @@ -539,7 +539,7 @@ public: * @param bundleName Indicates the bundle name. * @return Returns a reference of mutex that for locing by bundle name. */ - ffrt::mutex &GetBundleMutex(const std::string &bundleName); + std::mutex &GetBundleMutex(const std::string &bundleName); /** * @brief Obtains the provision Id based on a given bundle name. * @param bundleName Indicates the application bundle name to be queried. @@ -888,7 +888,7 @@ public: ErrCode GetMediaData(const std::string &bundleName, const std::string &moduleName, const std::string &abilityName, std::unique_ptr &mediaDataPtr, size_t &len, int32_t userId) const; - ffrt::shared_mutex &GetStatusCallbackMutex(); + std::shared_mutex &GetStatusCallbackMutex(); std::vector> GetCallBackList() const; @@ -922,7 +922,7 @@ public: const std::map GetAllInnerBundleInfos() const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); return bundleInfos_; } @@ -1244,7 +1244,7 @@ private: int32_t appIndex = 0) const; ErrCode ExplicitQueryAbilityInfoV9(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo, int32_t appIndex = 0) const; - bool GenerateBundleId(const std::string &bundleName, int32_t &bundleId); + ErrCode GenerateBundleId(const std::string &bundleName, int32_t &bundleId); int32_t GetUserIdByUid(int32_t uid) const; bool GetAllBundleInfos(int32_t flags, std::vector &bundleInfos) const; ErrCode GetAllBundleInfosV9(int32_t flags, std::vector &bundleInfos) const; @@ -1414,16 +1414,16 @@ private: private: bool initialUserFlag_ = false; int32_t baseAppUid_ = Constants::BASE_APP_UID; - mutable ffrt::mutex stateMutex_; - mutable ffrt::mutex multiUserIdSetMutex_; - mutable ffrt::mutex hspBundleNameMutex_; - mutable ffrt::mutex pluginCallbackMutex_; - mutable ffrt::mutex eventCallbackMutex_; - mutable ffrt::shared_mutex bundleInfoMutex_; - mutable ffrt::shared_mutex bundleIdMapMutex_; - mutable ffrt::shared_mutex callbackMutex_; - mutable ffrt::shared_mutex bundleMutex_; - mutable ffrt::shared_mutex otaNewInstallMutex_; + mutable std::mutex stateMutex_; + mutable std::mutex multiUserIdSetMutex_; + mutable std::mutex hspBundleNameMutex_; + mutable std::mutex pluginCallbackMutex_; + mutable std::mutex eventCallbackMutex_; + mutable std::shared_mutex bundleInfoMutex_; + mutable std::shared_mutex bundleIdMapMutex_; + mutable std::shared_mutex callbackMutex_; + mutable std::shared_mutex bundleMutex_; + mutable std::shared_mutex otaNewInstallMutex_; std::shared_ptr dataStorage_; std::shared_ptr preInstallDataStorage_; std::shared_ptr bundleStateStorage_; @@ -1439,7 +1439,7 @@ private: // common event callback std::vector> eventCallbackList_; // using for locking by bundleName - std::unordered_map bundleMutexMap_; + std::unordered_map bundleMutexMap_; // using for generating bundleId // key:bundleId // value:bundleName diff --git a/services/bundlemgr/include/bundle_mgr_service.h b/services/bundlemgr/include/bundle_mgr_service.h index 26e9c8856f..1c54aa2486 100644 --- a/services/bundlemgr/include/bundle_mgr_service.h +++ b/services/bundlemgr/include/bundle_mgr_service.h @@ -42,7 +42,6 @@ #include "default_app_host_impl.h" #endif #include "extend_resource_manager_host_impl.h" -#include "ffrt.h" #include "hidump_helper.h" #ifdef BUNDLE_FRAMEWORK_QUICK_FIX #include "quick_fix_manager_host_impl.h" @@ -197,7 +196,7 @@ private: std::shared_ptr dataMgr_; std::shared_ptr hidumpHelper_; #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL - mutable ffrt::mutex bundleConnectMutex_; + mutable std::mutex bundleConnectMutex_; std::shared_ptr agingMgr_; std::shared_ptr bundleDistributedManager_; // key is userId diff --git a/services/bundlemgr/include/bundle_promise.h b/services/bundlemgr/include/bundle_promise.h index 91b0609734..3124efc3b4 100644 --- a/services/bundlemgr/include/bundle_promise.h +++ b/services/bundlemgr/include/bundle_promise.h @@ -20,7 +20,6 @@ #include #include "app_log_wrapper.h" -#include "ffrt.h" namespace OHOS { namespace AppExecFwk { @@ -34,7 +33,7 @@ public: */ void NotifyAllTasksExecuteFinished() { - std::lock_guard lock(notifyTaskMutex_); + std::lock_guard lock(notifyTaskMutex_); if (hasNotified_) { APP_LOGE("promise has executed and abort when NotifyAllTasksExecuteFinished"); return; @@ -50,7 +49,7 @@ public: */ void WaitForAllTasksExecute() { - std::lock_guard lock(waitTaskMutex_); + std::lock_guard lock(waitTaskMutex_); if (hasWaited_) { APP_LOGE("promise has executed and abort when WaitForAllTasksExecute"); return; @@ -65,8 +64,8 @@ private: std::atomic_bool hasWaited_ = false; std::promise promise_; std::future future_ = promise_.get_future(); - ffrt::mutex waitTaskMutex_; - ffrt::mutex notifyTaskMutex_; + std::mutex waitTaskMutex_; + std::mutex notifyTaskMutex_; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/include/bundle_util.h b/services/bundlemgr/include/bundle_util.h index 78e90e93b2..bd35c6bed8 100644 --- a/services/bundlemgr/include/bundle_util.h +++ b/services/bundlemgr/include/bundle_util.h @@ -64,15 +64,15 @@ public: /** * @brief Check whether a file name is valid. * @param fileName Indicates the file path. - * @return Returns true if the file name checked successfully; returns false otherwise. + * @return Returns ERR_OK if the file name checked successfully; returns errcode otherwise. */ - static bool CheckFileName(const std::string &fileName); + static ErrCode CheckFileName(const std::string &fileName); /** * @brief Check whether a Hap size is valid. * @param fileName Indicates the file path. - * @return Returns true if the file size checked successfully; returns false otherwise. + * @return Returns ERR_OK if the file size checked successfully; returns errcode otherwise. */ - static bool CheckFileSize(const std::string &bundlePath, const int64_t fileSize); + static ErrCode CheckFileSize(const std::string &bundlePath, const int64_t fileSize); /** * @brief Check whether the disk path memory is available for installing the hap. * @param bundlePath Indicates the file path. @@ -94,9 +94,9 @@ public: * @brief to obtain the hap paths of the input bundle path. * @param currentBundlePath Indicates the current bundle path. * @param hapFileList Indicates the hap paths. - * @return Returns true if the hap path obtained successfully; returns false otherwise. + * @return Returns ERR_OK if the hap path obtained successfully; returns errcode otherwise. */ - static bool GetHapFilesFromBundlePath(const std::string& currentBundlePath, std::vector& hapFileList); + static ErrCode GetHapFilesFromBundlePath(const std::string& currentBundlePath, std::vector& hapFileList); /** * @brief to obtain the current time. * @return Returns current time. diff --git a/services/bundlemgr/include/distributed_manager/bundle_distributed_manager.h b/services/bundlemgr/include/distributed_manager/bundle_distributed_manager.h index 5ab13a587b..e23f913eb7 100644 --- a/services/bundlemgr/include/distributed_manager/bundle_distributed_manager.h +++ b/services/bundlemgr/include/distributed_manager/bundle_distributed_manager.h @@ -18,7 +18,6 @@ #include -#include "ffrt.h" #include "iremote_broker.h" #include "query_rpc_id_params.h" #include "rpc_id_result.h" @@ -51,7 +50,7 @@ private: return transactId_.load(); } mutable std::atomic transactId_ = 0; - ffrt::shared_mutex mutex_; + std::shared_mutex mutex_; std::shared_ptr serialQueue_; std::map queryAbilityParamsMap_; diff --git a/services/bundlemgr/include/free_install/bundle_connect_ability_mgr.h b/services/bundlemgr/include/free_install/bundle_connect_ability_mgr.h index eed1bf3e10..ff0db6787e 100644 --- a/services/bundlemgr/include/free_install/bundle_connect_ability_mgr.h +++ b/services/bundlemgr/include/free_install/bundle_connect_ability_mgr.h @@ -21,7 +21,6 @@ #include #include "bms_ecological_rule_mgr_service_client.h" -#include "ffrt.h" #include "free_install_params.h" #include "inner_bundle_info.h" #include "install_result.h" @@ -252,8 +251,8 @@ private: const sptr &callBack, InnerBundleInfo &innerBundleInfo); bool GetAbilityMgrProxy(); - void WaitFromConnecting(std::unique_lock &lock); - void WaitFromConnected(std::unique_lock &lock); + void WaitFromConnecting(std::unique_lock &lock); + void WaitFromConnected(std::unique_lock &lock); void DisconnectDelay(); void PreloadRequest(int32_t flag, const TargetAbilityInfo &targetAbilityInfo); @@ -277,9 +276,9 @@ private: mutable std::atomic transactId_ = 0; sptr serviceCenterConnection_; // maintain the order of using locks. mutex_ >> remoteObejctMutex_ >> mapMutex_ - ffrt::mutex mutex_; - ffrt::mutex mapMutex_; - ffrt::condition_variable cv_; + std::mutex mutex_; + std::mutex mapMutex_; + std::condition_variable cv_; std::shared_ptr serialQueue_; std::map freeInstallParamsMap_; }; diff --git a/services/bundlemgr/include/free_install/service_center_connection.h b/services/bundlemgr/include/free_install/service_center_connection.h index ece1fa0262..7ce6045b31 100644 --- a/services/bundlemgr/include/free_install/service_center_connection.h +++ b/services/bundlemgr/include/free_install/service_center_connection.h @@ -20,7 +20,6 @@ #include "ability_connect_callback_stub.h" #include "bundle_connect_ability_mgr.h" -#include "ffrt.h" #include "service_center_death_recipient.h" namespace OHOS { @@ -30,7 +29,7 @@ class ServiceCenterDeathRecipient; class ServiceCenterConnection : public AAFwk::AbilityConnectionStub { public: - ServiceCenterConnection(int32_t &connectState, ffrt::condition_variable &cv, + ServiceCenterConnection(int32_t &connectState, std::condition_variable &cv, const std::weak_ptr connectAbilityMgr) : connectState_(connectState), cv_(cv), connectAbilityMgr_(connectAbilityMgr) { @@ -58,7 +57,7 @@ private: int32_t &connectState_; sptr serviceCenterRemoteObject_; sptr deathRecipient_; - ffrt::condition_variable &cv_; + std::condition_variable &cv_; std::weak_ptr connectAbilityMgr_; }; } // namespace AppExecFwk diff --git a/services/bundlemgr/include/rdb/rdb_data_manager.h b/services/bundlemgr/include/rdb/rdb_data_manager.h index e17408530c..507dfe284f 100644 --- a/services/bundlemgr/include/rdb/rdb_data_manager.h +++ b/services/bundlemgr/include/rdb/rdb_data_manager.h @@ -16,7 +16,6 @@ #ifndef FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_RDB_DATA_MANAGER_H #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_RDB_DATA_MANAGER_H -#include "ffrt.h" #include #include @@ -68,11 +67,11 @@ private: int32_t InsertWithRetry(std::shared_ptr rdbStore, int64_t &rowId, const NativeRdb::ValuesBucket &valuesBucket); bool IsRetryErrCode(int32_t errCode); - ffrt::mutex &GetRdbRestoreMutex(const std::string &dbName); + std::mutex &GetRdbRestoreMutex(const std::string &dbName); bool isInitial_ = false; - ffrt::mutex rdbMutex_; - static ffrt::mutex restoreRdbMapMutex_; - static std::unordered_map restoreRdbMap_; + std::mutex rdbMutex_; + static std::mutex restoreRdbMapMutex_; + static std::unordered_map restoreRdbMap_; std::shared_ptr rdbStore_; BmsRdbConfig bmsRdbConfig_; diff --git a/services/bundlemgr/src/aging/aging_request.cpp b/services/bundlemgr/src/aging/aging_request.cpp index 599be13b36..c930fbf0a1 100644 --- a/services/bundlemgr/src/aging/aging_request.cpp +++ b/services/bundlemgr/src/aging/aging_request.cpp @@ -37,7 +37,7 @@ AgingRequest::AgingRequest() size_t AgingRequest::SortAgingBundles() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); AgingUtil::SortAgingBundles(agingBundles_); return agingBundles_.size(); } @@ -98,13 +98,13 @@ bool AgingRequest::IsReachEndAgingThreshold() const void AgingRequest::AddAgingBundle(AgingBundleInfo &bundleInfo) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); agingBundles_.emplace_back(bundleInfo); } void AgingRequest::ResetRequest() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); agingBundles_.clear(); agingCleanType_ = AgingCleanType::CLEAN_CACHE; totalDataBytes_ = 0; @@ -112,7 +112,7 @@ void AgingRequest::ResetRequest() void AgingRequest::Dump() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (const auto &agingBundle : agingBundles_) { APP_LOGD("bundle: %{public}s, lastTimeUsed: %{public}" PRId64 ", startCount: %{public}d", agingBundle.GetBundleName().c_str(), agingBundle.GetRecentlyUsedTime(), agingBundle.GetStartCount()); diff --git a/services/bundlemgr/src/aging/bundle_aging_mgr.cpp b/services/bundlemgr/src/aging/bundle_aging_mgr.cpp index 22a131c142..3d8f7017f6 100644 --- a/services/bundlemgr/src/aging/bundle_aging_mgr.cpp +++ b/services/bundlemgr/src/aging/bundle_aging_mgr.cpp @@ -228,7 +228,7 @@ void BundleAgingMgr::Process(const std::shared_ptr &dataMgr) } { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); running_ = false; } @@ -250,7 +250,7 @@ void BundleAgingMgr::Start(AgingTriggertype type) } { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (running_) { APP_LOGD("BundleAgingMgr is running, no need to start is again"); return; @@ -265,7 +265,7 @@ void BundleAgingMgr::Start(AgingTriggertype type) ffrt::task_handle task_handle = ffrt::submit_h(task); if (task_handle == nullptr) { APP_LOGE("submit_h return null, execute Process failed"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); running_ = false; } } diff --git a/services/bundlemgr/src/aging/recently_unused_bundle_aging_handler.cpp b/services/bundlemgr/src/aging/recently_unused_bundle_aging_handler.cpp index 343864ca88..a956e75ff1 100644 --- a/services/bundlemgr/src/aging/recently_unused_bundle_aging_handler.cpp +++ b/services/bundlemgr/src/aging/recently_unused_bundle_aging_handler.cpp @@ -15,7 +15,6 @@ #include "ability_manager_helper.h" #include "bundle_mgr_service.h" -#include "ffrt.h" #include "installd_client.h" namespace OHOS { @@ -28,13 +27,13 @@ public: bool IsRunning() { - std::lock_guard lock(stateMutex_); + std::lock_guard lock(stateMutex_); return isRunning_; } void MarkRunning() { - std::lock_guard lock(stateMutex_); + std::lock_guard lock(stateMutex_); isRunning_ = true; } @@ -48,7 +47,7 @@ public: void OnFinished(const int32_t resultCode, const std::string &resultMsg) override { - std::lock_guard lock(stateMutex_); + std::lock_guard lock(stateMutex_); isRunning_ = false; if (agingPromise_) { APP_LOGD("Notify task end"); @@ -57,7 +56,7 @@ public: } private: - ffrt::mutex stateMutex_; + std::mutex stateMutex_; bool isRunning_ = false; std::shared_ptr agingPromise_ = nullptr; }; diff --git a/services/bundlemgr/src/base_bundle_installer.cpp b/services/bundlemgr/src/base_bundle_installer.cpp index a0b436a0e3..f7bc1b6599 100644 --- a/services/bundlemgr/src/base_bundle_installer.cpp +++ b/services/bundlemgr/src/base_bundle_installer.cpp @@ -3326,10 +3326,10 @@ ErrCode BaseBundleInstaller::CreateBundleDataDir(InnerBundleInfo &info) const info.GetBundleName().c_str(), userId_); return ERR_APPEXECFWK_USER_NOT_EXIST; } - - if (!dataMgr_->GenerateUidAndGid(newInnerBundleUserInfo)) { + ErrCode ret = dataMgr_->GenerateUidAndGid(newInnerBundleUserInfo); + if (ret != ERR_OK) { LOG_E(BMS_TAG_INSTALLER, "fail to generate uid and gid"); - return ERR_APPEXECFWK_INSTALL_GENERATE_UID_ERROR; + return ret; } BundleUtil::MakeFsConfig(info.GetBundleName(), ServiceConstants::HMDFS_CONFIG_PATH, info.GetAppProvisionType(), Constants::APP_PROVISION_TYPE_FILE_NAME); @@ -5683,9 +5683,10 @@ ErrCode BaseBundleInstaller::ProcessAsanDirectory(InnerBundleInfo &info) const return ERR_APPEXECFWK_USER_NOT_EXIST; } - if (!dataMgr_->GenerateUidAndGid(newInnerBundleUserInfo)) { - LOG_E(BMS_TAG_INSTALLER, "fail to gererate uid and gid"); - return ERR_APPEXECFWK_INSTALL_GENERATE_UID_ERROR; + errCode = dataMgr_->GenerateUidAndGid(newInnerBundleUserInfo); + if (errCode != ERR_OK) { + LOG_E(BMS_TAG_INSTALLER, "fail to generate uid and gid"); + return errCode; } BundleUtil::MakeFsConfig(info.GetBundleName(), ServiceConstants::HMDFS_CONFIG_PATH, info.GetAppProvisionType(), Constants::APP_PROVISION_TYPE_FILE_NAME); @@ -5990,7 +5991,7 @@ ErrCode BaseBundleInstaller::ParseHapPaths(const InstallParam &installParam, LOG_D(BMS_TAG_INSTALLER, "parsed path: %{public}s", newPath.c_str()); } else { LOG_E(BMS_TAG_INSTALLER, "path invalid: %{public}s", bundlePath.c_str()); - return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; + return ERR_APPEXECFWK_INSTALL_RENAME_INSTALL_FILE_PATH_NOT_START_WITH_APP_INSTALL_SANDBOX; } } if (!parsedPaths.empty()) { diff --git a/services/bundlemgr/src/bundle_common_event_mgr.cpp b/services/bundlemgr/src/bundle_common_event_mgr.cpp index 338921e460..6b1c11a07e 100755 --- a/services/bundlemgr/src/bundle_common_event_mgr.cpp +++ b/services/bundlemgr/src/bundle_common_event_mgr.cpp @@ -21,7 +21,6 @@ #include "bundle_util.h" #include "common_event_manager.h" #include "common_event_support.h" -#include "ffrt.h" #include "ipc_skeleton.h" namespace OHOS { @@ -119,7 +118,7 @@ void BundleCommonEventMgr::NotifyBundleStatus(const NotifyBundleEvents &installR // trigger the status callback for status listening if ((dataMgr != nullptr) && (installResult.type != NotifyType::START_INSTALL)) { auto &callbackMutex = dataMgr->GetStatusCallbackMutex(); - std::shared_lock lock(callbackMutex); + std::shared_lock lock(callbackMutex); auto callbackList = dataMgr->GetCallBackList(); for (const auto& callback : callbackList) { int32_t callbackUserId = callback->GetUserId(); diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 3018b07311..2a18d1a950 100644 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -173,7 +173,7 @@ BundleDataMgr::~BundleDataMgr() bool BundleDataMgr::LoadDataFromPersistentStorage() { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); // Judge whether bundleState json db exists. // If it does not exist, create it and return the judgment result. bool bundleStateDbExist = bundleStateStorage_->HasBundleUserInfoJsonDb(); @@ -188,7 +188,7 @@ bool BundleDataMgr::LoadDataFromPersistentStorage() } for (const auto &item : bundleInfos_) { - std::lock_guard stateLock(stateMutex_); + std::lock_guard stateLock(stateMutex_); installStates_.emplace(item.first, InstallState::INSTALL_SUCCESS); AddAppHspBundleName(item.second.GetApplicationBundleType(), item.first); } @@ -271,8 +271,8 @@ bool BundleDataMgr::UpdateBundleInstallState(const std::string &bundleName, } // always keep lock bundleInfoMutex_ before locking stateMutex_ to avoid deadlock - std::unique_lock lck(bundleInfoMutex_); - std::lock_guard lock(stateMutex_); + std::unique_lock lck(bundleInfoMutex_); + std::lock_guard lock(stateMutex_); auto item = installStates_.find(bundleName); if (item == installStates_.end()) { if (state == InstallState::INSTALL_START) { @@ -311,13 +311,13 @@ bool BundleDataMgr::AddInnerBundleInfo(const std::string &bundleName, InnerBundl return false; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem != bundleInfos_.end()) { APP_LOGW("bundleName: %{public}s : bundle info already exist", bundleName.c_str()); return false; } - std::lock_guard stateLock(stateMutex_); + std::lock_guard stateLock(stateMutex_); auto statusItem = installStates_.find(bundleName); if (statusItem == installStates_.end()) { APP_LOGW("save info fail, bundleName:%{public}s is not installed", bundleName.c_str()); @@ -360,13 +360,13 @@ bool BundleDataMgr::AddNewModuleInfo( const std::string &bundleName, const InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo) { LOG_I(BMS_TAG_DEFAULT, "addInfo:%{public}s", newInfo.GetCurrentModulePackage().c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundleName: %{public}s : bundle info not exist", bundleName.c_str()); return false; } - std::lock_guard stateLock(stateMutex_); + std::lock_guard stateLock(stateMutex_); auto statusItem = installStates_.find(bundleName); if (statusItem == installStates_.end()) { APP_LOGW("save info fail, app:%{public}s is not updated", bundleName.c_str()); @@ -438,13 +438,13 @@ bool BundleDataMgr::RemoveModuleInfo( const std::string &bundleName, const std::string &modulePackage, InnerBundleInfo &oldInfo, bool needSaveStorage) { APP_LOGD("remove module info:%{public}s/%{public}s", bundleName.c_str(), modulePackage.c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundleName: %{public}s bundle info not exist", bundleName.c_str()); return false; } - std::lock_guard stateLock(stateMutex_); + std::lock_guard stateLock(stateMutex_); auto statusItem = installStates_.find(bundleName); if (statusItem == installStates_.end()) { APP_LOGW("save info fail, app:%{public}s is not updated", bundleName.c_str()); @@ -607,14 +607,14 @@ bool BundleDataMgr::DeleteFirstInstallBundleInfo(int32_t userId) bool BundleDataMgr::RemoveHspModuleByVersionCode(int32_t versionCode, InnerBundleInfo &info) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); std::string bundleName = info.GetBundleName(); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundleName: %{public}s bundle info not exist", bundleName.c_str()); return false; } - std::lock_guard stateLock(stateMutex_); + std::lock_guard stateLock(stateMutex_); auto statusItem = installStates_.find(bundleName); if (statusItem == installStates_.end()) { APP_LOGW("save info fail, app:%{public}s is not updated", bundleName.c_str()); @@ -636,14 +636,14 @@ ErrCode BundleDataMgr::AddInnerBundleUserInfo( const std::string &bundleName, const InnerBundleUserInfo& newUserInfo) { APP_LOGD("AddInnerBundleUserInfo:%{public}s", bundleName.c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundleName: %{public}s bundle info not exist", bundleName.c_str()); return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; } - std::lock_guard stateLock(stateMutex_); + std::lock_guard stateLock(stateMutex_); auto& info = bundleInfos_.at(bundleName); info.AddInnerBundleUserInfo(newUserInfo); info.SetBundleStatus(InnerBundleInfo::BundleStatus::ENABLED); @@ -659,14 +659,14 @@ bool BundleDataMgr::RemoveInnerBundleUserInfo( const std::string &bundleName, int32_t userId) { APP_LOGD("RemoveInnerBundleUserInfo:%{public}s", bundleName.c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundleName: %{public}s bundle info not exist", bundleName.c_str()); return false; } - std::lock_guard stateLock(stateMutex_); + std::lock_guard stateLock(stateMutex_); auto& info = bundleInfos_.at(bundleName); info.RemoveInnerBundleUserInfo(userId); info.SetBundleStatus(InnerBundleInfo::BundleStatus::ENABLED); @@ -683,13 +683,13 @@ bool BundleDataMgr::UpdateInnerBundleInfo( const std::string &bundleName, InnerBundleInfo &newInfo, InnerBundleInfo &oldInfo) { LOG_I(BMS_TAG_DEFAULT, "updateInfo:%{public}s", bundleName.c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundleName: %{public}s bundle info not exist", bundleName.c_str()); return false; } - std::lock_guard stateLock(stateMutex_); + std::lock_guard stateLock(stateMutex_); auto statusItem = installStates_.find(bundleName); if (statusItem == installStates_.end()) { APP_LOGW("save info fail, app:%{public}s is not updated", bundleName.c_str()); @@ -1003,7 +1003,7 @@ bool BundleDataMgr::ExplicitQueryAbilityInfo(const Want &want, int32_t flags, in return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; if ((appIndex == 0) && (!GetInnerBundleInfoWithFlags(bundleName, flags, innerBundleInfo, requestUserId))) { LOG_D(BMS_TAG_QUERY, "ExplicitQueryAbilityInfo failed, bundleName:%{public}s", bundleName.c_str()); @@ -1048,7 +1048,7 @@ ErrCode BundleDataMgr::ExplicitQueryAbilityInfoV9(const Want &want, int32_t flag if (requestUserId == Constants::INVALID_USERID) { return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; if (appIndex == 0) { ErrCode ret = GetInnerBundleInfoWithFlagsV9(bundleName, flags, innerBundleInfo, requestUserId); @@ -1115,7 +1115,7 @@ void BundleDataMgr::ImplicitQueryCloneAbilityInfos( LOG_D(BMS_TAG_QUERY, "action:%{public}s, uri:%{private}s, type:%{public}s", want.GetAction().c_str(), want.GetUriString().c_str(), want.GetType().c_str()); LOG_D(BMS_TAG_QUERY, "flags:%{public}d, userId:%{public}d", flags, userId); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { LOG_W(BMS_TAG_QUERY, "bundleInfos_ is empty"); return; @@ -1156,7 +1156,7 @@ bool BundleDataMgr::ImplicitQueryAbilityInfos( LOG_D(BMS_TAG_QUERY, "action:%{public}s, uri:%{private}s, type:%{public}s", want.GetAction().c_str(), want.GetUriString().c_str(), want.GetType().c_str()); LOG_D(BMS_TAG_QUERY, "flags:%{public}d, userId:%{public}d", flags, userId); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { LOG_W(BMS_TAG_QUERY, "bundleInfos_ is empty"); return false; @@ -1198,7 +1198,7 @@ ErrCode BundleDataMgr::ImplicitQueryAbilityInfosV9( LOG_D(BMS_TAG_QUERY, "action:%{public}s uri:%{private}s type:%{public}s", want.GetAction().c_str(), want.GetUriString().c_str(), want.GetType().c_str()); LOG_D(BMS_TAG_QUERY, "flags:%{public}d userId:%{public}d", flags, userId); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ is empty"); return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; @@ -1242,7 +1242,7 @@ void BundleDataMgr::ImplicitQueryCloneAbilityInfosV9( want.GetAction().c_str(), want.GetUriString().c_str(), want.GetType().c_str()); LOG_D(BMS_TAG_QUERY, "flags:%{public}d userId:%{public}d", flags, userId); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ is empty"); return; @@ -1321,7 +1321,7 @@ bool BundleDataMgr::QueryAbilityInfoWithFlags(const std::optional & ErrCode BundleDataMgr::IsSystemApp(const std::string &bundleName, bool &isSystemApp) { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto bundleInfoItem = bundleInfos_.find(bundleName); if (bundleInfoItem == bundleInfos_.end()) { APP_LOGW("%{public}s not found", bundleName.c_str()); @@ -2166,7 +2166,7 @@ std::vector BundleDataMgr::GetCloneAppIndexes(const std::string &bundle if (requestUserId == Constants::INVALID_USERID) { return cloneAppIndexes; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { LOG_W(BMS_TAG_QUERY, "no bundleName %{public}s found", bundleName.c_str()); @@ -2191,7 +2191,7 @@ std::vector BundleDataMgr::GetCloneAppIndexes(const std::string &bundle std::set BundleDataMgr::GetCloneAppIndexes(const std::string &bundleName) const { std::set cloneAppIndexes; - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { LOG_W(BMS_TAG_QUERY, "no bundleName %{public}s found", bundleName.c_str()); @@ -2364,7 +2364,7 @@ ErrCode BundleDataMgr::QueryLauncherAbilityInfos( LOG_E(BMS_TAG_QUERY, "request user id is invalid"); return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { LOG_W(BMS_TAG_QUERY, "bundleInfos_ is empty"); return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; @@ -2393,7 +2393,7 @@ ErrCode BundleDataMgr::GetLauncherAbilityInfoSync(const Want &want, const int32_ LOG_E(BMS_TAG_QUERY, "request user id is invalid"); return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); ElementName element = want.GetElement(); std::string bundleName = element.GetBundleName(); const auto &item = bundleInfos_.find(bundleName); @@ -2448,7 +2448,7 @@ bool BundleDataMgr::QueryAbilityInfoByUri( if (abilityUri.find(ServiceConstants::DATA_ABILITY_URI_PREFIX) == std::string::npos) { return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { LOG_W(BMS_TAG_QUERY, "bundleInfos_ data is empty"); return false; @@ -2502,7 +2502,7 @@ bool BundleDataMgr::QueryAbilityInfosByUri(const std::string &abilityUri, std::v if (abilityUri.find(ServiceConstants::DATA_ABILITY_URI_PREFIX) == std::string::npos) { return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { LOG_W(BMS_TAG_QUERY, "bundleInfos_ data is empty"); return false; @@ -2544,7 +2544,7 @@ bool BundleDataMgr::GetApplicationInfo( return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; if (!GetInnerBundleInfoWithFlags(appName, flags, innerBundleInfo, requestUserId)) { LOG_D(BMS_TAG_QUERY, "GetApplicationInfo failed, bundleName:%{public}s", appName.c_str()); @@ -2565,7 +2565,7 @@ ErrCode BundleDataMgr::GetApplicationInfoV9( return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; int32_t flag = 0; if ((static_cast(flags) & static_cast(GetApplicationFlag::GET_APPLICATION_INFO_WITH_DISABLE)) @@ -2597,7 +2597,7 @@ ErrCode BundleDataMgr::GetApplicationInfoWithResponseId( return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; int32_t flag = 0; if ((static_cast(flags) & static_cast(GetApplicationFlag::GET_APPLICATION_INFO_WITH_DISABLE)) @@ -2652,7 +2652,7 @@ bool BundleDataMgr::GetApplicationInfos( return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { LOG_W(BMS_TAG_QUERY, "bundleInfos_ data is empty"); return false; @@ -2685,7 +2685,7 @@ bool BundleDataMgr::UpdateExtResources(const std::string &bundleName, return false; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -2711,7 +2711,7 @@ bool BundleDataMgr::RemoveExtResources(const std::string &bundleName, return false; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -2733,7 +2733,7 @@ ErrCode BundleDataMgr::GetExtendResourceInfo( const std::string &bundleName, const std::string &moduleName, ExtendResourceInfo &extendResourceInfo) { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGE("can not find bundle %{public}s", bundleName.c_str()); @@ -2757,7 +2757,7 @@ bool BundleDataMgr::UpateCurDynamicIconModule( return false; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -2804,7 +2804,7 @@ ErrCode BundleDataMgr::GetApplicationInfosV9( return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; @@ -2847,7 +2847,7 @@ bool BundleDataMgr::GetBundleInfo( if (requestUserId == Constants::INVALID_USERID) { return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; if (!GetInnerBundleInfoWithFlags(bundleName, flags, innerBundleInfo, requestUserId)) { LOG_NOFUNC_W(BMS_TAG_QUERY, "GetBundleInfo failed -n %{public}s -u %{public}d", @@ -2899,7 +2899,7 @@ ErrCode BundleDataMgr::GetBundleInfoV9( int32_t originalUserId = requestUserId; PreProcessAnyUserFlag(bundleName, flags, requestUserId); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; auto ret = GetInnerBundleInfoWithBundleFlagsV9(bundleName, flags, innerBundleInfo, requestUserId); @@ -3072,7 +3072,7 @@ void BundleDataMgr::UpdateRouterInfo(const std::string &bundleName) } std::map> hapPathMap; { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); const auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundleName: %{public}s bundle info not exist", bundleName.c_str()); @@ -3199,8 +3199,8 @@ ErrCode BundleDataMgr::GetBaseSharedBundleInfos(const std::string &bundleName, if ((flag == GetDependentBundleInfoFlag::GET_APP_SERVICE_HSP_BUNDLE_INFO) || (flag == GetDependentBundleInfoFlag::GET_ALL_DEPENDENT_BUNDLE_INFO)) { // for app service hsp - std::shared_lock lock(bundleInfoMutex_); - std::lock_guard hspLock(hspBundleNameMutex_); + std::shared_lock lock(bundleInfoMutex_); + std::lock_guard hspLock(hspBundleNameMutex_); for (const std::string &hspName : appServiceHspBundleName_) { APP_LOGD("get hspBundleName: %{public}s", hspName.c_str()); auto infoItem = bundleInfos_.find(hspName); @@ -3213,7 +3213,7 @@ ErrCode BundleDataMgr::GetBaseSharedBundleInfos(const std::string &bundleName, } if (flag == GetDependentBundleInfoFlag::GET_APP_CROSS_HSP_BUNDLE_INFO || flag == GetDependentBundleInfoFlag::GET_ALL_DEPENDENT_BUNDLE_INFO) { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("GetBaseSharedBundleInfos get bundleInfo failed, bundleName:%{public}s", bundleName.c_str()); @@ -3235,7 +3235,7 @@ ErrCode BundleDataMgr::GetBaseSharedBundleInfos(const std::string &bundleName, bool BundleDataMgr::GetBundleType(const std::string &bundleName, BundleType &bundleType)const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -3292,7 +3292,7 @@ bool BundleDataMgr::GetAdaptBaseShareBundleInfo( bool BundleDataMgr::DeleteSharedBundleInfo(const std::string &bundleName) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem != bundleInfos_.end()) { APP_LOGD("del bundle name:%{public}s", bundleName.c_str()); @@ -3322,7 +3322,7 @@ ErrCode BundleDataMgr::GetBundlePackInfo( APP_LOGW("getBundlePackInfo userId is invalid"); return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; if (!GetInnerBundleInfoWithFlags(bundleName, flags, innerBundleInfo, requestUserId)) { APP_LOGW("GetBundlePackInfo failed, bundleName:%{public}s", bundleName.c_str()); @@ -3354,7 +3354,7 @@ bool BundleDataMgr::GetBundleInfosByMetaData( return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return false; @@ -3388,7 +3388,7 @@ bool BundleDataMgr::GetBundleList( return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return false; @@ -3418,7 +3418,7 @@ bool BundleDataMgr::GetDebugBundleList(std::vector &bundleNames, in return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGE("bundleInfos_ data is empty"); return false; @@ -3455,7 +3455,7 @@ bool BundleDataMgr::GetBundleInfos( return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { LOG_W(BMS_TAG_QUERY, "bundleInfos_ data is empty"); return false; @@ -3618,7 +3618,7 @@ ErrCode BundleDataMgr::CheckBundleAndAbilityDisabled( bool BundleDataMgr::GetAllBundleInfos(int32_t flags, std::vector &bundleInfos) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return false; @@ -3656,7 +3656,7 @@ ErrCode BundleDataMgr::GetBundleInfosV9(int32_t flags, std::vector & if (requestUserId == Constants::INVALID_USERID) { return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { LOG_W(BMS_TAG_QUERY, "bundleInfos_ data is empty"); return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; @@ -3722,7 +3722,7 @@ ErrCode BundleDataMgr::GetBundleInfosV9(int32_t flags, std::vector & ErrCode BundleDataMgr::GetAllBundleInfosV9(int32_t flags, std::vector &bundleInfos) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; @@ -3813,7 +3813,7 @@ ErrCode BundleDataMgr::GetBundleNameAndIndex(const int32_t uid, std::string &bun return ERR_BUNDLE_MANAGER_INVALID_UID; } - std::shared_lock bundleIdLock(bundleIdMapMutex_); + std::shared_lock bundleIdLock(bundleIdMapMutex_); auto bundleIdIter = bundleIdMap_.find(bundleId); if (bundleIdIter == bundleIdMap_.end()) { APP_LOGD("bundleId %{public}d is not existed", bundleId); @@ -3864,7 +3864,7 @@ ErrCode BundleDataMgr::GetInnerBundleInfoAndIndexByUid(const int32_t uid, InnerB std::string keyName; { - std::shared_lock bundleIdLock(bundleIdMapMutex_); + std::shared_lock bundleIdLock(bundleIdMapMutex_); auto bundleIdIter = bundleIdMap_.find(bundleId); if (bundleIdIter == bundleIdMap_.end()) { APP_LOGW_NOFUNC("uid %{public}d is not existed", uid); @@ -3875,7 +3875,7 @@ ErrCode BundleDataMgr::GetInnerBundleInfoAndIndexByUid(const int32_t uid, InnerB std::string bundleName = keyName; GetBundleNameAndIndexByName(keyName, bundleName, appIndex); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto bundleInfoIter = bundleInfos_.find(bundleName); if (bundleInfoIter == bundleInfos_.end()) { APP_LOGE("bundleName %{public}s is not existed in bundleInfos_", bundleName.c_str()); @@ -3917,7 +3917,7 @@ const std::vector BundleDataMgr::GetRecoverablePreInstallB if (BundleUserMgrHostImpl::SkipThirdPreloadAppInstallation(userId, preInstallBundleInfo)) { continue; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(preInstallBundleInfo.GetBundleName()); if (infoItem == bundleInfos_.end()) { recoverablePreInstallBundleInfos.emplace_back(preInstallBundleInfo); @@ -3938,14 +3938,14 @@ const std::vector BundleDataMgr::GetRecoverablePreInstallB bool BundleDataMgr::IsBundleExist(const std::string &bundleName) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); return bundleInfos_.find(bundleName) != bundleInfos_.end(); } bool BundleDataMgr::HasUserInstallInBundle( const std::string &bundleName, const int32_t userId) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { return false; @@ -4039,7 +4039,7 @@ bool BundleDataMgr::GetBundleStats(const std::string &bundleName, int32_t uid = -1; std::vector moduleNameList; { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); const auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { return false; @@ -4055,7 +4055,7 @@ bool BundleDataMgr::GetBundleStats(const std::string &bundleName, return false; } { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); const auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { return false; @@ -4084,7 +4084,7 @@ ErrCode BundleDataMgr::BatchGetBundleStats(const std::vector &bundl return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (auto bundleName = bundleNameList.begin(); bundleName != bundleNameList.end();) { const auto infoItem = bundleInfos_.find(*bundleName); InnerBundleUserInfo userInfo; @@ -4126,7 +4126,7 @@ void BundleDataMgr::GetPreBundleSize(const std::string &name, std::vector lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); const auto infoItem = bundleInfos_.find(name); if (infoItem->second.IsPreInstallApp() && !bundleStats.empty()) { for (const auto &innerModuleInfo : infoItem->second.GetInnerModuleInfos()) { @@ -4146,7 +4146,7 @@ void BundleDataMgr::GetPreBundleSize(const std::string &name, std::vector &moduleNameList) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); const auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("No modules of: %{public}s", bundleName.c_str()); @@ -4165,7 +4165,7 @@ bool BundleDataMgr::GetAllBundleStats(const int32_t userId, std::vector return false; } { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { const InnerBundleInfo &info = item.second; std::string bundleName = info.GetBundleName(); @@ -4260,7 +4260,7 @@ int64_t BundleDataMgr::GetAllFreeInstallBundleSpaceSize() const bool BundleDataMgr::GetFreeInstallModules( std::map> &freeInstallModules) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ is data is empty"); return false; @@ -4312,7 +4312,7 @@ ErrCode BundleDataMgr::GetAppIdentifierAndAppIndex(const uint32_t accessTokenId, APP_LOGE("accessTokenId %{public}d not exist", accessTokenId); return ERR_BUNDLE_MANAGER_ACCESS_TOKENID_NOT_EXIST; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); const auto infoItem = bundleInfos_.find(tokenInfo.bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGE("bundleName %{public}s not exist", tokenInfo.bundleName.c_str()); @@ -4364,7 +4364,7 @@ bool BundleDataMgr::GetBundleGidsByUid( bool BundleDataMgr::QueryKeepAliveBundleInfos(std::vector &bundleInfos) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return false; @@ -4393,7 +4393,7 @@ ErrCode BundleDataMgr::GetAbilityLabel(const std::string &bundleName, const std: const std::string &abilityName, std::string &label) const { #ifdef GLOBAL_RESMGR_ENABLE - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); int32_t requestUserId = GetUserId(); if (requestUserId == Constants::INVALID_USERID) { return ERR_BUNDLE_MANAGER_INVALID_USER_ID; @@ -4446,7 +4446,7 @@ ErrCode BundleDataMgr::GetAbilityLabel(const std::string &bundleName, const std: bool BundleDataMgr::GetHapModuleInfo( const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo, int32_t userId) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); int32_t requestUserId = GetUserId(userId); if (requestUserId == Constants::INVALID_USERID) { return false; @@ -4483,7 +4483,7 @@ bool BundleDataMgr::GetHapModuleInfo( ErrCode BundleDataMgr::GetLaunchWantForBundle( const std::string &bundleName, Want &want, int32_t userId) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; ErrCode ret = GetInnerBundleInfoWithFlagsV9( bundleName, BundleFlag::GET_BUNDLE_DEFAULT, innerBundleInfo, userId); @@ -4592,7 +4592,7 @@ void BundleDataMgr::DeleteBundleInfo(const std::string &bundleName, const Instal APP_LOGW("delete storage error name:%{public}s", bundleName.c_str()); } bundleInfos_.erase(bundleName); - std::lock_guard hspLock(hspBundleNameMutex_); + std::lock_guard hspLock(hspBundleNameMutex_); if (appServiceHspBundleName_.find(bundleName) != appServiceHspBundleName_.end()) { appServiceHspBundleName_.erase(bundleName); } @@ -4674,7 +4674,7 @@ bool BundleDataMgr::GetInnerBundleInfoWithFlags(const std::string &bundleName, bool BundleDataMgr::GetInnerBundleInfoWithBundleFlagsAndLock(const std::string &bundleName, const int32_t flags, InnerBundleInfo &info, int32_t userId) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); bool res = GetInnerBundleInfoWithFlags(bundleName, flags, info, userId); if (!res) { APP_LOGD("GetInnerBundleInfoWithBundleFlagsAndLock: bundleName %{public}s not find", bundleName.c_str()); @@ -4779,7 +4779,7 @@ bool BundleDataMgr::DisableBundle(const std::string &bundleName) return false; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -4797,7 +4797,7 @@ bool BundleDataMgr::EnableBundle(const std::string &bundleName) return false; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -4810,7 +4810,7 @@ bool BundleDataMgr::EnableBundle(const std::string &bundleName) ErrCode BundleDataMgr::IsDebuggableApplication(const std::string &bundleName, bool &isDebuggable) const { APP_LOGD("IsDebuggableApplication %{public}s", bundleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { return ERR_OK; @@ -4826,7 +4826,7 @@ ErrCode BundleDataMgr::IsApplicationEnabled( const std::string &bundleName, int32_t appIndex, bool &isEnabled, int32_t userId) const { APP_LOGD("IsApplicationEnabled %{public}s", bundleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -4859,7 +4859,7 @@ ErrCode BundleDataMgr::SetApplicationEnabled(const std::string &bundleName, int32_t appIndex, bool isEnable, const std::string &caller, int32_t userId) { APP_LOGD("SetApplicationEnabled %{public}s", bundleName.c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); int32_t requestUserId = GetUserId(userId); if (requestUserId == Constants::INVALID_USERID) { APP_LOGW("Request userId %{public}d is invalid, bundleName:%{public}s", userId, bundleName.c_str()); @@ -4917,7 +4917,7 @@ bool BundleDataMgr::SetModuleRemovable(const std::string &bundleName, const std: } APP_LOGD("bundleName:%{public}s, moduleName:%{public}s, userId:%{public}d", bundleName.c_str(), moduleName.c_str(), userId); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -4956,7 +4956,7 @@ ErrCode BundleDataMgr::IsModuleRemovable(const std::string &bundleName, const st } APP_LOGD("bundleName:%{public}s, moduleName:%{public}s, userId:%{public}d", bundleName.c_str(), moduleName.c_str(), userId); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -4968,7 +4968,7 @@ ErrCode BundleDataMgr::IsModuleRemovable(const std::string &bundleName, const st ErrCode BundleDataMgr::IsAbilityEnabled(const AbilityInfo &abilityInfo, int32_t appIndex, bool &isEnable) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(abilityInfo.bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", abilityInfo.bundleName.c_str()); @@ -4994,7 +4994,7 @@ ErrCode BundleDataMgr::IsAbilityEnabled(const AbilityInfo &abilityInfo, int32_t ErrCode BundleDataMgr::SetAbilityEnabled(const AbilityInfo &abilityInfo, int32_t appIndex, bool isEnabled, int32_t userId) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); int32_t requestUserId = GetUserId(userId); if (requestUserId == Constants::INVALID_USERID) { APP_LOGW("Request userId is invalid, bundleName:%{public}s, abilityName:%{public}s", @@ -5051,7 +5051,7 @@ std::shared_ptr BundleDataMgr::GetSandboxAppHelper() con bool BundleDataMgr::RegisterBundleStatusCallback(const sptr &bundleStatusCallback) { APP_LOGD("RegisterBundleStatusCallback %{public}s", bundleStatusCallback->GetBundleName().c_str()); - std::unique_lock lock(callbackMutex_); + std::unique_lock lock(callbackMutex_); callbackList_.emplace_back(bundleStatusCallback); if (bundleStatusCallback->AsObject() != nullptr) { sptr deathRecipient = @@ -5117,7 +5117,7 @@ void BundleDataMgr::NotifyBundleEventCallback(const EventFwk::CommonEventData &e bool BundleDataMgr::ClearBundleStatusCallback(const sptr &bundleStatusCallback) { APP_LOGD("ClearBundleStatusCallback %{public}s", bundleStatusCallback->GetBundleName().c_str()); - std::unique_lock lock(callbackMutex_); + std::unique_lock lock(callbackMutex_); callbackList_.erase(std::remove_if(callbackList_.begin(), callbackList_.end(), [&](const sptr &callback) { @@ -5129,44 +5129,45 @@ bool BundleDataMgr::ClearBundleStatusCallback(const sptr bool BundleDataMgr::UnregisterBundleStatusCallback() { - std::unique_lock lock(callbackMutex_); + std::unique_lock lock(callbackMutex_); callbackList_.clear(); return true; } -bool BundleDataMgr::GenerateUidAndGid(InnerBundleUserInfo &innerBundleUserInfo) +ErrCode BundleDataMgr::GenerateUidAndGid(InnerBundleUserInfo &innerBundleUserInfo) { if (innerBundleUserInfo.bundleName.empty()) { APP_LOGW("bundleName is null"); - return false; + return ERR_APPEXECFWK_INSTALL_BUNDLENAME_IS_EMPTY; } int32_t bundleId = INVALID_BUNDLEID; - if (!GenerateBundleId(innerBundleUserInfo.bundleName, bundleId)) { + ErrCode ret = GenerateBundleId(innerBundleUserInfo.bundleName, bundleId); + if (ret != ERR_OK) { APP_LOGW("Generate bundleId failed, bundleName: %{public}s", innerBundleUserInfo.bundleName.c_str()); - return false; + return ERR_APPEXECFWK_INSTALL_BUNDLEID_EXCEED_MAX_NUMBER; } innerBundleUserInfo.uid = innerBundleUserInfo.bundleUserInfo.userId * Constants::BASE_USER_RANGE + bundleId % Constants::BASE_USER_RANGE; innerBundleUserInfo.gids.emplace_back(innerBundleUserInfo.uid); - return true; + return ERR_OK; } -bool BundleDataMgr::GenerateBundleId(const std::string &bundleName, int32_t &bundleId) +ErrCode BundleDataMgr::GenerateBundleId(const std::string &bundleName, int32_t &bundleId) { - std::unique_lock lock(bundleIdMapMutex_); + std::unique_lock lock(bundleIdMapMutex_); if (bundleIdMap_.empty()) { APP_LOGD("first app install"); bundleId = baseAppUid_; bundleIdMap_.emplace(bundleId, bundleName); - return true; + return ERR_OK; } for (const auto &innerBundleId : bundleIdMap_) { if (innerBundleId.second == bundleName) { bundleId = innerBundleId.first; - return true; + return ERR_OK; } } @@ -5177,20 +5178,20 @@ bool BundleDataMgr::GenerateBundleId(const std::string &bundleName, int32_t &bun bundleIdMap_.emplace(bundleId, bundleName); BundleUtil::MakeFsConfig(bundleName, bundleId, ServiceConstants::HMDFS_CONFIG_PATH); BundleUtil::MakeFsConfig(bundleName, bundleId, ServiceConstants::SHAREFS_CONFIG_PATH); - return true; + return ERR_OK; } } if (bundleIdMap_.rbegin()->first == MAX_APP_UID) { APP_LOGW("the bundleId exceeding the maximum value, bundleName:%{public}s", bundleName.c_str()); - return false; + return ERR_APPEXECFWK_INSTALL_BUNDLEID_EXCEED_MAX_NUMBER; } bundleId = bundleIdMap_.rbegin()->first + 1; bundleIdMap_.emplace(bundleId, bundleName); BundleUtil::MakeFsConfig(bundleName, bundleId, ServiceConstants::HMDFS_CONFIG_PATH); BundleUtil::MakeFsConfig(bundleName, bundleId, ServiceConstants::SHAREFS_CONFIG_PATH); - return true; + return ERR_OK; } ErrCode BundleDataMgr::SetModuleUpgradeFlag(const std::string &bundleName, @@ -5201,7 +5202,7 @@ ErrCode BundleDataMgr::SetModuleUpgradeFlag(const std::string &bundleName, APP_LOGW("bundleName or moduleName is empty"); return ERR_BUNDLE_MANAGER_PARAM_ERROR; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; @@ -5225,7 +5226,7 @@ int32_t BundleDataMgr::GetModuleUpgradeFlag(const std::string &bundleName, const APP_LOGW("bundleName or moduleName is empty"); return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -5246,7 +5247,7 @@ void BundleDataMgr::RecycleUidAndGid(const InnerBundleInfo &info) auto innerBundleUserInfo = userInfos.begin()->second; int32_t bundleId = innerBundleUserInfo.uid - innerBundleUserInfo.bundleUserInfo.userId * Constants::BASE_USER_RANGE; - std::unique_lock lock(bundleIdMapMutex_); + std::unique_lock lock(bundleIdMapMutex_); auto infoItem = bundleIdMap_.find(bundleId); if (infoItem == bundleIdMap_.end()) { return; @@ -5272,7 +5273,7 @@ bool BundleDataMgr::RestoreUidAndGid() onlyInsertOne = true; int32_t bundleId = innerBundleUserInfo.uid - innerBundleUserInfo.bundleUserInfo.userId * Constants::BASE_USER_RANGE; - std::unique_lock lock(bundleIdMapMutex_); + std::unique_lock lock(bundleIdMapMutex_); auto item = bundleIdMap_.find(bundleId); if (item == bundleIdMap_.end()) { bundleIdMap_.emplace(bundleId, innerBundleUserInfo.bundleName); @@ -5293,7 +5294,7 @@ bool BundleDataMgr::RestoreUidAndGid() int32_t bundleId = cloneInfo.uid - cloneInfo.userId * Constants::BASE_USER_RANGE; std::string cloneBundleName = BundleCloneCommonHelper::GetCloneBundleIdKey(bundleName, cloneInfo.appIndex); - std::unique_lock lock(bundleIdMapMutex_); + std::unique_lock lock(bundleIdMapMutex_); auto item = bundleIdMap_.find(bundleId); if (item == bundleIdMap_.end()) { bundleIdMap_.emplace(bundleId, cloneBundleName); @@ -5315,12 +5316,12 @@ bool BundleDataMgr::RestoreUidAndGid() void BundleDataMgr::RestoreSandboxUidAndGid(std::map &bundleIdMap) { if (sandboxAppHelper_ != nullptr) { - std::unique_lock lock(bundleIdMapMutex_); + std::unique_lock lock(bundleIdMapMutex_); sandboxAppHelper_->RestoreSandboxUidAndGid(bundleIdMap); } } -ffrt::mutex &BundleDataMgr::GetBundleMutex(const std::string &bundleName) +std::mutex &BundleDataMgr::GetBundleMutex(const std::string &bundleName) { bundleMutex_.lock_shared(); auto it = bundleMutexMap_.find(bundleName); @@ -5340,7 +5341,7 @@ bool BundleDataMgr::GetProvisionId(const std::string &bundleName, std::string &p APP_LOGW("bundleName empty"); return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -5357,7 +5358,7 @@ bool BundleDataMgr::GetAppFeature(const std::string &bundleName, std::string &ap APP_LOGW("bundleName empty"); return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -5384,7 +5385,7 @@ std::shared_ptr BundleDataMgr::GetDataStorage() const bool BundleDataMgr::GetAllFormsInfo(std::vector &formInfos) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return false; @@ -5409,7 +5410,7 @@ bool BundleDataMgr::GetFormsInfoByModule( APP_LOGW("bundle name is empty"); return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return false; @@ -5437,7 +5438,7 @@ bool BundleDataMgr::GetFormsInfoByApp(const std::string &bundleName, std::vector APP_LOGW("bundle name is empty"); return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return false; @@ -5465,7 +5466,7 @@ bool BundleDataMgr::GetShortcutInfos( return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; if (!GetInnerBundleInfoWithFlags( bundleName, BundleFlag::GET_BUNDLE_DEFAULT, innerBundleInfo, requestUserId)) { @@ -5650,7 +5651,7 @@ ErrCode BundleDataMgr::GetShortcutInfoV9( APP_LOGW("input invalid userid, bundleName:%{public}s, userId:%{public}d", bundleName.c_str(), userId); return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; ErrCode ret = GetInnerBundleInfoWithFlagsV9(bundleName, BundleFlag::GET_BUNDLE_DEFAULT, innerBundleInfo, requestUserId); @@ -5680,7 +5681,7 @@ ErrCode BundleDataMgr::GetShortcutInfoByAppIndex(const std::string &bundleName, APP_LOGW("input invalid userid, bundleName:%{public}s, userId:%{public}d", bundleName.c_str(), requestUserId); return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; int32_t flag = static_cast(GetAbilityInfoFlag::GET_ABILITY_INFO_WITH_DISABLE); ErrCode ret = GetInnerBundleInfoWithFlagsV9(bundleName, flag, innerBundleInfo, requestUserId, appIndex); @@ -5705,7 +5706,7 @@ bool BundleDataMgr::GetAllCommonEventInfo(const std::string &eventKey, APP_LOGW("event key is empty"); return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return false; @@ -5816,7 +5817,7 @@ bool BundleDataMgr::GetInnerBundleUserInfoByUserId(const std::string &bundleName return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos data is empty, bundleName:%{public}s", bundleName.c_str()); return false; @@ -5856,7 +5857,7 @@ int32_t BundleDataMgr::GetUserIdByUid(int32_t uid) const void BundleDataMgr::AddUserId(int32_t userId) { - std::lock_guard lock(multiUserIdSetMutex_); + std::lock_guard lock(multiUserIdSetMutex_); auto item = multiUserIdsSet_.find(userId); if (item != multiUserIdsSet_.end()) { return; @@ -5867,7 +5868,7 @@ void BundleDataMgr::AddUserId(int32_t userId) void BundleDataMgr::RemoveUserId(int32_t userId) { - std::lock_guard lock(multiUserIdSetMutex_); + std::lock_guard lock(multiUserIdSetMutex_); auto item = multiUserIdsSet_.find(userId); if (item == multiUserIdsSet_.end()) { return; @@ -5878,7 +5879,7 @@ void BundleDataMgr::RemoveUserId(int32_t userId) bool BundleDataMgr::HasUserId(int32_t userId) const { - std::lock_guard lock(multiUserIdSetMutex_); + std::lock_guard lock(multiUserIdSetMutex_); return multiUserIdsSet_.find(userId) != multiUserIdsSet_.end(); } @@ -5889,7 +5890,7 @@ int32_t BundleDataMgr::GetUserIdByCallingUid() const std::set BundleDataMgr::GetAllUser() const { - std::lock_guard lock(multiUserIdSetMutex_); + std::lock_guard lock(multiUserIdSetMutex_); return multiUserIdsSet_; } @@ -5933,7 +5934,7 @@ bool BundleDataMgr::GetInnerBundleUserInfos( return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos data is empty, bundleName:%{public}s", bundleName.c_str()); return false; @@ -5955,7 +5956,7 @@ bool BundleDataMgr::GetInnerBundleUserInfos( std::string BundleDataMgr::GetAppPrivilegeLevel(const std::string &bundleName, int32_t userId) { APP_LOGD("GetAppPrivilegeLevel:%{public}s, userId:%{public}d", bundleName.c_str(), userId); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo info; if (!GetInnerBundleInfoWithFlags(bundleName, 0, info, userId)) { return Constants::EMPTY_STRING; @@ -6058,7 +6059,7 @@ ErrCode BundleDataMgr::QueryExtensionAbilityInfos(uint32_t flags, int32_t userId return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); ErrCode ret = ImplicitQueryAllExtensionInfos(flags, requestUserId, extensionInfos, appIndex); if (ret != ERR_OK) { LOG_D(BMS_TAG_QUERY, "ImplicitQueryAllExtensionInfos error: %{public}d", ret); @@ -6081,7 +6082,7 @@ ErrCode BundleDataMgr::QueryExtensionAbilityInfosByExtensionTypeName(const std:: if (requestUserId == Constants::INVALID_USERID) { return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); ErrCode ret = ImplicitQueryAllExtensionInfos( flags, requestUserId, extensionInfos, appIndex, typeName); if (ret != ERR_OK) { @@ -6121,7 +6122,7 @@ bool BundleDataMgr::ExplicitQueryExtensionInfo(const Want &want, int32_t flags, if (requestUserId == Constants::INVALID_USERID) { return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; if ((appIndex == 0) && (!GetInnerBundleInfoWithFlags(bundleName, flags, innerBundleInfo, requestUserId))) { LOG_W(BMS_TAG_QUERY, "ExplicitQueryExtensionInfo failed"); @@ -6197,7 +6198,7 @@ ErrCode BundleDataMgr::ExplicitQueryExtensionInfoV9(const Want &want, int32_t fl if (requestUserId == Constants::INVALID_USERID) { return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; if (appIndex == 0) { ErrCode ret = GetInnerBundleInfoWithFlagsV9(bundleName, flags, innerBundleInfo, requestUserId); @@ -6300,7 +6301,7 @@ bool BundleDataMgr::ImplicitQueryExtensionInfos(const Want &want, int32_t flags, if (requestUserId == Constants::INVALID_USERID) { return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::string bundleName = want.GetElement().GetBundleName(); if (!bundleName.empty()) { // query in current bundle @@ -6338,7 +6339,7 @@ ErrCode BundleDataMgr::ImplicitQueryExtensionInfosV9(const Want &want, int32_t f if (requestUserId == Constants::INVALID_USERID) { return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::string bundleName = want.GetElement().GetBundleName(); if (!bundleName.empty()) { // query in current bundle @@ -6799,7 +6800,7 @@ bool BundleDataMgr::QueryExtensionAbilityInfos(const ExtensionAbilityType &exten LOG_E(BMS_TAG_QUERY, "invalid userId, userId:%{public}d", requestUserId); return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { const InnerBundleInfo &innerBundleInfo = item.second; int32_t responseUserId = innerBundleInfo.GetResponseUserId(requestUserId); @@ -6850,7 +6851,7 @@ bool BundleDataMgr::QueryExtensionAbilityInfoByUri(const std::string &uri, int32 return false; } } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { LOG_W(BMS_TAG_QUERY, "bundleInfos_ data is empty, uri:%{public}s", uri.c_str()); return false; @@ -6885,7 +6886,7 @@ std::string BundleDataMgr::GetStringById(const std::string &bundleName, const st { APP_LOGD("GetStringById:%{public}s , %{public}s, %{public}d", bundleName.c_str(), moduleName.c_str(), resId); #ifdef GLOBAL_RESMGR_ENABLE - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::shared_ptr resourceManager = GetResourceManager(bundleName, moduleName, userId); if (resourceManager == nullptr) { @@ -6911,7 +6912,7 @@ std::string BundleDataMgr::GetIconById( APP_LOGI("GetIconById bundleName:%{public}s, moduleName:%{public}s, resId:%{public}d, density:%{public}d", bundleName.c_str(), moduleName.c_str(), resId, density); #ifdef GLOBAL_RESMGR_ENABLE - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::shared_ptr resourceManager = GetResourceManager(bundleName, moduleName, userId); if (resourceManager == nullptr) { @@ -7082,7 +7083,7 @@ bool BundleDataMgr::GetAllDependentModuleNames(const std::string &bundleName, co { APP_LOGD("GetAllDependentModuleNames bundleName: %{public}s, moduleName: %{public}s", bundleName.c_str(), moduleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGW("GetAllDependentModuleNames: bundleName:%{public}s not find", bundleName.c_str()); @@ -7101,7 +7102,7 @@ void BundleDataMgr::UpdateRemovable( return; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -7123,7 +7124,7 @@ void BundleDataMgr::UpdatePrivilegeCapability( return; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -7142,7 +7143,7 @@ bool BundleDataMgr::FetchInnerBundleInfo( return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW_NOFUNC("FetchInnerBundleInfo not found %{public}s", bundleName.c_str()); @@ -7211,7 +7212,7 @@ bool BundleDataMgr::QueryInfoAndSkillsByElement(int32_t userId, const Element& e } // get skills info - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ is empty"); return false; @@ -7305,7 +7306,7 @@ ErrCode BundleDataMgr::GetMediaData(const std::string &bundleName, const std::st { APP_LOGI("begin"); #ifdef GLOBAL_RESMGR_ENABLE - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); int32_t requestUserId = GetUserId(userId); if (requestUserId == Constants::INVALID_USERID) { return ERR_BUNDLE_MANAGER_INVALID_USER_ID; @@ -7349,7 +7350,7 @@ ErrCode BundleDataMgr::GetMediaData(const std::string &bundleName, const std::st #endif } -ffrt::shared_mutex &BundleDataMgr::GetStatusCallbackMutex() +std::shared_mutex &BundleDataMgr::GetStatusCallbackMutex() { return callbackMutex_; } @@ -7368,7 +7369,7 @@ bool BundleDataMgr::UpdateQuickFixInnerBundleInfo(const std::string &bundleName, return false; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundle:%{public}s info is not existed", bundleName.c_str()); @@ -7391,7 +7392,7 @@ bool BundleDataMgr::UpdateInnerBundleInfo(const InnerBundleInfo &innerBundleInfo return false; } APP_LOGD("UpdateInnerBundleInfo:%{public}s", bundleName.c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundle:%{public}s info is not existed", bundleName.c_str()); @@ -7408,7 +7409,7 @@ bool BundleDataMgr::UpdateInnerBundleInfo(const InnerBundleInfo &innerBundleInfo bool BundleDataMgr::UpdatePartialInnerBundleInfo(const InnerBundleInfo &info) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); std::string bundleName = info.GetBundleName(); if (bundleName.empty()) { APP_LOGE("bundle name empty"); @@ -7434,7 +7435,7 @@ bool BundleDataMgr::UpdateEl5KeyId(const CreateDirParam &el5Param, const std::st return false; } APP_LOGD("UpdateEl5KeyId:%{public}s", el5Param.bundleName.c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(el5Param.bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundle:%{public}s info is not existed", el5Param.bundleName.c_str()); @@ -7454,7 +7455,7 @@ bool BundleDataMgr::UpdateEl5KeyId(const CreateDirParam &el5Param, const std::st bool BundleDataMgr::QueryOverlayInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &info) { APP_LOGD("start to query overlay innerBundleInfo"); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.find(bundleName) != bundleInfos_.end()) { info = bundleInfos_.at(bundleName); return true; @@ -7466,7 +7467,7 @@ bool BundleDataMgr::QueryOverlayInnerBundleInfo(const std::string &bundleName, I void BundleDataMgr::SaveOverlayInfo(const std::string &bundleName, InnerBundleInfo &innerBundleInfo) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); innerBundleInfo.SetBundleStatus(InnerBundleInfo::BundleStatus::ENABLED); if (!dataStorage_->SaveStorageBundleInfo(innerBundleInfo)) { APP_LOGE("update storage failed bundle:%{public}s", bundleName.c_str()); @@ -7482,7 +7483,7 @@ ErrCode BundleDataMgr::GetAppProvisionInfo(const std::string &bundleName, int32_ APP_LOGW("GetAppProvisionInfo user is not existed. bundleName:%{public}s", bundleName.c_str()); return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW_NOFUNC("-n %{public}s not exist", bundleName.c_str()); @@ -7511,7 +7512,7 @@ ErrCode BundleDataMgr::GetProvisionMetadata(const std::string &bundleName, int32 ErrCode BundleDataMgr::GetAllSharedBundleInfo(std::vector &sharedBundles) const { APP_LOGD("GetAllSharedBundleInfo"); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto& [key, innerBundleInfo] : bundleInfos_) { if (innerBundleInfo.GetApplicationBundleType() != BundleType::SHARED) { @@ -7559,7 +7560,7 @@ ErrCode BundleDataMgr::GetSharedBundleInfo(const std::string &bundleName, const ErrCode BundleDataMgr::GetSharedBundleInfoBySelf(const std::string &bundleName, SharedBundleInfo &sharedBundleInfo) { APP_LOGD("GetSharedBundleInfoBySelf bundleName: %{public}s", bundleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("GetSharedBundleInfoBySelf failed, can not find bundle %{public}s", @@ -7582,7 +7583,7 @@ ErrCode BundleDataMgr::GetSharedDependencies(const std::string &bundleName, cons { APP_LOGD("GetSharedDependencies bundleName: %{public}s, moduleName: %{public}s", bundleName.c_str(), moduleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGW("GetSharedDependencies failed, can not find bundle %{public}s", bundleName.c_str()); @@ -7600,7 +7601,7 @@ ErrCode BundleDataMgr::GetSharedDependencies(const std::string &bundleName, cons bool BundleDataMgr::CheckHspVersionIsRelied(int32_t versionCode, const InnerBundleInfo &info) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::string hspBundleName = info.GetBundleName(); if (versionCode == Constants::ALL_VERSIONCODE) { // uninstall hsp bundle, check other bundle denpendency @@ -7653,7 +7654,7 @@ ErrCode BundleDataMgr::GetSharedBundleInfo(const std::string &bundleName, int32_ return ERR_BUNDLE_MANAGER_PARAM_ERROR; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -7667,7 +7668,7 @@ ErrCode BundleDataMgr::GetSharedBundleInfo(const std::string &bundleName, int32_ bool BundleDataMgr::IsPreInstallApp(const std::string &bundleName) { APP_LOGD("IsPreInstallApp bundleName: %{public}s", bundleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGW("IsPreInstallApp failed, can not find bundle %{public}s", @@ -7680,7 +7681,7 @@ bool BundleDataMgr::IsPreInstallApp(const std::string &bundleName) ErrCode BundleDataMgr::GetProxyDataInfos(const std::string &bundleName, const std::string &moduleName, int32_t userId, std::vector &proxyDatas) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo info; auto ret = GetInnerBundleInfoWithBundleFlagsV9( bundleName, static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE), info, userId); @@ -7711,7 +7712,7 @@ ErrCode BundleDataMgr::GetAllProxyDataInfos(int32_t userId, std::vector lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto it = std::find_if(bundleInfos_.cbegin(), bundleInfos_.cend(), [&appId](const auto &pair) { return appId == pair.second.GetAppId(); }); @@ -7727,7 +7728,7 @@ void BundleDataMgr::SetAOTCompileStatus(const std::string &bundleName, const std { APP_LOGD("SetAOTCompileStatus, bundleName : %{public}s, moduleName : %{public}s, aotCompileStatus : %{public}d", bundleName.c_str(), moduleName.c_str(), aotCompileStatus); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGW("bundleName %{public}s not exist", bundleName.c_str()); @@ -7756,7 +7757,7 @@ void BundleDataMgr::SetAOTCompileStatus(const std::string &bundleName, const std void BundleDataMgr::ResetAOTFlags() { APP_LOGI("ResetAOTFlags begin"); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); std::for_each(bundleInfos_.begin(), bundleInfos_.end(), [this](auto &item) { if (item.second.IsAOTFlagsInitial()) { return; @@ -7772,7 +7773,7 @@ void BundleDataMgr::ResetAOTFlags() void BundleDataMgr::ResetAOTFlagsCommand(const std::string &bundleName) { APP_LOGI("ResetAOTFlagsCommand begin"); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGE("bundleName %{public}s not exist", bundleName.c_str()); @@ -7793,7 +7794,7 @@ ErrCode BundleDataMgr::ResetAOTCompileStatus(const std::string &bundleName, cons int32_t triggerMode) { APP_LOGI("ResetAOTCompileStatus begin"); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGE("bundleName %{public}s not exist", bundleName.c_str()); @@ -7814,7 +7815,7 @@ ErrCode BundleDataMgr::ResetAOTCompileStatus(const std::string &bundleName, cons std::vector BundleDataMgr::GetAllBundleName() const { APP_LOGD("GetAllBundleName begin"); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::vector bundleNames; bundleNames.reserve(bundleInfos_.size()); std::transform(bundleInfos_.cbegin(), bundleInfos_.cend(), std::back_inserter(bundleNames), [](const auto &item) { @@ -7826,7 +7827,7 @@ std::vector BundleDataMgr::GetAllBundleName() const std::vector BundleDataMgr::GetAllSystemHspCodePaths() const { std::vector systemHspCodePaths; - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { if (item.second.GetApplicationBundleType() == BundleType::APP_SERVICE_FWK) { std::string installPath = item.second.GetAppCodePath(); @@ -7841,7 +7842,7 @@ std::vector BundleDataMgr::GetAllSystemHspCodePaths() const std::vector BundleDataMgr::GetAllExtensionBundleNames(const std::vector &types) const { APP_LOGD("GetAllExtensionBundleNames begin"); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::vector bundleNames; for (const auto &[bundleName, innerBundleInfo] : bundleInfos_) { const auto extensionAbilityInfos = innerBundleInfo.GetInnerExtensionInfos(); @@ -7862,7 +7863,7 @@ std::vector> BundleDataMgr::GetAllLite APP_LOGW("invalid userId"); return {}; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::vector> bundles; for (const auto &[bundleName, innerBundleInfo] : bundleInfos_) { auto installedUsers = innerBundleInfo.GetUsers(); @@ -7877,7 +7878,7 @@ std::vector> BundleDataMgr::GetAllLite std::vector BundleDataMgr::GetBundleNamesForNewUser() const { APP_LOGD("begin"); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::vector bundleNames; for (const auto &item : bundleInfos_) { if (item.second.GetApplicationBundleType() == BundleType::SHARED || @@ -7913,7 +7914,7 @@ std::vector BundleDataMgr::GetBundleNamesForNewUser() const bool BundleDataMgr::QueryInnerBundleInfo(const std::string &bundleName, InnerBundleInfo &info) const { APP_LOGD("QueryInnerBundleInfo begin, bundleName : %{public}s", bundleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGW_NOFUNC("QueryInnerBundleInfo not find %{public}s", bundleName.c_str()); @@ -7926,7 +7927,7 @@ bool BundleDataMgr::QueryInnerBundleInfo(const std::string &bundleName, InnerBun std::vector BundleDataMgr::GetUserIds(const std::string &bundleName) const { APP_LOGD("GetUserIds begin, bundleName : %{public}s", bundleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::vector userIds; auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { @@ -7942,7 +7943,7 @@ std::vector BundleDataMgr::GetUserIds(const std::string &bundleName) co void BundleDataMgr::CreateAppEl5GroupDir(const std::string &bundleName, int32_t userId) { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto bundleInfoItem = bundleInfos_.find(bundleName); if (bundleInfoItem == bundleInfos_.end()) { APP_LOGW("%{public}s not found", bundleName.c_str()); @@ -7989,7 +7990,7 @@ bool BundleDataMgr::CreateAppGroupDir(const InnerBundleInfo &info, int32_t userI bool BundleDataMgr::CreateAppGroupDir(const std::string &bundleName, int32_t userId) { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto bundleInfoItem = bundleInfos_.find(bundleName); if (bundleInfoItem == bundleInfos_.end()) { APP_LOGW("%{public}s not found", bundleName.c_str()); @@ -8068,7 +8069,7 @@ ErrCode BundleDataMgr::GetSpecifiedDistributionType( const std::string &bundleName, std::string &specifiedDistributionType) { APP_LOGD("GetSpecifiedDistributionType bundleName: %{public}s", bundleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW_NOFUNC("-n %{public}s does not exist", bundleName.c_str()); @@ -8094,7 +8095,7 @@ ErrCode BundleDataMgr::GetAdditionalInfo( const std::string &bundleName, std::string &additionalInfo) { APP_LOGD("GetAdditionalInfo bundleName: %{public}s", bundleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW_NOFUNC("%{public}s not exist", bundleName.c_str()); @@ -8120,7 +8121,7 @@ ErrCode BundleDataMgr::GetAdditionalInfoForAllUser( const std::string &bundleName, std::string &additionalInfo) { APP_LOGD("GetAdditionalInfo bundleName: %{public}s", bundleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW_NOFUNC("%{public}s not exist", bundleName.c_str()); @@ -8137,7 +8138,7 @@ ErrCode BundleDataMgr::GetAdditionalInfoForAllUser( ErrCode BundleDataMgr::SetExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName, const std::string &abilityName, const std::string &extName, const std::string &mimeType) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGW("bundleName %{public}s not exist", bundleName.c_str()); @@ -8168,7 +8169,7 @@ ErrCode BundleDataMgr::SetExtNameOrMIMEToApp(const std::string &bundleName, cons ErrCode BundleDataMgr::DelExtNameOrMIMEToApp(const std::string &bundleName, const std::string &moduleName, const std::string &abilityName, const std::string &extName, const std::string &mimeType) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGW("bundleName %{public}s not exist", bundleName.c_str()); @@ -8278,7 +8279,7 @@ ErrCode BundleDataMgr::GetJsonProfile(ProfileType profileType, const std::string return ERR_BUNDLE_MANAGER_PROFILE_NOT_EXIST; } std::string profilePath = mapItem->second; - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); const auto &item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGE("bundleName: %{public}s is not found", bundleName.c_str()); @@ -8343,7 +8344,7 @@ ErrCode __attribute__((no_sanitize("cfi"))) BundleDataMgr::GetJsonProfileByExtra bool BundleDataMgr::QueryDataGroupInfos(const std::string &bundleName, int32_t userId, std::vector &infos) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("bundleName: %{public}s is not existed", bundleName.c_str()); @@ -8367,7 +8368,7 @@ bool BundleDataMgr::GetGroupDir(const std::string &dataGroupId, std::string &dir std::string uuid; if (BundlePermissionMgr::IsSystemApp() && BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED)) { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { const auto &dataGroupInfos = item.second.GetDataGroupInfos(); auto dataGroupInfosIter = dataGroupInfos.find(dataGroupId); @@ -8473,7 +8474,7 @@ void BundleDataMgr::GenerateDataGroupInfos(const std::string &bundleName, const std::unordered_set &dataGroupIdList, int32_t userId, bool needSaveStorage) { APP_LOGD("called for user: %{public}d", userId); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto bundleInfoItem = bundleInfos_.find(bundleName); if (bundleInfoItem == bundleInfos_.end()) { APP_LOGW("%{public}s not found", bundleName.c_str()); @@ -8519,7 +8520,7 @@ void BundleDataMgr::GenerateDataGroupInfos(const std::string &bundleName, void BundleDataMgr::GenerateNewUserDataGroupInfos(const std::string &bundleName, int32_t userId) { APP_LOGD("called for -b %{public}s, -u %{public}d", bundleName.c_str(), userId); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto bundleInfoItem = bundleInfos_.find(bundleName); if (bundleInfoItem == bundleInfos_.end()) { APP_LOGW("%{public}s not found", bundleName.c_str()); @@ -8549,7 +8550,7 @@ void BundleDataMgr::GenerateNewUserDataGroupInfos(const std::string &bundleName, void BundleDataMgr::DeleteUserDataGroupInfos(const std::string &bundleName, int32_t userId, bool keepData) { APP_LOGD("called for -b %{public}s, -u %{public}d", bundleName.c_str(), userId); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto bundleInfoItem = bundleInfos_.find(bundleName); if (bundleInfoItem == bundleInfos_.end()) { APP_LOGW("%{public}s not found", bundleName.c_str()); @@ -8648,7 +8649,7 @@ bool BundleDataMgr::IsDataGroupIdExistNoLock(const std::string &dataGroupId, int void BundleDataMgr::DeleteGroupDirsForException(const InnerBundleInfo &oldInfo, int32_t userId) const { //find ids existed in newInfo, but not in oldInfo when there is no others share this id - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); const auto bundleInfoItem = bundleInfos_.find(oldInfo.GetBundleName()); if (bundleInfoItem == bundleInfos_.end()) { APP_LOGE("find bundle %{public}s failed", oldInfo.GetBundleName().c_str()); @@ -8707,7 +8708,7 @@ bool BundleDataMgr::HasAppOrAtomicServiceInUser(const std::string &bundleName, i APP_LOGW("param -n %{public}s error", bundleName.c_str()); return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto iter = bundleInfos_.find(bundleName); if (iter == bundleInfos_.end()) { APP_LOGW("bundle %{public}s not found", bundleName.c_str()); @@ -8727,7 +8728,7 @@ bool BundleDataMgr::GetAllAppAndAtomicServiceInUser(int32_t userId, std::vector< APP_LOGW("param -u %{public}d error", userId); return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { BundleType bundleType = item.second.GetApplicationBundleType(); if (bundleType != BundleType::APP && bundleType != BundleType::ATOMIC_SERVICE) { @@ -8750,7 +8751,7 @@ void BundleDataMgr::ScanAllBundleGroupInfo() std::map> needProcessGroupInfoBundleNames; // invalid GroupId std::set errorGroupIds; - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); for (const auto &info : bundleInfos_) { std::unordered_map> dataGroupInfos = info.second.GetDataGroupInfos(); if (dataGroupInfos.empty()) { @@ -9022,7 +9023,7 @@ bool BundleDataMgr::GetOldAppIds(const std::string &bundleName, std::vector lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto innerBundleInfo = bundleInfos_.find(bundleName); if (innerBundleInfo == bundleInfos_.end()) { APP_LOGE("can not find bundle %{public}s", bundleName.c_str()); @@ -9048,7 +9049,7 @@ std::string BundleDataMgr::GetModuleNameByBundleAndAbility( APP_LOGE("bundleName or abilityName is empty"); return std::string(); } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto innerBundleInfo = bundleInfos_.find(bundleName); if (innerBundleInfo == bundleInfos_.end()) { APP_LOGE("can not find bundle %{public}s", bundleName.c_str()); @@ -9066,7 +9067,7 @@ std::string BundleDataMgr::GetModuleNameByBundleAndAbility( ErrCode BundleDataMgr::SetAdditionalInfo(const std::string& bundleName, const std::string& additionalInfo) const { APP_LOGD("Called. BundleName: %{public}s", bundleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGE("BundleName: %{public}s does not exist", bundleName.c_str()); @@ -9111,7 +9112,7 @@ ErrCode BundleDataMgr::GetAppServiceHspBundleInfo(const std::string &bundleName, return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGE("can not find bundle %{public}s", bundleName.c_str()); @@ -9154,7 +9155,7 @@ void BundleDataMgr::AddAppHspBundleName(const BundleType type, const std::string { if (type == BundleType::APP_SERVICE_FWK) { APP_LOGD("add app hsp bundleName:%{public}s", bundleName.c_str()); - std::lock_guard hspLock(hspBundleNameMutex_); + std::lock_guard hspLock(hspBundleNameMutex_); appServiceHspBundleName_.insert(bundleName); } } @@ -9162,7 +9163,7 @@ void BundleDataMgr::AddAppHspBundleName(const BundleType type, const std::string ErrCode BundleDataMgr::CreateBundleDataDir(int32_t userId) { APP_LOGI("with -u %{public}d begin", userId); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); std::vector createDirParams; std::vector el5Params; for (const auto &item : bundleInfos_) { @@ -9207,7 +9208,7 @@ ErrCode BundleDataMgr::CreateBundleDataDirWithEl(int32_t userId, DataDirEl dirEl APP_LOGI("with -u %{public}d -el %{public}d begin", userId, static_cast(dirEl)); std::vector createDirParams; { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { const InnerBundleInfo &info = item.second; if (!info.HasInnerBundleUserInfo(userId)) { @@ -9273,7 +9274,7 @@ int32_t BundleDataMgr::GetUidByBundleName(const std::string &bundleName, int32_t return Constants::INVALID_UID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW_NOFUNC("FetchInnerBundleInfo not found %{public}s", bundleName.c_str()); @@ -9405,7 +9406,7 @@ void BundleDataMgr::GenerateOdid(const std::string &developerId, std::string &od return; } std::string groupId = BundleUtil::ExtractGroupIdByDevelopId(developerId); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { std::string developerIdExist; std::string odidExist; @@ -9444,7 +9445,7 @@ ErrCode BundleDataMgr::GetOdidByBundleName(const std::string &bundleName, std::s { APP_LOGI_NOFUNC("start GetOdidByBundleName -n %{public}s", bundleName.c_str()); InnerBundleInfo innerBundleInfo; - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); const auto &item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGE("bundleName: %{public}s is not found", bundleName.c_str()); @@ -9464,7 +9465,7 @@ void BundleDataMgr::HandleOTACodeEncryption() std::vector withoutKeyBundles; std::vector withKeyBundles; { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { item.second.HandleOTACodeEncryption(withoutKeyBundles, withKeyBundles); } @@ -9496,7 +9497,7 @@ ErrCode BundleDataMgr::GetAllBundleInfoByDeveloperId(const std::string &develope return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; @@ -9548,7 +9549,7 @@ ErrCode BundleDataMgr::GetDeveloperIds(const std::string &appDistributionType, return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; @@ -9589,7 +9590,7 @@ ErrCode BundleDataMgr::GetDeveloperIds(const std::string &appDistributionType, ErrCode BundleDataMgr::SwitchUninstallState(const std::string &bundleName, const bool &state, const bool isNeedSendNotify, bool &stateChange) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGE("BundleName: %{public}s does not exist", bundleName.c_str()); @@ -9616,7 +9617,7 @@ ErrCode BundleDataMgr::SwitchUninstallState(const std::string &bundleName, const ErrCode BundleDataMgr::AddCloneBundle(const std::string &bundleName, const InnerBundleCloneInfo &attr) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGE("BundleName: %{public}s does not exist", bundleName.c_str()); @@ -9706,7 +9707,7 @@ bool BundleDataMgr::HasAppLinkingFlag(uint32_t flags) ErrCode BundleDataMgr::RemoveCloneBundle(const std::string &bundleName, const int32_t userId, int32_t appIndex) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGE("BundleName: %{public}s does not exist", bundleName.c_str()); @@ -9743,7 +9744,7 @@ ErrCode BundleDataMgr::QueryAbilityInfoByContinueType(const std::string &bundleN return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; @@ -9797,7 +9798,7 @@ ErrCode BundleDataMgr::QueryCloneAbilityInfo(const ElementName &element, int32_t return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; ErrCode ret = GetInnerBundleInfoWithFlagsV9(bundleName, flags, innerBundleInfo, requestUserId, appIndex); @@ -9830,7 +9831,7 @@ ErrCode BundleDataMgr::ExplicitQueryCloneAbilityInfo(const ElementName &element, if (requestUserId == Constants::INVALID_USERID) { return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; bool ret = GetInnerBundleInfoWithFlags(bundleName, flags, innerBundleInfo, requestUserId, appIndex); @@ -9863,7 +9864,7 @@ ErrCode BundleDataMgr::ExplicitQueryCloneAbilityInfoV9(const ElementName &elemen if (requestUserId == Constants::INVALID_USERID) { return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; ErrCode ret = GetInnerBundleInfoWithFlagsV9(bundleName, flags, innerBundleInfo, requestUserId, appIndex); @@ -9898,7 +9899,7 @@ ErrCode BundleDataMgr::GetCloneBundleInfo( if (requestUserId == Constants::INVALID_USERID) { return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; auto ret = GetInnerBundleInfoWithBundleFlagsV9(bundleName, flags, innerBundleInfo, requestUserId, appIndex); @@ -10003,7 +10004,7 @@ bool BundleDataMgr::ImplicitQueryCurCloneExtensionAbilityInfos(const Want &want, LOG_D(BMS_TAG_QUERY, "begin ImplicitQueryCurCloneExtensionAbilityInfos"); std::string bundleName = want.GetElement().GetBundleName(); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; bool ret = GetInnerBundleInfoWithFlags(bundleName, flags, innerBundleInfo, userId); if (!ret) { @@ -10035,7 +10036,7 @@ ErrCode BundleDataMgr::ImplicitQueryCurCloneExtensionAbilityInfosV9(const Want & LOG_D(BMS_TAG_QUERY, "begin ImplicitQueryCurCloneExtensionAbilityInfosV9"); std::string bundleName = want.GetElement().GetBundleName(); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); InnerBundleInfo innerBundleInfo; ErrCode ret = GetInnerBundleInfoWithFlagsV9(bundleName, flags, innerBundleInfo, userId); if (ret != ERR_OK) { @@ -10064,7 +10065,7 @@ ErrCode BundleDataMgr::ImplicitQueryCurCloneExtensionAbilityInfosV9(const Want & bool BundleDataMgr::ImplicitQueryAllCloneExtensionAbilityInfos(const Want &want, int32_t flags, int32_t userId, std::vector &infos) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { const InnerBundleInfo &innerBundleInfo = item.second; std::vector cloneAppIndexes = GetCloneAppIndexesNoLock(innerBundleInfo.GetBundleName(), userId); @@ -10090,7 +10091,7 @@ bool BundleDataMgr::ImplicitQueryAllCloneExtensionAbilityInfos(const Want &want, ErrCode BundleDataMgr::ImplicitQueryAllCloneExtensionAbilityInfosV9(const Want &want, int32_t flags, int32_t userId, std::vector &infos) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { const InnerBundleInfo &innerBundleInfo = item.second; std::vector cloneAppIndexes = GetCloneAppIndexesNoLock(innerBundleInfo.GetBundleName(), userId); @@ -10117,7 +10118,7 @@ ErrCode BundleDataMgr::GetAppIdByBundleName( const std::string &bundleName, std::string &appId) const { HITRACE_METER_NAME_EX(HITRACE_LEVEL_INFO, HITRACE_TAG_APP, __PRETTY_FUNCTION__, nullptr); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; @@ -10130,7 +10131,7 @@ ErrCode BundleDataMgr::GetAppIdByBundleName( ErrCode BundleDataMgr::GetAppIdAndAppIdentifierByBundleName( const std::string &bundleName, std::string &appId, std::string &appIdentifier) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; @@ -10147,7 +10148,7 @@ std::string BundleDataMgr::AppIdAndAppIdentifierTransform(const std::string appI APP_LOGW("appIdOrAppIdentifier is empty"); return Constants::EMPTY_STRING; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto it = std::find_if(bundleInfos_.cbegin(), bundleInfos_.cend(), [&appIdOrAppIdentifier](const auto &pair) { return (appIdOrAppIdentifier == pair.second.GetAppId() || appIdOrAppIdentifier == pair.second.GetAppIdentifier()); @@ -10171,7 +10172,7 @@ ErrCode BundleDataMgr::GetAllBundleNames(uint32_t flags, int32_t userId, std::ve } bool ofAnyUserFlag = (flags & static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_OF_ANY_USER)) != 0; - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &[bundleName, innerInfo] : bundleInfos_) { if (innerInfo.GetApplicationBundleType() == BundleType::SHARED) { LOG_D(BMS_TAG_QUERY, "%{public}s is not app or atomic, ignore", bundleName.c_str()); @@ -10206,7 +10207,7 @@ ErrCode BundleDataMgr::GetAllBundleNames(uint32_t flags, int32_t userId, std::ve ErrCode BundleDataMgr::GetSignatureInfoByBundleName(const std::string &bundleName, SignatureInfo &signatureInfo) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { LOG_E(BMS_TAG_DEFAULT, "%{public}s not exist", bundleName.c_str()); @@ -10243,7 +10244,7 @@ ErrCode BundleDataMgr::GetSignatureInfoByUid(const int32_t uid, SignatureInfo &s ErrCode BundleDataMgr::UpdateAppEncryptedStatus( const std::string &bundleName, bool isExisted, int32_t appIndex, bool needSaveStorage) { - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST; @@ -10382,7 +10383,7 @@ ErrCode BundleDataMgr::GetContinueBundleNames( return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &[key, innerInfo] : bundleInfos_) { if (CheckInnerBundleInfoWithFlags( innerInfo, BundleFlag::GET_BUNDLE_WITH_ABILITIES, innerInfo.GetResponseUserId(requestUserId)) != ERR_OK) { @@ -10412,7 +10413,7 @@ ErrCode BundleDataMgr::IsBundleInstalled(const std::string &bundleName, int32_t APP_LOGE("name %{public}s invalid appIndex :%{public}d", bundleName.c_str(), appIndex); return ERR_APPEXECFWK_CLONE_INSTALL_INVALID_APP_INDEX; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { isInstalled = false; @@ -10458,7 +10459,7 @@ void BundleDataMgr::UpdateIsPreInstallApp(const std::string &bundleName, bool is return; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("can not find bundle %{public}s", bundleName.c_str()); @@ -10478,7 +10479,7 @@ ErrCode BundleDataMgr::GetBundleNameByAppId(const std::string &appId, std::strin APP_LOGW("appId is empty"); return ERR_APPEXECFWK_INSTALL_PARAM_ERROR; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &[key, innerInfo] : bundleInfos_) { if (innerInfo.GetAppId() == appId || innerInfo.GetAppIdentifier() == appId) { bundleName = key; @@ -10602,7 +10603,7 @@ ErrCode BundleDataMgr::GetAllBundleDirs(int32_t userId, std::vector & return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } AccountSA::OhosAccountInfo accountInfo; - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { const InnerBundleInfo &info = item.second; std::string bundleName = info.GetBundleName(); @@ -10637,7 +10638,7 @@ ErrCode BundleDataMgr::GetAllBundleDirs(int32_t userId, std::vector & void BundleDataMgr::RestoreUidAndGidFromUninstallInfo() { - std::unique_lock lock(bundleIdMapMutex_); + std::unique_lock lock(bundleIdMapMutex_); std::map uninstallBundleInfos; if (!GetAllUninstallBundleInfo(uninstallBundleInfos)) { return; @@ -10675,7 +10676,7 @@ void BundleDataMgr::RestoreUidAndGidFromUninstallInfo() ErrCode BundleDataMgr::GetAssetAccessGroups(const std::string &bundleName, std::vector &assetAccessGroups) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGE("%{public}s not exist", bundleName.c_str()); @@ -10687,7 +10688,7 @@ ErrCode BundleDataMgr::GetAssetAccessGroups(const std::string &bundleName, ErrCode BundleDataMgr::GetDeveloperId(const std::string &bundleName, std::string &developerId) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGE("%{public}s not exist", bundleName.c_str()); @@ -10708,7 +10709,7 @@ bool BundleDataMgr::IsObtainAbilityInfo(const Want &want, int32_t userId, Abilit return false; } { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); const auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGE("%{public}s not found", bundleName.c_str()); @@ -10731,7 +10732,7 @@ ErrCode BundleDataMgr::GetAllPluginInfo(const std::string &hostBundleName, int32 APP_LOGE("invalid userid :%{public}d", userId); return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(hostBundleName); if (item == bundleInfos_.end()) { APP_LOGE("hostBundleName: %{public}s does not exist", hostBundleName.c_str()); @@ -10760,7 +10761,7 @@ ErrCode BundleDataMgr::AddPluginInfo(const std::string &bundleName, const PluginBundleInfo &pluginBundleInfo, const int32_t userId) { APP_LOGD("start AddPluginInfo"); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGE("%{public}s not exist", bundleName.c_str()); @@ -10783,7 +10784,7 @@ ErrCode BundleDataMgr::RemovePluginInfo(const std::string &bundleName, const std::string &pluginBundleName, const int32_t userId) { APP_LOGD("start RemovePluginInfo"); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGE("%{public}s not exist", bundleName.c_str()); @@ -10811,7 +10812,7 @@ bool BundleDataMgr::GetPluginBundleInfo(const std::string &hostBundleName, const return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(hostBundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW_NOFUNC("%{public}s GetPluginBundleInfo not found %{public}s", hostBundleName.c_str(), @@ -10843,7 +10844,7 @@ bool BundleDataMgr::FetchPluginBundleInfo(const std::string &hostBundleName, con return false; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(hostBundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW_NOFUNC("%{public}s FetchPluginBundleInfo not found %{public}s", hostBundleName.c_str(), @@ -10866,7 +10867,7 @@ ErrCode BundleDataMgr::UpdatePluginBundleInfo(const std::string &hostBundleName, { APP_LOGD("hostBundleName:%{public}s start UpdatePluginBundleInfo, plugin:%{public}s", hostBundleName.c_str(), pluginBundleInfo.pluginBundleName.c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(hostBundleName); if (item == bundleInfos_.end()) { APP_LOGE("%{public}s not exist", hostBundleName.c_str()); @@ -10891,7 +10892,7 @@ ErrCode BundleDataMgr::RemovePluginFromUserInfo(const std::string &hostBundleNam { APP_LOGD("hostBundleName:%{public}s start RemovePluginFromUserInfo, plugin:%{public}s", hostBundleName.c_str(), pluginBundleName.c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(hostBundleName); if (item == bundleInfos_.end()) { APP_LOGE("%{public}s not exist", hostBundleName.c_str()); @@ -10916,7 +10917,7 @@ ErrCode BundleDataMgr::GetPluginAbilityInfo(const std::string &hostBundleName, c { APP_LOGD("bundleName:%{public}s start GetPluginAbilityInfo, plugin:%{public}s, abilityName:%{public}s", hostBundleName.c_str(), pluginBundleName.c_str(), pluginAbilityName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(hostBundleName); if (item == bundleInfos_.end()) { APP_LOGE("%{public}s not exist", hostBundleName.c_str()); @@ -10947,7 +10948,7 @@ ErrCode BundleDataMgr::GetPluginHapModuleInfo(const std::string &hostBundleName, { APP_LOGD("bundleName:%{public}s start GetPluginHapModuleInfo, plugin:%{public}s, moduleName:%{public}s", hostBundleName.c_str(), pluginBundleName.c_str(), pluginModuleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); int32_t requestUserId = GetUserId(userId); if (requestUserId == Constants::INVALID_USERID) { APP_LOGE("invalid userid :%{public}d", userId); @@ -11055,7 +11056,7 @@ ErrCode BundleDataMgr::GetAllDynamicIconInfo(const int32_t userId, std::vector lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { item.second.GetAllDynamicIconInfo(userId, dynamicIconInfos); } @@ -11067,7 +11068,7 @@ void BundleDataMgr::ProcessDynamicIconForOta() std::map bundleNames; { // process all old curDynamicIconModule when first ota - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); for (const auto &item : bundleInfos_) { if (!item.second.GetCurDynamicIconModule().empty()) { bundleNames[item.first] = item.second.GetCurDynamicIconModule(); @@ -11085,7 +11086,7 @@ void BundleDataMgr::ProcessDynamicIconForOta() ErrCode BundleDataMgr::GetDynamicIconInfo(const std::string &bundleName, std::vector &dynamicIconInfos) { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGW("bundleName: %{public}s not exist", bundleName.c_str()); @@ -11098,7 +11099,7 @@ ErrCode BundleDataMgr::GetDynamicIconInfo(const std::string &bundleName, std::string BundleDataMgr::GetCurDynamicIconModule( const std::string &bundleName, const int32_t userId, const int32_t appIndex) { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { return Constants::EMPTY_STRING; @@ -11120,7 +11121,7 @@ ErrCode BundleDataMgr::SetShortcutVisibleForSelf(const std::string &shortcutId, int32_t userId = GetUserIdByCallingUid(); std::vector shortcutInfos; { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto iter = bundleInfos_.find(bundleName); if (iter != bundleInfos_.end()) { GetShortcutInfosByInnerBundleInfo(iter->second, shortcutInfos); @@ -11175,7 +11176,7 @@ ErrCode BundleDataMgr::GetAllShortcutInfoForSelf(std::vector &shor } int32_t userId = GetUserIdByCallingUid(); { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto iter = bundleInfos_.find(bundleName); if (iter != bundleInfos_.end()) { GetShortcutInfosByInnerBundleInfo(iter->second, shortcutInfos); @@ -11270,7 +11271,7 @@ std::string BundleDataMgr::GenerateUuidByKey(const std::string &key) const ErrCode BundleDataMgr::GetAllCloneAppIndexesAndUidsByInnerBundleInfo(const int32_t userId, std::unordered_map>> &cloneInfos) const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); if (bundleInfos_.empty()) { APP_LOGW("bundleInfos_ data is empty"); return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; @@ -11329,7 +11330,7 @@ void BundleDataMgr::UpdateDesktopShortcutInfo(const std::string &bundleName) APP_LOGD("UpdateDesktopShortcutInfo begin"); std::vector shortcutInfos; { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto iter = bundleInfos_.find(bundleName); if (iter != bundleInfos_.end()) { GetShortcutInfosByInnerBundleInfo(iter->second, shortcutInfos); @@ -11353,7 +11354,7 @@ ErrCode BundleDataMgr::GetPluginInfo(const std::string &hostBundleName, const st APP_LOGE("invalid userid :%{public}d", userId); return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(hostBundleName); if (item == bundleInfos_.end()) { APP_LOGE("-n %{public}s does not exist", hostBundleName.c_str()); @@ -11381,7 +11382,7 @@ ErrCode BundleDataMgr::GetPluginInfo(const std::string &hostBundleName, const st bool BundleDataMgr::SetBundleUserInfoRemovable(const std::string bundleName, int32_t userId, bool removable) { APP_LOGD("SetBundleUserInfoRemovable: %{public}s", bundleName.c_str()); - std::unique_lock lock(bundleInfoMutex_); + std::unique_lock lock(bundleInfoMutex_); auto infoItem = bundleInfos_.find(bundleName); if (infoItem == bundleInfos_.end()) { APP_LOGW("%{public}s bundle info not exist", bundleName.c_str()); @@ -11411,7 +11412,7 @@ ErrCode BundleDataMgr::GetTestRunner(const std::string &bundleName, const std::s ModuleTestRunner &testRunner) { APP_LOGD("start GetTestRunner -n %{public}s -m %{public}s", bundleName.c_str(), moduleName.c_str()); - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); auto item = bundleInfos_.find(bundleName); if (item == bundleInfos_.end()) { APP_LOGE("-n %{public}s does not exist", bundleName.c_str()); diff --git a/services/bundlemgr/src/bundle_install_checker.cpp b/services/bundlemgr/src/bundle_install_checker.cpp index 36231e75a7..3a5d5b1a64 100644 --- a/services/bundlemgr/src/bundle_install_checker.cpp +++ b/services/bundlemgr/src/bundle_install_checker.cpp @@ -1655,7 +1655,8 @@ ErrCode BundleInstallChecker::CheckIsolationMode(const std::unordered_map connectLock(bundleConnectMutex_); + std::lock_guard connectLock(bundleConnectMutex_); if (!connectAbilityMgr_.empty()) { connectAbilityMgr_.clear(); } @@ -387,7 +387,7 @@ const std::shared_ptr BundleMgrService::GetConnectAbili if (currentUserId == Constants::UNSPECIFIED_USERID) { currentUserId = AccountHelper::GetUserIdByCallerType(); } - std::lock_guard connectLock(bundleConnectMutex_); + std::lock_guard connectLock(bundleConnectMutex_); if (connectAbilityMgr_.find(userId) == connectAbilityMgr_.end() || connectAbilityMgr_[userId] == nullptr) { auto ptr = std::make_shared(); @@ -413,7 +413,7 @@ void BundleMgrService::SelfClean() #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL agingMgr_.reset(); { - std::lock_guard connectLock(bundleConnectMutex_); + std::lock_guard connectLock(bundleConnectMutex_); connectAbilityMgr_.clear(); } bundleDistributedManager_.reset(); @@ -510,7 +510,7 @@ void BundleMgrService::CheckAllUser() userMgrHost_->RemoveUser(userId); #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL { - std::lock_guard connectLock(bundleConnectMutex_); + std::lock_guard connectLock(bundleConnectMutex_); connectAbilityMgr_.erase(userId); } #endif diff --git a/services/bundlemgr/src/bundle_multiuser_installer.cpp b/services/bundlemgr/src/bundle_multiuser_installer.cpp index f0da0f03a0..275e9f3124 100644 --- a/services/bundlemgr/src/bundle_multiuser_installer.cpp +++ b/services/bundlemgr/src/bundle_multiuser_installer.cpp @@ -146,8 +146,9 @@ ErrCode BundleMultiUserInstaller::ProcessBundleInstall(const std::string &bundle InnerBundleUserInfo newUserInfo; newUserInfo.bundleName = bundleName; newUserInfo.bundleUserInfo.userId = userId; - if (!dataMgr_->GenerateUidAndGid(newUserInfo)) { - return ERR_APPEXECFWK_INSTALL_GENERATE_UID_ERROR; + ErrCode ret = dataMgr_->GenerateUidAndGid(newUserInfo); + if (ret != ERR_OK) { + return ret; } BundleUtil::MakeFsConfig(info.GetBundleName(), ServiceConstants::HMDFS_CONFIG_PATH, info.GetAppProvisionType(), Constants::APP_PROVISION_TYPE_FILE_NAME); diff --git a/services/bundlemgr/src/bundle_util.cpp b/services/bundlemgr/src/bundle_util.cpp index c2d4647e52..286b8e8b3b 100644 --- a/services/bundlemgr/src/bundle_util.cpp +++ b/services/bundlemgr/src/bundle_util.cpp @@ -74,9 +74,10 @@ std::mutex BundleUtil::g_mutex; ErrCode BundleUtil::CheckFilePath(const std::string &bundlePath, std::string &realPath) { - if (!CheckFileName(bundlePath)) { + ErrCode ret = CheckFileName(bundlePath) + if (ret != ERR_OK) { APP_LOGE("bundle file path invalid"); - return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; + return ret; } if (!CheckFileType(bundlePath, ServiceConstants::INSTALL_FILE_SUFFIX) && !CheckFileType(bundlePath, ServiceConstants::HSP_FILE_SUFFIX) && @@ -87,15 +88,16 @@ ErrCode BundleUtil::CheckFilePath(const std::string &bundlePath, std::string &re } if (!PathToRealPath(bundlePath, realPath)) { APP_LOGE("file is not real path"); - return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; + return ERR_APPEXECFWK_INSTALL_FILE_PATH_IS_NOT_REAL; } if (access(realPath.c_str(), F_OK) != 0) { APP_LOGE("not access the bundle file path: %{public}s, errno:%{public}d", realPath.c_str(), errno); - return ERR_APPEXECFWK_INSTALL_INVALID_BUNDLE_FILE; + return ERR_APPEXECFWK_INSTALL_ACCESS_FILE_FAILED; } - if (!CheckFileSize(realPath, MAX_HAP_SIZE)) { + ret = CheckFileSize(realPath, MAX_HAP_SIZE); + if (ret != ERR_OK) { APP_LOGE("file size larger than max hap size Max size is: %{public}" PRId64, MAX_HAP_SIZE); - return ERR_APPEXECFWK_INSTALL_INVALID_HAP_SIZE; + return ret; } return ERR_OK; } @@ -110,7 +112,7 @@ ErrCode BundleUtil::CheckFilePath(const std::vector &bundlePaths, s APP_LOGD("check file path"); if (bundlePaths.empty()) { APP_LOGE("bundle file paths invalid"); - return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; + return ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY; } ErrCode ret = ERR_OK; @@ -120,9 +122,10 @@ ErrCode BundleUtil::CheckFilePath(const std::vector &bundlePaths, s if (stat(bundlePath.c_str(), &s) == 0) { std::string realPath = ""; // it is a direction - if ((s.st_mode & S_IFDIR) && !GetHapFilesFromBundlePath(bundlePath, realPaths)) { + ret = GetHapFilesFromBundlePath(bundlePath, realPaths); + if ((s.st_mode & S_IFDIR) && ret != ERR_OK) { APP_LOGE("GetHapFilesFromBundlePath failed with bundlePath:%{public}s", bundlePaths.front().c_str()); - return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; + return ret; } // it is a file if ((s.st_mode & S_IFREG) && (ret = CheckFilePath(bundlePaths.front(), realPath)) == ERR_OK) { @@ -131,7 +134,7 @@ ErrCode BundleUtil::CheckFilePath(const std::vector &bundlePaths, s return ret; } else { APP_LOGE("bundlePath not existed with :%{public}s errno %{public}d", bundlePaths.front().c_str(), errno); - return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; + return ERR_APPEXECFWK_INSTALL_STAT_FILE_FAILED; } } else { for (const std::string& bundlePath : bundlePaths) { @@ -164,31 +167,31 @@ bool BundleUtil::CheckFileType(const std::string &fileName, const std::string &e return LowerStr(suffixStr) == extensionName; } -bool BundleUtil::CheckFileName(const std::string &fileName) +ErrCode BundleUtil::CheckFileName(const std::string &fileName) { if (fileName.empty()) { APP_LOGE("the file name is empty"); - return false; + return ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY; } if (fileName.size() > ServiceConstants::PATH_MAX_SIZE) { APP_LOGE("bundle file path length %{public}zu too long", fileName.size()); - return false; + return ERR_APPEXECFWK_INSTALL_INVALID_FILE_NAME_SIZE; } - return true; + return ERR_OK; } -bool BundleUtil::CheckFileSize(const std::string &bundlePath, const int64_t fileSize) +ErrCode BundleUtil::CheckFileSize(const std::string &bundlePath, const int64_t fileSize) { APP_LOGD("fileSize is %{public}" PRId64, fileSize); struct stat fileInfo = { 0 }; if (stat(bundlePath.c_str(), &fileInfo) != 0) { APP_LOGE("call stat error:%{public}d", errno); - return false; + return ERR_APPEXECFWK_INSTALL_STAT_FILE_FAILED; } if (fileInfo.st_size > fileSize) { - return false; + return ERR_APPEXECFWK_INSTALL_INVALID_HAP_SIZE; } - return true; + return ERR_OK; } bool BundleUtil::CheckSystemSize(const std::string &bundlePath, const std::string &diskPath) @@ -233,11 +236,11 @@ bool BundleUtil::CheckSystemSizeAndHisysEvent(const std::string &path, const std return freeSize < DISK_REMAINING_SIZE_LIMIT; } -bool BundleUtil::GetHapFilesFromBundlePath(const std::string& currentBundlePath, std::vector& hapFileList) +ErrCode BundleUtil::GetHapFilesFromBundlePath(const std::string& currentBundlePath, std::vector& hapFileList) { APP_LOGD("GetHapFilesFromBundlePath with path is %{public}s", currentBundlePath.c_str()); if (currentBundlePath.empty()) { - return false; + return ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY; } DIR* dir = opendir(currentBundlePath.c_str()); if (dir == nullptr) { @@ -245,7 +248,7 @@ bool BundleUtil::GetHapFilesFromBundlePath(const std::string& currentBundlePath, strerror_r(errno, errMsg, sizeof(errMsg)); APP_LOGE("GetHapFilesFromBundlePath open bundle dir:%{public}s failed due to %{public}s, errno:%{public}d", currentBundlePath.c_str(), errMsg, errno); - return false; + return ERR_APPEXECFWK_INSTALL_OPENDIR_FAILED; } std::string bundlePath = currentBundlePath; if (bundlePath.back() != ServiceConstants::FILE_SEPARATOR_CHAR) { @@ -268,12 +271,12 @@ bool BundleUtil::GetHapFilesFromBundlePath(const std::string& currentBundlePath, if (!hapFileList.empty() && (hapFileList.size() > ServiceConstants::MAX_HAP_NUMBER)) { APP_LOGE("reach the max hap number 128, stop to add more"); closedir(dir); - return false; + return ERR_APPEXECFWK_INSTALL_HAP_NUMBER_EXCEED_MAX_NUMBER; } } APP_LOGI_NOFUNC("hap number: %{public}zu", hapFileList.size()); closedir(dir); - return true; + return ERR_OK; } int64_t BundleUtil::GetCurrentTime() diff --git a/services/bundlemgr/src/distributed_manager/bundle_distributed_manager.cpp b/services/bundlemgr/src/distributed_manager/bundle_distributed_manager.cpp index 3304312931..714b5d88b5 100644 --- a/services/bundlemgr/src/distributed_manager/bundle_distributed_manager.cpp +++ b/services/bundlemgr/src/distributed_manager/bundle_distributed_manager.cpp @@ -145,7 +145,7 @@ bool BundleDistributedManager::CheckAbilityEnableInstall( queryRpcIdParams->want = want; queryRpcIdParams->versionCode = applicationInfo.versionCode; { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); auto ret = queryAbilityParamsMap_.emplace(targetAbilityInfo.targetInfo.transactId, *queryRpcIdParams); if (!ret.second) { APP_LOGE("BundleDistributedManager::QueryAbilityInfo map emplace error"); @@ -250,7 +250,7 @@ void BundleDistributedManager::OnQueryRpcIdFinished(const std::string &queryRpcI } Want want; { - std::shared_lock lock(mutex_); + std::shared_lock lock(mutex_); auto queryAbilityParams = queryAbilityParamsMap_.find(rpcIdResult.transactId); if (queryAbilityParams == queryAbilityParamsMap_.end()) { APP_LOGE("no node"); @@ -276,7 +276,7 @@ void BundleDistributedManager::SendCallbackRequest(int32_t resultCode, const std APP_LOGI("sendCallbackRequest resultCode:%{public}d, transactId:%{public}s", resultCode, transactId.c_str()); QueryRpcIdParams queryRpcIdParams; { - std::shared_lock lock(mutex_); + std::shared_lock lock(mutex_); auto queryAbilityParams = queryAbilityParamsMap_.find(transactId); if (queryAbilityParams == queryAbilityParamsMap_.end()) { APP_LOGE("Can not find transactId:%{public}s in queryAbilityParamsMap", transactId.c_str()); @@ -288,7 +288,7 @@ void BundleDistributedManager::SendCallbackRequest(int32_t resultCode, const std uint32_t mapSize; { - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); queryAbilityParamsMap_.erase(transactId); mapSize = queryAbilityParamsMap_.size(); } diff --git a/services/bundlemgr/src/free_install/bundle_connect_ability_mgr.cpp b/services/bundlemgr/src/free_install/bundle_connect_ability_mgr.cpp index 6f36f1832c..6f33acaeb6 100644 --- a/services/bundlemgr/src/free_install/bundle_connect_ability_mgr.cpp +++ b/services/bundlemgr/src/free_install/bundle_connect_ability_mgr.cpp @@ -170,7 +170,7 @@ void BundleConnectAbilityMgr::PreloadRequest(int32_t flag, const TargetAbilityIn LOG_E(BMS_TAG_DEFAULT, "failed to WriteRemoteObject callbcak"); return; } - std::unique_lock mutexLock(mutex_); + std::unique_lock mutexLock(mutex_); sptr serviceCenterRemoteObject = serviceCenterConnection_->GetRemoteObject(); if (serviceCenterRemoteObject == nullptr) { LOG_E(BMS_TAG_DEFAULT, "failed to get remote object"); @@ -182,7 +182,7 @@ void BundleConnectAbilityMgr::PreloadRequest(int32_t flag, const TargetAbilityIn return; } freeInstallParams->serviceCenterFunction = ServiceCenterFunction::CONNECT_PRELOAD_INSTALL; - std::unique_lock lock(mapMutex_); + std::unique_lock lock(mapMutex_); auto emplaceResult = freeInstallParamsMap_.emplace(targetAbilityInfo.targetInfo.transactId, *freeInstallParams); LOG_I(BMS_TAG_DEFAULT, "emplace map size = %{public}zu, transactId = %{public}s", freeInstallParamsMap_.size(), targetAbilityInfo.targetInfo.transactId.c_str()); @@ -444,7 +444,7 @@ void BundleConnectAbilityMgr::LoadService(int32_t saId) const void BundleConnectAbilityMgr::DisconnectAbility() { - std::unique_lock mutexLock(mutex_); + std::unique_lock mutexLock(mutex_); if (serviceCenterConnection_ != nullptr) { LOG_I(BMS_TAG_DEFAULT, "DisconnectAbility"); int result = AbilityManagerClient::GetInstance()->DisconnectAbility(serviceCenterConnection_); @@ -454,7 +454,7 @@ void BundleConnectAbilityMgr::DisconnectAbility() } } -void BundleConnectAbilityMgr::WaitFromConnecting(std::unique_lock &lock) +void BundleConnectAbilityMgr::WaitFromConnecting(std::unique_lock &lock) { LOG_I(BMS_TAG_DEFAULT, "ConnectAbility await start CONNECTING"); while (connectState_ == ServiceCenterConnectState::CONNECTING) { @@ -463,7 +463,7 @@ void BundleConnectAbilityMgr::WaitFromConnecting(std::unique_lock & LOG_I(BMS_TAG_DEFAULT, "ConnectAbility await end CONNECTING"); } -void BundleConnectAbilityMgr::WaitFromConnected(std::unique_lock &lock) +void BundleConnectAbilityMgr::WaitFromConnected(std::unique_lock &lock) { LOG_I(BMS_TAG_DEFAULT, "ConnectAbility await start CONNECTED"); while (connectState_ != ServiceCenterConnectState::CONNECTED) { @@ -478,7 +478,7 @@ void BundleConnectAbilityMgr::WaitFromConnected(std::unique_lock &l bool BundleConnectAbilityMgr::ConnectAbility(const Want &want, const sptr &callerToken) { LOG_I(BMS_TAG_DEFAULT, "ConnectAbility start target bundle = %{public}s", want.GetBundle().c_str()); - std::unique_lock lock(mutex_); + std::unique_lock lock(mutex_); serialQueue_->CancelDelayTask(DISCONNECT_DELAY_TASK); if (connectState_ == ServiceCenterConnectState::CONNECTING) { WaitFromConnecting(lock); @@ -535,7 +535,7 @@ void BundleConnectAbilityMgr::SendCallBack( return; } - std::unique_lock lock(mapMutex_); + std::unique_lock lock(mapMutex_); if (freeInstallParamsMap_[transactId].serviceCenterFunction == ServiceCenterFunction::CONNECT_UPGRADE_INSTALL && resultCode != ServiceCenterResultCode::FREE_INSTALL_OK) { LOG_E(BMS_TAG_DEFAULT, "SendCallBack, freeinstall upgrade return ok"); @@ -611,9 +611,9 @@ void BundleConnectAbilityMgr::SendCallBack(const std::string &transactId, const void BundleConnectAbilityMgr::DeathRecipientSendCallback() { LOG_I(BMS_TAG_DEFAULT, "DeathRecipientSendCallback start"); - std::unique_lock mutexLock(mutex_); + std::unique_lock mutexLock(mutex_); connectState_ = ServiceCenterConnectState::DISCONNECTED; - std::unique_lock lock(mapMutex_); + std::unique_lock lock(mapMutex_); LOG_I(BMS_TAG_DEFAULT, "freeInstallParamsMap size = %{public}zu", freeInstallParamsMap_.size()); for (auto &it : freeInstallParamsMap_) { SendCallBack(it.first, it.second); @@ -635,7 +635,7 @@ void BundleConnectAbilityMgr::OnServiceCenterCall(std::string installResultStr) } LOG_I(BMS_TAG_DEFAULT, "OnServiceCenterCall, retCode = %{public}d", installResult.result.retCode); FreeInstallParams freeInstallParams; - std::unique_lock lock(mapMutex_); + std::unique_lock lock(mapMutex_); auto node = freeInstallParamsMap_.find(installResult.result.transactId); if (node == freeInstallParamsMap_.end()) { LOG_E(BMS_TAG_DEFAULT, "Can not find node"); @@ -670,7 +670,7 @@ void BundleConnectAbilityMgr::OnDelayedHeartbeat(std::string installResultStr) } LOG_I(BMS_TAG_DEFAULT, "OnDelayedHeartbeat, retCode = %{public}d", installResult.result.retCode); FreeInstallParams freeInstallParams; - std::unique_lock lock(mapMutex_); + std::unique_lock lock(mapMutex_); auto node = freeInstallParamsMap_.find(installResult.result.transactId); if (node == freeInstallParamsMap_.end()) { LOG_E(BMS_TAG_DEFAULT, "Can not find node"); @@ -691,7 +691,7 @@ void BundleConnectAbilityMgr::OnServiceCenterReceived(std::string installResultS return; } FreeInstallParams freeInstallParams; - std::unique_lock lock(mapMutex_); + std::unique_lock lock(mapMutex_); auto node = freeInstallParamsMap_.find(installResult.result.transactId); if (node == freeInstallParamsMap_.end()) { LOG_E(BMS_TAG_DEFAULT, "Can not find node"); @@ -716,7 +716,7 @@ void BundleConnectAbilityMgr::OutTimeMonitor(std::string transactId) { LOG_I(BMS_TAG_DEFAULT, "BundleConnectAbilityMgr::OutTimeMonitor"); FreeInstallParams freeInstallParams; - std::unique_lock lock(mapMutex_); + std::unique_lock lock(mapMutex_); auto node = freeInstallParamsMap_.find(transactId); if (node == freeInstallParamsMap_.end()) { LOG_E(BMS_TAG_DEFAULT, "Can not find node"); @@ -765,7 +765,7 @@ void BundleConnectAbilityMgr::SendRequest(int32_t flag, const TargetAbilityInfo SendSysEvent(FreeInstallErrorCode::UNDEFINED_ERROR, want, userId); return; } - std::unique_lock mutexLock(mutex_); + std::unique_lock mutexLock(mutex_); sptr serviceCenterRemoteObject = serviceCenterConnection_->GetRemoteObject(); if (serviceCenterRemoteObject == nullptr) { LOG_E(BMS_TAG_DEFAULT, "failed to get remote object"); @@ -773,7 +773,7 @@ void BundleConnectAbilityMgr::SendRequest(int32_t flag, const TargetAbilityInfo SendSysEvent(FreeInstallErrorCode::CONNECT_ERROR, want, userId); return; } - std::unique_lock lock(mapMutex_); + std::unique_lock lock(mapMutex_); auto emplaceResult = freeInstallParamsMap_.emplace(targetAbilityInfo.targetInfo.transactId, freeInstallParams); LOG_I(BMS_TAG_DEFAULT, "emplace map size = %{public}zu, transactId = %{public}s", freeInstallParamsMap_.size(), targetAbilityInfo.targetInfo.transactId.c_str()); @@ -796,7 +796,7 @@ void BundleConnectAbilityMgr::SendRequest(int32_t flag, const TargetAbilityInfo bool BundleConnectAbilityMgr::SendRequest(int32_t code, MessageParcel &data, MessageParcel &reply) { LOG_I(BMS_TAG_DEFAULT, "BundleConnectAbilityMgr::SendRequest to service center"); - std::unique_lock mutexLock(mutex_); + std::unique_lock mutexLock(mutex_); sptr serviceCenterRemoteObject = serviceCenterConnection_->GetRemoteObject(); if (serviceCenterRemoteObject == nullptr) { LOG_E(BMS_TAG_DEFAULT, "failed to get remote object"); @@ -815,7 +815,7 @@ sptr BundleConnectAbilityMgr::GetAbilityManagerServiceCallBack(st { LOG_I(BMS_TAG_DEFAULT, "GetAbilityManagerServiceCallBack"); FreeInstallParams freeInstallParams; - std::unique_lock lock(mapMutex_); + std::unique_lock lock(mapMutex_); auto node = freeInstallParamsMap_.find(transactId); if (node == freeInstallParamsMap_.end()) { LOG_E(BMS_TAG_DEFAULT, "Can not find node transactId = %{public}s", transactId.c_str()); diff --git a/services/bundlemgr/src/rdb/rdb_data_manager.cpp b/services/bundlemgr/src/rdb/rdb_data_manager.cpp index adab06040d..47668bd58e 100644 --- a/services/bundlemgr/src/rdb/rdb_data_manager.cpp +++ b/services/bundlemgr/src/rdb/rdb_data_manager.cpp @@ -72,8 +72,8 @@ const std::unordered_map RDB_ERR_MAP = { }; } -ffrt::mutex RdbDataManager::restoreRdbMapMutex_; -std::unordered_map RdbDataManager::restoreRdbMap_; +std::mutex RdbDataManager::restoreRdbMapMutex_; +std::unordered_map RdbDataManager::restoreRdbMap_; RdbDataManager::RdbDataManager(const BmsRdbConfig &bmsRdbConfig) : bmsRdbConfig_(bmsRdbConfig) @@ -91,9 +91,9 @@ void RdbDataManager::ClearCache() NativeRdb::RdbHelper::ClearCache(); } -ffrt::mutex &RdbDataManager::GetRdbRestoreMutex(const std::string &dbName) +std::mutex &RdbDataManager::GetRdbRestoreMutex(const std::string &dbName) { - std::lock_guard restoreLock(restoreRdbMapMutex_); + std::lock_guard restoreLock(restoreRdbMapMutex_); if (!isInitial_) { isInitial_ = restoreRdbMap_.find(dbName) != restoreRdbMap_.end(); } @@ -103,7 +103,7 @@ ffrt::mutex &RdbDataManager::GetRdbRestoreMutex(const std::string &dbName) ErrCode RdbDataManager::GetRdbStoreFromNative() { auto &mutex = GetRdbRestoreMutex(bmsRdbConfig_.dbName); - std::lock_guard restoreLock(mutex); + std::lock_guard restoreLock(mutex); NativeRdb::RdbStoreConfig rdbStoreConfig(bmsRdbConfig_.dbPath + bmsRdbConfig_.dbName); rdbStoreConfig.SetSecurityLevel(NativeRdb::SecurityLevel::S1); rdbStoreConfig.SetWriteTime(WRITE_TIMEOUT); @@ -148,7 +148,7 @@ ErrCode RdbDataManager::GetRdbStoreFromNative() std::shared_ptr RdbDataManager::GetRdbStore(ErrCode &result) { - std::lock_guard lock(rdbMutex_); + std::lock_guard lock(rdbMutex_); if (rdbStore_ == nullptr) { result = GetRdbStoreFromNative(); } @@ -492,7 +492,7 @@ void RdbDataManager::DelayCloseRdbStore() if (sharedPtr == nullptr) { return; } - std::lock_guard lock(sharedPtr->rdbMutex_); + std::lock_guard lock(sharedPtr->rdbMutex_); sharedPtr->rdbStore_ = nullptr; APP_LOGD("DelayCloseRdbStore of %{public}s thread end", sharedPtr->bmsRdbConfig_.tableName.c_str()); }; diff --git a/services/bundlemgr/src/shared/inner_shared_bundle_installer.cpp b/services/bundlemgr/src/shared/inner_shared_bundle_installer.cpp index 0d7ca80ceb..ea2a896ad8 100644 --- a/services/bundlemgr/src/shared/inner_shared_bundle_installer.cpp +++ b/services/bundlemgr/src/shared/inner_shared_bundle_installer.cpp @@ -588,14 +588,18 @@ ErrCode InnerSharedBundleInstaller::CopyHspToSecurityDir(std::vector &inBundlePaths, std::vector &bundlePaths, std::string &signatureFilePath) { - if (inBundlePaths.empty() || inBundlePaths.size() > MAX_FILE_NUMBER) { - APP_LOGE("number of files in single shared lib path is illegal"); - return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; + if (inBundlePaths.empty()) { + APP_LOGE("bundle path is empty"); + return ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY; + } + if (inBundlePaths.size() > MAX_FILE_NUMBER) { + APP_LOGE("number of files in single shared lib path exceed max number"); + return ERR_APPEXECFWK_INSTALL_HSP_NUMBER_EXCEED_MAX_NUMBER; } if (inBundlePaths.size() == 1) { if (!BundleUtil::EndWith(inBundlePaths[0], ServiceConstants::HSP_FILE_SUFFIX)) { APP_LOGE("invalid file in shared bundle dir"); - return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; + return ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR; } bundlePaths.emplace_back(inBundlePaths[0]); return ERR_OK; @@ -606,7 +610,7 @@ ErrCode InnerSharedBundleInstaller::ObtainHspFileAndSignatureFilePath(const std: if ((path.find(ServiceConstants::HSP_FILE_SUFFIX) == std::string::npos) && (path.find(ServiceConstants::CODE_SIGNATURE_FILE_SUFFIX) == std::string::npos)) { APP_LOGE("only hsp or sig file can be contained in shared bundle dir"); - return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; + return ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR; } if (BundleUtil::EndWith(path, ServiceConstants::HSP_FILE_SUFFIX)) { numberOfHsp++; @@ -616,9 +620,13 @@ ErrCode InnerSharedBundleInstaller::ObtainHspFileAndSignatureFilePath(const std: numberOfSignatureFile++; signatureFilePath = path; } - if ((numberOfHsp >= MAX_FILE_NUMBER) || (numberOfSignatureFile >= MAX_FILE_NUMBER)) { - APP_LOGE("only one hsp and one signature file can be contained in a single shared bundle dir"); - return ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID; + if (numberOfHsp >= MAX_FILE_NUMBER) { + APP_LOGE("only one hsp file can be contained in a single shared bundle dir"); + return ERR_APPEXECFWK_INSTALL_ONLY_ONE_HSP_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR; + } + if (numberOfSignatureFile >= MAX_FILE_NUMBER) { + APP_LOGE("only one signature file can be contained in a single shared bundle dir"); + return ERR_APPEXECFWK_INSTALL_ONLY_ONE_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR; } } APP_LOGD("signatureFilePath is %{public}s", signatureFilePath.c_str()); diff --git a/services/bundlemgr/src/status_receiver_proxy.cpp b/services/bundlemgr/src/status_receiver_proxy.cpp index cfe95489c6..d6f8e3ab5f 100644 --- a/services/bundlemgr/src/status_receiver_proxy.cpp +++ b/services/bundlemgr/src/status_receiver_proxy.cpp @@ -359,6 +359,10 @@ const std::unordered_map MAP_RECEIVED_RESULTS { {IStatusReceiver::ERR_INSTALL_INVALID_HAP_SIZE, MSG_ERR_INSTALL_INVALID_HAP_SIZE}}, {ERR_APPEXECFWK_INSTALL_GENERATE_UID_ERROR, {IStatusReceiver::ERR_INSTALL_GENERATE_UID_ERROR, MSG_ERR_INSTALL_GENERATE_UID_ERROR}}, + {ERR_APPEXECFWK_INSTALL_BUNDLENAME_IS_EMPTY, + {IStatusReceiver::ERR_INSTALL_GENERATE_UID_ERROR, MSG_ERR_INSTALL_GENERATE_UID_ERROR}}, + {ERR_APPEXECFWK_INSTALL_BUNDLEID_EXCEED_MAX_NUMBER, + {IStatusReceiver::ERR_INSTALL_GENERATE_UID_ERROR, MSG_ERR_INSTALL_GENERATE_UID_ERROR}}, {ERR_APPEXECFWK_INSTALL_INSTALLD_SERVICE_ERROR, {IStatusReceiver::ERR_INSTALL_INSTALLD_SERVICE_ERROR, MSG_ERR_INSTALL_INSTALLD_SERVICE_ERROR}}, {ERR_APPEXECFWK_INSTALL_BUNDLE_MGR_SERVICE_ERROR, @@ -765,6 +769,30 @@ const std::unordered_map MAP_RECEIVED_RESULTS { {IStatusReceiver::ERR_INSTALL_INTERNAL_ERROR, MSG_ERR_INSTALL_INTERNAL_ERROR}}, {ERR_APPEXECFWK_DB_CAPABILITY_NOT_SUPPORT, {IStatusReceiver::ERR_INSTALL_INTERNAL_ERROR, MSG_ERR_INSTALL_INTERNAL_ERROR}}, + {ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_INVALID_FILE_NAME_SIZE, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_FILE_PATH_IS_NOT_REAL, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_ACCESS_FILE_FAILED, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_STAT_FILE_FAILED, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_OPENDIR_FAILED, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_HAP_NUMBER_EXCEED_MAX_NUMBER, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_HSP_NUMBER_EXCEED_MAX_NUMBER, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_RENAME_INSTALL_FILE_PATH_NOT_START_WITH_APP_INSTALL_SANDBOX, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_ONLY_ONE_HSP_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, + {ERR_APPEXECFWK_INSTALL_ONLY_ONE_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR, + {IStatusReceiver::ERR_INSTALL_FILE_PATH_INVALID, MSG_ERR_INSTALL_FILE_PATH_INVALID}}, }; } // namespace diff --git a/services/bundlemgr/test/mock/src/bundle_util.cpp b/services/bundlemgr/test/mock/src/bundle_util.cpp index 26391daca2..5e30b265f4 100644 --- a/services/bundlemgr/test/mock/src/bundle_util.cpp +++ b/services/bundlemgr/test/mock/src/bundle_util.cpp @@ -38,14 +38,14 @@ bool BundleUtil::CheckFileType(const std::string &fileName, const std::string &e return true; } -bool BundleUtil::CheckFileName(const std::string &fileName) +ErrCode BundleUtil::CheckFileName(const std::string &fileName) { - return true; + return ERR_OK; } -bool BundleUtil::CheckFileSize(const std::string &bundlePath, const int64_t fileSize) +ErrCode BundleUtil::CheckFileSize(const std::string &bundlePath, const int64_t fileSize) { - return true; + return ERR_OK; } bool BundleUtil::CheckSystemSize(const std::string &bundlePath, const std::string &diskPath) @@ -63,9 +63,9 @@ bool BundleUtil::CheckSystemSizeAndHisysEvent(const std::string &path, const std return true; } -bool BundleUtil::GetHapFilesFromBundlePath(const std::string& currentBundlePath, std::vector& hapFileList) +ErrCode BundleUtil::GetHapFilesFromBundlePath(const std::string& currentBundlePath, std::vector& hapFileList) { - return true; + return ERR_OK; } int64_t BundleUtil::GetCurrentTime() @@ -349,14 +349,14 @@ bool BundleUtil::CheckFileType(const std::string &fileName, const std::string &e return false; } -bool BundleUtil::CheckFileName(const std::string &fileName) +ErrCode BundleUtil::CheckFileName(const std::string &fileName) { - return false; + return ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY; } -bool BundleUtil::CheckFileSize(const std::string &bundlePath, const int64_t fileSize) +ErrCode BundleUtil::CheckFileSize(const std::string &bundlePath, const int64_t fileSize) { - return false; + return ERR_APPEXECFWK_INSTALL_STAT_FILE_FAILED; } bool BundleUtil::CheckSystemSize(const std::string &bundlePath, const std::string &diskPath) @@ -374,9 +374,9 @@ bool BundleUtil::CheckSystemSizeAndHisysEvent(const std::string &path, const std return false; } -bool BundleUtil::GetHapFilesFromBundlePath(const std::string& currentBundlePath, std::vector& hapFileList) +ErrCode BundleUtil::GetHapFilesFromBundlePath(const std::string& currentBundlePath, std::vector& hapFileList) { - return false; + return ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY; } int64_t BundleUtil::GetCurrentTime() diff --git a/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/bms_bundle_app_provision_info_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/bms_bundle_app_provision_info_test.cpp index 0a78a831f7..fc6401cd2b 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/bms_bundle_app_provision_info_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/bms_bundle_app_provision_info_test.cpp @@ -1022,7 +1022,7 @@ HWTEST_F(BmsBundleAppProvisionInfoTest, InnerSharedBundleInstallerTest_0600, Fun std::vector bundlePaths; std::string signatureFilePath; auto ret = installer.ObtainHspFileAndSignatureFilePath(inBundlePaths, bundlePaths, signatureFilePath); - EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID); + EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY); inBundlePaths.emplace_back(HSP_FILE_PATH1); ret = installer.ObtainHspFileAndSignatureFilePath(inBundlePaths, bundlePaths, signatureFilePath); @@ -1045,7 +1045,7 @@ HWTEST_F(BmsBundleAppProvisionInfoTest, InnerSharedBundleInstallerTest_0700, Fun inBundlePaths.emplace_back(HAP_FILE_PATH1); inBundlePaths.emplace_back(HSP_FILE_PATH1); ret = installer.ObtainHspFileAndSignatureFilePath(inBundlePaths, bundlePaths, signatureFilePath); - EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID); + EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR); } /** @@ -1060,12 +1060,12 @@ HWTEST_F(BmsBundleAppProvisionInfoTest, InnerSharedBundleInstallerTest_0800, Fun std::vector bundlePaths; std::string signatureFilePath; auto ret = installer.ObtainHspFileAndSignatureFilePath(inBundlePaths, bundlePaths, signatureFilePath); - EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID); + EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR); inBundlePaths.clear(); inBundlePaths = {HSP_FILE_PATH1, HSP_FILE_PATH1}; ret = installer.ObtainHspFileAndSignatureFilePath(inBundlePaths, bundlePaths, signatureFilePath); - EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID); + EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_ONLY_ONE_HSP_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR); inBundlePaths[0] = "test.sig"; ret = installer.ObtainHspFileAndSignatureFilePath(inBundlePaths, bundlePaths, signatureFilePath); diff --git a/services/bundlemgr/test/unittest/bms_bundle_free_install_test/bms_bundle_free_install_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_free_install_test/bms_bundle_free_install_test.cpp index 04be85e837..9197917e9d 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_free_install_test/bms_bundle_free_install_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_free_install_test/bms_bundle_free_install_test.cpp @@ -1044,7 +1044,7 @@ HWTEST_F(BmsBundleFreeInstallTest, BundleConnectAbilityMgr_0001, Function | Smal want.SetElement(name); bundleMgr->UpgradeAtomicService(want, USERID); int32_t connectState = 0; - ffrt::condition_variable cv; + std::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); bool ret = bundleMgr->QueryAbilityInfo(want, @@ -1077,7 +1077,7 @@ HWTEST_F(BmsBundleFreeInstallTest, BundleConnectAbilityMgr_0003, Function | Smal bundleMgr->UpgradeAtomicService(want, USERID); bundleMgr->DisconnectDelay(); int32_t connectState = 0; - ffrt::condition_variable cv; + std::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); bool ret = bundleMgr->ConnectAbility(want, connection.serviceCenterRemoteObject_); @@ -1107,7 +1107,7 @@ HWTEST_F(BmsBundleFreeInstallTest, BundleConnectAbilityMgr_0004, Function | Smal name.SetBundleName(BUNDLE_NAME); want.SetElement(name); InnerBundleInfo innerBundleInfo; - ffrt::condition_variable cv; + std::condition_variable cv; int32_t connectState = 0; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); @@ -1438,7 +1438,7 @@ HWTEST_F(BmsBundleFreeInstallTest, BundleConnectAbilityMgr_0026, Function | Smal HWTEST_F(BmsBundleFreeInstallTest, OnAbilityConnectDone_0001, Function | SmallTest | Level0) { int32_t connectState = 0; - ffrt::condition_variable cv; + std::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -1459,7 +1459,7 @@ HWTEST_F(BmsBundleFreeInstallTest, OnAbilityConnectDone_0001, Function | SmallTe HWTEST_F(BmsBundleFreeInstallTest, OnAbilityConnectDone_0002, Function | SmallTest | Level0) { int32_t connectState = 0; - ffrt::condition_variable cv; + std::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -1480,7 +1480,7 @@ HWTEST_F(BmsBundleFreeInstallTest, OnAbilityConnectDone_0002, Function | SmallTe HWTEST_F(BmsBundleFreeInstallTest, OnAbilityConnectDone_0003, Function | SmallTest | Level0) { int32_t connectState = 0; - ffrt::condition_variable cv; + std::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -1884,7 +1884,7 @@ HWTEST_F(BmsBundleFreeInstallTest, QueryBundleStatsInfoByInterval_0100, Function HWTEST_F(BmsBundleFreeInstallTest, OnAbilityDisconnectDone_0100, Function | SmallTest | Level0) { int32_t connectState = 0; - ffrt::condition_variable cv; + std::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -1911,7 +1911,7 @@ HWTEST_F(BmsBundleFreeInstallTest, OnAbilityDisconnectDone_0100, Function | Smal HWTEST_F(BmsBundleFreeInstallTest, OnAbilityDisconnectDone_0200, Function | SmallTest | Level0) { int32_t connectState = 0; - ffrt::condition_variable cv; + std::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -1937,7 +1937,7 @@ HWTEST_F(BmsBundleFreeInstallTest, OnAbilityDisconnectDone_0200, Function | Smal HWTEST_F(BmsBundleFreeInstallTest, OnAbilityDisconnectDone_0300, Function | SmallTest | Level0) { int32_t connectState = 0; - ffrt::condition_variable cv; + std::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -1963,7 +1963,7 @@ HWTEST_F(BmsBundleFreeInstallTest, OnAbilityDisconnectDone_0300, Function | Smal HWTEST_F(BmsBundleFreeInstallTest, OnAbilityDisconnectDone_0400, Function | SmallTest | Level0) { int32_t connectState = 0; - ffrt::condition_variable cv; + std::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; diff --git a/services/bundlemgr/test/unittest/bms_bundle_hsp_test/bms_bundle_shared_library_install_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_hsp_test/bms_bundle_shared_library_install_test.cpp index 12b9a66ea2..078b383f30 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_hsp_test/bms_bundle_shared_library_install_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_hsp_test/bms_bundle_shared_library_install_test.cpp @@ -267,7 +267,7 @@ HWTEST_F(BmsBundleSharedLibraryInstallTest, BmsBundleSharedLibraryInstallCompati sharedBundlePaths = {MODULE_FILE_PATH + LIBA_NORMAL_HAP}; installResult = InstallBundle(bundleFilePaths, sharedBundlePaths); - EXPECT_EQ(installResult, ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID); + EXPECT_EQ(installResult, ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR); ErrCode unInstallResult = UninstallSharedBundle(SHARED_BUNDLE_NAME_A); EXPECT_EQ(unInstallResult, ERR_OK); @@ -304,7 +304,7 @@ HWTEST_F(BmsBundleSharedLibraryInstallTest, BmsBundleSharedLibraryInstallParam_0 std::vector bundleFilePaths{}; std::vector sharedBundlePaths{}; ErrCode installResult = InstallBundle(bundleFilePaths, sharedBundlePaths); - EXPECT_EQ(installResult, ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID); + EXPECT_EQ(installResult, ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY); } /** @@ -330,7 +330,7 @@ HWTEST_F(BmsBundleSharedLibraryInstallTest, BmsBundleSharedLibraryInstallParam_0 std::vector bundleFilePaths{}; std::vector sharedBundlePaths{MODULE_FILE_PATH + LIBA_NORMAL_HAP}; ErrCode installResult = InstallBundle(bundleFilePaths, sharedBundlePaths); - EXPECT_EQ(installResult, ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID); + EXPECT_EQ(installResult, ERR_APPEXECFWK_INSTALL_ONLY_HSP_OR_SIG_FILE_CAN_BE_CONTAINED_IN_SHARED_BUNDLE_DIR); } /** diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_app_service_fwk_installer.cpp b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_app_service_fwk_installer.cpp index 51ef995ca6..46f4958d54 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_app_service_fwk_installer.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_app_service_fwk_installer.cpp @@ -1837,7 +1837,7 @@ HWTEST_F(BmsBundleAppServiceFwkInstallerTest, CheckAndParseFiles_0010, Function std::unordered_map newInfos; auto res = installer.CheckAndParseFiles(hspPaths, installParam, newInfos); - EXPECT_EQ(res, ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID); + EXPECT_EQ(res, ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY); } /** diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp index a5e3a0edd8..aa680c90a1 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp @@ -1932,11 +1932,11 @@ HWTEST_F(BmsBundleInstallerTest, CreateInstallTempDir_0400, Function | SmallTest { BundleUtil bundleUtil; std::string maxFileName = std::string(256, 'a'); - bool res = bundleUtil.CheckFileName(maxFileName); - EXPECT_EQ(res, true); + ErrCode res = bundleUtil.CheckFileName(maxFileName); + EXPECT_EQ(res, ERR_OK); maxFileName.append(".txt"); res = bundleUtil.CheckFileName(maxFileName); - EXPECT_EQ(res, false); + EXPECT_NE(res, ERR_OK); } /** @@ -1947,8 +1947,8 @@ HWTEST_F(BmsBundleInstallerTest, CreateInstallTempDir_0400, Function | SmallTest HWTEST_F(BmsBundleInstallerTest, CreateInstallTempDir_0500, Function | SmallTest | Level0) { BundleUtil bundleUtil; - bool res = bundleUtil.CheckFileSize(BUNDLE_NAME, 0); - EXPECT_EQ(res, false); + ErrCode res = bundleUtil.CheckFileSize(BUNDLE_NAME, 0); + EXPECT_NE(res, ERR_OK); } /** @@ -1961,11 +1961,11 @@ HWTEST_F(BmsBundleInstallerTest, CreateInstallTempDir_0600, Function | SmallTest BundleUtil bundleUtil; std::string currentPath = ""; std::vector fileList = {"test1.hap"}; - bool res = bundleUtil.GetHapFilesFromBundlePath(currentPath, fileList); - EXPECT_EQ(res, false); + ErrCode res = bundleUtil.GetHapFilesFromBundlePath(currentPath, fileList); + EXPECT_EQ(res, ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY); currentPath = "/data/test/test2.hap"; res = bundleUtil.GetHapFilesFromBundlePath(currentPath, fileList); - EXPECT_EQ(res, false); + EXPECT_NE(res, ERR_OK); } /** @@ -2287,7 +2287,7 @@ HWTEST_F(BmsBundleInstallerTest, baseBundleInstaller_0300, Function | SmallTest int32_t uid = 0; ErrCode ret = installer.ProcessBundleInstall( inBundlePaths, installParam, appType, uid); - EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_FILE_PATH_INVALID); + EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_FILE_PATH_EMPTY); installer.dataMgr_ = GetBundleDataMgr(); installParam.userId = Constants::INVALID_USERID; @@ -5622,7 +5622,7 @@ HWTEST_F(BmsBundleInstallerTest, CreateBundleDataDir_0010, Function | SmallTest InnerBundleInfo info; installer.InitDataMgr(); ErrCode res = installer.CreateBundleDataDir(info); - EXPECT_EQ(res, ERR_APPEXECFWK_INSTALL_GENERATE_UID_ERROR); + EXPECT_EQ(res, ERR_APPEXECFWK_INSTALL_BUNDLENAME_IS_EMPTY); } /** @@ -5652,10 +5652,11 @@ HWTEST_F(BmsBundleInstallerTest, CreateBundleDataDir_0020, Function | SmallTest dataMgr->bundleInfos_.clear(); bool ret1 = dataMgr->UpdateBundleInstallState(BUNDLE_NAME_TEST, InstallState::INSTALL_START); bool ret2 = dataMgr->AddInnerBundleInfo(BUNDLE_NAME_TEST, info); - bool ret3 = dataMgr->GenerateUidAndGid(innerBundleUserInfo); + ErrCode ret3 = dataMgr->GenerateUidAndGid(innerBundleUserInfo); + EXPECT_TRUE(ret1); EXPECT_TRUE(ret2); - EXPECT_TRUE(ret3); + EXPECT_EQ(ret3, ERR_OK); BaseBundleInstaller installer; installer.InitDataMgr(); @@ -5663,10 +5664,10 @@ HWTEST_F(BmsBundleInstallerTest, CreateBundleDataDir_0020, Function | SmallTest ErrCode res = installer.CreateBundleDataDir(info); EXPECT_NE(res, ERR_OK); - ret3 = dataMgr->UpdateBundleInstallState(BUNDLE_NAME_TEST, InstallState::UNINSTALL_START); - EXPECT_TRUE(ret3); - ret3 = dataMgr->UpdateBundleInstallState(BUNDLE_NAME_TEST, InstallState::UNINSTALL_SUCCESS); - EXPECT_TRUE(ret3); + bool ret4 = dataMgr->UpdateBundleInstallState(BUNDLE_NAME_TEST, InstallState::UNINSTALL_START); + EXPECT_TRUE(ret4); + ret4 = dataMgr->UpdateBundleInstallState(BUNDLE_NAME_TEST, InstallState::UNINSTALL_SUCCESS); + EXPECT_TRUE(ret4); } /** @@ -5906,8 +5907,8 @@ HWTEST_F(BmsBundleInstallerTest, GetHapFilesFromBundlePath_0100, Function | Smal } bundleUtil.MakeFsConfig("testWrong.hap", 1, "/data/testWrong"); bundleUtil.MakeFsConfig("testWrong.hap", "/data/testWrong", "1", "appid"); - bool res = bundleUtil.GetHapFilesFromBundlePath(CURRENT_PATH, fileList); - EXPECT_EQ(res, false); + ErrCode res = bundleUtil.GetHapFilesFromBundlePath(CURRENT_PATH, fileList); + EXPECT_NE(res, ERR_OK); bundleUtil.DeleteTempDirs(fileList); } diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp index 7c69becbd4..93e25873f7 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/bms_bundle_data_mgr_test.cpp @@ -2820,8 +2820,8 @@ HWTEST_F(BmsBundleDataMgrTest, GenerateUidAndGid_0100, Function | SmallTest | Le innerBundleInfo.SetBaseApplicationInfo(applicationInfo); GetBundleDataMgr()->bundleIdMap_.emplace(MAX_APP_UID, BUNDLE_TEST1); GetBundleDataMgr()->bundleInfos_.emplace(BUNDLE_NAME_TEST, innerBundleInfo); - bool res = GetBundleDataMgr()->GenerateUidAndGid(innerBundleUserInfo); - EXPECT_EQ(res, false); + ErrCode res = GetBundleDataMgr()->GenerateUidAndGid(innerBundleUserInfo); + EXPECT_EQ(res, ERR_APPEXECFWK_INSTALL_BUNDLENAME_IS_EMPTY); } /** diff --git a/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_data_mgr_test.cpp b/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_data_mgr_test.cpp index a6c958d329..0a51321a87 100644 --- a/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_data_mgr_test.cpp +++ b/services/bundlemgr/test/unittest/bms_data_mgr_test/bms_data_mgr_test.cpp @@ -854,10 +854,10 @@ HWTEST_F(BmsDataMgrTest, GenerateUidAndGid_0100, Function | SmallTest | Level0) EXPECT_NE(dataMgr, nullptr); bool ret1 = dataMgr->UpdateBundleInstallState(BUNDLE_NAME, InstallState::INSTALL_START); bool ret2 = dataMgr->AddInnerBundleInfo(BUNDLE_NAME, info); - bool ret3 = dataMgr->GenerateUidAndGid(innerBundleUserInfo); + ErrCode ret3 = dataMgr->GenerateUidAndGid(innerBundleUserInfo); EXPECT_TRUE(ret1); EXPECT_TRUE(ret2); - EXPECT_TRUE(ret3); + EXPECT_EQ(ret3, ERR_OK); dataMgr->UpdateBundleInstallState(BUNDLE_NAME, InstallState::UNINSTALL_START); } @@ -888,10 +888,10 @@ HWTEST_F(BmsDataMgrTest, GenerateUidAndGid_0200, Function | SmallTest | Level0) EXPECT_NE(dataMgr, nullptr); bool ret1 = dataMgr->UpdateBundleInstallState(BUNDLE_NAME, InstallState::INSTALL_START); bool ret2 = dataMgr->AddInnerBundleInfo(BUNDLE_NAME, info); - bool ret3 = dataMgr->GenerateUidAndGid(innerBundleUserInfo); + ErrCode ret3 = dataMgr->GenerateUidAndGid(innerBundleUserInfo); EXPECT_TRUE(ret1); EXPECT_TRUE(ret2); - EXPECT_TRUE(ret3); + EXPECT_EQ(ret3, ERR_OK); dataMgr->UpdateBundleInstallState(BUNDLE_NAME, InstallState::UNINSTALL_START); } @@ -924,10 +924,10 @@ HWTEST_F(BmsDataMgrTest, GenerateUidAndGid_0300, Function | SmallTest | Level0) bool ret1 = dataMgr->UpdateBundleInstallState(BUNDLE_NAME, InstallState::INSTALL_START); bool ret2 = dataMgr->AddInnerBundleInfo(BUNDLE_NAME, info); - bool ret3 = dataMgr->GenerateUidAndGid(innerBundleUserInfo); + ErrCode ret3 = dataMgr->GenerateUidAndGid(innerBundleUserInfo); EXPECT_TRUE(ret1); EXPECT_TRUE(ret2); - EXPECT_TRUE(ret3); + EXPECT_EQ(ret3, ERR_OK); dataMgr->UpdateBundleInstallState(BUNDLE_NAME, InstallState::UNINSTALL_START); } @@ -946,8 +946,8 @@ HWTEST_F(BmsDataMgrTest, GenerateUidAndGid_0400, Function | SmallTest | Level0) EXPECT_NE(dataMgr, nullptr); dataMgr->AddUserId(USERID); - bool ret = dataMgr->GenerateUidAndGid(innerBundleUserInfo); - EXPECT_FALSE(ret); + ErrCode ret = dataMgr->GenerateUidAndGid(innerBundleUserInfo); + EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_BUNDLENAME_IS_EMPTY); dataMgr->UpdateBundleInstallState(BUNDLE_NAME, InstallState::UNINSTALL_START); } @@ -6074,7 +6074,7 @@ HWTEST_F(BmsDataMgrTest, GetAllExtensionBundleNames_0002, Function | MediumTest InnerExtensionInfo innerExtensionInfo; innerExtensionInfo.type = ExtensionAbilityType::INPUTMETHOD; info.InsertExtensionInfo("test.extension", innerExtensionInfo); - std::shared_lock lock(dataMgr_->bundleInfoMutex_); + std::shared_lock lock(dataMgr_->bundleInfoMutex_); dataMgr_->bundleInfos_.emplace("test.bundle", info); std::vector types = { ExtensionAbilityType::INPUTMETHOD, diff --git a/test/fuzztest/fuzztest_bundlemanager/bmsfreeinstall_fuzzer/bmsfreeinstall_fuzzer003.cpp b/test/fuzztest/fuzztest_bundlemanager/bmsfreeinstall_fuzzer/bmsfreeinstall_fuzzer003.cpp index a8300f9bd4..35684914bf 100644 --- a/test/fuzztest/fuzztest_bundlemanager/bmsfreeinstall_fuzzer/bmsfreeinstall_fuzzer003.cpp +++ b/test/fuzztest/fuzztest_bundlemanager/bmsfreeinstall_fuzzer/bmsfreeinstall_fuzzer003.cpp @@ -41,7 +41,7 @@ bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) FuzzedDataProvider fdp(data, size); std::shared_ptr bundleConnectAbilityMgrPtr = std::make_shared(); int32_t connectState = fdp.ConsumeIntegralInRange(0, 2); - ffrt::condition_variable cv; + std::condition_variable cv; OHOS::AppExecFwk::ServiceCenterConnection serviceCenterConnection(connectState, cv, bundleConnectAbilityMgrPtr); AppExecFwk::ElementName element; int32_t resultCode = fdp.ConsumeIntegralInRange(0, 1); diff --git a/test/fuzztest/fuzztest_others/servicecenterconnection_fuzzer/servicecenterconnection_fuzzer.cpp b/test/fuzztest/fuzztest_others/servicecenterconnection_fuzzer/servicecenterconnection_fuzzer.cpp index 262621b926..66a678a340 100644 --- a/test/fuzztest/fuzztest_others/servicecenterconnection_fuzzer/servicecenterconnection_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/servicecenterconnection_fuzzer/servicecenterconnection_fuzzer.cpp @@ -38,7 +38,7 @@ uint32_t GetU32Data(const char* ptr) bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { int32_t connectState = 0; - ffrt::condition_variable cv; + std::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection serviceCenterConnection(connectState, cv, connectAbilityMgr); sptr remoteObject = nullptr; -- Gitee