summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Berglund <ericberglund@google.com>2020-07-10 14:19:02 -0700
committerEric Berglund <ericberglund@google.com>2020-07-10 18:00:20 -0700
commitc806ac41606435ef0224bc48b2b96995be498512 (patch)
tree1205a506e18f2080f5e5321b73545d1da18791b0
parent25ca95d732bec5249d71b564df753fe06d159cd6 (diff)
downloadplatform_packages_apps_Car_Notification-c806ac41606435ef0224bc48b2b96995be498512.tar.gz
platform_packages_apps_Car_Notification-c806ac41606435ef0224bc48b2b96995be498512.tar.bz2
platform_packages_apps_Car_Notification-c806ac41606435ef0224bc48b2b96995be498512.zip
Prevent dismissed calls from being added to the notification panel.android11-dev
Bug: 158675321 Test: manual, robolectric Change-Id: Ib6899d008122c8c82efee80b9642966a9fba1fa9
-rw-r--r--src/com/android/car/notification/PreprocessingManager.java8
-rw-r--r--tests/robotests/src/com/android/car/notification/PreprocessingManagerTest.java36
2 files changed, 44 insertions, 0 deletions
diff --git a/src/com/android/car/notification/PreprocessingManager.java b/src/com/android/car/notification/PreprocessingManager.java
index 02bfd73..8a06e4e 100644
--- a/src/com/android/car/notification/PreprocessingManager.java
+++ b/src/com/android/car/notification/PreprocessingManager.java
@@ -210,6 +210,14 @@ public class PreprocessingManager {
if (!showLessImportantNotifications) {
notifications.removeIf(alertEntry -> shouldFilter(alertEntry, rankingMap));
}
+
+ // Call notifications should not be shown in the panel.
+ // Since they're shown as persistent HUNs, and notifications are not added to the panel
+ // until after they're dismissed as HUNs, it does not make sense to have them in the panel,
+ // and sequencing could cause them to be removed before being added here.
+ notifications.removeIf(alertEntry -> Notification.CATEGORY_CALL.equals(
+ alertEntry.getNotification().category));
+
return notifications;
}
diff --git a/tests/robotests/src/com/android/car/notification/PreprocessingManagerTest.java b/tests/robotests/src/com/android/car/notification/PreprocessingManagerTest.java
index f70d33b..e76a72c 100644
--- a/tests/robotests/src/com/android/car/notification/PreprocessingManagerTest.java
+++ b/tests/robotests/src/com/android/car/notification/PreprocessingManagerTest.java
@@ -22,6 +22,7 @@ import static android.service.notification.NotificationListenerService.Ranking.U
import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -234,6 +235,41 @@ public class PreprocessingManagerTest {
}
@Test
+ public void onFilter_doShowLessImportantNotifications_doesNotFilterMediaOrNavigation() {
+ mPreprocessingManager
+ .filter(/* showLessImportantNotifications= */true, mAlertEntries, mRankingMap);
+
+ assertThat(mAlertEntries.contains(mMedia)).isTrue();
+ assertThat(mAlertEntries.contains(mNavigation)).isTrue();
+ }
+
+ @Test
+ public void onFilter_doShowLessImportantNotifications_filtersCalls() {
+ StatusBarNotification callSBN = mock(StatusBarNotification.class);
+ Notification callNotification = new Notification();
+ callNotification.category = Notification.CATEGORY_CALL;
+ when(callSBN.getNotification()).thenReturn(callNotification);
+ List<AlertEntry> entries = new ArrayList<>();
+ entries.add(new AlertEntry(callSBN));
+
+ mPreprocessingManager.filter(true, entries, mRankingMap);
+ assertThat(entries).isEmpty();
+ }
+
+ @Test
+ public void onFilter_dontShowLessImportantNotifications_filtersCalls() {
+ StatusBarNotification callSBN = mock(StatusBarNotification.class);
+ Notification callNotification = new Notification();
+ callNotification.category = Notification.CATEGORY_CALL;
+ when(callSBN.getNotification()).thenReturn(callNotification);
+ List<AlertEntry> entries = new ArrayList<>();
+ entries.add(new AlertEntry(callSBN));
+
+ mPreprocessingManager.filter(false, entries, mRankingMap);
+ assertThat(entries).isEmpty();
+ }
+
+ @Test
public void onOptimizeForDriving_alertEntryHasNonMessageNotification_trimsNotificationTexts() {
when(mCarUxRestrictions.getMaxRestrictedStringLength()).thenReturn(MAX_STRING_LENGTH);
when(mCarUxRestrictionManagerWrapper.getCurrentCarUxRestrictions())