Don't prevent notification updates in DOS protection.
The NotificationManagerService limits the number of
notifications per package+user to 50. Once that limit is
reached, it will refuse new notifications. However, it was
also erroneously refusing updates to existing notifications.
Bug: 5821364
Change-Id: I3aa4be9ad4b288e4a22bf7a64f67521695dfb579
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index f49d77d..0c47e37 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -1771,6 +1771,9 @@
for (int i=0; i<N; i++) {
final NotificationRecord r = mNotificationList.get(i);
if (r.sbn.getPackageName().equals(pkg) && r.sbn.getUserId() == userId) {
+ if (r.sbn.getId() == id && TextUtils.equals(r.sbn.getTag(), tag)) {
+ break; // Allow updating existing notification
+ }
count++;
if (count >= MAX_PACKAGE_NOTIFICATIONS) {
Slog.e(TAG, "Package has already posted " + count
@@ -2788,19 +2791,8 @@
final int len = list.size();
for (int i=0; i<len; i++) {
NotificationRecord r = list.get(i);
- if (!notificationMatchesUserId(r, userId) || r.sbn.getId() != id) {
- continue;
- }
- if (tag == null) {
- if (r.sbn.getTag() != null) {
- continue;
- }
- } else {
- if (!tag.equals(r.sbn.getTag())) {
- continue;
- }
- }
- if (r.sbn.getPackageName().equals(pkg)) {
+ if (notificationMatchesUserId(r, userId) && r.sbn.getId() == id &&
+ TextUtils.equals(r.sbn.getTag(), tag) && r.sbn.getPackageName().equals(pkg)) {
return i;
}
}