Loading services/core/java/com/android/server/notification/NotificationManagerService.java +9 −16 Original line number Diff line number Diff line Loading @@ -4402,22 +4402,12 @@ public class NotificationManagerService extends SystemService { } protected boolean isBlocked(NotificationRecord r, NotificationUsageStats usageStats) { final String pkg = r.sbn.getPackageName(); final int callingUid = r.sbn.getUid(); final boolean isPackageSuspended = isPackageSuspendedForUser(pkg, callingUid); if (isPackageSuspended) { Slog.e(TAG, "Suppressing notification from package due to package " + "suspended by administrator."); usageStats.registerSuspendedByAdmin(r); return isPackageSuspended; } final boolean isBlocked = isBlocked(r); if (isBlocked) { if (isBlocked(r)) { Slog.e(TAG, "Suppressing notification from package by user request."); usageStats.registerBlocked(r); return true; } return isBlocked; return false; } private boolean isBlocked(NotificationRecord r) { Loading Loading @@ -4691,7 +4681,11 @@ public class NotificationManagerService extends SystemService { return; } r.setHidden(isPackageSuspendedLocked(r)); final boolean isPackageSuspended = isPackageSuspendedLocked(r); r.setHidden(isPackageSuspended); if (isPackageSuspended) { mUsageStats.registerSuspendedByAdmin(r); } NotificationRecord old = mNotificationsByKey.get(key); final StatusBarNotification n = r.sbn; final Notification notification = n.getNotification(); Loading Loading @@ -6922,7 +6916,6 @@ public class NotificationManagerService extends SystemService { if (!oldSbnVisible && !sbnVisible) { continue; } // If the notification is hidden, don't notifyPosted listeners targeting < P. // Instead, those listeners will receive notifyPosted when the notification is // unhidden. Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -519,8 +519,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { NotificationChannel channel = new NotificationChannel("id", "name", IMPORTANCE_HIGH); NotificationRecord r = generateNotificationRecord(channel); assertTrue(mService.isBlocked(r, mUsageStats)); verify(mUsageStats, times(1)).registerSuspendedByAdmin(eq(r)); // isBlocked is only used for user blocking, not app suspension assertFalse(mService.isBlocked(r, mUsageStats)); } @Test Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +9 −16 Original line number Diff line number Diff line Loading @@ -4402,22 +4402,12 @@ public class NotificationManagerService extends SystemService { } protected boolean isBlocked(NotificationRecord r, NotificationUsageStats usageStats) { final String pkg = r.sbn.getPackageName(); final int callingUid = r.sbn.getUid(); final boolean isPackageSuspended = isPackageSuspendedForUser(pkg, callingUid); if (isPackageSuspended) { Slog.e(TAG, "Suppressing notification from package due to package " + "suspended by administrator."); usageStats.registerSuspendedByAdmin(r); return isPackageSuspended; } final boolean isBlocked = isBlocked(r); if (isBlocked) { if (isBlocked(r)) { Slog.e(TAG, "Suppressing notification from package by user request."); usageStats.registerBlocked(r); return true; } return isBlocked; return false; } private boolean isBlocked(NotificationRecord r) { Loading Loading @@ -4691,7 +4681,11 @@ public class NotificationManagerService extends SystemService { return; } r.setHidden(isPackageSuspendedLocked(r)); final boolean isPackageSuspended = isPackageSuspendedLocked(r); r.setHidden(isPackageSuspended); if (isPackageSuspended) { mUsageStats.registerSuspendedByAdmin(r); } NotificationRecord old = mNotificationsByKey.get(key); final StatusBarNotification n = r.sbn; final Notification notification = n.getNotification(); Loading Loading @@ -6922,7 +6916,6 @@ public class NotificationManagerService extends SystemService { if (!oldSbnVisible && !sbnVisible) { continue; } // If the notification is hidden, don't notifyPosted listeners targeting < P. // Instead, those listeners will receive notifyPosted when the notification is // unhidden. Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -519,8 +519,9 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { NotificationChannel channel = new NotificationChannel("id", "name", IMPORTANCE_HIGH); NotificationRecord r = generateNotificationRecord(channel); assertTrue(mService.isBlocked(r, mUsageStats)); verify(mUsageStats, times(1)).registerSuspendedByAdmin(eq(r)); // isBlocked is only used for user blocking, not app suspension assertFalse(mService.isBlocked(r, mUsageStats)); } @Test Loading