diff --git a/services/ans/include/notification_config_parse.h b/services/ans/include/notification_config_parse.h index eb8520dbee36a48ac5be2cafa26a76b767f4b211..53b7a1dc2208536d109a7a4f69c02c9509aeacf9 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" @@ -43,7 +44,7 @@ public: std::map> ¤tSlotReminder) const; void GetReportTrustListConfig(); bool IsReportTrustList(const std::string& bundleName) const; - uint32_t GetConfigSlotReminderModeByType(NotificationConstant::SlotType slotType) const; + uint32_t GetConfigSlotReminderModeByType(NotificationConstant::SlotType slotType); uint32_t GetConfigSlotReminderModeByType(NotificationConstant::SlotType slotType, const sptr &bundleOption) const; void GetFlowCtrlConfigFromCCM(FlowControlThreshold &threshold); @@ -51,6 +52,7 @@ public: private: std::map defaultCurrentSlotReminder_; std::vector notificationConfigJsons_; + std::mutex slotReminderMutex_; std::set reporteTrustSet_ {}; public: diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index a0cffd382311c087891193894b5c09cc6083cea8..2120cdcf02e37f0d4fbc697bf9f5aa4681851a66 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -2510,8 +2510,6 @@ ErrCode AdvancedNotificationService::SetBadgeNumberByBundle( sptr bundle = bundleOption; ErrCode result = CheckBundleOptionValid(bundle); if (result != ERR_OK) { - message.ErrorCode(result).Append(" Bundle is invalid."); - NotificationAnalyticsUtil::ReportModifyEvent(message); ANS_LOGE("Bundle is invalid."); return result; } diff --git a/services/ans/src/advanced_notification_utils.cpp b/services/ans/src/advanced_notification_utils.cpp index 7c04ef608b8a36b83ef46497c109ab571c624ec4..713c8f165ac76cbc56706b12b41ecd26c37d9d7f 100644 --- a/services/ans/src/advanced_notification_utils.cpp +++ b/services/ans/src/advanced_notification_utils.cpp @@ -1898,11 +1898,12 @@ bool AdvancedNotificationService::GetBundleInfoByNotificationBundleOption( ErrCode AdvancedNotificationService::CheckBundleOptionValid(sptr &bundleOption) { + HaMetaMessage message = HaMetaMessage(EventSceneId::SCENE_7, EventBranchId::BRANCH_8); if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { ANS_LOGE("Bundle option is invalid."); return ERR_ANS_INVALID_PARAM; } - + message.Message(bundleOption->GetBundleName() + "_" +std::to_string(bundleOption->GetUid())); int32_t activeUserId = 0; if (OsAccountManagerHelper::GetInstance().GetCurrentActiveUserId(activeUserId) != ERR_OK) { ANS_LOGE("Failed to get active user id."); @@ -1910,11 +1911,15 @@ ErrCode AdvancedNotificationService::CheckBundleOptionValid(sptr bundleManager = BundleManagerHelper::GetInstance(); if (bundleManager == nullptr) { + message.ErrorCode(ERR_ANS_INVALID_BUNDLE).Append("Failed to get bundle manager."); + NotificationAnalyticsUtil::ReportModifyEvent(message); ANS_LOGE("Failed to get bundle manager."); return ERR_ANS_INVALID_BUNDLE; } int32_t uid = bundleManager->GetDefaultUidByBundleName(bundleOption->GetBundleName(), activeUserId); if (uid == -1) { + message.ErrorCode(ERR_ANS_INVALID_BUNDLE).Append("Bundle name was not found."); + NotificationAnalyticsUtil::ReportModifyEvent(message); ANS_LOGE("The specified bundle name was not found."); return ERR_ANS_INVALID_BUNDLE; } diff --git a/services/ans/src/common/notification_config_parse.cpp b/services/ans/src/common/notification_config_parse.cpp index 9cb36f96391e753bc51a2366f2e9a363a2f66056..f90f5528f8679949fb045a3f93f7be58ccc83403 100644 --- a/services/ans/src/common/notification_config_parse.cpp +++ b/services/ans/src/common/notification_config_parse.cpp @@ -115,13 +115,15 @@ bool NotificationConfigParse::GetCurrentSlotReminder( return true; } -uint32_t NotificationConfigParse::GetConfigSlotReminderModeByType(NotificationConstant::SlotType slotType) const +uint32_t NotificationConfigParse::GetConfigSlotReminderModeByType(NotificationConstant::SlotType slotType) { static std::map> configSlotsReminder; - if (configSlotsReminder.empty()) { - GetCurrentSlotReminder(configSlotsReminder); + { + std::lock_guard lock(slotReminderMutex_); + if (configSlotsReminder.empty()) { + GetCurrentSlotReminder(configSlotsReminder); + } } - auto iter = configSlotsReminder.find(slotType); if (iter != configSlotsReminder.end()) { return iter->second->GetReminderFlags(); @@ -138,7 +140,8 @@ uint32_t NotificationConfigParse::GetConfigSlotReminderModeByType(NotificationCo uint32_t NotificationConfigParse::GetConfigSlotReminderModeByType(NotificationConstant::SlotType slotType, const sptr &bundleOption) const { - uint32_t reminderFlags = GetConfigSlotReminderModeByType(slotType); + uint32_t reminderFlags = + DelayedSingleton::GetInstance()->GetConfigSlotReminderModeByType(slotType); if (DelayedSingleton::GetInstance()->IsSlotFlagsTrustlistAsBundle(bundleOption)) { return reminderFlags & 0b111111; }