From 4419233e1fe09cbe77e7f3f6c9e30002bb32d3e4 Mon Sep 17 00:00:00 2001 From: z30053788 Date: Sun, 2 Mar 2025 15:46:09 +0800 Subject: [PATCH] uodate Signed-off-by: z30053788 Change-Id: I8705e3c991911d6e2d4e779a26fe4acec10791b4 --- services/ans/include/notification_config_parse.h | 5 +++++ services/ans/src/common/notification_config_parse.cpp | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/services/ans/include/notification_config_parse.h b/services/ans/include/notification_config_parse.h index eb8520dbe..760591f4f 100644 --- a/services/ans/include/notification_config_parse.h +++ b/services/ans/include/notification_config_parse.h @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef CONFIG_POLICY_ENABLE #include "config_policy_utils.h" @@ -41,6 +42,9 @@ public: bool GetConfigJson(const std::string &keyCheck, nlohmann::json &configJson) const; bool GetCurrentSlotReminder( std::map> ¤tSlotReminder) const; + void SetCurrentSlotReminder( + std::map> ¤tSlotReminder, + NotificationConstant::SlotType &slotType, std::shared_ptr &reminderFlags); void GetReportTrustListConfig(); bool IsReportTrustList(const std::string& bundleName) const; uint32_t GetConfigSlotReminderModeByType(NotificationConstant::SlotType slotType) const; @@ -51,6 +55,7 @@ public: private: std::map defaultCurrentSlotReminder_; std::vector notificationConfigJsons_; + std::mutex slotReminderMutex_; std::set reporteTrustSet_ {}; public: diff --git a/services/ans/src/common/notification_config_parse.cpp b/services/ans/src/common/notification_config_parse.cpp index 9cb36f963..cc7cb25de 100644 --- a/services/ans/src/common/notification_config_parse.cpp +++ b/services/ans/src/common/notification_config_parse.cpp @@ -68,6 +68,14 @@ bool NotificationConfigParse::GetConfigJson(const std::string &keyCheck, nlohman return ret; } +void NotificationConfigParse::SetCurrentSlotReminder( + std::map> ¤tSlotReminder, + NotificationConstant::SlotType &slotType, std::shared_ptr &reminderFlags) +{ + std::lock_guard lock(slotReminderMutex_); + currentSlotReminder[slotType] = reminderFlags; +} + bool NotificationConfigParse::GetCurrentSlotReminder( std::map> ¤tSlotReminder) const { @@ -106,7 +114,8 @@ bool NotificationConfigParse::GetCurrentSlotReminder( reminderFilterSlot[CFG_KEY_REMINDER_FLAGS].get(), reminderFlags)) { continue; } - currentSlotReminder[slotType] = reminderFlags; + DelayedSingleton::GetInstance()-> + SetCurrentSlotReminder(currentSlotReminder, slotType, reminderFlags); } if (currentSlotReminder.size() <= 0) { ANS_LOGE("GetCurrentSlotReminder failed as invalid currentSlotReminder size."); -- Gitee