From ca475aa05df012e09906c6593b5ed200d0dfce78 Mon Sep 17 00:00:00 2001 From: songbao1 Date: Fri, 13 Sep 2024 11:51:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E9=99=A4=E6=AD=BB=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=20=EF=BC=88cherry=20picked=20commit=20from=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/advanced_notification_publish_service.cpp | 14 +++++++------- services/ans/src/bundle_manager_helper.cpp | 10 ++++------ services/ans/src/notification_preferences.cpp | 4 +++- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/services/ans/src/advanced_notification_publish_service.cpp b/services/ans/src/advanced_notification_publish_service.cpp index 17a97cd2f..984d29fd9 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/bundle_manager_helper.cpp b/services/ans/src/bundle_manager_helper.cpp index 8c6932d1a..b05cc5b50 100644 --- a/services/ans/src/bundle_manager_helper.cpp +++ b/services/ans/src/bundle_manager_helper.cpp @@ -96,13 +96,11 @@ bool BundleManagerHelper::CheckApiCompatibility(const std::string &bundleName, c bundleName.c_str()); return false; } - - for (auto abilityInfo : bundleInfo.abilityInfos) { - if (abilityInfo.isStageBasedModel) { - return false; - } + if (bundleInfo.applicationInfo.allowEnableNotification) { + return true; } - return true; + + return false; } bool BundleManagerHelper::GetBundleInfoByBundleName( diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index 845bbcbc0..cd6c10aff 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; } -- Gitee