diff --git a/services/ans/src/advanced_notification_utils.cpp b/services/ans/src/advanced_notification_utils.cpp index 89ae1e53835f60308112e2136b97242adb0af4b7..004da9de182c9921651f985aa2d05b1a8297ce26 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);