diff --git a/services/ans/src/advanced_notification_utils.cpp b/services/ans/src/advanced_notification_utils.cpp index 32ff419d7db82da4f7fc0709da84b1775a1ea627..0c57c6119a234825796d680e3fe89b0f9649c310 100644 --- a/services/ans/src/advanced_notification_utils.cpp +++ b/services/ans/src/advanced_notification_utils.cpp @@ -1848,11 +1848,10 @@ bool AdvancedNotificationService::AllowUseReminder(const std::string& bundleName } #ifdef ENABLE_ANS_ADDITIONAL_CONTROL int32_t ctrlResult = EXTENTION_WRAPPER->ReminderControl(bundleName); - if (ctrlResult != ERR_OK) { - return ctrlResult; - } -#endif + return ctrlResult == ERR_OK; +#else return true; +#endif } ErrCode AdvancedNotificationService::AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder) diff --git a/services/ans/src/notification_subscriber_manager.cpp b/services/ans/src/notification_subscriber_manager.cpp index c1055f5ed558d0239d7198ff7c8766c778fcfa78..eee873e853f7c597d1e7b1c4f903c3e3a765f140 100644 --- a/services/ans/src/notification_subscriber_manager.cpp +++ b/services/ans/src/notification_subscriber_manager.cpp @@ -356,7 +356,6 @@ void NotificationSubscriberManager::OnRemoteDied(const wptr &obje auto subscriberUid = record->subscriberUid; ANS_LOGI("subscriber removed . subscriberUid = %{public}d", record->subscriberUid); subscriberRecordList_.remove(record); - AdvancedNotificationService::GetInstance()->RemoveSystemLiveViewNotificationsOfSa(record->subscriberUid); } })); notificationSubQueue_->wait(handler); diff --git a/services/ans/test/unittest/advanced_notification_utils_test.cpp b/services/ans/test/unittest/advanced_notification_utils_test.cpp index f364fd750381e182d1d689a69316f88c1a6dab70..9c4bbfd9f5c5a2e9101a701e81d21e8e38946fd9 100644 --- a/services/ans/test/unittest/advanced_notification_utils_test.cpp +++ b/services/ans/test/unittest/advanced_notification_utils_test.cpp @@ -40,6 +40,7 @@ #include "refbase.h" #include "bundle_manager_helper.h" #include "mock_bundle_mgr.h" +#include "notification_extension_wrapper.h" using namespace testing::ext; using namespace OHOS::Media; @@ -902,6 +903,25 @@ HWTEST_F(AnsUtilsTest, AllowUseReminder_00001, Function | SmallTest | Level1) ASSERT_EQ(advancedNotificationService_->AllowUseReminder(str, b), (int)ERR_OK); } + +#ifdef ENABLE_ANS_ADDITIONAL_CONTROL +HWTEST_F(AnsUtilsTest, AllowUseReminder_00002, Function | SmallTest | Level1) +{ + EXTENTION_WRAPPER->reminderControl_ = [](const std::string &bundleName) { return ERR_OK; }; + std::string str = "test1"; + + ASSERT_TRUE(advancedNotificationService_->AllowUseReminder(str);); +} + +HWTEST_F(AnsUtilsTest, AllowUseReminder_00003, Function | SmallTest | Level1) +{ + EXTENTION_WRAPPER->reminderControl_ = [](const std::string &bundleName) { return ERR_ANS_INVALID_BUNDLE; }; + std::string str = "test1"; + + ASSERT_FALSE(advancedNotificationService_->AllowUseReminder(str);); +} +#endif // ENABLE_ANS_ADDITIONAL_CONTROL + /** * @tc.name: CloseAlert_00001 * @tc.desc: Test CloseAlert