diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 953a519df58fdbf3b55f2c5662c42d73a8dac95a..8f2af8f4f510f264566a89a6dd1eea852766609d 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -798,16 +798,18 @@ ErrCode AdvancedNotificationService::DeleteAll() ErrCode result = ERR_OK; handler_->PostSyncTask(std::bind([&]() { + int activeUserId = SUBSCRIBE_USER_INIT; + (void)GetActiveUserId(activeUserId); std::vector keys = GetNotificationKeys(nullptr); for (auto key : keys) { sptr notification = nullptr; result = RemoveFromNotificationListForDeleteAll(key, notification); - if (result != ERR_OK) { + if (result != ERR_OK || notification == nullptr) { continue; } - if (notification != nullptr) { + if ((notification->GetUserId() == activeUserId) || (notification->GetUserId() == SUBSCRIBE_USER_ALL)) { int reason = NotificationConstant::CANCEL_ALL_REASON_DELETE; UpdateRecentNotification(notification, true, reason); sptr sortingMap = GenerateSortingMap(); diff --git a/services/ans/src/notification_subscriber_manager.cpp b/services/ans/src/notification_subscriber_manager.cpp index 1e850b74be56e62c19e6caa05686081f7e19101f..f6a4e947c2f578b2369c47671205cb5bb2e2cf40 100644 --- a/services/ans/src/notification_subscriber_manager.cpp +++ b/services/ans/src/notification_subscriber_manager.cpp @@ -206,8 +206,7 @@ void NotificationSubscriberManager::AddRecordInfo( record->subscribedAll = false; } record->userId = subscribeInfo->GetAppUserId(); - if (record->userId == SUBSCRIBE_USER_INIT || - (record->userId >= SUBSCRIBE_USER_SYSTEM_BEGIN && record->userId <= SUBSCRIBE_USER_SYSTEM_END)) { + if (record->userId == SUBSCRIBE_USER_INIT) { record->userId = SUBSCRIBE_USER_ALL; } } else {