diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 17a97cd2f1ed09c0912dd36a0bb52692a16fe420..984d29fd9dbe56540fddd2ece42ae52d4e6c2cf5 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -888,13 +888,13 @@ ErrCode AdvancedNotificationService::SetNotificationsEnabledForSpecialBundle( // Local device result = NotificationPreferences::GetInstance()->SetNotificationsEnabledForBundle(bundle, enabled); bool enableSuccessed = result == ERR_OK; - if (!enabled && result == ERR_OK) { - result = RemoveAllNotificationsForDisable(bundle); - } - if (saveRef != ERR_OK) { - SetSlotFlagsTrustlistsAsBundle(bundle); - } - if (enableSuccessed) { + if (result == ERR_OK) { + if (!enabled) { + result = RemoveAllNotificationsForDisable(bundle); + } + if (saveRef != ERR_OK) { + SetSlotFlagsTrustlistsAsBundle(bundle); + } NotificationSubscriberManager::GetInstance()->NotifyEnabledNotificationChanged(bundleData); PublishSlotChangeCommonEvent(bundle); } diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index 845bbcbc0fae4d85bd9cb1e4f438b2bbeda47906..cd6c10aff7fa739944703bf8d6d7c8b75459683d 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -813,7 +813,9 @@ ErrCode NotificationPreferences::SetBundleProperty(NotificationPreferencesInfo & bundleInfo.SetEnableNotification(CheckApiCompatibility(bundleOption)); } result = SaveBundleProperty(bundleInfo, bundleOption, type, value); - preferencesInfo.SetBundleInfo(bundleInfo); + if (result == ERR_OK) { + preferencesInfo.SetBundleInfo(bundleInfo); + } return result; }