Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinator.java +15 −5 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public class AppOpsCoordinator implements Coordinator { }; /** * Puts foreground service notifications into its own section. * Puts colorized foreground service and call notifications into its own section. */ private final NotifSectioner mNotifSectioner = new NotifSectioner("ForegroundService", NotificationPriorityBucketKt.BUCKET_FOREGROUND_SERVICE) { Loading @@ -109,12 +109,22 @@ public class AppOpsCoordinator implements Coordinator { public boolean isInSection(ListEntry entry) { NotificationEntry notificationEntry = entry.getRepresentativeEntry(); if (notificationEntry != null) { Notification notification = notificationEntry.getSbn().getNotification(); return isColorizedForegroundService(notificationEntry) || isCall(notificationEntry); } return false; } private boolean isColorizedForegroundService(NotificationEntry entry) { Notification notification = entry.getSbn().getNotification(); return notification.isForegroundService() && notification.isColorized() && entry.getRepresentativeEntry().getImportance() > IMPORTANCE_MIN; && entry.getImportance() > IMPORTANCE_MIN; } return false; private boolean isCall(NotificationEntry entry) { Notification notification = entry.getSbn().getNotification(); return entry.getImportance() > IMPORTANCE_MIN && notification.isStyle(Notification.CallStyle.class); } }; } packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinatorTest.java +35 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,10 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.Notification; import android.app.PendingIntent; import android.app.Person; import android.content.Intent; import android.graphics.Color; import android.os.UserHandle; import android.service.notification.StatusBarNotification; Loading Loading @@ -151,4 +155,35 @@ public class AppOpsCoordinatorTest extends SysuiTestCase { // THEN the entry is NOT in the fgs section assertFalse(mFgsSection.isInSection(mEntryBuilder.build())); } @Test public void testIncludeCallInSection_importanceDefault() { // GIVEN the notification represents a call with > min importance mEntryBuilder .setImportance(IMPORTANCE_DEFAULT) .modifyNotification(mContext) .setStyle(makeCallStyle()); // THEN the entry is in the fgs section assertTrue(mFgsSection.isInSection(mEntryBuilder.build())); } @Test public void testDiscludeCallInSection_importanceMin() { // GIVEN the notification represents a call with min importance mEntryBuilder .setImportance(IMPORTANCE_MIN) .modifyNotification(mContext) .setStyle(makeCallStyle()); // THEN the entry is NOT in the fgs section assertFalse(mFgsSection.isInSection(mEntryBuilder.build())); } private Notification.CallStyle makeCallStyle() { final PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent("action"), PendingIntent.FLAG_IMMUTABLE); final Person person = new Person.Builder().setName("person").build(); return Notification.CallStyle.forIncomingCall(person, pendingIntent, pendingIntent); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinator.java +15 −5 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ public class AppOpsCoordinator implements Coordinator { }; /** * Puts foreground service notifications into its own section. * Puts colorized foreground service and call notifications into its own section. */ private final NotifSectioner mNotifSectioner = new NotifSectioner("ForegroundService", NotificationPriorityBucketKt.BUCKET_FOREGROUND_SERVICE) { Loading @@ -109,12 +109,22 @@ public class AppOpsCoordinator implements Coordinator { public boolean isInSection(ListEntry entry) { NotificationEntry notificationEntry = entry.getRepresentativeEntry(); if (notificationEntry != null) { Notification notification = notificationEntry.getSbn().getNotification(); return isColorizedForegroundService(notificationEntry) || isCall(notificationEntry); } return false; } private boolean isColorizedForegroundService(NotificationEntry entry) { Notification notification = entry.getSbn().getNotification(); return notification.isForegroundService() && notification.isColorized() && entry.getRepresentativeEntry().getImportance() > IMPORTANCE_MIN; && entry.getImportance() > IMPORTANCE_MIN; } return false; private boolean isCall(NotificationEntry entry) { Notification notification = entry.getSbn().getNotification(); return entry.getImportance() > IMPORTANCE_MIN && notification.isStyle(Notification.CallStyle.class); } }; }
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinatorTest.java +35 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,10 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.app.Notification; import android.app.PendingIntent; import android.app.Person; import android.content.Intent; import android.graphics.Color; import android.os.UserHandle; import android.service.notification.StatusBarNotification; Loading Loading @@ -151,4 +155,35 @@ public class AppOpsCoordinatorTest extends SysuiTestCase { // THEN the entry is NOT in the fgs section assertFalse(mFgsSection.isInSection(mEntryBuilder.build())); } @Test public void testIncludeCallInSection_importanceDefault() { // GIVEN the notification represents a call with > min importance mEntryBuilder .setImportance(IMPORTANCE_DEFAULT) .modifyNotification(mContext) .setStyle(makeCallStyle()); // THEN the entry is in the fgs section assertTrue(mFgsSection.isInSection(mEntryBuilder.build())); } @Test public void testDiscludeCallInSection_importanceMin() { // GIVEN the notification represents a call with min importance mEntryBuilder .setImportance(IMPORTANCE_MIN) .modifyNotification(mContext) .setStyle(makeCallStyle()); // THEN the entry is NOT in the fgs section assertFalse(mFgsSection.isInSection(mEntryBuilder.build())); } private Notification.CallStyle makeCallStyle() { final PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent("action"), PendingIntent.FLAG_IMMUTABLE); final Person person = new Person.Builder().setName("person").build(); return Notification.CallStyle.forIncomingCall(person, pendingIntent, pendingIntent); } }