Don't recommend downranking _HIGH notifications

Test: atest
Change-Id: Iede3988e97e9205d64c67d26e10c84db0a550158
Fixes: 123586747
This commit is contained in:
Julia Reynolds
2019-01-29 16:31:56 -05:00
parent a319c6448b
commit 98f6e69f32
2 changed files with 15 additions and 1 deletions

View File

@@ -45,12 +45,13 @@ public class NotificationCategorizer {
protected static final int CATEGORY_PEOPLE = 4;
protected static final int CATEGORY_ALARM = 5;
protected static final int CATEGORY_CALL = 6;
protected static final int CATEGORY_HIGH = 7;
/** @hide */
@IntDef(prefix = { "CATEGORY_" }, value = {
CATEGORY_MIN, CATEGORY_EVERYTHING_ELSE, CATEGORY_ONGOING, CATEGORY_CALL,
CATEGORY_SYSTEM_LOW, CATEGORY_EVENT, CATEGORY_REMINDER, CATEGORY_SYSTEM,
CATEGORY_PEOPLE, CATEGORY_ALARM
CATEGORY_PEOPLE, CATEGORY_ALARM, CATEGORY_HIGH
})
@Retention(RetentionPolicy.SOURCE)
public @interface Category {}
@@ -96,6 +97,9 @@ public class NotificationCategorizer {
return CATEGORY_SYSTEM_LOW;
}
}
if (entry.getChannel().getImportance() == IMPORTANCE_HIGH) {
return CATEGORY_HIGH;
}
if (entry.isOngoing()) {
return CATEGORY_ONGOING;
}

View File

@@ -84,6 +84,16 @@ public class NotificationCategorizerTest {
assertTrue(nc.shouldSilence(NotificationCategorizer.CATEGORY_MIN));
}
@Test
public void testHigh() {
NotificationCategorizer nc = new NotificationCategorizer();
when(mEntry.getChannel()).thenReturn(new NotificationChannel("", "", IMPORTANCE_HIGH));
assertEquals(NotificationCategorizer.CATEGORY_HIGH, nc.getCategory(mEntry));
assertFalse(nc.shouldSilence(NotificationCategorizer.CATEGORY_HIGH));
}
@Test
public void testOngoingCategory() {
NotificationCategorizer nc = new NotificationCategorizer();