From 165814cd1838302c317a143212dc8d9a7f71a43a Mon Sep 17 00:00:00 2001 From: z30053788 Date: Sun, 29 Sep 2024 18:47:35 +0800 Subject: [PATCH] update Signed-off-by: z30053788 Change-Id: I1657f5f720ed7574ec12d5aa265f9164799e4c67 --- .../ans/src/advanced_notification_utils.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/services/ans/src/advanced_notification_utils.cpp b/services/ans/src/advanced_notification_utils.cpp index 89ae1e538..004da9de1 100644 --- a/services/ans/src/advanced_notification_utils.cpp +++ b/services/ans/src/advanced_notification_utils.cpp @@ -606,14 +606,27 @@ void AdvancedNotificationService::OnBundleDataAdd(const sptr slot; + NotificationPreferences::GetInstance()->GetNotificationSlot( + bundleOption, NotificationConstant::SlotType::CUSTOM, slot); + if (slot == nullptr) { + slot = new (std::nothrow) NotificationSlot(); + if (slot == nullptr) { + ANS_LOGW("Failed to create NotificationSlot instance"); + } + } + bool notificationEnable = false; + ErrCode saveRef = NotificationPreferences::GetInstance()->GetNotificationsEnabledForBundle( + bundleOption, notificationEnable); + if (saveRef != ERR_OK) { + SetSlotFlagsTrustlistsAsBundle(bundleOption); + } // In order to adapt to the publish reminder interface, currently only the input from the whitelist is written if (bundleInfo.applicationInfo.allowEnableNotification) { auto errCode = NotificationPreferences::GetInstance()->SetNotificationsEnabledForBundle(bundleOption, true); if (errCode != ERR_OK) { ANS_LOGE("Set notification enable error! code: %{public}d", errCode); } - SetSlotFlagsTrustlistsAsBundle(bundleOption); errCode = NotificationPreferences::GetInstance()->SetShowBadge(bundleOption, true); if (errCode != ERR_OK) { ANS_LOGE("Set badge enable error! code: %{public}d", errCode); -- Gitee