diff --git a/packages/SystemUI/src/com/android/systemui/ForegroundServiceControllerImpl.java b/packages/SystemUI/src/com/android/systemui/ForegroundServiceControllerImpl.java index fc2b5b490e2c8..1fa925e5ad1f0 100644 --- a/packages/SystemUI/src/com/android/systemui/ForegroundServiceControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/ForegroundServiceControllerImpl.java @@ -23,6 +23,7 @@ import android.service.notification.StatusBarNotification; import android.util.ArrayMap; import android.util.ArraySet; import android.util.Log; +import android.util.Slog; import android.util.SparseArray; import com.android.internal.messages.nano.SystemMessageProto; @@ -174,9 +175,9 @@ public class ForegroundServiceControllerImpl @Override public boolean isSystemAlertNotification(StatusBarNotification sbn) { - // TODO: tag system alert notifications so they can be suppressed if app's notification - // is tagged - return false; + return sbn.getPackageName().equals("android") + && sbn.getTag() != null + && sbn.getTag().contains("AlertWindowNotification"); } /** diff --git a/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java index 18dd3c734660a..f278a17d06375 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/ForegroundServiceControllerTest.java @@ -368,6 +368,17 @@ public class ForegroundServiceControllerTest extends SysuiTestCase { assertFalse(fsc.isDungeonNeededForUser(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(fsc.isSystemAlertNotification(sbn_user1_overlay)); + assertFalse(fsc.isSystemAlertNotification(sbn_user1_app1)); + } + @Test public void testStdLayoutBasic() { final String PKG1 = "com.example.app0"; @@ -439,7 +450,7 @@ public class ForegroundServiceControllerTest extends SysuiTestCase { when(sbn.getNotification()).thenReturn(n); when(sbn.getId()).thenReturn(id); when(sbn.getPackageName()).thenReturn(pkg); - when(sbn.getTag()).thenReturn(null); + when(sbn.getTag()).thenReturn(tag); when(sbn.getUserId()).thenReturn(userid); when(sbn.getUser()).thenReturn(new UserHandle(userid)); when(sbn.getKey()).thenReturn("MOCK:"+userid+"|"+pkg+"|"+id+"|"+tag);