Loading services/core/java/com/android/server/notification/NotificationComparator.java +20 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,12 @@ public class NotificationComparator return -1 * Boolean.compare(leftPeople, rightPeople); } boolean leftSystemMax = isSystemMax(left); boolean rightSystemMax = isSystemMax(right); if (leftSystemMax != rightSystemMax) { return -1 * Boolean.compare(leftSystemMax, rightSystemMax); } if (leftImportance != rightImportance) { // by importance, high to low return -1 * Integer.compare(leftImportance, rightImportance); Loading Loading @@ -173,6 +179,20 @@ public class NotificationComparator return mMessagingUtil.isImportantMessaging(record.getSbn(), record.getImportance()); } protected boolean isSystemMax(NotificationRecord record) { if (record.getImportance() < NotificationManager.IMPORTANCE_HIGH) { return false; } String packageName = record.getSbn().getPackageName(); if ("android".equals(packageName)) { return true; } if ("com.android.systemui".equals(packageName)) { return true; } return false; } private boolean isOngoing(NotificationRecord record) { final int ongoingFlags = Notification.FLAG_FOREGROUND_SERVICE; return (record.getNotification().flags & ongoingFlags) != 0; Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationComparatorTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ public class NotificationComparatorTest extends UiServiceTestCase { @Mock Vibrator mVibrator; private final String callPkg = "com.android.server.notification"; private final String sysPkg = "android"; private final int callUid = 10; private String smsPkg; private final int smsUid = 11; Loading @@ -79,6 +80,7 @@ public class NotificationComparatorTest extends UiServiceTestCase { private NotificationRecord mRecordHighCall; private NotificationRecord mRecordHighCallStyle; private NotificationRecord mRecordEmail; private NotificationRecord mRecordSystemMax; private NotificationRecord mRecordInlineReply; private NotificationRecord mRecordSms; private NotificationRecord mRecordStarredContact; Loading Loading @@ -191,6 +193,12 @@ public class NotificationComparatorTest extends UiServiceTestCase { mRecordContact.setContactAffinity(ValidateNotificationPeople.VALID_CONTACT); mRecordContact.setSystemImportance(NotificationManager.IMPORTANCE_DEFAULT); Notification nSystemMax = new Notification.Builder(mContext, TEST_CHANNEL_ID).build(); mRecordSystemMax = new NotificationRecord(mContext, new StatusBarNotification(sysPkg, sysPkg, 1, "systemmax", uid2, uid2, nSystemMax, new UserHandle(userId), "", 1244), getDefaultChannel()); mRecordSystemMax.setSystemImportance(NotificationManager.IMPORTANCE_HIGH); Notification n8 = new Notification.Builder(mContext, TEST_CHANNEL_ID).build(); mRecordUrgent = new NotificationRecord(mContext, new StatusBarNotification(pkg2, pkg2, 1, "urgent", uid2, uid2, n8, new UserHandle(userId), Loading Loading @@ -267,6 +275,7 @@ public class NotificationComparatorTest extends UiServiceTestCase { } expected.add(mRecordStarredContact); expected.add(mRecordContact); expected.add(mRecordSystemMax); expected.add(mRecordEmail); expected.add(mRecordUrgent); expected.add(mNoMediaSessionMedia); Loading Loading
services/core/java/com/android/server/notification/NotificationComparator.java +20 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,12 @@ public class NotificationComparator return -1 * Boolean.compare(leftPeople, rightPeople); } boolean leftSystemMax = isSystemMax(left); boolean rightSystemMax = isSystemMax(right); if (leftSystemMax != rightSystemMax) { return -1 * Boolean.compare(leftSystemMax, rightSystemMax); } if (leftImportance != rightImportance) { // by importance, high to low return -1 * Integer.compare(leftImportance, rightImportance); Loading Loading @@ -173,6 +179,20 @@ public class NotificationComparator return mMessagingUtil.isImportantMessaging(record.getSbn(), record.getImportance()); } protected boolean isSystemMax(NotificationRecord record) { if (record.getImportance() < NotificationManager.IMPORTANCE_HIGH) { return false; } String packageName = record.getSbn().getPackageName(); if ("android".equals(packageName)) { return true; } if ("com.android.systemui".equals(packageName)) { return true; } return false; } private boolean isOngoing(NotificationRecord record) { final int ongoingFlags = Notification.FLAG_FOREGROUND_SERVICE; return (record.getNotification().flags & ongoingFlags) != 0; Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationComparatorTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ public class NotificationComparatorTest extends UiServiceTestCase { @Mock Vibrator mVibrator; private final String callPkg = "com.android.server.notification"; private final String sysPkg = "android"; private final int callUid = 10; private String smsPkg; private final int smsUid = 11; Loading @@ -79,6 +80,7 @@ public class NotificationComparatorTest extends UiServiceTestCase { private NotificationRecord mRecordHighCall; private NotificationRecord mRecordHighCallStyle; private NotificationRecord mRecordEmail; private NotificationRecord mRecordSystemMax; private NotificationRecord mRecordInlineReply; private NotificationRecord mRecordSms; private NotificationRecord mRecordStarredContact; Loading Loading @@ -191,6 +193,12 @@ public class NotificationComparatorTest extends UiServiceTestCase { mRecordContact.setContactAffinity(ValidateNotificationPeople.VALID_CONTACT); mRecordContact.setSystemImportance(NotificationManager.IMPORTANCE_DEFAULT); Notification nSystemMax = new Notification.Builder(mContext, TEST_CHANNEL_ID).build(); mRecordSystemMax = new NotificationRecord(mContext, new StatusBarNotification(sysPkg, sysPkg, 1, "systemmax", uid2, uid2, nSystemMax, new UserHandle(userId), "", 1244), getDefaultChannel()); mRecordSystemMax.setSystemImportance(NotificationManager.IMPORTANCE_HIGH); Notification n8 = new Notification.Builder(mContext, TEST_CHANNEL_ID).build(); mRecordUrgent = new NotificationRecord(mContext, new StatusBarNotification(pkg2, pkg2, 1, "urgent", uid2, uid2, n8, new UserHandle(userId), Loading Loading @@ -267,6 +275,7 @@ public class NotificationComparatorTest extends UiServiceTestCase { } expected.add(mRecordStarredContact); expected.add(mRecordContact); expected.add(mRecordSystemMax); expected.add(mRecordEmail); expected.add(mRecordUrgent); expected.add(mNoMediaSessionMedia); Loading