summaryrefslogtreecommitdiff
path: root/services/core/java/com/android/server/notification/NotificationManagerService.java
diff options
context:
space:
mode:
Diffstat (limited to 'services/core/java/com/android/server/notification/NotificationManagerService.java')
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index bdea24704ef5..c3f9dc96c67b 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -519,7 +519,8 @@ public class NotificationManagerService extends SystemService {
}
}
- private final NotificationDelegate mNotificationDelegate = new NotificationDelegate() {
+ @VisibleForTesting
+ final NotificationDelegate mNotificationDelegate = new NotificationDelegate() {
@Override
public void onSetDisabled(int status) {
@@ -1011,6 +1012,25 @@ public class NotificationManagerService extends SystemService {
}
@VisibleForTesting
+ int getNotificationRecordCount() {
+ synchronized (mNotificationLock) {
+ int count = mNotificationList.size() + mNotificationsByKey.size()
+ + mSummaryByGroupKey.size() + mEnqueuedNotifications.size();
+ // subtract duplicates
+ for (NotificationRecord posted : mNotificationList) {
+ if (mNotificationsByKey.containsKey(posted.getKey())) {
+ count--;
+ }
+ if (posted.sbn.isGroup() && posted.getNotification().isGroupSummary()) {
+ count --;
+ }
+ }
+
+ return count;
+ }
+ }
+
+ @VisibleForTesting
void addNotification(NotificationRecord r) {
mNotificationList.add(r);
mNotificationsByKey.put(r.sbn.getKey(), r);
@@ -4506,6 +4526,7 @@ public class NotificationManagerService extends SystemService {
canceledNotifications = new ArrayList<>();
}
notificationList.remove(i);
+ mNotificationsByKey.remove(r.getKey());
canceledNotifications.add(r);
cancelNotificationLocked(r, sendDelete, reason, wasPosted);
}
@@ -4615,6 +4636,7 @@ public class NotificationManagerService extends SystemService {
EventLogTags.writeNotificationCancel(callingUid, callingPid, pkg, childSbn.getId(),
childSbn.getTag(), userId, 0, 0, reason, listenerName);
notificationList.remove(i);
+ mNotificationsByKey.remove(childR.getKey());
cancelNotificationLocked(childR, sendDelete, reason, wasPosted);
}
}