From eb385118e9a99b8240aee1772d99141d90066c96 Mon Sep 17 00:00:00 2001 From: small_leek Date: Sat, 5 Jul 2025 10:26:27 +0800 Subject: [PATCH] replace ffrt Signed-off-by: small_leek --- .../inner_api/bundlemgr_extension/BUILD.gn | 1 + .../include/bundle_mgr_ext_register.h | 5 +- .../src/bundle_mgr_ext_register.cpp | 8 +- interfaces/kits/js/bundle_manager/BUILD.gn | 1 + .../bundle_manager/clean_cache_callback.cpp | 2 +- .../js/bundle_manager/clean_cache_callback.h | 3 +- .../bundlemgr/include/aging/aging_request.h | 5 +- .../include/aging/bundle_aging_mgr.h | 3 +- services/bundlemgr/include/bundle_data_mgr.h | 24 +- .../bundlemgr/include/bundle_mgr_service.h | 3 +- services/bundlemgr/include/bundle_promise.h | 9 +- .../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/bundle_common_event_mgr.cpp | 3 +- services/bundlemgr/src/bundle_data_mgr.cpp | 452 +++++++++--------- services/bundlemgr/src/bundle_mgr_service.cpp | 8 +- .../bundle_distributed_manager.cpp | 8 +- .../bundle_connect_ability_mgr.cpp | 34 +- .../bundlemgr/src/rdb/rdb_data_manager.cpp | 14 +- .../bms_bundle_free_install_test.cpp | 6 +- .../bms_bundle_free_install_test_two.cpp | 14 +- .../bms_data_mgr_test/bms_data_mgr_test.cpp | 2 +- .../bmsfreeinstall_fuzzer003.cpp | 2 +- .../servicecenterconnection_fuzzer.cpp | 2 +- 29 files changed, 337 insertions(+), 323 deletions(-) diff --git a/interfaces/inner_api/bundlemgr_extension/BUILD.gn b/interfaces/inner_api/bundlemgr_extension/BUILD.gn index a79976527c..a72cad7fc3 100644 --- a/interfaces/inner_api/bundlemgr_extension/BUILD.gn +++ b/interfaces/inner_api/bundlemgr_extension/BUILD.gn @@ -68,6 +68,7 @@ ohos_shared_library("bundlemgr_extension") { "init:libbegetutil", "ipc:ipc_single", "relational_store:native_rdb", + "ffrt:libffrt", ] subsystem_name = "bundlemanager" 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 bc9e05725e..5fa6a93961 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,6 +22,7 @@ #include #include "bundle_mgr_ext.h" +#include "ffrt.h" #include "nocopyable.h" namespace OHOS { @@ -36,8 +37,8 @@ public: void RegisterBundleMgrExt(const std::string& bundleExtName, const CreateFunc& createFunc); std::shared_ptr GetBundleMgrExt(const std::string &bundleExtName); private: - static std::mutex mutex_; - mutable std::mutex BundleMgrExtMutex_; + static ffrt::mutex mutex_; + mutable ffrt::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 452f44e637..fab1650b77 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 { -std::mutex BundleMgrExtRegister::mutex_; +ffrt::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/BUILD.gn b/interfaces/kits/js/bundle_manager/BUILD.gn index 7ab246e4d2..dbc41429e7 100644 --- a/interfaces/kits/js/bundle_manager/BUILD.gn +++ b/interfaces/kits/js/bundle_manager/BUILD.gn @@ -65,6 +65,7 @@ ohos_shared_library("bundlemanager") { "hilog:libhilog", "ipc:ipc_single", "napi:ace_napi", + "ffrt:libffrt", ] if (global_resmgr_enable && bundle_framework_graphics) { diff --git a/interfaces/kits/js/bundle_manager/clean_cache_callback.cpp b/interfaces/kits/js/bundle_manager/clean_cache_callback.cpp index 33e753edb1..c96e7c4914 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 8c4086519a..bc4ea81f83 100644 --- a/interfaces/kits/js/bundle_manager/clean_cache_callback.h +++ b/interfaces/kits/js/bundle_manager/clean_cache_callback.h @@ -16,6 +16,7 @@ #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 @@ -42,7 +43,7 @@ public: private: bool err_ = false; - std::mutex mutex_; + ffrt::mutex mutex_; bool complete_ = false; std::promise promise_; std::future future_ = promise_.get_future(); diff --git a/services/bundlemgr/include/aging/aging_request.h b/services/bundlemgr/include/aging/aging_request.h index 45dd51af00..98935a1fd0 100644 --- a/services/bundlemgr/include/aging/aging_request.h +++ b/services/bundlemgr/include/aging/aging_request.h @@ -21,6 +21,7 @@ #include "aging_bundle_info.h" #include "aging_util.h" +#include "ffrt.h" namespace OHOS { namespace AppExecFwk { @@ -41,7 +42,7 @@ public: const std::vector GetAgingBundles() const { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return agingBundles_; }; @@ -90,7 +91,7 @@ private: static int64_t totalDataBytesThreshold_; static int64_t oneDayTimeMs_; - mutable std::mutex mutex_; + mutable ffrt::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 b793e94d48..126dbb6a3c 100644 --- a/services/bundlemgr/include/aging/bundle_aging_mgr.h +++ b/services/bundlemgr/include/aging/bundle_aging_mgr.h @@ -24,6 +24,7 @@ #include "aging/aging_request.h" #include "bundle_active_client.h" #include "bundle_data_mgr.h" +#include "ffrt.h" #include "singleton.h" namespace OHOS { @@ -61,7 +62,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; - std::mutex mutex_; + ffrt::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 12db278346..67f76fa78d 100644 --- a/services/bundlemgr/include/bundle_data_mgr.h +++ b/services/bundlemgr/include/bundle_data_mgr.h @@ -536,7 +536,7 @@ public: * @param bundleName Indicates the bundle name. * @return Returns a reference of mutex that for locing by bundle name. */ - std::mutex &GetBundleMutex(const std::string &bundleName); + ffrt::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. @@ -879,7 +879,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; - std::shared_mutex &GetStatusCallbackMutex(); + ffrt::shared_mutex &GetStatusCallbackMutex(); std::vector> GetCallBackList() const; @@ -913,7 +913,7 @@ public: const std::map GetAllInnerBundleInfos() const { - std::shared_lock lock(bundleInfoMutex_); + std::shared_lock lock(bundleInfoMutex_); return bundleInfos_; } @@ -1389,15 +1389,15 @@ private: private: bool initialUserFlag_ = false; int32_t baseAppUid_ = Constants::BASE_APP_UID; - mutable std::mutex stateMutex_; - mutable std::mutex multiUserIdSetMutex_; - mutable std::mutex hspBundleNameMutex_; - mutable std::mutex pluginCallbackMutex_; + mutable ffrt::mutex stateMutex_; + mutable ffrt::mutex multiUserIdSetMutex_; + mutable ffrt::mutex hspBundleNameMutex_; + mutable ffrt::mutex pluginCallbackMutex_; mutable ffrt::mutex eventCallbackMutex_; - mutable std::shared_mutex bundleInfoMutex_; - mutable std::shared_mutex bundleIdMapMutex_; - mutable std::shared_mutex callbackMutex_; - mutable std::shared_mutex bundleMutex_; + mutable ffrt::shared_mutex bundleInfoMutex_; + mutable ffrt::shared_mutex bundleIdMapMutex_; + mutable ffrt::shared_mutex callbackMutex_; + mutable ffrt::shared_mutex bundleMutex_; std::shared_ptr dataStorage_; std::shared_ptr preInstallDataStorage_; std::shared_ptr bundleStateStorage_; @@ -1413,7 +1413,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 1c54aa2486..26e9c8856f 100644 --- a/services/bundlemgr/include/bundle_mgr_service.h +++ b/services/bundlemgr/include/bundle_mgr_service.h @@ -42,6 +42,7 @@ #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" @@ -196,7 +197,7 @@ private: std::shared_ptr dataMgr_; std::shared_ptr hidumpHelper_; #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL - mutable std::mutex bundleConnectMutex_; + mutable ffrt::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 3124efc3b4..91b0609734 100644 --- a/services/bundlemgr/include/bundle_promise.h +++ b/services/bundlemgr/include/bundle_promise.h @@ -20,6 +20,7 @@ #include #include "app_log_wrapper.h" +#include "ffrt.h" namespace OHOS { namespace AppExecFwk { @@ -33,7 +34,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; @@ -49,7 +50,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; @@ -64,8 +65,8 @@ private: std::atomic_bool hasWaited_ = false; std::promise promise_; std::future future_ = promise_.get_future(); - std::mutex waitTaskMutex_; - std::mutex notifyTaskMutex_; + ffrt::mutex waitTaskMutex_; + ffrt::mutex notifyTaskMutex_; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/include/distributed_manager/bundle_distributed_manager.h b/services/bundlemgr/include/distributed_manager/bundle_distributed_manager.h index e23f913eb7..5ab13a587b 100644 --- a/services/bundlemgr/include/distributed_manager/bundle_distributed_manager.h +++ b/services/bundlemgr/include/distributed_manager/bundle_distributed_manager.h @@ -18,6 +18,7 @@ #include +#include "ffrt.h" #include "iremote_broker.h" #include "query_rpc_id_params.h" #include "rpc_id_result.h" @@ -50,7 +51,7 @@ private: return transactId_.load(); } mutable std::atomic transactId_ = 0; - std::shared_mutex mutex_; + ffrt::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 ff0db6787e..eed1bf3e10 100644 --- a/services/bundlemgr/include/free_install/bundle_connect_ability_mgr.h +++ b/services/bundlemgr/include/free_install/bundle_connect_ability_mgr.h @@ -21,6 +21,7 @@ #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" @@ -251,8 +252,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); @@ -276,9 +277,9 @@ private: mutable std::atomic transactId_ = 0; sptr serviceCenterConnection_; // maintain the order of using locks. mutex_ >> remoteObejctMutex_ >> mapMutex_ - std::mutex mutex_; - std::mutex mapMutex_; - std::condition_variable cv_; + ffrt::mutex mutex_; + ffrt::mutex mapMutex_; + ffrt::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 7ce6045b31..ece1fa0262 100644 --- a/services/bundlemgr/include/free_install/service_center_connection.h +++ b/services/bundlemgr/include/free_install/service_center_connection.h @@ -20,6 +20,7 @@ #include "ability_connect_callback_stub.h" #include "bundle_connect_ability_mgr.h" +#include "ffrt.h" #include "service_center_death_recipient.h" namespace OHOS { @@ -29,7 +30,7 @@ class ServiceCenterDeathRecipient; class ServiceCenterConnection : public AAFwk::AbilityConnectionStub { public: - ServiceCenterConnection(int32_t &connectState, std::condition_variable &cv, + ServiceCenterConnection(int32_t &connectState, ffrt::condition_variable &cv, const std::weak_ptr connectAbilityMgr) : connectState_(connectState), cv_(cv), connectAbilityMgr_(connectAbilityMgr) { @@ -57,7 +58,7 @@ private: int32_t &connectState_; sptr serviceCenterRemoteObject_; sptr deathRecipient_; - std::condition_variable &cv_; + ffrt::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 bfa8e3b474..c14b748ae8 100644 --- a/services/bundlemgr/include/rdb/rdb_data_manager.h +++ b/services/bundlemgr/include/rdb/rdb_data_manager.h @@ -16,6 +16,7 @@ #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 @@ -66,11 +67,11 @@ private: int32_t InsertWithRetry(std::shared_ptr rdbStore, int64_t &rowId, const NativeRdb::ValuesBucket &valuesBucket); bool IsRetryErrCode(int32_t errCode); - std::mutex &GetRdbRestoreMutex(const std::string &dbName); + ffrt::mutex &GetRdbRestoreMutex(const std::string &dbName); bool isInitial_ = false; - std::mutex rdbMutex_; - static std::mutex restoreRdbMapMutex_; - static std::unordered_map restoreRdbMap_; + ffrt::mutex rdbMutex_; + static ffrt::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 c930fbf0a1..599be13b36 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 3d8f7017f6..22a131c142 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 d948fbcd48..23e08287e4 100644 --- a/services/bundlemgr/src/aging/recently_unused_bundle_aging_handler.cpp +++ b/services/bundlemgr/src/aging/recently_unused_bundle_aging_handler.cpp @@ -15,6 +15,7 @@ #include "ability_manager_helper.h" #include "bundle_mgr_service.h" +#include "ffrt.h" #include "installd_client.h" namespace OHOS { @@ -27,13 +28,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; } @@ -47,7 +48,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"); @@ -56,7 +57,7 @@ public: } private: - std::mutex stateMutex_; + ffrt::mutex stateMutex_; bool isRunning_ = false; std::shared_ptr agingPromise_ = nullptr; }; diff --git a/services/bundlemgr/src/bundle_common_event_mgr.cpp b/services/bundlemgr/src/bundle_common_event_mgr.cpp index 176269428a..3ae5656599 100755 --- a/services/bundlemgr/src/bundle_common_event_mgr.cpp +++ b/services/bundlemgr/src/bundle_common_event_mgr.cpp @@ -21,6 +21,7 @@ #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 +120,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 f21b781f0e..414fa24bad 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 @@ bool 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 false; } - std::lock_guard stateLock(stateMutex_); + std::lock_guard stateLock(stateMutex_); auto& info = bundleInfos_.at(bundleName); info.AddInnerBundleUserInfo(newUserInfo); info.SetBundleStatus(InnerBundleInfo::BundleStatus::ENABLED); @@ -658,14 +658,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); @@ -682,13 +682,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()); @@ -1002,7 +1002,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()); @@ -1047,7 +1047,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); @@ -1114,7 +1114,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; @@ -1155,7 +1155,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; @@ -1197,7 +1197,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; @@ -1241,7 +1241,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; @@ -1320,7 +1320,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()); @@ -2162,7 +2162,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()); @@ -2187,7 +2187,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()); @@ -2360,7 +2360,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; @@ -2389,7 +2389,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); @@ -2444,7 +2444,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; @@ -2498,7 +2498,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; @@ -2540,7 +2540,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()); @@ -2561,7 +2561,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)) @@ -2593,7 +2593,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)) @@ -2648,7 +2648,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; @@ -2681,7 +2681,7 @@ bool BundleDataMgr::UpateExtResources(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()); @@ -2707,7 +2707,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 @@ 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()); @@ -2780,7 +2780,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; @@ -2823,7 +2823,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", @@ -2875,7 +2875,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); @@ -3048,7 +3048,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()); @@ -3175,8 +3175,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); @@ -3189,7 +3189,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()); @@ -3211,7 +3211,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()); @@ -3245,7 +3245,7 @@ bool BundleDataMgr::GetBaseSharedBundleInfo(const Dependency &dependency, 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()); @@ -3275,7 +3275,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()); @@ -3307,7 +3307,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; @@ -3341,7 +3341,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; @@ -3371,7 +3371,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; @@ -3408,7 +3408,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; @@ -3571,7 +3571,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; @@ -3609,7 +3609,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; @@ -3675,7 +3675,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; @@ -3766,7 +3766,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_LOGW_NOFUNC("bundleId %{public}d is not existed", bundleId); @@ -3817,7 +3817,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); @@ -3828,7 +3828,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()); @@ -3871,7 +3871,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); @@ -3892,14 +3892,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; @@ -3993,7 +3993,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; @@ -4009,7 +4009,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; @@ -4039,7 +4039,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; @@ -4081,7 +4081,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()) { @@ -4101,7 +4101,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()); @@ -4120,7 +4120,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(); @@ -4215,7 +4215,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; @@ -4267,7 +4267,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()); @@ -4319,7 +4319,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; @@ -4348,7 +4348,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; @@ -4401,7 +4401,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; @@ -4438,7 +4438,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); @@ -4547,7 +4547,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); } @@ -4629,7 +4629,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()); @@ -4734,7 +4734,7 @@ bool BundleDataMgr::GetInnerBundleInfoWithDisable(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()); @@ -4754,7 +4754,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()); @@ -4772,7 +4772,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()); @@ -4786,7 +4786,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()); @@ -4819,7 +4819,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()); @@ -4878,7 +4878,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()); @@ -4918,7 +4918,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()); @@ -4930,7 +4930,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()); @@ -4956,7 +4956,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", @@ -5013,7 +5013,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 = @@ -5079,7 +5079,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) { @@ -5091,7 +5091,7 @@ bool BundleDataMgr::ClearBundleStatusCallback(const sptr bool BundleDataMgr::UnregisterBundleStatusCallback() { - std::unique_lock lock(callbackMutex_); + std::unique_lock lock(callbackMutex_); callbackList_.clear(); return true; } @@ -5117,7 +5117,7 @@ bool BundleDataMgr::GenerateUidAndGid(InnerBundleUserInfo &innerBundleUserInfo) bool 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_; @@ -5163,7 +5163,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; @@ -5187,7 +5187,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()); @@ -5208,7 +5208,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; @@ -5234,7 +5234,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); @@ -5255,7 +5255,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); @@ -5277,12 +5277,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); } } -std::mutex &BundleDataMgr::GetBundleMutex(const std::string &bundleName) +ffrt::mutex &BundleDataMgr::GetBundleMutex(const std::string &bundleName) { bundleMutex_.lock_shared(); auto it = bundleMutexMap_.find(bundleName); @@ -5302,7 +5302,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()); @@ -5319,7 +5319,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()); @@ -5346,7 +5346,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; @@ -5371,7 +5371,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; @@ -5399,7 +5399,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; @@ -5427,7 +5427,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)) { @@ -5612,7 +5612,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); @@ -5642,7 +5642,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); @@ -5667,7 +5667,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; @@ -5778,7 +5778,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; @@ -5818,7 +5818,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; @@ -5829,7 +5829,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; @@ -5840,7 +5840,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(); } @@ -5851,7 +5851,7 @@ int32_t BundleDataMgr::GetUserIdByCallingUid() const std::set BundleDataMgr::GetAllUser() const { - std::lock_guard lock(multiUserIdSetMutex_); + std::lock_guard lock(multiUserIdSetMutex_); return multiUserIdsSet_; } @@ -5895,7 +5895,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; @@ -5917,7 +5917,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; @@ -6020,7 +6020,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); @@ -6043,7 +6043,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) { @@ -6083,7 +6083,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"); @@ -6159,7 +6159,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); @@ -6262,7 +6262,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 @@ -6300,7 +6300,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 @@ -6758,7 +6758,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); @@ -6809,7 +6809,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; @@ -6844,7 +6844,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) { @@ -6870,7 +6870,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) { @@ -7041,7 +7041,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()); @@ -7060,7 +7060,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()); @@ -7082,7 +7082,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()); @@ -7101,7 +7101,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()); @@ -7170,7 +7170,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; @@ -7264,7 +7264,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; @@ -7308,7 +7308,7 @@ ErrCode BundleDataMgr::GetMediaData(const std::string &bundleName, const std::st #endif } -std::shared_mutex &BundleDataMgr::GetStatusCallbackMutex() +ffrt::shared_mutex &BundleDataMgr::GetStatusCallbackMutex() { return callbackMutex_; } @@ -7327,7 +7327,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()); @@ -7350,7 +7350,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()); @@ -7368,7 +7368,7 @@ bool BundleDataMgr::UpdateInnerBundleInfo(const InnerBundleInfo &innerBundleInfo 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; @@ -7380,7 +7380,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()); @@ -7396,7 +7396,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()); @@ -7425,7 +7425,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) { @@ -7473,7 +7473,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", @@ -7496,7 +7496,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()); @@ -7514,7 +7514,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 @@ -7567,7 +7567,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()); @@ -7581,7 +7581,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", @@ -7594,7 +7594,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); @@ -7625,7 +7625,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(); }); @@ -7641,7 +7641,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()); @@ -7670,7 +7670,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) { item.second.ResetAOTFlags(); if (!dataStorage_->SaveStorageBundleInfo(item.second)) { @@ -7683,7 +7683,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()); @@ -7701,7 +7701,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()); @@ -7722,7 +7722,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) { @@ -7734,7 +7734,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(); @@ -7749,7 +7749,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(); @@ -7770,7 +7770,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(); @@ -7785,7 +7785,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 || @@ -7821,7 +7821,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()); @@ -7834,7 +7834,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()) { @@ -7850,7 +7850,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()); @@ -7897,7 +7897,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()); @@ -7976,7 +7976,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()); @@ -8002,7 +8002,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()); @@ -8028,7 +8028,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()); @@ -8045,7 +8045,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()); @@ -8076,7 +8076,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()); @@ -8186,7 +8186,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()); @@ -8251,7 +8251,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()); @@ -8278,7 +8278,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); @@ -8384,7 +8384,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()); @@ -8430,7 +8430,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()); @@ -8460,7 +8460,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()); @@ -8559,7 +8559,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()); @@ -8618,7 +8618,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()); @@ -8638,7 +8638,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) { @@ -8661,7 +8661,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()) { @@ -8933,7 +8933,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()); @@ -8959,7 +8959,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()); @@ -8977,7 +8977,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()); @@ -9022,7 +9022,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()); @@ -9064,7 +9064,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); } } @@ -9072,7 +9072,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_) { @@ -9117,7 +9117,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)) { @@ -9181,7 +9181,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()); @@ -9310,7 +9310,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; @@ -9349,7 +9349,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()); @@ -9369,7 +9369,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); } @@ -9401,7 +9401,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; @@ -9453,7 +9453,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; @@ -9494,7 +9494,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()); @@ -9521,7 +9521,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()); @@ -9611,7 +9611,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()); @@ -9648,7 +9648,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; @@ -9702,7 +9702,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); @@ -9735,7 +9735,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); @@ -9768,7 +9768,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); @@ -9803,7 +9803,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); @@ -9908,7 +9908,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) { @@ -9940,7 +9940,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) { @@ -9969,7 +9969,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); @@ -9995,7 +9995,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); @@ -10022,7 +10022,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; @@ -10035,7 +10035,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; @@ -10052,7 +10052,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()); @@ -10069,7 +10069,7 @@ std::string BundleDataMgr::AppIdAndAppIdentifierTransform(const std::string appI 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()); @@ -10106,7 +10106,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; @@ -10245,7 +10245,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) { @@ -10275,7 +10275,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; @@ -10321,7 +10321,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()); @@ -10341,7 +10341,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; @@ -10465,7 +10465,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(); @@ -10500,7 +10500,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; @@ -10534,7 +10534,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()); @@ -10546,7 +10546,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()); @@ -10567,7 +10567,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()); @@ -10590,7 +10590,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()); @@ -10619,7 +10619,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()); @@ -10642,7 +10642,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()); @@ -10670,7 +10670,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(), @@ -10702,7 +10702,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(), @@ -10725,7 +10725,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()); @@ -10750,7 +10750,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()); @@ -10775,7 +10775,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()); @@ -10806,7 +10806,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); @@ -10896,7 +10896,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); } @@ -10908,7 +10908,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(); @@ -10926,7 +10926,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()); @@ -10939,7 +10939,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; @@ -10961,7 +10961,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); @@ -11016,7 +11016,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); @@ -11111,7 +11111,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; @@ -11170,7 +11170,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); @@ -11194,7 +11194,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()); diff --git a/services/bundlemgr/src/bundle_mgr_service.cpp b/services/bundlemgr/src/bundle_mgr_service.cpp index 3315cb64f5..9051b2f95d 100644 --- a/services/bundlemgr/src/bundle_mgr_service.cpp +++ b/services/bundlemgr/src/bundle_mgr_service.cpp @@ -71,7 +71,7 @@ BundleMgrService::~BundleMgrService() } #ifdef BUNDLE_FRAMEWORK_FREE_INSTALL { - std::lock_guard 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::GetCurrentActiveUserId(); } - 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/distributed_manager/bundle_distributed_manager.cpp b/services/bundlemgr/src/distributed_manager/bundle_distributed_manager.cpp index 92a4a57406..68be4abb0e 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 7c8a461913..2f2a541ac0 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 &l 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 &lo 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 84471c3040..9392d02e3b 100644 --- a/services/bundlemgr/src/rdb/rdb_data_manager.cpp +++ b/services/bundlemgr/src/rdb/rdb_data_manager.cpp @@ -40,8 +40,8 @@ constexpr const char* INTEGRITY_CHECK = "PRAGMA integrity_check"; constexpr const char* CHECK_OK = "ok"; } -std::mutex RdbDataManager::restoreRdbMapMutex_; -std::unordered_map RdbDataManager::restoreRdbMap_; +ffrt::mutex RdbDataManager::restoreRdbMapMutex_; +std::unordered_map RdbDataManager::restoreRdbMap_; RdbDataManager::RdbDataManager(const BmsRdbConfig &bmsRdbConfig) : bmsRdbConfig_(bmsRdbConfig) @@ -59,9 +59,9 @@ void RdbDataManager::ClearCache() NativeRdb::RdbHelper::ClearCache(); } -std::mutex &RdbDataManager::GetRdbRestoreMutex(const std::string &dbName) +ffrt::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(); } @@ -71,7 +71,7 @@ std::mutex &RdbDataManager::GetRdbRestoreMutex(const std::string &dbName) void 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); @@ -114,7 +114,7 @@ void RdbDataManager::GetRdbStoreFromNative() std::shared_ptr RdbDataManager::GetRdbStore() { - std::lock_guard lock(rdbMutex_); + std::lock_guard lock(rdbMutex_); if (rdbStore_ == nullptr) { GetRdbStoreFromNative(); } @@ -423,7 +423,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/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 d3bd184c61..8edb5823cd 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; - std::condition_variable cv; + ffrt::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; - std::condition_variable cv; + ffrt::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; - std::condition_variable cv; + ffrt::condition_variable cv; int32_t connectState = 0; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); diff --git a/services/bundlemgr/test/unittest/bms_bundle_free_install_test/bms_bundle_free_install_test_two.cpp b/services/bundlemgr/test/unittest/bms_bundle_free_install_test/bms_bundle_free_install_test_two.cpp index 9116a348d6..a30de0ead7 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_free_install_test/bms_bundle_free_install_test_two.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_free_install_test/bms_bundle_free_install_test_two.cpp @@ -417,7 +417,7 @@ HWTEST_F(BmsBundleFreeInstallTest2, BundleConnectAbilityMgr_0026, Function | Sma HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityConnectDone_0001, Function | SmallTest | Level0) { int32_t connectState = 0; - std::condition_variable cv; + ffrt::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -438,7 +438,7 @@ HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityConnectDone_0001, Function | SmallT HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityConnectDone_0002, Function | SmallTest | Level0) { int32_t connectState = 0; - std::condition_variable cv; + ffrt::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -459,7 +459,7 @@ HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityConnectDone_0002, Function | SmallT HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityConnectDone_0003, Function | SmallTest | Level0) { int32_t connectState = 0; - std::condition_variable cv; + ffrt::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -863,7 +863,7 @@ HWTEST_F(BmsBundleFreeInstallTest2, QueryBundleStatsInfoByInterval_0100, Functio HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityDisconnectDone_0100, Function | SmallTest | Level0) { int32_t connectState = 0; - std::condition_variable cv; + ffrt::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -890,7 +890,7 @@ HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityDisconnectDone_0100, Function | Sma HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityDisconnectDone_0200, Function | SmallTest | Level0) { int32_t connectState = 0; - std::condition_variable cv; + ffrt::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -916,7 +916,7 @@ HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityDisconnectDone_0200, Function | Sma HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityDisconnectDone_0300, Function | SmallTest | Level0) { int32_t connectState = 0; - std::condition_variable cv; + ffrt::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; @@ -942,7 +942,7 @@ HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityDisconnectDone_0300, Function | Sma HWTEST_F(BmsBundleFreeInstallTest2, OnAbilityDisconnectDone_0400, Function | SmallTest | Level0) { int32_t connectState = 0; - std::condition_variable cv; + ffrt::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection connection(connectState, cv, connectAbilityMgr); ElementName element; 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 4ff478aa0b..d40ee11cdf 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 @@ -6022,7 +6022,7 @@ HWTEST_F(BmsDataMgrTest, GetAllExtensionBundleNames_0002, Function | MediumTest ExtensionAbilityInfo extensionInfo; extensionInfo.type = ExtensionAbilityType::INPUTMETHOD; info.InsertExtensionInfo("test.extension", extensionInfo); - 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 35684914bf..a8300f9bd4 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); - std::condition_variable cv; + ffrt::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 66a678a340..262621b926 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; - std::condition_variable cv; + ffrt::condition_variable cv; const std::weak_ptr connectAbilityMgr; ServiceCenterConnection serviceCenterConnection(connectState, cv, connectAbilityMgr); sptr remoteObject = nullptr; -- Gitee