From 9d1bd2cf2f5c8baa3451cfb60c29dd4612d168ca Mon Sep 17 00:00:00 2001 From: songbao1 Date: Wed, 16 Jul 2025 11:04:12 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E6=9B=BF=E6=8D=A2std::mutex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- ...vanced_notification_flow_control_service.h | 5 +- .../include/advanced_notification_service.h | 4 +- services/ans/include/bundle_manager_helper.h | 2 +- .../distributed_device_data_service.h | 4 +- .../distributed_extension_service.h | 3 +- .../notification_operation_service.h | 2 +- .../ans/include/notification_preferences.h | 4 +- .../ans/include/notification_rdb_data_mgr.h | 5 +- ...nced_notification_flow_control_service.cpp | 10 +- ...dvanced_notification_live_view_service.cpp | 6 +- .../ans/src/advanced_notification_service.cpp | 14 +-- services/ans/src/bundle_manager_helper.cpp | 28 ++--- services/ans/src/common/aes_gcm_helper.cpp | 5 +- .../common/notification_analytics_util.cpp | 51 ++++---- .../distributed_device_data_service.cpp | 14 +-- .../distributed_extension_service.cpp | 6 +- .../notification_operation_service.cpp | 6 +- services/ans/src/notification_preferences.cpp | 118 +++++++++--------- .../ans/src/notification_rdb_data_mgr.cpp | 40 +++--- ..._notification_system_live_view_service.cpp | 2 +- .../include/base/distributed_client.h | 3 +- .../include/base/distributed_server.h | 3 +- .../include/distributed_database.h | 3 +- .../distributed_notification_manager.h | 2 +- .../distributed_preferences_database.h | 3 +- .../include/helper/ability_manager_helper.h | 2 +- .../include/helper/bundle_resource_helper.h | 3 +- .../helper/distributed_operation_helper.h | 3 +- .../include/helper/distributed_preference.h | 3 +- .../include/helper/distributed_rdb_helper.h | 3 +- .../soft_bus/distributed_device_service.h | 3 +- .../soft_bus/distributed_subscribe_service.h | 3 +- ...distributed_unlock_listener_oper_service.h | 2 +- .../src/base/distributed_client.cpp | 14 +-- .../src/base/distributed_server.cpp | 6 +- .../distributed/src/distributed_database.cpp | 20 +-- .../src/distributed_notification_manager.cpp | 12 +- .../src/distributed_preferences_database.cpp | 10 +- .../src/helper/ability_manager_helper.cpp | 4 +- .../src/helper/bundle_resource_helper.cpp | 12 +- .../helper/distributed_operation_helper.cpp | 8 +- .../src/helper/distributed_preference.cpp | 10 +- .../src/helper/distributed_rdb_helper.cpp | 16 +-- .../soft_bus/distributed_device_service.cpp | 34 ++--- .../distributed_subscribe_service_v2.cpp | 6 +- ...stributed_unlock_listener_oper_service.cpp | 6 +- 46 files changed, 270 insertions(+), 253 deletions(-) diff --git a/services/ans/include/advanced_notification_flow_control_service.h b/services/ans/include/advanced_notification_flow_control_service.h index 646ddf81f..6adb44712 100644 --- a/services/ans/include/advanced_notification_flow_control_service.h +++ b/services/ans/include/advanced_notification_flow_control_service.h @@ -26,6 +26,7 @@ #include "ans_const_define.h" #include "notification_record.h" #include "notification_analytics_util.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -87,7 +88,7 @@ public: private: uint32_t threshold_; FlowControlErrMsg errMsg_; - std::mutex globalFlowControllerMutex_; + ffrt::mutex globalFlowControllerMutex_; std::list globalFlowControllerList_; }; @@ -127,7 +128,7 @@ public: private: uint32_t threshold_; FlowControlErrMsg errMsg_; - std::mutex callerFlowControllerMutex_; + ffrt::mutex callerFlowControllerMutex_; std::map>> callerFlowControllerMapper_; }; diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 4e3f72360..93c38df01 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -1797,8 +1797,8 @@ private: std::list> distributedUniqueKeyList_; std::list> localUniqueKeyList_; std::list, uint64_t>> delayNotificationList_; - std::mutex delayNotificationMutext_; - static std::mutex doNotDisturbMutex_; + ffrt::mutex delayNotificationMutext_; + static ffrt::mutex doNotDisturbMutex_; std::map doNotDisturbEnableRecord_; bool isCachedAppAndDeviceRelationMap_ = false; std::map appAndDeviceRelationMap_; diff --git a/services/ans/include/bundle_manager_helper.h b/services/ans/include/bundle_manager_helper.h index 5bc8a5a9f..948982014 100644 --- a/services/ans/include/bundle_manager_helper.h +++ b/services/ans/include/bundle_manager_helper.h @@ -182,7 +182,7 @@ private: private: sptr bundleMgr_ = nullptr; - std::mutex connectionMutex_; + ffrt::mutex connectionMutex_; sptr deathRecipient_ = nullptr; DECLARE_DELAYED_SINGLETON(BundleManagerHelper) diff --git a/services/ans/include/notification_extension/distributed_device_data_service.h b/services/ans/include/notification_extension/distributed_device_data_service.h index 6fbbd8911..9ac2ed12a 100644 --- a/services/ans/include/notification_extension/distributed_device_data_service.h +++ b/services/ans/include/notification_extension/distributed_device_data_service.h @@ -21,6 +21,8 @@ #include #include +#include "ffrt.h" + namespace OHOS { namespace Notification { @@ -52,7 +54,7 @@ private: DistributedDeviceDataService() = default; ~DistributedDeviceDataService() = default; - std::mutex lock_; + ffrt::mutex lock_; std::vector devicesData_; }; } diff --git a/services/ans/include/notification_extension/distributed_extension_service.h b/services/ans/include/notification_extension/distributed_extension_service.h index 9427bb6c8..d1a224ee2 100644 --- a/services/ans/include/notification_extension/distributed_extension_service.h +++ b/services/ans/include/notification_extension/distributed_extension_service.h @@ -22,6 +22,7 @@ #include "ffrt.h" #include "notification_config_parse.h" #include "distributed_data_define.h" +#include "ffrt.h" #include #include @@ -72,7 +73,7 @@ private: bool SetSupportPeerDevice(nlohmann::json &configJson); bool SetMaxTitleLength(nlohmann::json &configJson); - std::mutex mapLock_; + ffrt::mutex mapLock_; std::atomic dansRunning_ = false; std::shared_ptr distributedQueue_ = nullptr; std::shared_ptr dansHandler_; diff --git a/services/ans/include/notification_extension/notification_operation_service.h b/services/ans/include/notification_extension/notification_operation_service.h index 983cb7c73..e2c0ada63 100644 --- a/services/ans/include/notification_extension/notification_operation_service.h +++ b/services/ans/include/notification_extension/notification_operation_service.h @@ -78,7 +78,7 @@ private: ~DistributedOperationService() = default; private: - std::mutex mapLock_; + ffrt::mutex mapLock_; std::shared_ptr operationQueue_ = nullptr; std::map timerMap_; std::map> callbackMap_; diff --git a/services/ans/include/notification_preferences.h b/services/ans/include/notification_preferences.h index 38f7ab216..8629f2d08 100644 --- a/services/ans/include/notification_preferences.h +++ b/services/ans/include/notification_preferences.h @@ -580,10 +580,10 @@ private: void SetDistributedEnabledForBundle(const NotificationPreferencesInfo::BundleInfo& bundleInfo); private: - static std::mutex instanceMutex_; + static ffrt::mutex instanceMutex_; static std::shared_ptr instance_; NotificationPreferencesInfo preferencesInfo_ {}; - std::mutex preferenceMutex_; + ffrt::mutex preferenceMutex_; std::shared_ptr preferncesDB_ = nullptr; bool isCachedMirrorNotificationEnabledStatus_ = false; std::vector mirrorNotificationEnabledStatus_ = {}; diff --git a/services/ans/include/notification_rdb_data_mgr.h b/services/ans/include/notification_rdb_data_mgr.h index 25abe4fca..6e49a8c19 100644 --- a/services/ans/include/notification_rdb_data_mgr.h +++ b/services/ans/include/notification_rdb_data_mgr.h @@ -27,6 +27,7 @@ #include "rdb_helper.h" #include "rdb_open_callback.h" #include "rdb_store_config.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -176,9 +177,9 @@ private: private: NotificationRdbConfig notificationRdbConfig_; std::shared_ptr rdbStore_; - mutable std::mutex rdbStorePtrMutex_; + mutable ffrt::mutex rdbStorePtrMutex_; std::set createdTables_; - mutable std::mutex createdTableMutex_; + mutable ffrt::mutex createdTableMutex_; }; } // namespace Notification } // namespace OHOS diff --git a/services/ans/src/advanced_notification_flow_control_service.cpp b/services/ans/src/advanced_notification_flow_control_service.cpp index ad54e01fb..859531840 100644 --- a/services/ans/src/advanced_notification_flow_control_service.cpp +++ b/services/ans/src/advanced_notification_flow_control_service.cpp @@ -40,7 +40,7 @@ void RemoveExpiredTimestamp(std::list &list, const TimePoint &now) ErrCode GlobalFlowController::FlowControl(const std::shared_ptr record, const TimePoint &now) { - std::lock_guard lock(globalFlowControllerMutex_); + std::lock_guard lock(globalFlowControllerMutex_); RemoveExpiredTimestamp(globalFlowControllerList_, now); if (globalFlowControllerList_.size() >= threshold_) { ANS_LOGE("%{public}s", errMsg_.msg.c_str()); @@ -54,14 +54,14 @@ ErrCode GlobalFlowController::FlowControl(const std::shared_ptr lock(globalFlowControllerMutex_); + std::lock_guard lock(globalFlowControllerMutex_); globalFlowControllerList_.push_back(now); } ErrCode CallerFlowController::FlowControl( const std::shared_ptr record, const int32_t callingUid, const TimePoint &now) { - std::lock_guard lock(callerFlowControllerMutex_); + std::lock_guard lock(callerFlowControllerMutex_); auto callerFlowControlIter = callerFlowControllerMapper_.find(callingUid); if (callerFlowControlIter == callerFlowControllerMapper_.end()) { return ERR_OK; @@ -80,7 +80,7 @@ ErrCode CallerFlowController::FlowControl( void CallerFlowController::RecordTimestamp( const std::shared_ptr record, const int32_t callingUid, const TimePoint &now) { - std::lock_guard lock(callerFlowControllerMutex_); + std::lock_guard lock(callerFlowControllerMutex_); auto callerFlowControlIter = callerFlowControllerMapper_.find(callingUid); if (callerFlowControlIter == callerFlowControllerMapper_.end()) { callerFlowControllerMapper_[callingUid] = std::make_shared>(); @@ -91,7 +91,7 @@ void CallerFlowController::RecordTimestamp( void CallerFlowController::RemoveExpired(const TimePoint &now) { - std::lock_guard lock(callerFlowControllerMutex_); + std::lock_guard lock(callerFlowControllerMutex_); for (auto iter = callerFlowControllerMapper_.begin(); iter != callerFlowControllerMapper_.end();) { auto latest = iter->second->back(); if (std::chrono::abs(now - latest) > CALLER_FLOW_CONTRL_EXPIRE_TIME) { diff --git a/services/ans/src/advanced_notification_live_view_service.cpp b/services/ans/src/advanced_notification_live_view_service.cpp index e7ef7046f..4eca3ecda 100644 --- a/services/ans/src/advanced_notification_live_view_service.cpp +++ b/services/ans/src/advanced_notification_live_view_service.cpp @@ -497,7 +497,7 @@ ErrCode AdvancedNotificationService::GetLockScreenPictureFromDb(NotificationRequ void AdvancedNotificationService::UpdateInDelayNotificationList(const std::shared_ptr &record) { - std::lock_guard lock(delayNotificationMutext_); + std::lock_guard lock(delayNotificationMutext_); auto iter = delayNotificationList_.begin(); while (iter != delayNotificationList_.end()) { if ((*iter).first->notification->GetKey() == record->notification->GetKey()) { @@ -514,7 +514,7 @@ void AdvancedNotificationService::UpdateInDelayNotificationList(const std::share void AdvancedNotificationService::AddToDelayNotificationList(const std::shared_ptr &record) { - std::lock_guard lock(delayNotificationMutext_); + std::lock_guard lock(delayNotificationMutext_); auto request = record->notification->GetNotificationRequest(); auto timerId = StartDelayPublishTimer( request.GetOwnerUid(), request.GetNotificationId(), request.GetPublishDelayTime()); @@ -539,7 +539,7 @@ ErrCode AdvancedNotificationService::SaPublishSystemLiveViewAsBundle(const std:: bool AdvancedNotificationService::IsNotificationExistsInDelayList(const std::string &key) { - std::lock_guard lock(delayNotificationMutext_); + std::lock_guard lock(delayNotificationMutext_); for (auto delayNotification : delayNotificationList_) { if (delayNotification.first->notification->GetKey() == key) { return true; diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 696891c5b..c22439349 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -110,7 +110,7 @@ constexpr const char *KEY_UNIFIED_GROUP_ENABLE = "unified_group_enable"; sptr AdvancedNotificationService::instance_; std::mutex AdvancedNotificationService::instanceMutex_; std::mutex AdvancedNotificationService::pushMutex_; -std::mutex AdvancedNotificationService::doNotDisturbMutex_; +ffrt::mutex AdvancedNotificationService::doNotDisturbMutex_; std::map slotFlagsDefaultMap_; std::map> AdvancedNotificationService::pushCallBacks_; @@ -810,7 +810,7 @@ void AdvancedNotificationService::QueryIntelligentExperienceEnable(const int32_t void AdvancedNotificationService::ReportDoNotDisturbModeChanged(const int32_t &userId, std::string &enable) { - std::lock_guard lock(doNotDisturbMutex_); + std::lock_guard lock(doNotDisturbMutex_); HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_3, EventBranchId::BRANCH_2); std::string info = "Do not disturb mode changed, userId: " + std::to_string(userId) + ", enable: " + enable; auto it = doNotDisturbEnableRecord_.find(userId); @@ -1229,7 +1229,7 @@ std::vector AdvancedNotificationService::GetNotificationKeys( keys.push_back(record->notification->GetKey()); } - std::lock_guard lock(delayNotificationMutext_); + std::lock_guard lock(delayNotificationMutext_); for (auto delayNotification : delayNotificationList_) { auto delayRequest = delayNotification.first->notification->GetNotificationRequest(); if (bundleOption != nullptr && delayRequest.GetOwnerUid() == bundleOption->GetUid()) { @@ -1260,7 +1260,7 @@ std::vector AdvancedNotificationService::GetNotificationKeysByBundl } } - std::lock_guard lock(delayNotificationMutext_); + std::lock_guard lock(delayNotificationMutext_); for (auto delayNotification : delayNotificationList_) { auto delayRequest = delayNotification.first->notification->GetNotificationRequest(); if (bundleOption != nullptr && delayRequest.GetOwnerUid() == bundleOption->GetUid()) { @@ -1358,7 +1358,7 @@ ErrCode AdvancedNotificationService::RemoveFromNotificationList(const sptr lock(delayNotificationMutext_); + std::lock_guard lock(delayNotificationMutext_); for (auto delayNotification : delayNotificationList_) { if ((delayNotification.first->bundleOption->GetUid() == bundleOption->GetUid()) && (delayNotification.first->notification->GetLabel() == notificationKey.label) && @@ -1430,7 +1430,7 @@ ErrCode AdvancedNotificationService::RemoveFromNotificationListForDeleteAll( bool AdvancedNotificationService::RemoveFromDelayedNotificationList(const std::string &key) { - std::lock_guard lock(delayNotificationMutext_); + std::lock_guard lock(delayNotificationMutext_); for (auto delayNotification : delayNotificationList_) { if (delayNotification.first->notification->GetKey() == key) { CancelTimer(delayNotification.second); @@ -1469,7 +1469,7 @@ std::shared_ptr AdvancedNotificationService::GetFromNotifica std::shared_ptr AdvancedNotificationService::GetFromDelayedNotificationList( const int32_t ownerUid, const int32_t notificationId) { - std::lock_guard lock(delayNotificationMutext_); + std::lock_guard lock(delayNotificationMutext_); for (auto delayNotification : delayNotificationList_) { auto delayRequest = delayNotification.first->notification->GetNotificationRequest(); if (delayRequest.GetOwnerUid() == ownerUid && diff --git a/services/ans/src/bundle_manager_helper.cpp b/services/ans/src/bundle_manager_helper.cpp index 22b58573a..02b697c73 100644 --- a/services/ans/src/bundle_manager_helper.cpp +++ b/services/ans/src/bundle_manager_helper.cpp @@ -38,13 +38,13 @@ BundleManagerHelper::BundleManagerHelper() BundleManagerHelper::~BundleManagerHelper() { - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Disconnect(); } void BundleManagerHelper::OnRemoteDied(const wptr &object) { - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Disconnect(); } @@ -52,7 +52,7 @@ std::string BundleManagerHelper::GetBundleNameByUid(int32_t uid) { std::string bundle; - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); @@ -68,7 +68,7 @@ bool BundleManagerHelper::IsSystemApp(int32_t uid) { bool isSystemApp = false; - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); @@ -113,7 +113,7 @@ bool BundleManagerHelper::CheckApiCompatibility(const std::string &bundleName, c bool BundleManagerHelper::GetBundleInfoByBundleName( const std::string bundle, const int32_t userId, AppExecFwk::BundleInfo &bundleInfo) { - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (bundleMgr_ == nullptr) { @@ -161,7 +161,7 @@ int32_t BundleManagerHelper::GetDefaultUidByBundleName(const std::string &bundle { int32_t uid = -1; - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); @@ -180,7 +180,7 @@ int32_t BundleManagerHelper::GetDefaultUidByBundleName(const std::string &bundle #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED bool BundleManagerHelper::GetDistributedNotificationEnabled(const std::string &bundleName, const int32_t userId) { - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); @@ -201,7 +201,7 @@ bool BundleManagerHelper::GetDistributedNotificationEnabled(const std::string &b bool BundleManagerHelper::GetBundleInfo(const std::string &bundleName, const AppExecFwk::BundleFlag flag, int32_t userId, AppExecFwk::BundleInfo &bundleInfo) { - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); @@ -219,7 +219,7 @@ bool BundleManagerHelper::GetBundleInfo(const std::string &bundleName, const App bool BundleManagerHelper::GetBundleInfos( const AppExecFwk::BundleFlag flag, std::vector &bundleInfos, int32_t userId) { - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (bundleMgr_ == nullptr) { @@ -235,7 +235,7 @@ bool BundleManagerHelper::GetBundleInfos( int32_t BundleManagerHelper::GetAppIndexByUid(const int32_t uid) { int32_t appIndex = 0; - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (nullptr == bundleMgr_) { return appIndex; @@ -251,7 +251,7 @@ int32_t BundleManagerHelper::GetDefaultUidByBundleName(const std::string &bundle const int32_t appIndex) { int32_t uid = -1; - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (bundleMgr_ != nullptr) { std::string identity = IPCSkeleton::ResetCallingIdentity(); @@ -268,7 +268,7 @@ bool BundleManagerHelper::GetBundleInfoV9( const std::string bundle, const int32_t flag, AppExecFwk::BundleInfo &bundleInfo, const int32_t userId) { - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (bundleMgr_ == nullptr) { @@ -289,7 +289,7 @@ ErrCode BundleManagerHelper::GetApplicationInfo(const std::string &bundleName, i AppExecFwk::ApplicationInfo &appInfo) { ErrCode result = 0; - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (bundleMgr_ == nullptr) { ANS_LOGE("GetBundleInfo bundle proxy failed."); @@ -323,7 +323,7 @@ ErrCode BundleManagerHelper::GetBundleResourceInfo(const std::string &bundleName AppExecFwk::BundleResourceInfo &bundleResourceInfo, const int32_t appIndex) { ErrCode result = 0; - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (bundleMgr_ == nullptr) { ANS_LOGE("GetBundleInfo bundle proxy failed."); diff --git a/services/ans/src/common/aes_gcm_helper.cpp b/services/ans/src/common/aes_gcm_helper.cpp index 41dc2b599..289e814d6 100644 --- a/services/ans/src/common/aes_gcm_helper.cpp +++ b/services/ans/src/common/aes_gcm_helper.cpp @@ -28,6 +28,7 @@ #include "aes_gcm_helper.h" #include "ans_log_wrapper.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -40,7 +41,7 @@ static const int STEP = 2; static const int OFFSET = 4; static const int HEX_OF_A = 10; static const int WIDTH_PER_BYTE = 2; -static inline std::mutex g_generateKeyMutex{}; +static inline ffrt::mutex g_generateKeyMutex{}; std::string AesGcmHelper::Byte2Hex(const std::string &bytes) { @@ -82,7 +83,7 @@ std::string AesGcmHelper::Hex2Byte(const std::string &hex) bool AesGcmHelper::GenerateKey(std::string &key) { - std::lock_guard lck(g_generateKeyMutex); + std::lock_guard lck(g_generateKeyMutex); const char *keyPathPtr = G_KEY_PATH.c_str(); char *resolvedPath = (char *)malloc(PATH_MAX); if (resolvedPath != nullptr) { diff --git a/services/ans/src/common/notification_analytics_util.cpp b/services/ans/src/common/notification_analytics_util.cpp index 724d70f56..b8a0e8db4 100644 --- a/services/ans/src/common/notification_analytics_util.cpp +++ b/services/ans/src/common/notification_analytics_util.cpp @@ -33,6 +33,7 @@ #include "notification_constant.h" #include "advanced_notification_inline.h" #include "hitrace_util.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -70,7 +71,7 @@ constexpr const int32_t BANNER_FLAG = 1 << 12; constexpr const int32_t VIBRATION_FLAG = 1 << 13; const static std::string NOTIFICATION_EVENT_PUSH_AGENT = "notification.event.PUSH_AGENT"; -static std::mutex reportFlowControlMutex_; +static ffrt::mutex reportFlowControlMutex_; static std::map> flowControlTimestampMap_ = { {MODIFY_ERROR_EVENT_CODE, {}}, {PUBLISH_ERROR_EVENT_CODE, {}}, @@ -80,14 +81,14 @@ static std::map> flowC static std::map badgeInfos; static std::map liveViewMessages; -static std::mutex reportCacheMutex_; +static ffrt::mutex reportCacheMutex_; static uint64_t reportTimerId = 0; static std::list reportCacheList; static bool g_reportFlag = false; static std::shared_ptr reportTimeInfo = std::make_shared(); -static std::mutex badgeInfosMutex_; -static std::mutex reportSuccessCacheMutex_; +static ffrt::mutex badgeInfosMutex_; +static ffrt::mutex reportSuccessCacheMutex_; static uint64_t reportAggregateTimeId = 0; static std::list successReportCacheList; static bool g_successReportFlag = false; @@ -96,20 +97,20 @@ static std::list reportAggList; static int32_t SLOT_REPORT_INTERVAL = 7 * 24 * NotificationConstant::HOUR_TO_MS; static int64_t lastReportTime_ = 0; -static std::mutex lastReportTimeMutex_; +static ffrt::mutex lastReportTimeMutex_; static int32_t SLOT_SUB_CODE = 101; static int32_t SLOT_ONCE_REPORT = 10; static uint32_t SLOT_MAX_REPORT = 200; static uint64_t reportSlotEnabledTimerId_ = 0; static std::shared_ptr slotTimeInfo = std::make_shared(); static std::list slotEnabledList_; -static std::mutex slotEnabledListMutex_; +static ffrt::mutex slotEnabledListMutex_; static bool g_reportSlotFlag = false; -static std::mutex reportSlotEnabledMutex_; +static ffrt::mutex reportSlotEnabledMutex_; static int32_t LIVEVIEW_SUB_CODE = 202; static int32_t LIVEVIEW_AGGREGATE_NUM = 10; -static std::mutex ReportLiveViewMessageMutex_; +static ffrt::mutex ReportLiveViewMessageMutex_; static uint64_t reportLiveViewMessageTimerId_ = 0; static std::shared_ptr liveViewTimeInfo = std::make_shared(); static int32_t LIVEVIEW_REPORT_INTERVAL = 2 * NotificationConstant::HOUR_TO_MS; @@ -474,7 +475,7 @@ void NotificationAnalyticsUtil::ReportLiveViewNumber(const sptrGetExtraInfo() != nullptr) { std::string bundle = bundleName + MESSAGE_DELIMITER + liveViewContent->GetExtraInfo()->GetStringParam("event"); - std::lock_guard lock(ReportLiveViewMessageMutex_); + std::lock_guard lock(ReportLiveViewMessageMutex_); if (reportType == ANS_CUSTOMIZE_CODE) { AddLiveViewSuccessNum(bundle, static_cast(liveViewContent->GetLiveViewStatus())); } else if (reportType == PUBLISH_ERROR_EVENT_CODE) { @@ -484,7 +485,7 @@ void NotificationAnalyticsUtil::ReportLiveViewNumber(const sptr lock(ReportLiveViewMessageMutex_); + std::lock_guard lock(ReportLiveViewMessageMutex_); std::string bundle = bundleName + "#-99"; if (reportType == ANS_CUSTOMIZE_CODE) { AddLocalLiveViewSuccessNum(bundle); @@ -591,7 +592,7 @@ void NotificationAnalyticsUtil::CreateLiveViewTimerExecute() void NotificationAnalyticsUtil::ExecuteLiveViewReport() { - std::lock_guard lock(ReportLiveViewMessageMutex_); + std::lock_guard lock(ReportLiveViewMessageMutex_); if (liveViewMessages.empty()) { ANS_LOGI("report end"); g_reportLiveViewFlag = false; @@ -912,7 +913,7 @@ void NotificationAnalyticsUtil::ReportNotificationEvent(EventFwk::Want want, bool NotificationAnalyticsUtil::ReportFlowControl(const int32_t reportType) { std::chrono::system_clock::time_point now = std::chrono::system_clock::now(); - std::lock_guard lock(reportFlowControlMutex_); + std::lock_guard lock(reportFlowControlMutex_); auto iter = flowControlTimestampMap_.find(reportType); if (iter == flowControlTimestampMap_.end()) { return false; @@ -1072,7 +1073,7 @@ void NotificationAnalyticsUtil::SetCommonWant(EventFwk::Want& want, const HaMeta void NotificationAnalyticsUtil::AddListCache(EventFwk::Want& want, int32_t eventCode) { - std::lock_guard lock(reportCacheMutex_); + std::lock_guard lock(reportCacheMutex_); int32_t size = static_cast(reportCacheList.size()); if (size >= REPORT_CACHE_MAX_SIZE) { ANS_LOGW("list size is max"); @@ -1111,7 +1112,7 @@ void NotificationAnalyticsUtil::ReportBadgeChange(const sptrGetBadgeNumber(); std::string badgeNumStr = (badgeNumber > MAX_BADGE_NUMBER) ? "99+" : std::to_string(badgeNumber); { - std::lock_guard lock(badgeInfosMutex_); + std::lock_guard lock(badgeInfosMutex_); auto iter = badgeInfos.find(bundle); if (iter != badgeInfos.end()) { badgeInfo.badgeNum = iter->second.badgeNum + "_" + badgeNumStr; @@ -1149,7 +1150,7 @@ void NotificationAnalyticsUtil::ReportPublishBadge(const sptrGetBadgeNumber(); std::string badgeNumStr = (badgeNumber > MAX_BADGE_NUMBER) ? "99+" : std::to_string(badgeNumber); { - std::lock_guard lock(badgeInfosMutex_); + std::lock_guard lock(badgeInfosMutex_); auto iter = badgeInfos.find(bundle); if (iter != badgeInfos.end()) { badgeInfo.badgeNum = iter->second.badgeNum + "_+" + badgeNumStr; @@ -1195,7 +1196,7 @@ void NotificationAnalyticsUtil::CheckBadgeReport() auto now = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()).count(); { - std::lock_guard lock(badgeInfosMutex_); + std::lock_guard lock(badgeInfosMutex_); for (auto& pair : badgeInfos) { if (pair.second.changeCount == MAX_NUMBER_EVERY_BADGE_DATA || now - pair.second.startTime > MAX_BADGE_CHANGE_REPORT_TIME) { @@ -1224,7 +1225,7 @@ void NotificationAnalyticsUtil::AggregateBadgeChange() want.SetAction(NOTIFICATION_EVENT_PUSH_AGENT); ansData["subCode"] = std::to_string(BADGE_CHANGE_CODE); { - std::lock_guard lock(badgeInfosMutex_); + std::lock_guard lock(badgeInfosMutex_); for (const auto& pair : badgeInfos) { const std::string bundle = pair.first; const BadgeInfo info = pair.second; @@ -1267,7 +1268,7 @@ void NotificationAnalyticsUtil::AggregateBadgeChange() void NotificationAnalyticsUtil::AddSuccessListCache(EventFwk::Want& want, int32_t eventCode) { - std::lock_guard lock(reportSuccessCacheMutex_); + std::lock_guard lock(reportSuccessCacheMutex_); int32_t size = static_cast(successReportCacheList.size()); if (size >= SUCCESS_REPORT_CACHE_MAX_SIZE) { ANS_LOGW("Success list size is max."); @@ -1354,7 +1355,7 @@ void NotificationAnalyticsUtil::ExecuteSuccessCacheList() } CheckBadgeReport(); auto triggerFunc = [] { - std::lock_guard lock(reportSuccessCacheMutex_); + std::lock_guard lock(reportSuccessCacheMutex_); NotificationAnalyticsUtil::ExecuteSuccessCacheList(); }; reportAggregateTimeInfo->SetCallbackInfo(triggerFunc); @@ -1380,7 +1381,7 @@ void NotificationAnalyticsUtil::ExecuteCacheList() auto reportCache = reportCacheList.front(); ReportCommonEvent(reportCache); auto triggerFunc = [] { - std::lock_guard lock(reportCacheMutex_); + std::lock_guard lock(reportCacheMutex_); NotificationAnalyticsUtil::ExecuteCacheList(); }; reportCacheList.pop_front(); @@ -1484,7 +1485,7 @@ bool NotificationAnalyticsUtil::ReportAllBundlesSlotEnabled() bool NotificationAnalyticsUtil::CreateSlotTimerExecute(const int32_t &userId) { - std::lock_guard lock(reportSlotEnabledMutex_); + std::lock_guard lock(reportSlotEnabledMutex_); if (g_reportSlotFlag) { ANS_LOGW("now has message is reporting"); return false; @@ -1516,7 +1517,7 @@ bool NotificationAnalyticsUtil::CreateSlotTimerExecute(const int32_t &userId) void NotificationAnalyticsUtil::ExecuteSlotReportList() { - std::lock_guard lock(reportSlotEnabledMutex_); + std::lock_guard lock(reportSlotEnabledMutex_); if (!ReportSlotEnable()) { g_reportSlotFlag = false; @@ -1541,7 +1542,7 @@ void NotificationAnalyticsUtil::ExecuteSlotReportList() bool NotificationAnalyticsUtil::ReportSlotEnable() { - std::lock_guard lock(slotEnabledListMutex_); + std::lock_guard lock(slotEnabledListMutex_); if (slotEnabledList_.empty()) { ANS_LOGI("report end"); return false; @@ -1590,7 +1591,7 @@ bool NotificationAnalyticsUtil::BuildSlotReportCache(ReportCache &reportCache, bool NotificationAnalyticsUtil::CheckSlotNeedReport() { - std::lock_guard lock(lastReportTimeMutex_); + std::lock_guard lock(lastReportTimeMutex_); auto now = GetCurrentTime(); if (lastReportTime_ != 0 && abs(now - lastReportTime_) <= SLOT_REPORT_INTERVAL) { ANS_LOGD("no need report"); @@ -1616,7 +1617,7 @@ bool NotificationAnalyticsUtil::GetAllSlotMessageCache(const int32_t &userId) ANS_LOGW("slotEnablesMap size %{public}zu", slotEnablesMap.size()); return false; } - std::lock_guard lock(slotEnabledListMutex_); + std::lock_guard lock(slotEnabledListMutex_); for (const auto& budleEntry : slotEnablesMap) { std::string budleEntryKey = budleEntry.first; // enable diff --git a/services/ans/src/notification_extension/distributed_device_data_service.cpp b/services/ans/src/notification_extension/distributed_device_data_service.cpp index 4c2697717..e6cc2df41 100644 --- a/services/ans/src/notification_extension/distributed_device_data_service.cpp +++ b/services/ans/src/notification_extension/distributed_device_data_service.cpp @@ -30,7 +30,7 @@ DistributedDeviceDataService& DistributedDeviceDataService::GetInstance() void DistributedDeviceDataService::ResetTargetDevice(const std::string& deviceType, const std::string& deviceId) { - std::lock_guard lock(lock_); + std::lock_guard lock(lock_); for (auto itemIter = devicesData_.begin(); itemIter != devicesData_.end(); itemIter++) { if (itemIter->deviceType == deviceType && itemIter->deviceId == deviceId) { devicesData_.erase(itemIter); @@ -43,7 +43,7 @@ void DistributedDeviceDataService::ResetTargetDevice(const std::string& deviceTy int32_t DistributedDeviceDataService::SetDeviceSyncSwitch(const std::string& deviceType, const std::string& deviceId, bool notificationEnable, bool liveViewEnable) { - std::lock_guard lock(lock_); + std::lock_guard lock(lock_); for (auto itemIter = devicesData_.begin(); itemIter != devicesData_.end(); itemIter++) { if (itemIter->deviceType == deviceType && itemIter->deviceId == deviceId) { itemIter->liveViewSyncEnable = liveViewEnable; @@ -73,7 +73,7 @@ int32_t DistributedDeviceDataService::SetDeviceSyncSwitch(const std::string& dev int32_t DistributedDeviceDataService::SetTargetDeviceBundleList(const std::string& deviceType, const std::string& deviceId, int operatorType, const std::vector& bundleList) { - std::lock_guard lock(lock_); + std::lock_guard lock(lock_); for (auto itemIter = devicesData_.begin(); itemIter != devicesData_.end(); itemIter++) { if (itemIter->deviceType != deviceType || itemIter->deviceId != deviceId) { continue; @@ -122,7 +122,7 @@ int32_t DistributedDeviceDataService::SetTargetDeviceBundleList(const std::strin int32_t DistributedDeviceDataService::GetTargetDeviceBundleList(const std::string& deviceType, const std::string& deviceId, std::vector& bundleList) { - std::lock_guard lock(lock_); + std::lock_guard lock(lock_); for (auto& item : devicesData_) { if (item.deviceType == deviceType && item.deviceId == deviceId) { bundleList.assign(item.installedBundles.begin(), item.installedBundles.end()); @@ -136,7 +136,7 @@ int32_t DistributedDeviceDataService::GetTargetDeviceBundleList(const std::strin bool DistributedDeviceDataService::CheckDeviceBundleExist(const std::string& deviceType, const std::string& deviceId, const std::string bundleName) { - std::lock_guard lock(lock_); + std::lock_guard lock(lock_); for (auto& item : devicesData_) { if (item.deviceType == deviceType && item.deviceId == deviceId) { return item.installedBundles.count(bundleName); @@ -149,7 +149,7 @@ bool DistributedDeviceDataService::CheckDeviceBundleExist(const std::string& dev bool DistributedDeviceDataService::GetDeviceNotificationEnable(const std::string& deviceType, const std::string& deviceId) { - std::lock_guard lock(lock_); + std::lock_guard lock(lock_); for (auto& item : devicesData_) { if (item.deviceType == deviceType && item.deviceId == deviceId) { return item.notificationSyncEnable; @@ -161,7 +161,7 @@ bool DistributedDeviceDataService::GetDeviceNotificationEnable(const std::string bool DistributedDeviceDataService::GetDeviceLiveViewEnable(const std::string& deviceType, const std::string& deviceId) { - std::lock_guard lock(lock_); + std::lock_guard lock(lock_); for (auto& item : devicesData_) { if (item.deviceType == deviceType && item.deviceId == deviceId) { return item.liveViewSyncEnable; diff --git a/services/ans/src/notification_extension/distributed_extension_service.cpp b/services/ans/src/notification_extension/distributed_extension_service.cpp index 37698ad0c..c47cb5a1c 100644 --- a/services/ans/src/notification_extension/distributed_extension_service.cpp +++ b/services/ans/src/notification_extension/distributed_extension_service.cpp @@ -272,7 +272,7 @@ void DistributedExtensionService::OnDeviceOnline(const DmDeviceInfo &deviceInfo) ANS_LOGE("Dans handler is null ptr."); return; } - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); DistributedDeviceDataService::GetInstance().ResetTargetDevice( DeviceTypeToTypeString(deviceInfo.deviceTypeId), deviceInfo.deviceId); handler(deviceInfo.deviceId, udid, deviceInfo.deviceTypeId, deviceInfo.networkId); @@ -356,7 +356,7 @@ void DistributedExtensionService::OnDeviceOffline(const DmDeviceInfo &deviceInfo return; } std::function offlineTask = std::bind([&, deviceInfo]() { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); if (deviceMap_.count(deviceInfo.deviceId) == 0) { ANS_LOGE("Not target device %{public}s", StringAnonymous(deviceInfo.deviceId).c_str()); return; @@ -385,7 +385,7 @@ void DistributedExtensionService::OnDeviceChanged(const DmDeviceInfo &deviceInfo return; } std::function changeTask = std::bind([&, deviceInfo]() { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); if (deviceMap_.count(deviceInfo.deviceId) == 0) { ANS_LOGE("Not target device %{public}s", StringAnonymous(deviceInfo.deviceId).c_str()); return; diff --git a/services/ans/src/notification_extension/notification_operation_service.cpp b/services/ans/src/notification_extension/notification_operation_service.cpp index c94d543b6..486af5498 100644 --- a/services/ans/src/notification_extension/notification_operation_service.cpp +++ b/services/ans/src/notification_extension/notification_operation_service.cpp @@ -60,7 +60,7 @@ void DistributedOperationService::AddOperation(const std::string& hashCode, } uint64_t timerId = timer->CreateTimer(timerInfo); timer->StartTimer(timerId, expiredTime); - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iterCallback = callbackMap_.find(hashCode); if (iterCallback != callbackMap_.end()) { ANS_LOGW("Operation callback has same key %{public}s.", hashCode.c_str()); @@ -84,7 +84,7 @@ void DistributedOperationService::AddOperation(const std::string& hashCode, void DistributedOperationService::RemoveOperationResponse(const std::string& hashCode) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iterCallback = callbackMap_.find(hashCode); if (iterCallback != callbackMap_.end()) { callbackMap_.erase(iterCallback); @@ -106,7 +106,7 @@ void DistributedOperationService::RemoveOperationResponse(const std::string& has void DistributedOperationService::ReplyOperationResponse(const std::string& hashCode, int32_t result) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iterCallback = callbackMap_.find(hashCode); if (iterCallback != callbackMap_.end()) { iterCallback->second->OnOperationCallback(result); diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index dbdb1ecdf..aed11ea2e 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -38,7 +38,7 @@ namespace Notification { namespace { const static std::string KEY_BUNDLE_LABEL = "label_ans_bundle_"; } -std::mutex NotificationPreferences::instanceMutex_; +ffrt::mutex NotificationPreferences::instanceMutex_; std::shared_ptr NotificationPreferences::instance_; NotificationPreferences::NotificationPreferences() @@ -55,7 +55,7 @@ NotificationPreferences::NotificationPreferences() std::shared_ptr NotificationPreferences::GetInstance() { if (instance_ == nullptr) { - std::lock_guard lock(instanceMutex_); + std::lock_guard lock(instanceMutex_); if (instance_ == nullptr) { auto instance = std::make_shared(); instance_ = instance; @@ -76,7 +76,7 @@ ErrCode NotificationPreferences::AddNotificationSlots( NotificationAnalyticsUtil::ReportModifyEvent(message); return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = ERR_OK; for (auto slot : slots) { @@ -105,7 +105,7 @@ ErrCode NotificationPreferences::AddNotificationBundleProperty(const sptrGetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; NotificationPreferencesInfo::BundleInfo bundleInfo; preferencesInfo.SetBundleInfo(bundleInfo); @@ -131,7 +131,7 @@ ErrCode NotificationPreferences::RemoveNotificationSlot( message.Message(bundleOption->GetBundleName() + "_" +std::to_string(bundleOption->GetUid()) + " slotType: " + std::to_string(static_cast(slotType))); message.SlotType(static_cast(slotType)); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = ERR_OK; result = CheckSlotForRemoveSlot(bundleOption, slotType, preferencesInfo); @@ -160,7 +160,7 @@ ErrCode NotificationPreferences::RemoveNotificationAllSlots(const sptrGetBundleName() + "_" +std::to_string(bundleOption->GetUid())); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = ERR_OK; NotificationPreferencesInfo::BundleInfo bundleInfo; @@ -196,7 +196,7 @@ ErrCode NotificationPreferences::RemoveNotificationForBundle(const sptrGetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = ERR_OK; @@ -226,7 +226,7 @@ ErrCode NotificationPreferences::UpdateNotificationSlots( } HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_5, EventBranchId::BRANCH_2) .BundleName(bundleOption->GetBundleName()); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = ERR_OK; for (auto slotIter : slots) { @@ -263,7 +263,7 @@ ErrCode NotificationPreferences::GetNotificationSlot(const sptr lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (GetBundleInfo(preferencesInfo_, bundleOption, bundleInfo)) { if (!bundleInfo.GetSlot(type, slot)) { result = ERR_ANS_PREFERENCES_NOTIFICATION_SLOT_TYPE_NOT_EXIST; @@ -290,7 +290,7 @@ ErrCode NotificationPreferences::GetNotificationAllSlots( ErrCode result = ERR_OK; NotificationPreferencesInfo::BundleInfo bundleInfo; - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (GetBundleInfo(preferencesInfo_, bundleOption, bundleInfo)) { bundleInfo.GetAllSlots(slots); } else { @@ -310,7 +310,7 @@ ErrCode NotificationPreferences::GetNotificationSlotsNumForBundle( ErrCode result = ERR_OK; NotificationPreferencesInfo::BundleInfo bundleInfo; - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (GetBundleInfo(preferencesInfo_, bundleOption, bundleInfo)) { num = static_cast(bundleInfo.GetAllSlotsSize()); } else { @@ -337,7 +337,7 @@ ErrCode NotificationPreferences::SetNotificationSlotFlagsForBundle( return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = SetBundleProperty(preferencesInfo, bundleOption, BundleType::BUNDLE_SLOTFLGS_TYPE, slotFlags); if (result == ERR_OK) { @@ -375,7 +375,7 @@ ErrCode NotificationPreferences::SetShowBadge(const sptrGetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = SetBundleProperty(preferencesInfo, bundleOption, BundleType::BUNDLE_SHOW_BADGE_TYPE, enable); if (result == ERR_OK) { @@ -400,7 +400,7 @@ ErrCode NotificationPreferences::SetImportance( if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = SetBundleProperty(preferencesInfo, bundleOption, BundleType::BUNDLE_IMPORTANCE_TYPE, importance); if (result == ERR_OK) { @@ -424,7 +424,7 @@ ErrCode NotificationPreferences::SetTotalBadgeNums( if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = SetBundleProperty(preferencesInfo, bundleOption, BundleType::BUNDLE_BADGE_TOTAL_NUM_TYPE, num); if (result == ERR_OK) { @@ -450,7 +450,7 @@ ErrCode NotificationPreferences::SetNotificationsEnabledForBundle( return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = SetBundleProperty(preferencesInfo, bundleOption, BundleType::BUNDLE_ENABLE_NOTIFICATION_TYPE, enabled); @@ -467,7 +467,7 @@ ErrCode NotificationPreferences::GetNotificationsEnabled(const int32_t &userId, } ErrCode result = ERR_OK; - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (!preferencesInfo_.GetEnabledAllNotification(userId, enabled)) { result = ERR_ANS_INVALID_PARAM; } @@ -479,7 +479,7 @@ ErrCode NotificationPreferences::SetNotificationsEnabled(const int32_t &userId, if (userId <= SUBSCRIBE_USER_INIT) { return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; preferencesInfo.SetEnabledAllNotification(userId, enabled); ErrCode result = ERR_OK; @@ -506,7 +506,7 @@ ErrCode NotificationPreferences::SetHasPoppedDialog(const sptr lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; ErrCode result = ERR_OK; result = SetBundleProperty(preferencesInfo, bundleOption, BundleType::BUNDLE_POPPED_DIALOG_TYPE, hasPopped); @@ -524,7 +524,7 @@ ErrCode NotificationPreferences::GetDoNotDisturbDate(const int32_t &userId, } ErrCode result = ERR_OK; - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; if (!preferencesInfo.GetDoNotDisturbDate(userId, date)) { result = ERR_ANS_INVALID_PARAM; @@ -539,7 +539,7 @@ ErrCode NotificationPreferences::SetDoNotDisturbDate(const int32_t &userId, if (userId <= SUBSCRIBE_USER_INIT) { return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; preferencesInfo.SetDoNotDisturbDate(userId, date); @@ -572,7 +572,7 @@ ErrCode NotificationPreferences::AddDoNotDisturbProfiles( } profile->SetProfileTrustList(trustList); } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; preferencesInfo.AddDoNotDisturbProfiles(userId, profiles); if (preferncesDB_ == nullptr) { @@ -617,7 +617,7 @@ ErrCode NotificationPreferences::RemoveDoNotDisturbProfiles( return ERR_ANS_INVALID_PARAM; } } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; preferencesInfo.RemoveDoNotDisturbProfiles(userId, profiles); if (preferncesDB_ == nullptr) { @@ -662,7 +662,7 @@ ErrCode NotificationPreferences::UpdateDoNotDisturbProfiles(int32_t userId, int6 ANS_LOGE("profile is nullptr"); return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; if (preferencesInfo.GetDoNotDisturbProfiles(profileId, userId, profile)) { auto trustList = profile->GetProfileTrustList(); @@ -699,7 +699,7 @@ void NotificationPreferences::UpdateCloneBundleInfo(int32_t userId, } bundleOption->SetBundleName(cloneBundleInfo.GetBundleName()); bundleOption->SetUid(cloneBundleInfo.GetUid()); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; if (!GetBundleInfo(preferencesInfo, bundleOption, bundleInfo)) { bundleInfo.SetBundleName(cloneBundleInfo.GetBundleName()); @@ -753,7 +753,7 @@ void NotificationPreferences::UpdateCloneBundleInfo(int32_t userId, void NotificationPreferences::GetAllCLoneBundlesInfo(int32_t userId, std::vector &cloneBundles) { - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; std::unordered_map bundlesMap; if (GetBatchKvsFromDb(KEY_BUNDLE_LABEL, bundlesMap, userId) != ERR_OK) { @@ -768,14 +768,14 @@ void NotificationPreferences::GetAllCLoneBundlesInfo(int32_t userId, void NotificationPreferences::GetDoNotDisturbProfileListByUserId(int32_t userId, std::vector> &profiles) { - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); preferencesInfo_.GetAllDoNotDisturbProfiles(userId, profiles); } ErrCode NotificationPreferences::GetAllNotificationEnabledBundles(std::vector &bundleOption) { ANS_LOGD("called"); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (preferncesDB_ == nullptr) { return ERR_ANS_SERVICE_NOT_READY; } @@ -789,7 +789,7 @@ ErrCode NotificationPreferences::GetAllLiveViewEnabledBundles(const int32_t user std::vector &bundleOption) { ANS_LOGD("called"); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); return preferencesInfo_.GetAllLiveViewEnabledBundles(userId, bundleOption); } @@ -797,7 +797,7 @@ ErrCode NotificationPreferences::GetAllDistribuedEnabledBundles(int32_t userId, const std::string &deviceType, std::vector &bundleOption) { ANS_LOGD("called"); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (preferncesDB_ == nullptr) { return ERR_ANS_SERVICE_NOT_READY; } @@ -810,7 +810,7 @@ ErrCode NotificationPreferences::GetAllDistribuedEnabledBundles(int32_t userId, ErrCode NotificationPreferences::ClearNotificationInRestoreFactorySettings() { ErrCode result = ERR_OK; - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (!preferncesDB_->RemoveAllDataFromDisturbeDB()) { result = ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; } @@ -824,7 +824,7 @@ ErrCode NotificationPreferences::ClearNotificationInRestoreFactorySettings() ErrCode NotificationPreferences::GetDoNotDisturbProfile( int64_t profileId, int32_t userId, sptr &profile) { - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (!preferencesInfo_.GetDoNotDisturbProfiles(profileId, userId, profile)) { return ERR_ANS_NO_PROFILE_TEMPLATE; } @@ -842,7 +842,7 @@ void NotificationPreferences::RemoveDoNotDisturbProfileTrustList( int32_t appIndex = bundleOption->GetAppIndex(); auto bundleName = bundleOption->GetBundleName(); ANS_LOGI("Remove %{public}s %{public}d %{public}d.", bundleName.c_str(), uid, appIndex); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo preferencesInfo = preferencesInfo_; std::vector> profiles; @@ -1006,7 +1006,7 @@ ErrCode NotificationPreferences::GetBundleProperty( { ErrCode result = ERR_OK; NotificationPreferencesInfo::BundleInfo bundleInfo; - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (GetBundleInfo(preferencesInfo_, bundleOption, bundleInfo)) { switch (type) { case BundleType::BUNDLE_IMPORTANCE_TYPE: @@ -1088,7 +1088,7 @@ ErrCode NotificationPreferences::SetDistributedEnabledByBundle(const sptr lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo::BundleInfo bundleInfo; bundleInfo.SetBundleName(bundleOption->GetBundleName()); bundleInfo.SetBundleUid(bundleOption->GetUid()); @@ -1106,7 +1106,7 @@ ErrCode NotificationPreferences::IsDistributedEnabledByBundle(const sptr lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo::BundleInfo bundleInfo; bundleInfo.SetBundleName(bundleOption->GetBundleName()); bundleInfo.SetBundleUid(bundleOption->GetUid()); @@ -1124,7 +1124,7 @@ ErrCode NotificationPreferences::SetSilentReminderEnabled(const sptr lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo::SilentReminderInfo silentReminderInfo; silentReminderInfo.bundleName = bundleOption->GetBundleName(); silentReminderInfo.uid = bundleOption->GetUid(); @@ -1146,7 +1146,7 @@ ErrCode NotificationPreferences::IsSilentReminderEnabled(const sptr lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); NotificationPreferencesInfo::SilentReminderInfo silentReminderInfo; if (preferencesInfo_.GetSilentReminderInfo(bundleOption, silentReminderInfo)) { enableStatus = silentReminderInfo.enableStatus; @@ -1167,7 +1167,7 @@ void NotificationPreferences::RemoveSilentEnabledDbByBundle(const sptr lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); preferncesDB_->RemoveSilentEnabledDbByBundle(bundleOption->GetBundleName(), bundleOption->GetUid()); preferencesInfo_.RemoveSilentReminderInfo(bundleOption); } @@ -1177,7 +1177,7 @@ ErrCode NotificationPreferences::SetDistributedEnabled( const std::string &deviceType, const NotificationConstant::SWITCH_STATE &enableStatus) { ANS_LOGD("%{public}s", __FUNCTION__); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; storeDBResult = preferncesDB_->PutDistributedEnabled(deviceType, enableStatus); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; @@ -1187,7 +1187,7 @@ ErrCode NotificationPreferences::IsDistributedEnabled( const std::string &deviceType, NotificationConstant::SWITCH_STATE &enableStatus) { ANS_LOGD("%{public}s", __FUNCTION__); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; enableStatus = NotificationConstant::SWITCH_STATE::SYSTEM_DEFAULT_OFF; storeDBResult = preferncesDB_->GetDistributedEnabled(deviceType, enableStatus); @@ -1198,7 +1198,7 @@ ErrCode NotificationPreferences::GetDistributedAuthStatus( const std::string &deviceType, const std::string &deviceId, int32_t targetUserId, bool &isAuth) { ANS_LOGD("%{public}s", __FUNCTION__); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; storeDBResult = preferncesDB_->GetDistributedAuthStatus(deviceType, deviceId, targetUserId, isAuth); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; @@ -1208,7 +1208,7 @@ ErrCode NotificationPreferences::SetDistributedAuthStatus( const std::string &deviceType, const std::string &deviceId, int32_t targetUserId, bool isAuth) { ANS_LOGD("%{public}s", __FUNCTION__); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; storeDBResult = preferncesDB_->SetDistributedAuthStatus(deviceType, deviceId, targetUserId, isAuth); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; @@ -1221,7 +1221,7 @@ ErrCode NotificationPreferences::SetSmartReminderEnabled(const std::string &devi return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; storeDBResult = preferncesDB_->SetSmartReminderEnabled(deviceType, enabled); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; @@ -1234,7 +1234,7 @@ ErrCode NotificationPreferences::IsSmartReminderEnabled(const std::string &devic return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; storeDBResult = preferncesDB_->IsSmartReminderEnabled(deviceType, enabled); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; @@ -1248,7 +1248,7 @@ ErrCode NotificationPreferences::SetDistributedEnabledBySlot( return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; storeDBResult = preferncesDB_->SetDistributedEnabledBySlot(slotType, deviceType, enabled); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; @@ -1262,7 +1262,7 @@ ErrCode NotificationPreferences::IsDistributedEnabledBySlot( return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; storeDBResult = preferncesDB_->IsDistributedEnabledBySlot(slotType, deviceType, enabled); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; @@ -1271,7 +1271,7 @@ ErrCode NotificationPreferences::IsDistributedEnabledBySlot( void NotificationPreferences::InitSettingFromDisturbDB(int32_t userId) { ANS_LOGI("%{public}s userId is %{public}d", __FUNCTION__, userId); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (preferncesDB_ != nullptr) { preferncesDB_->ParseFromDisturbeDB(preferencesInfo_, userId); } @@ -1280,7 +1280,7 @@ void NotificationPreferences::InitSettingFromDisturbDB(int32_t userId) void NotificationPreferences::RemoveSettings(int32_t userId) { ANS_LOGD("%{public}s", __FUNCTION__); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); preferencesInfo_.RemoveNotificationEnable(userId); preferencesInfo_.RemoveDoNotDisturbDate(userId); if (preferncesDB_ != nullptr) { @@ -1312,7 +1312,7 @@ void NotificationPreferences::RemoveEnabledDbByBundle(const sptr lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); preferncesDB_->RemoveEnabledDbByBundleName(bundleOption->GetBundleName(), bundleOption->GetUid()); } } @@ -1517,7 +1517,7 @@ bool NotificationPreferences::DelBatchCloneBundleInfo(const int32_t &userId, ErrCode NotificationPreferences::SetDisableNotificationInfo(const sptr ¬ificationDisable) { ANS_LOGD("called"); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); preferencesInfo_.SetDisableNotificationInfo(notificationDisable); if (preferncesDB_ == nullptr) { ANS_LOGE("the prefernces db is nullptr"); @@ -1533,7 +1533,7 @@ ErrCode NotificationPreferences::SetDisableNotificationInfo(const sptr lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (preferencesInfo_.GetDisableNotificationInfo(notificationDisable)) { ANS_LOGD("info get disable notification success"); return true; @@ -1555,7 +1555,7 @@ bool NotificationPreferences::GetDisableNotificationInfo(NotificationDisable &no bool NotificationPreferences::GetUserDisableNotificationInfo(int32_t userId, NotificationDisable ¬ificationDisable) { - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (preferencesInfo_.GetUserDisableNotificationInfo(userId, notificationDisable)) { ANS_LOGD("info get disable notification success"); return true; @@ -1609,7 +1609,7 @@ bool NotificationPreferences::GetkioskAppTrustList(std::vector &kio ErrCode NotificationPreferences::SetDistributedDevicelist(std::vector &deviceTypes, const int32_t &userId) { ANS_LOGD("%{public}s", __FUNCTION__); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; nlohmann::json deviceTypesJson = deviceTypes; std::string deviceTypesjsonString = deviceTypesJson.dump(); @@ -1620,7 +1620,7 @@ ErrCode NotificationPreferences::SetDistributedDevicelist(std::vector &deviceTypes) { ANS_LOGD("%{public}s", __FUNCTION__); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); std::string value = ""; auto storeDBResult = preferncesDB_->GetDistributedDevicelist(value); if (!storeDBResult) { @@ -1659,7 +1659,7 @@ ErrCode NotificationPreferences::SetSubscriberExistFlag(const std::string& devic return ERR_ANS_SERVICE_NOT_READY; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = preferncesDB_->SetSubscriberExistFlag(deviceType, existFlag); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; } @@ -1675,7 +1675,7 @@ ErrCode NotificationPreferences::GetSubscriberExistFlag(const std::string& devic return ERR_ANS_SERVICE_NOT_READY; } - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = preferncesDB_->GetSubscriberExistFlag(deviceType, existFlag); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; } @@ -1712,7 +1712,7 @@ ErrCode NotificationPreferences::SetHashCodeRule(const int32_t uid, const uint32 { ANS_LOGD("%{public}s", __FUNCTION__); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); bool storeDBResult = true; storeDBResult = preferncesDB_->SetHashCodeRule(uid, type); return storeDBResult ? ERR_OK : ERR_ANS_PREFERENCES_NOTIFICATION_DB_OPERATION_FAILED; @@ -1721,7 +1721,7 @@ ErrCode NotificationPreferences::SetHashCodeRule(const int32_t uid, const uint32 uint32_t NotificationPreferences::GetHashCodeRule(const int32_t uid) { ANS_LOGD("%{public}s", __FUNCTION__); - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); uint32_t result = 0; result = preferncesDB_->GetHashCodeRule(uid); ANS_LOGI("uid = %{public}d result = %{public}d", uid, result); diff --git a/services/ans/src/notification_rdb_data_mgr.cpp b/services/ans/src/notification_rdb_data_mgr.cpp index 198a1f0db..62924f79e 100644 --- a/services/ans/src/notification_rdb_data_mgr.cpp +++ b/services/ans/src/notification_rdb_data_mgr.cpp @@ -99,7 +99,7 @@ int32_t NotificationDataMgr::Init() { ANS_LOGD("Create rdbStore"); { - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ != nullptr) { ANS_LOGD("notification rdb has existed"); return NativeRdb::E_OK; @@ -116,9 +116,9 @@ int32_t NotificationDataMgr::Init() rdbStoreConfig.SetHaMode(NativeRdb::HAMode::MAIN_REPLICA); rdbStoreConfig.SetClearMemorySize(NOTIFICATION_RDB_MAX_MEMORY_SIZE); RdbStoreDataCallBackNotificationStorage rdbDataCallBack_(notificationRdbConfig_); - std::lock_guard lock(createdTableMutex_); + std::lock_guard lock(createdTableMutex_); { - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); int32_t ret = NativeRdb::E_OK; rdbStore_ = NativeRdb::RdbHelper::GetRdbStore(rdbStoreConfig, notificationRdbConfig_.version, rdbDataCallBack_, ret); @@ -157,10 +157,10 @@ int32_t NotificationDataMgr::InitCreatedTables() int32_t NotificationDataMgr::Destroy() { ANS_LOGD("Destory rdbStore"); - std::lock_guard lock(createdTableMutex_); + std::lock_guard lock(createdTableMutex_); createdTables_.clear(); { - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -188,7 +188,7 @@ int32_t NotificationDataMgr::InsertData(const std::string &key, const std::strin ANS_LOGE("Get user table name failed."); return NativeRdb::E_ERROR; } - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -223,7 +223,7 @@ int32_t NotificationDataMgr::InsertData(const std::string &key, const std::vecto ANS_LOGE("Get user table name failed."); return NativeRdb::E_ERROR; } - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -259,7 +259,7 @@ int32_t NotificationDataMgr::InsertBatchData(const std::unordered_map lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -292,7 +292,7 @@ int32_t NotificationDataMgr::DeleteData(const std::string &key, const int32_t &u ANS_LOGD("DeleteData start"); std::vector operatedTables = GenerateOperatedTables(userId); std::reverse(operatedTables.begin(), operatedTables.end()); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -333,7 +333,7 @@ int32_t NotificationDataMgr::DeleteBatchData(const std::vector &key { std::vector operatedTables = GenerateOperatedTables(userId); std::reverse(operatedTables.begin(), operatedTables.end()); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -370,7 +370,7 @@ int32_t NotificationDataMgr::QueryData(const std::string &key, std::string &valu { ANS_LOGD("QueryData start"); std::vector operatedTables = GenerateOperatedTables(userId); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -429,7 +429,7 @@ int32_t NotificationDataMgr::QueryData(const std::string tableName, const std::s int32_t NotificationDataMgr::QueryData(const std::string &key, std::vector &values, const int32_t &userId) { std::vector operatedTables = GenerateOperatedTables(userId); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -488,7 +488,7 @@ int32_t NotificationDataMgr::QueryDataBeginWithKey( { ANS_LOGD("QueryData BeginWithKey start"); std::vector operatedTables = GenerateOperatedTables(userId); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -567,7 +567,7 @@ int32_t NotificationDataMgr::QueryDataContainsWithKey( { ANS_LOGD("QueryDataContainsWithKey start"); std::vector operatedTables = GenerateOperatedTables(userId); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -640,7 +640,7 @@ int32_t NotificationDataMgr::QueryAllData(std::unordered_map operatedTables = GenerateOperatedTables(userId); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -718,10 +718,10 @@ int32_t NotificationDataMgr::DropUserTable(const int32_t userId) std::stringstream stream; stream << notificationRdbConfig_.tableName << keySpliter << userId; std::string tableName = stream.str(); - std::lock_guard lock(createdTableMutex_); + std::lock_guard lock(createdTableMutex_); int32_t ret = NativeRdb::E_OK; { - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { return NativeRdb::E_ERROR; } @@ -749,9 +749,9 @@ int32_t NotificationDataMgr::GetUserTableName(const int32_t &userId, std::string stream << notificationRdbConfig_.tableName << keySpliter << userId; tableName = stream.str(); if (createdTables_.find(tableName) == createdTables_.end()) { - std::lock_guard lock(createdTableMutex_); + std::lock_guard lock(createdTableMutex_); if (createdTables_.find(tableName) == createdTables_.end()) { - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { return NativeRdb::E_ERROR; } @@ -780,7 +780,7 @@ std::vector NotificationDataMgr::GenerateOperatedTables(const int32 std::stringstream stream; stream << notificationRdbConfig_.tableName << keySpliter << userId; std::string tableName = stream.str(); - std::lock_guard lock(createdTableMutex_); + std::lock_guard lock(createdTableMutex_); if (createdTables_.find(tableName) != createdTables_.end()) { operatedTables.emplace_back(tableName); } diff --git a/services/ans/src/system_live_view/advanced_notification_system_live_view_service.cpp b/services/ans/src/system_live_view/advanced_notification_system_live_view_service.cpp index f827c1021..701f235d2 100644 --- a/services/ans/src/system_live_view/advanced_notification_system_live_view_service.cpp +++ b/services/ans/src/system_live_view/advanced_notification_system_live_view_service.cpp @@ -166,7 +166,7 @@ ErrCode AdvancedNotificationService::RemoveSystemLiveViewNotifications( ErrCode AdvancedNotificationService::RemoveSystemLiveViewNotificationsOfSa(int32_t uid) { { - std::lock_guard lock(delayNotificationMutext_); + std::lock_guard lock(delayNotificationMutext_); for (auto iter = delayNotificationList_.begin(); iter != delayNotificationList_.end();) { if ((*iter).first->notification->GetNotificationRequest().GetCreatorUid() == uid && (*iter).first->notification->GetNotificationRequest().IsInProgress()) { diff --git a/services/distributed/include/base/distributed_client.h b/services/distributed/include/base/distributed_client.h index 929926879..eb6285d2e 100644 --- a/services/distributed/include/base/distributed_client.h +++ b/services/distributed/include/base/distributed_client.h @@ -21,6 +21,7 @@ #include #include "distributed_device_data.h" #include "box_base.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -43,7 +44,7 @@ private: ~DistributedClient() = default; std::string ShutdownReasonToString(ShutdownReason reason); - std::mutex clientLock_; + ffrt::mutex clientLock_; DistributedDeviceInfo localDevice_; std::map socketsId_; std::map networksId_; diff --git a/services/distributed/include/base/distributed_server.h b/services/distributed/include/base/distributed_server.h index 21e920023..602c787fd 100644 --- a/services/distributed/include/base/distributed_server.h +++ b/services/distributed/include/base/distributed_server.h @@ -20,6 +20,7 @@ #include #include #include "distributed_device_data.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -38,7 +39,7 @@ private: DistributedServer() = default; ~DistributedServer() = default; std::atomic init = false; - std::mutex serverLock_; + ffrt::mutex serverLock_; DistributedDeviceInfo localDevice_; std::vector> peerSockets_; std::map serverSocket_; diff --git a/services/distributed/include/distributed_database.h b/services/distributed/include/distributed_database.h index 6833350ea..e963fb182 100644 --- a/services/distributed/include/distributed_database.h +++ b/services/distributed/include/distributed_database.h @@ -27,6 +27,7 @@ #include "distributed_database_callback.h" #include "distributed_device_callback.h" #include "distributed_flow_control.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -131,7 +132,7 @@ private: void GetKvStore(); bool CheckKvStore(); - std::mutex mutex_; + ffrt::mutex mutex_; std::unique_ptr kvDataManager_; std::shared_ptr kvStore_; std::shared_ptr databaseCb_; diff --git a/services/distributed/include/distributed_notification_manager.h b/services/distributed/include/distributed_notification_manager.h index e3ee32b96..3d4a23e68 100644 --- a/services/distributed/include/distributed_notification_manager.h +++ b/services/distributed/include/distributed_notification_manager.h @@ -172,7 +172,7 @@ private: std::shared_ptr databaseCb_; std::shared_ptr deviceCb_; IDistributedCallback callback_ = {0}; - std::mutex callbackMutex_; + ffrt::mutex callbackMutex_; std::shared_ptr distributedQueue_ = nullptr; DECLARE_DELAYED_SINGLETON(DistributedNotificationManager); diff --git a/services/distributed/include/distributed_preferences_database.h b/services/distributed/include/distributed_preferences_database.h index 282ea1c22..4ae114208 100644 --- a/services/distributed/include/distributed_preferences_database.h +++ b/services/distributed/include/distributed_preferences_database.h @@ -26,6 +26,7 @@ #include "distributed_database_callback.h" #include "distributed_device_callback.h" #include "distributed_flow_control.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -84,7 +85,7 @@ private: void GetKvStore(); bool CheckKvStore(); - std::mutex mutex_; + ffrt::mutex mutex_; std::unique_ptr kvDataManager_; std::shared_ptr kvStore_; diff --git a/services/distributed/include/helper/ability_manager_helper.h b/services/distributed/include/helper/ability_manager_helper.h index 0a5d71901..9f85a51e6 100644 --- a/services/distributed/include/helper/ability_manager_helper.h +++ b/services/distributed/include/helper/ability_manager_helper.h @@ -39,7 +39,7 @@ public: void DisconnectServiceAbility(const std::string &eventId, const AppExecFwk::ElementName& element); private: - std::mutex connectionLock_; + ffrt::mutex connectionLock_; std::shared_ptr operationQueue_ = nullptr; std::map> operationConnection_; }; diff --git a/services/distributed/include/helper/bundle_resource_helper.h b/services/distributed/include/helper/bundle_resource_helper.h index 99597a6c3..79bd078a1 100644 --- a/services/distributed/include/helper/bundle_resource_helper.h +++ b/services/distributed/include/helper/bundle_resource_helper.h @@ -22,6 +22,7 @@ #include "refbase.h" #include "singleton.h" #include "ans_log_wrapper.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -98,7 +99,7 @@ private: void OnRemoteDied(const wptr &object); sptr bundleMgr_ = nullptr; - std::mutex connectionMutex_; + ffrt::mutex connectionMutex_; sptr deathRecipient_ = nullptr; DECLARE_DELAYED_SINGLETON(BundleResourceHelper) diff --git a/services/distributed/include/helper/distributed_operation_helper.h b/services/distributed/include/helper/distributed_operation_helper.h index 70962c219..1d8bb8e2e 100644 --- a/services/distributed/include/helper/distributed_operation_helper.h +++ b/services/distributed/include/helper/distributed_operation_helper.h @@ -25,6 +25,7 @@ #include "power_mgr_client.h" #include "screenlock_callback_interface.h" #include "notification_operation_info.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -57,7 +58,7 @@ public: private: OperationService() = default; ~OperationService() = default; - std::mutex operationMutex_; + ffrt::mutex operationMutex_; std::map operationInfoMaps_; }; } diff --git a/services/distributed/include/helper/distributed_preference.h b/services/distributed/include/helper/distributed_preference.h index bf139fb9e..6336765ba 100644 --- a/services/distributed/include/helper/distributed_preference.h +++ b/services/distributed/include/helper/distributed_preference.h @@ -19,6 +19,7 @@ #include #include "distributed_rdb_helper.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -38,7 +39,7 @@ public: int32_t GetIconByBundleName(const std::string& bundleName, std::string &icon); int32_t GetSavedBundlesIcon(std::vector& bundleNames); private: - std::mutex preferenceMutex_; + ffrt::mutex preferenceMutex_; std::shared_ptr preferncesDB_ = nullptr; }; } diff --git a/services/distributed/include/helper/distributed_rdb_helper.h b/services/distributed/include/helper/distributed_rdb_helper.h index 39f35f65d..80f4bc342 100644 --- a/services/distributed/include/helper/distributed_rdb_helper.h +++ b/services/distributed/include/helper/distributed_rdb_helper.h @@ -22,6 +22,7 @@ #include "rdb_open_callback.h" #include "rdb_store_config.h" #include "notification_constant.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -116,7 +117,7 @@ private: private: DistributedRdbConfig notificationRdbConfig_; std::shared_ptr rdbStore_; - mutable std::mutex rdbStorePtrMutex_; + mutable ffrt::mutex rdbStorePtrMutex_; }; } diff --git a/services/distributed/include/soft_bus/distributed_device_service.h b/services/distributed/include/soft_bus/distributed_device_service.h index 7c2c463f3..df0f3ff94 100644 --- a/services/distributed/include/soft_bus/distributed_device_service.h +++ b/services/distributed/include/soft_bus/distributed_device_service.h @@ -20,6 +20,7 @@ #include #include "match_box.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -67,7 +68,7 @@ public: #endif private: - std::mutex mapLock_; + ffrt::mutex mapLock_; bool subscribeAllConnect = false; DistributedDeviceInfo localDevice_; std::map peerDevice_; diff --git a/services/distributed/include/soft_bus/distributed_subscribe_service.h b/services/distributed/include/soft_bus/distributed_subscribe_service.h index cec232a77..ee2aacb6e 100644 --- a/services/distributed/include/soft_bus/distributed_subscribe_service.h +++ b/services/distributed/include/soft_bus/distributed_subscribe_service.h @@ -19,6 +19,7 @@ #include "distributed_subscriber.h" #include #include "distributed_device_data.h" +#include "ffrt.h" namespace OHOS { namespace Notification { @@ -30,7 +31,7 @@ public: void SubscribeNotification(const DistributedDeviceInfo peerDevice); void UnSubscribeNotification(const std::string &deviceId, uint16_t deviceType, bool releaseDevice = true); private: - std::mutex mapLock_; + ffrt::mutex mapLock_; std::map> subscriberMap_; }; } diff --git a/services/distributed/include/soft_bus/distributed_unlock_listener_oper_service.h b/services/distributed/include/soft_bus/distributed_unlock_listener_oper_service.h index 30975302a..268edd209 100644 --- a/services/distributed/include/soft_bus/distributed_unlock_listener_oper_service.h +++ b/services/distributed/include/soft_bus/distributed_unlock_listener_oper_service.h @@ -94,7 +94,7 @@ private: const int32_t btnIndex, std::shared_ptr& wantAgentPtr); private: - std::mutex mapLock_; + ffrt::mutex mapLock_; std::shared_ptr operationQueue_ = nullptr; std::vector hashCodeOrder_; std::map timerMap_; diff --git a/services/distributed/src/base/distributed_client.cpp b/services/distributed/src/base/distributed_client.cpp index 6fbf99d7e..58deb0393 100644 --- a/services/distributed/src/base/distributed_client.cpp +++ b/services/distributed/src/base/distributed_client.cpp @@ -31,7 +31,7 @@ DistributedClient& DistributedClient::GetInstance() void DistributedClient::ReleaseClient() { - std::lock_guard lock(clientLock_); + std::lock_guard lock(clientLock_); ANS_LOGI("Release client socket %{public}d.", (int32_t)(socketsId_.size())); for (auto& socketItem : socketsId_) { CloseSocket(socketItem.second); @@ -41,7 +41,7 @@ void DistributedClient::ReleaseClient() void DistributedClient::OnShutdown(int32_t socket, ShutdownReason reason) { - std::lock_guard lock(clientLock_); + std::lock_guard lock(clientLock_); for (auto& socketItem : socketsId_) { if (socketItem.second == socket) { socketItem.second = -1; @@ -55,7 +55,7 @@ void DistributedClient::OnShutdown(int32_t socket, ShutdownReason reason) void DistributedClient::AddDevice(DistributedDeviceInfo peerDevice) { - std::lock_guard lock(clientLock_); + std::lock_guard lock(clientLock_); ANS_LOGI("Distributed client AddDevice %{public}s %{public}s", StringAnonymous(peerDevice.deviceId_).c_str(), StringAnonymous(peerDevice.networkId_).c_str()); networksId_[peerDevice.deviceId_] = peerDevice.networkId_; @@ -69,7 +69,7 @@ void DistributedClient::ReleaseDevice(const std::string &deviceId, uint16_t devi { std::string messageKey = deviceId + '_' + std::to_string(TransDataType::DATA_TYPE_MESSAGE); std::string byteKey = deviceId + '_' + std::to_string(TransDataType::DATA_TYPE_BYTES); - std::lock_guard lock(clientLock_); + std::lock_guard lock(clientLock_); auto socket = socketsId_.find(messageKey); if (socket != socketsId_.end()) { CloseSocket(socket->second); @@ -92,7 +92,7 @@ void DistributedClient::RefreshDevice(const std::string &deviceId, uint16_t devi const std::string &networkId) { ReleaseDevice(deviceId, deviceType); - std::lock_guard lock(clientLock_); + std::lock_guard lock(clientLock_); networksId_[deviceId] = networkId; ANS_LOGI("Distributed refresh device %{public}s %{public}s", StringAnonymous(deviceId).c_str(), StringAnonymous(networkId).c_str()); @@ -106,7 +106,7 @@ int32_t DistributedClient::GetSocketId(const std::string &deviceId, TransDataTyp { std::string key = deviceId + '_' + std::to_string(dataType); { - std::lock_guard lock(clientLock_); + std::lock_guard lock(clientLock_); auto socketItem = socketsId_.find(key); if (socketItem != socketsId_.end() && socketItem->second != -1) { socketId = socketItem->second; @@ -131,7 +131,7 @@ int32_t DistributedClient::GetSocketId(const std::string &deviceId, TransDataTyp return result; } { - std::lock_guard lock(clientLock_); + std::lock_guard lock(clientLock_); socketsId_[key] = socketId; ANS_LOGI("Get socketid insert %{public}s %{public}d", key.c_str(), socketId); } diff --git a/services/distributed/src/base/distributed_server.cpp b/services/distributed/src/base/distributed_server.cpp index 01fd0c645..2f915b16a 100644 --- a/services/distributed/src/base/distributed_server.cpp +++ b/services/distributed/src/base/distributed_server.cpp @@ -39,7 +39,7 @@ void DistributedServer::ReleaseServer() CloseSocket(item.second); } serverSocket_.clear(); - std::lock_guard lock(serverLock_); + std::lock_guard lock(serverLock_); for (auto& item : peerSockets_) { CloseSocket(item->socketId_); } @@ -87,7 +87,7 @@ int32_t DistributedServer::InitServer(const std::string &deviceId, uint16_t devi void DistributedServer::OnBind(int32_t socket, PeerSocketInfo info) { - std::lock_guard lock(serverLock_); + std::lock_guard lock(serverLock_); std::shared_ptr socketInfo = std::make_shared(); socketInfo->pkgName_ = info.pkgName; socketInfo->peerName_ = info.name; @@ -99,7 +99,7 @@ void DistributedServer::OnBind(int32_t socket, PeerSocketInfo info) void DistributedServer::OnShutdown(int32_t socket, ShutdownReason reason) { - std::lock_guard lock(serverLock_); + std::lock_guard lock(serverLock_); for (auto socketInfo = peerSockets_.begin(); socketInfo != peerSockets_.end(); socketInfo++) { if ((*socketInfo)->socketId_ == socket) { diff --git a/services/distributed/src/distributed_database.cpp b/services/distributed/src/distributed_database.cpp index f62f3dc5e..80959814f 100644 --- a/services/distributed/src/distributed_database.cpp +++ b/services/distributed/src/distributed_database.cpp @@ -122,7 +122,7 @@ void DistributedDatabase::GetKvStore() bool DistributedDatabase::CheckKvStore() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (kvStore_ == nullptr) { GetKvStore(); } @@ -140,7 +140,7 @@ bool DistributedDatabase::OnDeviceConnected() bool DistributedDatabase::PutToDistributedDB(const std::string &key, const std::string &value) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (kvStore_ == nullptr) { ANS_LOGE("null kvStore"); @@ -165,7 +165,7 @@ bool DistributedDatabase::PutToDistributedDB(const std::string &key, const std:: bool DistributedDatabase::GetFromDistributedDB(const std::string &key, std::string &value) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (kvStore_ == nullptr) { ANS_LOGE("null kvStore"); @@ -192,7 +192,7 @@ bool DistributedDatabase::GetFromDistributedDB(const std::string &key, std::stri bool DistributedDatabase::GetEntriesFromDistributedDB(const std::string &prefixKey, std::vector &entries) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (kvStore_ == nullptr) { ANS_LOGE("null kvStore"); @@ -216,7 +216,7 @@ bool DistributedDatabase::GetEntriesFromDistributedDB(const std::string &prefixK bool DistributedDatabase::DeleteToDistributedDB(const std::string &key) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (kvStore_ == nullptr) { ANS_LOGE("null kvStore"); @@ -240,7 +240,7 @@ bool DistributedDatabase::DeleteToDistributedDB(const std::string &key) bool DistributedDatabase::ClearDataByDevice(const std::string &deviceId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (kvStore_ == nullptr) { ANS_LOGE("null kvStore"); @@ -263,7 +263,7 @@ bool DistributedDatabase::ClearDataByDevice(const std::string &deviceId) bool DistributedDatabase::GetLocalDeviceId(std::string &deviceId) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckKvDataManager()) { return false; } @@ -289,7 +289,7 @@ bool DistributedDatabase::GetLocalDeviceId(std::string &deviceId) bool DistributedDatabase::GetLocalDeviceInfo(DeviceInfo &localInfo) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckKvDataManager()) { return false; } @@ -310,7 +310,7 @@ bool DistributedDatabase::GetLocalDeviceInfo(DeviceInfo &localInfo) bool DistributedDatabase::GetDeviceInfoList(std::vector &deviceList) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckKvDataManager()) { return false; } @@ -331,7 +331,7 @@ bool DistributedDatabase::GetDeviceInfoList(std::vector &deviceList) bool DistributedDatabase::RecreateDistributedDB() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckKvDataManager()) { return false; } diff --git a/services/distributed/src/distributed_notification_manager.cpp b/services/distributed/src/distributed_notification_manager.cpp index 1d1098bbf..1dbd70250 100644 --- a/services/distributed/src/distributed_notification_manager.cpp +++ b/services/distributed/src/distributed_notification_manager.cpp @@ -62,7 +62,7 @@ DistributedNotificationManager::DistributedNotificationManager() DistributedNotificationManager::~DistributedNotificationManager() { ANS_LOGI("deconstructor"); - std::lock_guard lock(callbackMutex_); + std::lock_guard lock(callbackMutex_); callback_ = {}; } @@ -276,7 +276,7 @@ bool DistributedNotificationManager::PublishCallback( const std::string &deviceId, const std::string &bundleName, sptr &request) { ANS_LOGI("start"); - std::lock_guard lock(callbackMutex_); + std::lock_guard lock(callbackMutex_); if (callback_.OnPublish) { callback_.OnPublish(deviceId, bundleName, request); } @@ -289,7 +289,7 @@ bool DistributedNotificationManager::UpdateCallback( const std::string &deviceId, const std::string &bundleName, sptr &request) { ANS_LOGI("start"); - std::lock_guard lock(callbackMutex_); + std::lock_guard lock(callbackMutex_); if (callback_.OnUpdate) { callback_.OnUpdate(deviceId, bundleName, request); } @@ -302,7 +302,7 @@ bool DistributedNotificationManager::DeleteCallback( const std::string &deviceId, const std::string &bundleName, const std::string &label, int32_t id) { ANS_LOGI("start"); - std::lock_guard lock(callbackMutex_); + std::lock_guard lock(callbackMutex_); if (callback_.OnDelete) { callback_.OnDelete(deviceId, bundleName, label, id); } @@ -415,7 +415,7 @@ ErrCode DistributedNotificationManager::RegisterCallback(const IDistributedCallb ANS_LOGE("Serial queue is invalid."); return ERR_ANS_INVALID_PARAM; } - std::lock_guard lock(callbackMutex_); + std::lock_guard lock(callbackMutex_); callback_ = callback; return ERR_OK; } @@ -423,7 +423,7 @@ ErrCode DistributedNotificationManager::RegisterCallback(const IDistributedCallb ErrCode DistributedNotificationManager::UngegisterCallback() { ANS_LOGD("start"); - std::lock_guard lock(callbackMutex_); + std::lock_guard lock(callbackMutex_); callback_ = {}; return ERR_OK; } diff --git a/services/distributed/src/distributed_preferences_database.cpp b/services/distributed/src/distributed_preferences_database.cpp index 13cee84a8..7d1b62e1a 100644 --- a/services/distributed/src/distributed_preferences_database.cpp +++ b/services/distributed/src/distributed_preferences_database.cpp @@ -90,7 +90,7 @@ bool DistributedPreferencesDatabase::CheckKvStore() bool DistributedPreferencesDatabase::PutToDistributedDB(const std::string &key, const std::string &value) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckKvStore()) { return false; @@ -114,7 +114,7 @@ bool DistributedPreferencesDatabase::PutToDistributedDB(const std::string &key, bool DistributedPreferencesDatabase::GetFromDistributedDB(const std::string &key, std::string &value) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckKvStore()) { return false; } @@ -137,7 +137,7 @@ bool DistributedPreferencesDatabase::GetFromDistributedDB(const std::string &key bool DistributedPreferencesDatabase::GetEntriesFromDistributedDB( const std::string &prefixKey, std::vector &entries) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckKvStore()) { return false; } @@ -156,7 +156,7 @@ bool DistributedPreferencesDatabase::GetEntriesFromDistributedDB( bool DistributedPreferencesDatabase::DeleteToDistributedDB(const std::string &key) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckKvStore()) { return false; @@ -177,7 +177,7 @@ bool DistributedPreferencesDatabase::DeleteToDistributedDB(const std::string &ke bool DistributedPreferencesDatabase::ClearDatabase() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!CheckKvDataManager()) { return false; diff --git a/services/distributed/src/helper/ability_manager_helper.cpp b/services/distributed/src/helper/ability_manager_helper.cpp index aef7414b1..c4a0abed3 100644 --- a/services/distributed/src/helper/ability_manager_helper.cpp +++ b/services/distributed/src/helper/ability_manager_helper.cpp @@ -38,7 +38,7 @@ int AbilityManagerHelper::ConnectAbility(const std::string &eventId, const AAFwk const std::string& userInputKey, const std::string& userInput) { ANS_LOGI("enter, target bundle = %{public}s", want.GetBundle().c_str()); - std::lock_guard lock(connectionLock_); + std::lock_guard lock(connectionLock_); sptr connection = new (std::nothrow) DistributedOperationConnection(eventId, userInputKey, userInput); if (connection == nullptr) { @@ -62,7 +62,7 @@ void AbilityManagerHelper::DisconnectServiceAbility(const std::string &eventId, } std::function task = [this, eventId, element]() { - std::lock_guard lock(connectionLock_); + std::lock_guard lock(connectionLock_); auto iter = operationConnection_.find(eventId); if (iter == operationConnection_.end()) { ANS_LOGI("failed to find connection!"); diff --git a/services/distributed/src/helper/bundle_resource_helper.cpp b/services/distributed/src/helper/bundle_resource_helper.cpp index 9262a30a6..7a8d98063 100644 --- a/services/distributed/src/helper/bundle_resource_helper.cpp +++ b/services/distributed/src/helper/bundle_resource_helper.cpp @@ -31,7 +31,7 @@ BundleResourceHelper::BundleResourceHelper() BundleResourceHelper::~BundleResourceHelper() { - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Disconnect(); } @@ -68,7 +68,7 @@ void BundleResourceHelper::Disconnect() void BundleResourceHelper::OnRemoteDied(const wptr &object) { - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Disconnect(); } @@ -76,7 +76,7 @@ ErrCode BundleResourceHelper::GetBundleInfo(const std::string &bundleName, AppExecFwk::BundleResourceInfo &bundleResourceInfo, const int32_t appIndex) { ErrCode result = 0; - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (bundleMgr_ == nullptr) { ANS_LOGE("GetBundleInfo bundle proxy failed."); @@ -99,7 +99,7 @@ ErrCode BundleResourceHelper::GetAllBundleInfos(int32_t flags, std::vector lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (bundleMgr_ == nullptr) { ANS_LOGE("GetBundleInfo bundle proxy failed."); @@ -141,7 +141,7 @@ ErrCode BundleResourceHelper::GetApplicationInfo(const std::string &appName, int AppExecFwk::ApplicationInfo &appInfo) { ErrCode result = 0; - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (bundleMgr_ == nullptr) { ANS_LOGE("GetBundleInfo bundle proxy failed."); @@ -169,7 +169,7 @@ ErrCode BundleResourceHelper::GetBundleInfoV9(const std::string& bundleName, int AppExecFwk::BundleInfo& bundleInfo) { int32_t flags = static_cast(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION); - std::lock_guard lock(connectionMutex_); + std::lock_guard lock(connectionMutex_); Connect(); if (bundleMgr_ == nullptr) { return false; diff --git a/services/distributed/src/helper/distributed_operation_helper.cpp b/services/distributed/src/helper/distributed_operation_helper.cpp index 170386b5c..cccb92941 100644 --- a/services/distributed/src/helper/distributed_operation_helper.cpp +++ b/services/distributed/src/helper/distributed_operation_helper.cpp @@ -47,7 +47,7 @@ OperationService& OperationService::GetInstance() void OperationService::AddOperation(OperationInfo operationInfo) { - std::lock_guard lock(operationMutex_); + std::lock_guard lock(operationMutex_); auto iter = operationInfoMaps_.find(operationInfo.eventId); if (iter != operationInfoMaps_.end()) { ANS_LOGW("OperationService operation exist %{public}s.", operationInfo.eventId.c_str()); @@ -60,7 +60,7 @@ void OperationService::AddOperation(OperationInfo operationInfo) void OperationService::HandleScreenEvent() { - std::lock_guard lock(operationMutex_); + std::lock_guard lock(operationMutex_); for (auto iter = operationInfoMaps_.begin(); iter != operationInfoMaps_.end();) { ANS_LOGI("OperationService erase operation %{public}s %{public}d.", iter->second.eventId.c_str(), iter->second.type); @@ -70,7 +70,7 @@ void OperationService::HandleScreenEvent() void OperationService::TriggerOperation(std::string eventId) { - std::lock_guard lock(operationMutex_); + std::lock_guard lock(operationMutex_); auto iter = operationInfoMaps_.find(eventId); if (iter == operationInfoMaps_.end()) { ANS_LOGW("Operation not exist %{public}s.", eventId.c_str()); @@ -96,7 +96,7 @@ void OperationService::TriggerOperation(std::string eventId) void OperationService::TimeOutOperation(std::string eventId) { - std::lock_guard lock(operationMutex_); + std::lock_guard lock(operationMutex_); auto iter = operationInfoMaps_.find(eventId); if (iter == operationInfoMaps_.end()) { ANS_LOGI("Operation not exist %{public}s.", eventId.c_str()); diff --git a/services/distributed/src/helper/distributed_preference.cpp b/services/distributed/src/helper/distributed_preference.cpp index 24c66c470..cc161956b 100644 --- a/services/distributed/src/helper/distributed_preference.cpp +++ b/services/distributed/src/helper/distributed_preference.cpp @@ -39,7 +39,7 @@ DistributedPreferences& DistributedPreferences::GetInstance() int32_t DistributedPreferences::InsertBundleIcon(const std::string &bundleName, const std::string &icon) { - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (preferncesDB_ == nullptr) { ANS_LOGW("Prefernces handler is nullptr."); return -1; @@ -53,7 +53,7 @@ int32_t DistributedPreferences::InsertBundleIcon(const std::string &bundleName, int32_t DistributedPreferences::DeleteBundleIcon(const std::string &bundleName) { - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (preferncesDB_ == nullptr) { ANS_LOGW("Prefernces handler is nullptr."); return -1; @@ -67,7 +67,7 @@ int32_t DistributedPreferences::DeleteBundleIcon(const std::string &bundleName) int32_t DistributedPreferences::InsertBatchBundleIcons(std::unordered_map &values) { - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (preferncesDB_ == nullptr) { ANS_LOGW("Prefernces handler is nullptr."); return -1; @@ -85,7 +85,7 @@ int32_t DistributedPreferences::InsertBatchBundleIcons(std::unordered_map lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (preferncesDB_ == nullptr) { ANS_LOGW("Prefernces handler is nullptr."); return -1; @@ -99,7 +99,7 @@ int32_t DistributedPreferences::GetIconByBundleName(const std::string& bundleNam int32_t DistributedPreferences::GetSavedBundlesIcon(std::vector& bundleNames) { - std::lock_guard lock(preferenceMutex_); + std::lock_guard lock(preferenceMutex_); if (preferncesDB_ == nullptr) { ANS_LOGW("Prefernces handler is nullptr."); return -1; diff --git a/services/distributed/src/helper/distributed_rdb_helper.cpp b/services/distributed/src/helper/distributed_rdb_helper.cpp index d7cac40c4..3ce9581da 100644 --- a/services/distributed/src/helper/distributed_rdb_helper.cpp +++ b/services/distributed/src/helper/distributed_rdb_helper.cpp @@ -88,7 +88,7 @@ int32_t DistributedRdbHelper::Init() { ANS_LOGD("Create rdbStore"); { - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ != nullptr) { ANS_LOGD("notification rdb has existed"); return NativeRdb::E_OK; @@ -104,7 +104,7 @@ int32_t DistributedRdbHelper::Init() config.SetSecurityLevel(NativeRdb::SecurityLevel::S1); config.SetHaMode(NativeRdb::HAMode::MAIN_REPLICA); RdbCallBack rdbDataCallBack_(notificationRdbConfig_); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); int32_t ret = NativeRdb::E_OK; rdbStore_ = NativeRdb::RdbHelper::GetRdbStore(config, notificationRdbConfig_.version, rdbDataCallBack_, ret); @@ -120,7 +120,7 @@ int32_t DistributedRdbHelper::Destroy() { ANS_LOGD("Destory rdbStore"); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -137,7 +137,7 @@ int32_t DistributedRdbHelper::Destroy() int32_t DistributedRdbHelper::InsertData(const std::string &key, const std::string &value) { - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -160,7 +160,7 @@ int32_t DistributedRdbHelper::InsertData(const std::string &key, const std::stri int32_t DistributedRdbHelper::InsertBatchData(const std::unordered_map &values) { - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -186,7 +186,7 @@ int32_t DistributedRdbHelper::InsertBatchData(const std::unordered_map lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -204,7 +204,7 @@ int32_t DistributedRdbHelper::DeleteData(const std::string &key) int32_t DistributedRdbHelper::QueryData(const std::string &key, std::string &value) { ANS_LOGD("QueryData start"); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; @@ -221,7 +221,7 @@ int32_t DistributedRdbHelper::QueryDataBeginWithKey( const std::string &key, std::unordered_map &values) { ANS_LOGD("QueryData BeginWithKey start"); - std::lock_guard lock(rdbStorePtrMutex_); + std::lock_guard lock(rdbStorePtrMutex_); if (rdbStore_ == nullptr) { ANS_LOGE("notification rdb is null"); return NativeRdb::E_ERROR; diff --git a/services/distributed/src/soft_bus/distributed_device_service.cpp b/services/distributed/src/soft_bus/distributed_device_service.cpp index 01b52c160..5a9cd11b7 100644 --- a/services/distributed/src/soft_bus/distributed_device_service.cpp +++ b/services/distributed/src/soft_bus/distributed_device_service.cpp @@ -92,7 +92,7 @@ bool DistributedDeviceService::IsSubscribeAllConnect() bool DistributedDeviceService::CheckNeedSubscribeAllConnect() { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); for (auto& device : peerDevice_) { if (device.second.IsPadOrPc()) { return true; @@ -103,7 +103,7 @@ bool DistributedDeviceService::CheckNeedSubscribeAllConnect() bool DistributedDeviceService::IsSyncLiveView(const std::string& deviceId, bool forceSync) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iter = peerDevice_.find(deviceId); if (iter == peerDevice_.end()) { ANS_LOGE("Dans unknown device is data %{public}s.", StringAnonymous(deviceId).c_str()); @@ -132,7 +132,7 @@ bool DistributedDeviceService::IsSyncLiveView(const std::string& deviceId, bool bool DistributedDeviceService::IsSyncIcons(const std::string& deviceId, bool forceSync) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iter = peerDevice_.find(deviceId); if (iter == peerDevice_.end()) { ANS_LOGE("Dans unknown device is data %{public}s.", StringAnonymous(deviceId).c_str()); @@ -151,7 +151,7 @@ bool DistributedDeviceService::IsSyncIcons(const std::string& deviceId, bool for bool DistributedDeviceService::IsSyncInstalledBundle(const std::string& deviceId, bool forceSync) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iter = peerDevice_.find(deviceId); if (iter == peerDevice_.end()) { ANS_LOGE("Dans unknown device is data %{public}s.", StringAnonymous(deviceId).c_str()); @@ -171,7 +171,7 @@ bool DistributedDeviceService::IsSyncInstalledBundle(const std::string& deviceId void DistributedDeviceService::SetDeviceSyncData(const std::string& deviceId, int32_t type, bool syncData) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iter = peerDevice_.find(deviceId); if (iter == peerDevice_.end()) { ANS_LOGE("Dans unknown device set data %{public}s.", StringAnonymous(deviceId).c_str()); @@ -193,7 +193,7 @@ void DistributedDeviceService::SetDeviceSyncData(const std::string& deviceId, in void DistributedDeviceService::ResetDeviceInfo(const std::string& deviceId) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto deviceIter = peerDevice_.find(deviceId); if (deviceIter == peerDevice_.end()) { ANS_LOGI("Dans unknown device %{public}s.", StringAnonymous(deviceId).c_str()); @@ -209,7 +209,7 @@ void DistributedDeviceService::ResetDeviceInfo(const std::string& deviceId) void DistributedDeviceService::SetDeviceState(const std::string& deviceId, int32_t state) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iter = peerDevice_.find(deviceId); if (iter == peerDevice_.end()) { ANS_LOGE("Dans unknown device set status %{public}s.", StringAnonymous(deviceId).c_str()); @@ -220,7 +220,7 @@ void DistributedDeviceService::SetDeviceState(const std::string& deviceId, int32 bool DistributedDeviceService::CheckDeviceExist(const std::string& deviceId) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); if (peerDevice_.find(deviceId) == peerDevice_.end()) { ANS_LOGI("Dans unknown device %{public}s.", StringAnonymous(deviceId).c_str()); return false; @@ -230,7 +230,7 @@ bool DistributedDeviceService::CheckDeviceExist(const std::string& deviceId) bool DistributedDeviceService::GetDeviceInfo(const std::string& deviceId, DistributedDeviceInfo& device) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iter = peerDevice_.find(deviceId); if (iter == peerDevice_.end()) { ANS_LOGI("Dans get deviceId unknonw %{public}s.", StringAnonymous(deviceId).c_str()); @@ -242,7 +242,7 @@ bool DistributedDeviceService::GetDeviceInfo(const std::string& deviceId, Distri bool DistributedDeviceService::GetDeviceInfoByUdid(const std::string& udid, DistributedDeviceInfo& device) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); for (auto deviceItem : peerDevice_) { if (udid == deviceItem.second.udid_) { device = deviceItem.second; @@ -255,7 +255,7 @@ bool DistributedDeviceService::GetDeviceInfoByUdid(const std::string& udid, Dist bool DistributedDeviceService::CheckDeviceNeedSync(const std::string& deviceId) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iter = peerDevice_.find(deviceId); if (iter == peerDevice_.end()) { ANS_LOGE("Dans unknown device connected %{public}s.", StringAnonymous(deviceId).c_str()); @@ -272,7 +272,7 @@ bool DistributedDeviceService::CheckDeviceNeedSync(const std::string& deviceId) void DistributedDeviceService::IncreaseDeviceSyncCount(const std::string& deviceId) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iter = peerDevice_.find(deviceId); if (iter == peerDevice_.end()) { ANS_LOGE("Dans unknown device count %{public}s.", StringAnonymous(deviceId).c_str()); @@ -285,13 +285,13 @@ void DistributedDeviceService::IncreaseDeviceSyncCount(const std::string& device void DistributedDeviceService::AddDeviceInfo(DistributedDeviceInfo deviceItem) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); peerDevice_[deviceItem.deviceId_] = deviceItem; } void DistributedDeviceService::DeleteDeviceInfo(const std::string& deviceId) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto deviceIter = peerDevice_.find(deviceId); if (deviceIter != peerDevice_.end()) { ANS_LOGI("Delete device %{public}s.", StringAnonymous(deviceId).c_str()); @@ -301,13 +301,13 @@ void DistributedDeviceService::DeleteDeviceInfo(const std::string& deviceId) std::map& DistributedDeviceService::GetDeviceList() { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); return peerDevice_; } void DistributedDeviceService::GetDeviceList(std::map& peerDevices) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); for (auto deviceItem : peerDevice_) { peerDevices[deviceItem.first] = deviceItem.second; } @@ -408,7 +408,7 @@ void DistributedDeviceService::SyncDeviceStatus(int32_t type, int32_t status, return; } bool isPad = IsLocalPadOrPC(); - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); for (const auto& peer : peerDevice_) { if (isPad && peer.second.peerState_ != DeviceState::STATE_ONLINE) { ANS_LOGI("DeviceState %{public}d %{public}d %{public}d %{public}d %{public}s.", diff --git a/services/distributed/src/soft_bus/distributed_subscribe_service_v2.cpp b/services/distributed/src/soft_bus/distributed_subscribe_service_v2.cpp index ef52c1eca..16d2d93cf 100644 --- a/services/distributed/src/soft_bus/distributed_subscribe_service_v2.cpp +++ b/services/distributed/src/soft_bus/distributed_subscribe_service_v2.cpp @@ -71,7 +71,7 @@ void DistributedSubscribeService::SubscribeNotification(const DistributedDeviceI subscribeInfo->SetNeedNotifyResponse(true); int result = NotificationHelper::SubscribeNotification(subscriber, subscribeInfo); if (result == 0) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iter = subscriberMap_.find(peerDevice.deviceId_); if (iter != subscriberMap_.end()) { NotificationHelper::UnSubscribeNotification(iter->second); @@ -92,7 +92,7 @@ void DistributedSubscribeService::UnSubscribeNotification(const std::string &dev if (releaseDevice) { DistributedDeviceService::GetInstance().DeleteDeviceInfo(deviceId); } - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iter = subscriberMap_.find(deviceId); if (iter == subscriberMap_.end()) { ANS_LOGI("UnSubscribe invalid %{public}s.", StringAnonymous(deviceId).c_str()); @@ -111,7 +111,7 @@ void DistributedSubscribeService::UnSubscribeNotification(const std::string &dev void DistributedSubscribeService::UnSubscribeAllNotification() { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); for (auto& subscriberInfo : subscriberMap_) { int32_t result = NotificationHelper::UnSubscribeNotification(subscriberInfo.second); ANS_LOGI("UnSubscribe %{public}s %{public}d.", subscriberInfo.first.c_str(), result); diff --git a/services/distributed/src/soft_bus/distributed_unlock_listener_oper_service.cpp b/services/distributed/src/soft_bus/distributed_unlock_listener_oper_service.cpp index 6f89570a4..4f39b626e 100644 --- a/services/distributed/src/soft_bus/distributed_unlock_listener_oper_service.cpp +++ b/services/distributed/src/soft_bus/distributed_unlock_listener_oper_service.cpp @@ -64,7 +64,7 @@ void UnlockListenerOperService::AddDelayTask(const std::string& hashCode, const } uint64_t timerId = timer->CreateTimer(timerInfo); timer->StartTimer(timerId, expiredTime); - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iterDelayTask = delayTaskMap_.find(hashCode); if (iterDelayTask != delayTaskMap_.end()) { ANS_LOGW("Operation delayTask has same key %{public}s.", hashCode.c_str()); @@ -94,7 +94,7 @@ void UnlockListenerOperService::AddDelayTask(const std::string& hashCode, const void UnlockListenerOperService::RemoveOperationResponse(const std::string& hashCode) { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); auto iterDelayTask = delayTaskMap_.find(hashCode); if (iterDelayTask != delayTaskMap_.end()) { delayTaskMap_.erase(iterDelayTask); @@ -119,7 +119,7 @@ void UnlockListenerOperService::RemoveOperationResponse(const std::string& hashC void UnlockListenerOperService::ReplyOperationResponse() { - std::lock_guard lock(mapLock_); + std::lock_guard lock(mapLock_); ANS_LOGI("UnlockListenerOperService ReplyOperationResponse hashCodeOrder size %{public}u", hashCodeOrder_.size()); for (std::string hashCode : hashCodeOrder_) { auto iterDelayTask = delayTaskMap_.find(hashCode); -- Gitee From 4fa915e710331d3ad28aadeecf22d3efb26e2813 Mon Sep 17 00:00:00 2001 From: songbao1 Date: Wed, 16 Jul 2025 11:38:47 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E6=9B=BF=E6=8D=A2std::mutex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- services/ans/include/bundle_manager_helper.h | 1 + 1 file changed, 1 insertion(+) diff --git a/services/ans/include/bundle_manager_helper.h b/services/ans/include/bundle_manager_helper.h index 948982014..3f45cbba4 100644 --- a/services/ans/include/bundle_manager_helper.h +++ b/services/ans/include/bundle_manager_helper.h @@ -27,6 +27,7 @@ #include "refbase.h" #include "remote_death_recipient.h" #include "singleton.h" +#include "ffrt.h" namespace OHOS { namespace Notification { -- Gitee From 415bc202301877fd3db34ea8b8e40347ac219e9d Mon Sep 17 00:00:00 2001 From: songbao1 Date: Wed, 16 Jul 2025 14:20:48 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=9B=BF=E6=8D=A2std::mutex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- services/distributed/test/unittest/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributed/test/unittest/BUILD.gn b/services/distributed/test/unittest/BUILD.gn index b52b8d67d..08fad0624 100644 --- a/services/distributed/test/unittest/BUILD.gn +++ b/services/distributed/test/unittest/BUILD.gn @@ -254,6 +254,7 @@ ohos_unittest("distributed_preferences_branch_test") { "c_utils:utils", "device_manager:devicemanagersdk", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "hitrace:hitrace_meter", -- Gitee From adf869b0071f85788aacf0d18f7d3c26e549abea Mon Sep 17 00:00:00 2001 From: songbao1 Date: Wed, 16 Jul 2025 15:17:57 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=9B=BF=E6=8D=A2std::mutex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- services/distributed/test/unittest/BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/services/distributed/test/unittest/BUILD.gn b/services/distributed/test/unittest/BUILD.gn index 08fad0624..4ade3e44c 100644 --- a/services/distributed/test/unittest/BUILD.gn +++ b/services/distributed/test/unittest/BUILD.gn @@ -214,6 +214,7 @@ ohos_unittest("distributed_database_branch_test") { "c_utils:utils", "device_manager:devicemanagersdk", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "hitrace:hitrace_meter", -- Gitee From eaa956714ae0c3483aea86e9b4969b4c28b66142 Mon Sep 17 00:00:00 2001 From: songbao1 Date: Wed, 16 Jul 2025 15:48:15 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=9B=BF=E6=8D=A2std::mutex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- services/distributed/test/unittest/BUILD.gn | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/distributed/test/unittest/BUILD.gn b/services/distributed/test/unittest/BUILD.gn index 4ade3e44c..764a66ed4 100644 --- a/services/distributed/test/unittest/BUILD.gn +++ b/services/distributed/test/unittest/BUILD.gn @@ -122,6 +122,7 @@ ohos_unittest("distributed_preferences_database_test") { "c_utils:utils", "device_manager:devicemanagersdk", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "hitrace:hitrace_meter", @@ -168,6 +169,7 @@ ohos_unittest("distributed_screen_status_manager_branch_test") { "c_utils:utils", "device_manager:devicemanagersdk", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "hitrace:hitrace_meter", @@ -293,6 +295,7 @@ ohos_unittest("distributed_device_callback_test") { "c_utils:utils", "device_manager:devicemanagersdk", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "hitrace:hitrace_meter", @@ -329,6 +332,7 @@ ohos_unittest("distributed_database_callback_test") { "bundle_framework:appexecfwk_base", "c_utils:utils", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "hitrace:hitrace_meter", @@ -365,6 +369,7 @@ ohos_unittest("distributed_flow_control_test") { "bundle_framework:appexecfwk_base", "c_utils:utils", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "hitrace:hitrace_meter", -- Gitee From 669ca2656969ced20ea484d2a8552a88283525ce Mon Sep 17 00:00:00 2001 From: songbao1 Date: Wed, 16 Jul 2025 16:14:11 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=9B=BF=E6=8D=A2std::mutex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- services/ans/test/unittest/BUILD.gn | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/ans/test/unittest/BUILD.gn b/services/ans/test/unittest/BUILD.gn index 431159ffc..5de036380 100644 --- a/services/ans/test/unittest/BUILD.gn +++ b/services/ans/test/unittest/BUILD.gn @@ -894,6 +894,7 @@ ohos_unittest("bundle_manager_helper_branch_test") { "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "hitrace:hitrace_meter", @@ -1202,6 +1203,7 @@ ohos_unittest("push_callback_stub_test") { "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "hitrace:hitrace_meter", @@ -1257,6 +1259,7 @@ ohos_unittest("notification_rdb_data_mgr_test") { "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", + "ffrt:libffrt", "googletest:gtest_main", "hilog:libhilog", "hitrace:hitrace_meter", @@ -1564,6 +1567,7 @@ ohos_unittest("common_utils_test") { external_deps = [ "ability_base:zuri", "c_utils:utils", + "ffrt:libffrt", "hilog:libhilog", ] -- Gitee