From aeab19fe9909685814f20b41cdd826ebb27788b2 Mon Sep 17 00:00:00 2001 From: songbao1 Date: Fri, 13 Sep 2024 11:51:53 +0800 Subject: [PATCH] =?UTF-8?q?cherry=20pick=207515495=20from=20https://gitee.?= =?UTF-8?q?com/songbao1/notification=5Fdistributed=5Fnotification=5Fservic?= =?UTF-8?q?e/pulls/2196=20=E5=BE=AA=E7=8E=AF=E9=97=AE=E9=A2=98=E8=A7=A3?= =?UTF-8?q?=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: songbao1 --- .../src/advanced_notification_publish_service.cpp | 13 +++++++------ services/ans/src/notification_preferences.cpp | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 50b169bbd..456b22be8 100644 --- a/services/ans/src/advanced_notification_publish_service.cpp +++ b/services/ans/src/advanced_notification_publish_service.cpp @@ -810,13 +810,14 @@ ErrCode AdvancedNotificationService::SetNotificationsEnabledForSpecialBundle( bundle, notificationEnable); // Local device result = NotificationPreferences::GetInstance()->SetNotificationsEnabledForBundle(bundle, enabled); - if (!enabled) { - result = RemoveAllNotificationsForDisable(bundle); - } - if (saveRef != ERR_OK) { - SetSlotFlagsTrustlistsAsBundle(bundle); - } + bool enableSuccessed = result == ERR_OK; 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 e9c6b658c..985242ecb 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -722,7 +722,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; } -- Gitee