diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 153e6bc7247116b5c482d596162835dc5a583dd3..3d8eb02a93fee674458a9dbcc7de388d9e6f4e3b 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -1453,11 +1453,27 @@ void AdvancedNotificationService::OnBundleRemoved(const sptrPostTask(std::bind([bundleOption]() { + handler_->PostTask(std::bind([this, bundleOption]() { ErrCode result = NotificationPreferences::GetInstance().RemoveNotificationForBundle(bundleOption); if (result != ERR_OK) { ANS_LOGW("NotificationPreferences::RemoveNotificationForBundle failed: %{public}d", result); } + + std::vector keys = GetNotificationKeys(bundleOption); + for (auto key : keys) { + sptr notification = nullptr; + result = RemoveFromNotificationList(key, notification, true); + if (result != ERR_OK) { + continue; + } + + if (notification != nullptr) { + int reason = NotificationConstant::PACKAGE_CHANGED_REASON_DELETE; + UpdateRecentNotification(notification, true, reason); + sptr sortingMap = GenerateSortingMap(); + NotificationSubscriberManager::GetInstance()->NotifyCanceled(notification, sortingMap, reason); + } + } })); }