Loading core/java/android/app/INotificationManager.aidl +1 −0 Original line number Original line Diff line number Diff line Loading @@ -86,6 +86,7 @@ interface INotificationManager ParceledListSlice getNotificationChannelGroups(String pkg); ParceledListSlice getNotificationChannelGroups(String pkg); boolean onlyHasDefaultChannel(String pkg, int uid); boolean onlyHasDefaultChannel(String pkg, int uid); ParceledListSlice getRecentNotifyingAppsForUser(int userId); ParceledListSlice getRecentNotifyingAppsForUser(int userId); int getBlockedAppCount(int userId); // TODO: Remove this when callers have been migrated to the equivalent // TODO: Remove this when callers have been migrated to the equivalent // INotificationListener method. // INotificationListener method. Loading services/core/java/com/android/server/notification/NotificationManagerService.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -2393,6 +2393,12 @@ public class NotificationManagerService extends SystemService { } } } } @Override public int getBlockedAppCount(int userId) { checkCallerIsSystem(); return mRankingHelper.getBlockedAppCount(userId); } @Override @Override public void clearData(String packageName, int uid, boolean fromApp) throws RemoteException { public void clearData(String packageName, int uid, boolean fromApp) throws RemoteException { checkCallerIsSystem(); checkCallerIsSystem(); Loading services/core/java/com/android/server/notification/RankingHelper.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -1011,6 +1011,21 @@ public class RankingHelper implements RankingConfig { return blockedCount; return blockedCount; } } public int getBlockedAppCount(int userId) { int count = 0; synchronized (mRecords) { final int N = mRecords.size(); for (int i = 0; i < N; i++) { final Record r = mRecords.valueAt(i); if (userId == UserHandle.getUserId(r.uid) && r.importance == IMPORTANCE_NONE) { count++; } } } return count; } /** /** * Sets importance. * Sets importance. */ */ Loading services/tests/uiservicestests/src/com/android/server/notification/RankingHelperTest.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -1733,4 +1733,24 @@ public class RankingHelperTest extends UiServiceTestCase { mHelper.createNotificationChannel(PKG, 1000, update, true, false); mHelper.createNotificationChannel(PKG, 1000, update, true, false); assertFalse(mHelper.getNotificationChannel(PKG, 1000, "A", false).canBypassDnd()); assertFalse(mHelper.getNotificationChannel(PKG, 1000, "A", false).canBypassDnd()); } } @Test public void testGetBlockedAppCount_noApps() { assertEquals(0, mHelper.getBlockedAppCount(0)); } @Test public void testGetBlockedAppCount_noAppsForUserId() { mHelper.setEnabled(PKG, 100, false); assertEquals(0, mHelper.getBlockedAppCount(9)); } @Test public void testGetBlockedAppCount_appsForUserId() { mHelper.setEnabled(PKG, 1020, false); mHelper.setEnabled(PKG, 1030, false); mHelper.setEnabled(PKG, 1060, false); mHelper.setEnabled(PKG, 1000, true); assertEquals(3, mHelper.getBlockedAppCount(0)); } } } Loading
core/java/android/app/INotificationManager.aidl +1 −0 Original line number Original line Diff line number Diff line Loading @@ -86,6 +86,7 @@ interface INotificationManager ParceledListSlice getNotificationChannelGroups(String pkg); ParceledListSlice getNotificationChannelGroups(String pkg); boolean onlyHasDefaultChannel(String pkg, int uid); boolean onlyHasDefaultChannel(String pkg, int uid); ParceledListSlice getRecentNotifyingAppsForUser(int userId); ParceledListSlice getRecentNotifyingAppsForUser(int userId); int getBlockedAppCount(int userId); // TODO: Remove this when callers have been migrated to the equivalent // TODO: Remove this when callers have been migrated to the equivalent // INotificationListener method. // INotificationListener method. Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -2393,6 +2393,12 @@ public class NotificationManagerService extends SystemService { } } } } @Override public int getBlockedAppCount(int userId) { checkCallerIsSystem(); return mRankingHelper.getBlockedAppCount(userId); } @Override @Override public void clearData(String packageName, int uid, boolean fromApp) throws RemoteException { public void clearData(String packageName, int uid, boolean fromApp) throws RemoteException { checkCallerIsSystem(); checkCallerIsSystem(); Loading
services/core/java/com/android/server/notification/RankingHelper.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -1011,6 +1011,21 @@ public class RankingHelper implements RankingConfig { return blockedCount; return blockedCount; } } public int getBlockedAppCount(int userId) { int count = 0; synchronized (mRecords) { final int N = mRecords.size(); for (int i = 0; i < N; i++) { final Record r = mRecords.valueAt(i); if (userId == UserHandle.getUserId(r.uid) && r.importance == IMPORTANCE_NONE) { count++; } } } return count; } /** /** * Sets importance. * Sets importance. */ */ Loading
services/tests/uiservicestests/src/com/android/server/notification/RankingHelperTest.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -1733,4 +1733,24 @@ public class RankingHelperTest extends UiServiceTestCase { mHelper.createNotificationChannel(PKG, 1000, update, true, false); mHelper.createNotificationChannel(PKG, 1000, update, true, false); assertFalse(mHelper.getNotificationChannel(PKG, 1000, "A", false).canBypassDnd()); assertFalse(mHelper.getNotificationChannel(PKG, 1000, "A", false).canBypassDnd()); } } @Test public void testGetBlockedAppCount_noApps() { assertEquals(0, mHelper.getBlockedAppCount(0)); } @Test public void testGetBlockedAppCount_noAppsForUserId() { mHelper.setEnabled(PKG, 100, false); assertEquals(0, mHelper.getBlockedAppCount(9)); } @Test public void testGetBlockedAppCount_appsForUserId() { mHelper.setEnabled(PKG, 1020, false); mHelper.setEnabled(PKG, 1030, false); mHelper.setEnabled(PKG, 1060, false); mHelper.setEnabled(PKG, 1000, true); assertEquals(3, mHelper.getBlockedAppCount(0)); } } }