Exempt more notifications from heuristic
Bug: 123942966 Test: atest Change-Id: I3415b992b3fb5397f7a8ea080de6d0c11b259417
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package android.ext.services.notification;
|
||||
|
||||
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
||||
import static android.app.NotificationManager.IMPORTANCE_HIGH;
|
||||
import static android.app.NotificationManager.IMPORTANCE_MIN;
|
||||
|
||||
@@ -91,7 +92,7 @@ public class NotificationCategorizer {
|
||||
}
|
||||
// TODO: is from signature app
|
||||
if (entry.getSbn().getUid() < Process.FIRST_APPLICATION_UID) {
|
||||
if (entry.getImportance() >= IMPORTANCE_HIGH) {
|
||||
if (entry.getImportance() >= IMPORTANCE_DEFAULT) {
|
||||
return CATEGORY_SYSTEM;
|
||||
} else {
|
||||
return CATEGORY_SYSTEM_LOW;
|
||||
|
||||
@@ -18,6 +18,7 @@ package android.ext.services.notification;
|
||||
|
||||
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
|
||||
import static android.app.NotificationManager.IMPORTANCE_HIGH;
|
||||
import static android.app.NotificationManager.IMPORTANCE_LOW;
|
||||
import static android.app.NotificationManager.IMPORTANCE_MIN;
|
||||
import static android.os.Process.FIRST_APPLICATION_UID;
|
||||
|
||||
@@ -172,23 +173,23 @@ public class NotificationCategorizerTest {
|
||||
public void testSystemCategory() {
|
||||
NotificationCategorizer nc = new NotificationCategorizer();
|
||||
|
||||
when(mEntry.getChannel()).thenReturn(new NotificationChannel("", "", IMPORTANCE_HIGH));
|
||||
when(mEntry.getImportance()).thenReturn(IMPORTANCE_HIGH);
|
||||
when(mEntry.getChannel()).thenReturn(new NotificationChannel("", "", IMPORTANCE_DEFAULT));
|
||||
when(mEntry.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
|
||||
when(mSbn.getUid()).thenReturn(FIRST_APPLICATION_UID - 1);
|
||||
|
||||
assertEquals(NotificationCategorizer.CATEGORY_SYSTEM, nc.getCategory(mEntry));
|
||||
assertFalse(nc.shouldSilence(NotificationCategorizer.CATEGORY_SYSTEM));
|
||||
|
||||
when(mSbn.getUid()).thenReturn(FIRST_APPLICATION_UID);
|
||||
assertEquals(NotificationCategorizer.CATEGORY_HIGH, nc.getCategory(mEntry));
|
||||
assertEquals(NotificationCategorizer.CATEGORY_EVERYTHING_ELSE, nc.getCategory(mEntry));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSystemLowCategory() {
|
||||
NotificationCategorizer nc = new NotificationCategorizer();
|
||||
|
||||
when(mEntry.getChannel()).thenReturn(new NotificationChannel("", "", IMPORTANCE_DEFAULT));
|
||||
when(mEntry.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
|
||||
when(mEntry.getChannel()).thenReturn(new NotificationChannel("", "", IMPORTANCE_LOW));
|
||||
when(mEntry.getImportance()).thenReturn(IMPORTANCE_LOW);
|
||||
when(mSbn.getUid()).thenReturn(FIRST_APPLICATION_UID - 1);
|
||||
|
||||
assertEquals(NotificationCategorizer.CATEGORY_SYSTEM_LOW, nc.getCategory(mEntry));
|
||||
|
||||
Reference in New Issue
Block a user