Merge "Hide overlay notification" into pi-dev

This commit is contained in:
TreeHugger Robot
2018-03-06 23:33:28 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 4 deletions

View File

@@ -23,6 +23,7 @@ import android.service.notification.StatusBarNotification;
import android.util.ArrayMap; import android.util.ArrayMap;
import android.util.ArraySet; import android.util.ArraySet;
import android.util.Log; import android.util.Log;
import android.util.Slog;
import android.util.SparseArray; import android.util.SparseArray;
import com.android.internal.messages.nano.SystemMessageProto; import com.android.internal.messages.nano.SystemMessageProto;
@@ -174,9 +175,9 @@ public class ForegroundServiceControllerImpl
@Override @Override
public boolean isSystemAlertNotification(StatusBarNotification sbn) { public boolean isSystemAlertNotification(StatusBarNotification sbn) {
// TODO: tag system alert notifications so they can be suppressed if app's notification return sbn.getPackageName().equals("android")
// is tagged && sbn.getTag() != null
return false; && sbn.getTag().contains("AlertWindowNotification");
} }
/** /**

View File

@@ -368,6 +368,17 @@ public class ForegroundServiceControllerTest extends SysuiTestCase {
assertFalse(fsc.isDungeonNeededForUser(USERID_TWO)); 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 @Test
public void testStdLayoutBasic() { public void testStdLayoutBasic() {
final String PKG1 = "com.example.app0"; final String PKG1 = "com.example.app0";
@@ -439,7 +450,7 @@ public class ForegroundServiceControllerTest extends SysuiTestCase {
when(sbn.getNotification()).thenReturn(n); when(sbn.getNotification()).thenReturn(n);
when(sbn.getId()).thenReturn(id); when(sbn.getId()).thenReturn(id);
when(sbn.getPackageName()).thenReturn(pkg); when(sbn.getPackageName()).thenReturn(pkg);
when(sbn.getTag()).thenReturn(null); when(sbn.getTag()).thenReturn(tag);
when(sbn.getUserId()).thenReturn(userid); when(sbn.getUserId()).thenReturn(userid);
when(sbn.getUser()).thenReturn(new UserHandle(userid)); when(sbn.getUser()).thenReturn(new UserHandle(userid));
when(sbn.getKey()).thenReturn("MOCK:"+userid+"|"+pkg+"|"+id+"|"+tag); when(sbn.getKey()).thenReturn("MOCK:"+userid+"|"+pkg+"|"+id+"|"+tag);