Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationFilter.java +0 −9 Original line number Diff line number Diff line Loading @@ -128,15 +128,6 @@ public class NotificationFilter { // this is a foreground-service disclosure for a user that does not need to show one return true; } if (getFsc().isSystemAlertNotification(sbn)) { final String[] apps = sbn.getNotification().extras.getStringArray( Notification.EXTRA_FOREGROUND_APPS); if (apps != null && apps.length >= 1) { if (!getFsc().isSystemAlertWarningNeeded(sbn.getUserId(), apps[0])) { return true; } } } if (mIsMediaFlagEnabled && isMediaNotification(sbn)) { return true; Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinator.java +0 −12 Original line number Diff line number Diff line Loading @@ -95,18 +95,6 @@ public class AppOpsCoordinator implements Coordinator { sbn.getUser().getIdentifier())) { return true; } // Filters out system alert notifications when unneeded if (mForegroundServiceController.isSystemAlertNotification(sbn)) { final String[] apps = sbn.getNotification().extras.getStringArray( Notification.EXTRA_FOREGROUND_APPS); if (apps != null && apps.length >= 1) { if (!mForegroundServiceController.isSystemAlertWarningNeeded( sbn.getUser().getIdentifier(), apps[0])) { return true; } } } return false; } }; Loading packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java +0 −11 Original line number Diff line number Diff line Loading @@ -308,17 +308,6 @@ public class ForegroundServiceControllerTest extends SysuiTestCase { assertFalse(mFsc.isDisclosureNeededForUser(USERID_TWO)); } @Test public void testOverlayPredicate() { StatusBarNotification sbn_user1_app1 = makeMockSBN(USERID_ONE, "com.example.app1", 5000, "monkeys", Notification.FLAG_AUTO_CANCEL); StatusBarNotification sbn_user1_overlay = makeMockSBN(USERID_ONE, "android", 0, "AlertWindowNotification", Notification.FLAG_NO_CLEAR); assertTrue(mFsc.isSystemAlertNotification(sbn_user1_overlay)); assertFalse(mFsc.isSystemAlertNotification(sbn_user1_app1)); } @Test public void testNoNotifsNorAppOps_noSystemAlertWarningRequired() { // no notifications nor app op signals that this package/userId requires system alert Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationFilterTest.java +0 −52 Original line number Diff line number Diff line Loading @@ -170,63 +170,11 @@ public class NotificationFilterTest extends SysuiTestCase { mMockStatusBarNotification)); } @Test public void testSuppressSystemAlertNotification() { when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(true); StatusBarNotification sbn = mRow.getEntry().getSbn(); Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{"something"}); sbn.getNotification().extras = bundle; assertTrue(mNotificationFilter.shouldFilterOut(mRow.getEntry())); } @Test public void testDoNotSuppressSystemAlertNotification() { StatusBarNotification sbn = mRow.getEntry().getSbn(); Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{"something"}); sbn.getNotification().extras = bundle; when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true); when(mFsc.isSystemAlertNotification(any())).thenReturn(true); assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true); when(mFsc.isSystemAlertNotification(any())).thenReturn(false); assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(false); assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); } @Test public void testDoNotSuppressMalformedSystemAlertNotification() { when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true); // missing extra assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); StatusBarNotification sbn = mRow.getEntry().getSbn(); Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{}); sbn.getNotification().extras = bundle; // extra missing values assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); } @Test public void testShouldFilterHiddenNotifications() { initStatusBarNotification(false); // setup when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(false); // test should filter out hidden notifications: // hidden Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinatorTest.java +0 −35 Original line number Diff line number Diff line Loading @@ -114,41 +114,6 @@ public class AppOpsCoordinatorTest extends SysuiTestCase { assertTrue(mForegroundFilter.shouldFilterOut(entry, 0)); } @Test public void filterTest_systemAlertNotificationUnnecessary() { // GIVEN the alert notification isn't needed for this user final Bundle extras = new Bundle(); extras.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{TEST_PKG}); mEntryBuilder.modifyNotification(mContext) .setExtras(extras); NotificationEntry entry = mEntryBuilder.build(); StatusBarNotification sbn = entry.getSbn(); when(mForegroundServiceController.isSystemAlertWarningNeeded(sbn.getUserId(), TEST_PKG)) .thenReturn(false); // GIVEN the notification is a system alert notification + not a disclosure notification when(mForegroundServiceController.isSystemAlertNotification(sbn)).thenReturn(true); when(mForegroundServiceController.isDisclosureNotification(sbn)).thenReturn(false); // THEN filter out the notification assertTrue(mForegroundFilter.shouldFilterOut(entry, 0)); } @Test public void filterTest_doNotFilter() { NotificationEntry entry = mEntryBuilder.build(); StatusBarNotification sbn = entry.getSbn(); // GIVEN the notification isn't a system alert notification nor a disclosure notification when(mForegroundServiceController.isSystemAlertNotification(sbn)).thenReturn(false); when(mForegroundServiceController.isDisclosureNotification(sbn)).thenReturn(false); // THEN don't filter out the notification assertFalse(mForegroundFilter.shouldFilterOut(entry, 0)); } @Test public void testIncludeFGSInSection_importanceDefault() { // GIVEN the notification represents a colorized foreground service with > min importance Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationFilter.java +0 −9 Original line number Diff line number Diff line Loading @@ -128,15 +128,6 @@ public class NotificationFilter { // this is a foreground-service disclosure for a user that does not need to show one return true; } if (getFsc().isSystemAlertNotification(sbn)) { final String[] apps = sbn.getNotification().extras.getStringArray( Notification.EXTRA_FOREGROUND_APPS); if (apps != null && apps.length >= 1) { if (!getFsc().isSystemAlertWarningNeeded(sbn.getUserId(), apps[0])) { return true; } } } if (mIsMediaFlagEnabled && isMediaNotification(sbn)) { return true; Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinator.java +0 −12 Original line number Diff line number Diff line Loading @@ -95,18 +95,6 @@ public class AppOpsCoordinator implements Coordinator { sbn.getUser().getIdentifier())) { return true; } // Filters out system alert notifications when unneeded if (mForegroundServiceController.isSystemAlertNotification(sbn)) { final String[] apps = sbn.getNotification().extras.getStringArray( Notification.EXTRA_FOREGROUND_APPS); if (apps != null && apps.length >= 1) { if (!mForegroundServiceController.isSystemAlertWarningNeeded( sbn.getUser().getIdentifier(), apps[0])) { return true; } } } return false; } }; Loading
packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java +0 −11 Original line number Diff line number Diff line Loading @@ -308,17 +308,6 @@ public class ForegroundServiceControllerTest extends SysuiTestCase { assertFalse(mFsc.isDisclosureNeededForUser(USERID_TWO)); } @Test public void testOverlayPredicate() { StatusBarNotification sbn_user1_app1 = makeMockSBN(USERID_ONE, "com.example.app1", 5000, "monkeys", Notification.FLAG_AUTO_CANCEL); StatusBarNotification sbn_user1_overlay = makeMockSBN(USERID_ONE, "android", 0, "AlertWindowNotification", Notification.FLAG_NO_CLEAR); assertTrue(mFsc.isSystemAlertNotification(sbn_user1_overlay)); assertFalse(mFsc.isSystemAlertNotification(sbn_user1_app1)); } @Test public void testNoNotifsNorAppOps_noSystemAlertWarningRequired() { // no notifications nor app op signals that this package/userId requires system alert Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationFilterTest.java +0 −52 Original line number Diff line number Diff line Loading @@ -170,63 +170,11 @@ public class NotificationFilterTest extends SysuiTestCase { mMockStatusBarNotification)); } @Test public void testSuppressSystemAlertNotification() { when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(true); StatusBarNotification sbn = mRow.getEntry().getSbn(); Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{"something"}); sbn.getNotification().extras = bundle; assertTrue(mNotificationFilter.shouldFilterOut(mRow.getEntry())); } @Test public void testDoNotSuppressSystemAlertNotification() { StatusBarNotification sbn = mRow.getEntry().getSbn(); Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{"something"}); sbn.getNotification().extras = bundle; when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true); when(mFsc.isSystemAlertNotification(any())).thenReturn(true); assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true); when(mFsc.isSystemAlertNotification(any())).thenReturn(false); assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(false); assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); } @Test public void testDoNotSuppressMalformedSystemAlertNotification() { when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(true); // missing extra assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); StatusBarNotification sbn = mRow.getEntry().getSbn(); Bundle bundle = new Bundle(); bundle.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{}); sbn.getNotification().extras = bundle; // extra missing values assertFalse(mNotificationFilter.shouldFilterOut(mRow.getEntry())); } @Test public void testShouldFilterHiddenNotifications() { initStatusBarNotification(false); // setup when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(false); // test should filter out hidden notifications: // hidden Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinatorTest.java +0 −35 Original line number Diff line number Diff line Loading @@ -114,41 +114,6 @@ public class AppOpsCoordinatorTest extends SysuiTestCase { assertTrue(mForegroundFilter.shouldFilterOut(entry, 0)); } @Test public void filterTest_systemAlertNotificationUnnecessary() { // GIVEN the alert notification isn't needed for this user final Bundle extras = new Bundle(); extras.putStringArray(Notification.EXTRA_FOREGROUND_APPS, new String[]{TEST_PKG}); mEntryBuilder.modifyNotification(mContext) .setExtras(extras); NotificationEntry entry = mEntryBuilder.build(); StatusBarNotification sbn = entry.getSbn(); when(mForegroundServiceController.isSystemAlertWarningNeeded(sbn.getUserId(), TEST_PKG)) .thenReturn(false); // GIVEN the notification is a system alert notification + not a disclosure notification when(mForegroundServiceController.isSystemAlertNotification(sbn)).thenReturn(true); when(mForegroundServiceController.isDisclosureNotification(sbn)).thenReturn(false); // THEN filter out the notification assertTrue(mForegroundFilter.shouldFilterOut(entry, 0)); } @Test public void filterTest_doNotFilter() { NotificationEntry entry = mEntryBuilder.build(); StatusBarNotification sbn = entry.getSbn(); // GIVEN the notification isn't a system alert notification nor a disclosure notification when(mForegroundServiceController.isSystemAlertNotification(sbn)).thenReturn(false); when(mForegroundServiceController.isDisclosureNotification(sbn)).thenReturn(false); // THEN don't filter out the notification assertFalse(mForegroundFilter.shouldFilterOut(entry, 0)); } @Test public void testIncludeFGSInSection_importanceDefault() { // GIVEN the notification represents a colorized foreground service with > min importance Loading