Ensure call notifications appear in the "ForegroundService" section.
Fixes: 215584504
Test: atest AppOpsCoordinatorTest
Change-Id: I53fe4e91446a6f4a8b306ecd4ed268dedac57f68
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinator.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinator.java
index 3a39c39..f04b24e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinator.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinator.java
@@ -101,7 +101,7 @@
};
/**
- * 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) {
@@ -109,12 +109,22 @@
public boolean isInSection(ListEntry entry) {
NotificationEntry notificationEntry = entry.getRepresentativeEntry();
if (notificationEntry != null) {
- Notification notification = notificationEntry.getSbn().getNotification();
- return notification.isForegroundService()
- && notification.isColorized()
- && entry.getRepresentativeEntry().getImportance() > IMPORTANCE_MIN;
+ return isColorizedForegroundService(notificationEntry) || isCall(notificationEntry);
}
return false;
}
+
+ private boolean isColorizedForegroundService(NotificationEntry entry) {
+ Notification notification = entry.getSbn().getNotification();
+ return notification.isForegroundService()
+ && notification.isColorized()
+ && entry.getImportance() > IMPORTANCE_MIN;
+ }
+
+ private boolean isCall(NotificationEntry entry) {
+ Notification notification = entry.getSbn().getNotification();
+ return entry.getImportance() > IMPORTANCE_MIN
+ && notification.isStyle(Notification.CallStyle.class);
+ }
};
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinatorTest.java
index f2e7081..bc32759 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinatorTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/coordinator/AppOpsCoordinatorTest.java
@@ -28,6 +28,10 @@
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;
@@ -151,4 +155,35 @@
// 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);
+ }
}