Merge "Bring back the SAW notification" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
92e23aa512
@@ -128,15 +128,6 @@ public class NotificationFilter {
|
|||||||
// this is a foreground-service disclosure for a user that does not need to show one
|
// this is a foreground-service disclosure for a user that does not need to show one
|
||||||
return true;
|
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)) {
|
if (mIsMediaFlagEnabled && isMediaNotification(sbn)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -95,18 +95,6 @@ public class AppOpsCoordinator implements Coordinator {
|
|||||||
sbn.getUser().getIdentifier())) {
|
sbn.getUser().getIdentifier())) {
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -308,17 +308,6 @@ public class ForegroundServiceControllerTest extends SysuiTestCase {
|
|||||||
assertFalse(mFsc.isDisclosureNeededForUser(USERID_TWO));
|
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
|
@Test
|
||||||
public void testNoNotifsNorAppOps_noSystemAlertWarningRequired() {
|
public void testNoNotifsNorAppOps_noSystemAlertWarningRequired() {
|
||||||
// no notifications nor app op signals that this package/userId requires system alert
|
// no notifications nor app op signals that this package/userId requires system alert
|
||||||
|
|||||||
@@ -170,63 +170,11 @@ public class NotificationFilterTest extends SysuiTestCase {
|
|||||||
mMockStatusBarNotification));
|
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
|
@Test
|
||||||
public void testShouldFilterHiddenNotifications() {
|
public void testShouldFilterHiddenNotifications() {
|
||||||
initStatusBarNotification(false);
|
initStatusBarNotification(false);
|
||||||
// setup
|
// setup
|
||||||
when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false);
|
when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false);
|
||||||
when(mFsc.isSystemAlertNotification(any())).thenReturn(false);
|
|
||||||
|
|
||||||
// test should filter out hidden notifications:
|
// test should filter out hidden notifications:
|
||||||
// hidden
|
// hidden
|
||||||
|
|||||||
@@ -114,41 +114,6 @@ public class AppOpsCoordinatorTest extends SysuiTestCase {
|
|||||||
assertTrue(mForegroundFilter.shouldFilterOut(entry, 0));
|
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
|
@Test
|
||||||
public void testIncludeFGSInSection_importanceDefault() {
|
public void testIncludeFGSInSection_importanceDefault() {
|
||||||
// GIVEN the notification represents a colorized foreground service with > min importance
|
// GIVEN the notification represents a colorized foreground service with > min importance
|
||||||
|
|||||||
Reference in New Issue
Block a user