Loading services/core/java/com/android/server/notification/NotificationManagerService.java +20 −19 Original line number Diff line number Diff line Loading @@ -6568,7 +6568,7 @@ public class NotificationManagerService extends SystemService { // limit the number of non-fgs outstanding notificationrecords an app can have if (!n.isForegroundService()) { int count = getNotificationCountLocked(pkg, userId, id, tag); int count = getNotificationCount(pkg, userId, id, tag); if (count >= MAX_PACKAGE_NOTIFICATIONS) { mUsageStats.registerOverCountQuota(pkg); Slog.e(TAG, "Package has already posted or enqueued " + count Loading Loading @@ -6647,10 +6647,10 @@ public class NotificationManagerService extends SystemService { return true; } @GuardedBy("mNotificationLock") protected int getNotificationCountLocked(String pkg, int userId, int excludedId, protected int getNotificationCount(String pkg, int userId, int excludedId, String excludedTag) { int count = 0; synchronized (mNotificationLock) { final int N = mNotificationList.size(); for (int i = 0; i < N; i++) { final NotificationRecord existing = mNotificationList.get(i); Loading @@ -6671,6 +6671,7 @@ public class NotificationManagerService extends SystemService { count++; } } } return count; } Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -3394,16 +3394,16 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { // anything that's currently enqueued or posted int userId = UserHandle.getUserId(mUid); assertEquals(40, mService.getNotificationCountLocked(PKG, userId, 0, null)); mService.getNotificationCount(PKG, userId, 0, null)); assertEquals(40, mService.getNotificationCountLocked(PKG, userId, 0, "tag2")); mService.getNotificationCount(PKG, userId, 0, "tag2")); // return all for package "a" - "banana" tag isn't used assertEquals(2, mService.getNotificationCountLocked("a", userId, 0, "banana")); mService.getNotificationCount("a", userId, 0, "banana")); // exclude a known notification - it's excluded from only the posted list, not enqueued assertEquals(39, mService.getNotificationCountLocked( assertEquals(39, mService.getNotificationCount( PKG, userId, sampleIdToExclude, sampleTagToExclude)); } Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +20 −19 Original line number Diff line number Diff line Loading @@ -6568,7 +6568,7 @@ public class NotificationManagerService extends SystemService { // limit the number of non-fgs outstanding notificationrecords an app can have if (!n.isForegroundService()) { int count = getNotificationCountLocked(pkg, userId, id, tag); int count = getNotificationCount(pkg, userId, id, tag); if (count >= MAX_PACKAGE_NOTIFICATIONS) { mUsageStats.registerOverCountQuota(pkg); Slog.e(TAG, "Package has already posted or enqueued " + count Loading Loading @@ -6647,10 +6647,10 @@ public class NotificationManagerService extends SystemService { return true; } @GuardedBy("mNotificationLock") protected int getNotificationCountLocked(String pkg, int userId, int excludedId, protected int getNotificationCount(String pkg, int userId, int excludedId, String excludedTag) { int count = 0; synchronized (mNotificationLock) { final int N = mNotificationList.size(); for (int i = 0; i < N; i++) { final NotificationRecord existing = mNotificationList.get(i); Loading @@ -6671,6 +6671,7 @@ public class NotificationManagerService extends SystemService { count++; } } } return count; } Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +4 −4 Original line number Diff line number Diff line Loading @@ -3394,16 +3394,16 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { // anything that's currently enqueued or posted int userId = UserHandle.getUserId(mUid); assertEquals(40, mService.getNotificationCountLocked(PKG, userId, 0, null)); mService.getNotificationCount(PKG, userId, 0, null)); assertEquals(40, mService.getNotificationCountLocked(PKG, userId, 0, "tag2")); mService.getNotificationCount(PKG, userId, 0, "tag2")); // return all for package "a" - "banana" tag isn't used assertEquals(2, mService.getNotificationCountLocked("a", userId, 0, "banana")); mService.getNotificationCount("a", userId, 0, "banana")); // exclude a known notification - it's excluded from only the posted list, not enqueued assertEquals(39, mService.getNotificationCountLocked( assertEquals(39, mService.getNotificationCount( PKG, userId, sampleIdToExclude, sampleTagToExclude)); } Loading