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/bundle_manager_helper.cpp b/services/ans/src/bundle_manager_helper.cpp index 8c6932d1a3f252aafe2ec9f87164c015378ea03c..b05cc5b50f3d639900fe8dcf64c3da03f6c29f13 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 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; }