Loading services/core/java/com/android/server/notification/NotificationManagerService.java +6 −4 Original line number Diff line number Diff line Loading @@ -1306,14 +1306,16 @@ public class NotificationManagerService extends SystemService { mRankingHelper.updateNotificationChannel(pkg, uid, channel); } synchronized (mNotificationList) { synchronized (mNotificationLock) { final int N = mNotificationList.size(); for (int i = N - 1; i >= 0; --i) { NotificationRecord r = mNotificationList.get(i); if (channel.getId() != null && channel.getId().equals(r.getChannel().getId())) { if (r.sbn.getPackageName().equals(pkg) && r.sbn.getUid() == uid && channel.getId() != null && channel.getId().equals(r.getChannel().getId())) { r.updateNotificationChannel(mRankingHelper.getNotificationChannel( r.sbn.getPackageName(), r.getUser().getIdentifier(), channel.getId(), false)); pkg, uid, channel.getId(), false)); } } } Loading services/core/java/com/android/server/notification/NotificationRecord.java +50 −48 Original line number Diff line number Diff line Loading @@ -294,8 +294,9 @@ public final class NotificationRecord { stats.isNoisy = mSound != null || mVibration != null; if (mPreChannelsNotification && (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0) { && (importance == IMPORTANCE_UNSPECIFIED || (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0)) { if (!stats.isNoisy && requestedImportance > IMPORTANCE_LOW) { requestedImportance = IMPORTANCE_LOW; } Loading Loading @@ -358,6 +359,7 @@ public final class NotificationRecord { } void dump(PrintWriter pw, String prefix, Context baseContext, boolean redact) { prefix = prefix + " "; final Notification notification = sbn.getNotification(); final Icon icon = notification.getSmallIcon(); String iconStr = String.valueOf(icon); Loading services/tests/notification/src/com/android/server/notification/ImportanceExtractorTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -94,10 +94,12 @@ public class ImportanceExtractorTest { new NotificationChannel("a", "a", NotificationManager.IMPORTANCE_UNSPECIFIED); NotificationRecord r = getNotificationRecord(channel); int notificationImportance = r.getImportance(); extractor.process(r); assertEquals(r.getUserImportance(), NotificationManager.IMPORTANCE_UNSPECIFIED); assertEquals(NotificationManager.IMPORTANCE_UNSPECIFIED, r.getUserImportance()); assertEquals(notificationImportance, r.getImportance()); } @Test Loading services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -288,6 +288,18 @@ public class NotificationRecordTest { assertEquals(NotificationManager.IMPORTANCE_LOW, record.getImportance()); } @Test public void testImportance_locked_unspecified_preUpgrade() throws Exception { defaultChannel.setImportance(NotificationManager.IMPORTANCE_UNSPECIFIED); defaultChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /*defaultLights */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel); assertEquals(NotificationManager.IMPORTANCE_HIGH, record.getImportance()); } @Test public void testImportance_upgrade() throws Exception { StatusBarNotification sbn = getNotification(false /*preO */, true /* noisy */, Loading Loading
services/core/java/com/android/server/notification/NotificationManagerService.java +6 −4 Original line number Diff line number Diff line Loading @@ -1306,14 +1306,16 @@ public class NotificationManagerService extends SystemService { mRankingHelper.updateNotificationChannel(pkg, uid, channel); } synchronized (mNotificationList) { synchronized (mNotificationLock) { final int N = mNotificationList.size(); for (int i = N - 1; i >= 0; --i) { NotificationRecord r = mNotificationList.get(i); if (channel.getId() != null && channel.getId().equals(r.getChannel().getId())) { if (r.sbn.getPackageName().equals(pkg) && r.sbn.getUid() == uid && channel.getId() != null && channel.getId().equals(r.getChannel().getId())) { r.updateNotificationChannel(mRankingHelper.getNotificationChannel( r.sbn.getPackageName(), r.getUser().getIdentifier(), channel.getId(), false)); pkg, uid, channel.getId(), false)); } } } Loading
services/core/java/com/android/server/notification/NotificationRecord.java +50 −48 Original line number Diff line number Diff line Loading @@ -294,8 +294,9 @@ public final class NotificationRecord { stats.isNoisy = mSound != null || mVibration != null; if (mPreChannelsNotification && (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0) { && (importance == IMPORTANCE_UNSPECIFIED || (getChannel().getUserLockedFields() & NotificationChannel.USER_LOCKED_IMPORTANCE) == 0)) { if (!stats.isNoisy && requestedImportance > IMPORTANCE_LOW) { requestedImportance = IMPORTANCE_LOW; } Loading Loading @@ -358,6 +359,7 @@ public final class NotificationRecord { } void dump(PrintWriter pw, String prefix, Context baseContext, boolean redact) { prefix = prefix + " "; final Notification notification = sbn.getNotification(); final Icon icon = notification.getSmallIcon(); String iconStr = String.valueOf(icon); Loading
services/tests/notification/src/com/android/server/notification/ImportanceExtractorTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -94,10 +94,12 @@ public class ImportanceExtractorTest { new NotificationChannel("a", "a", NotificationManager.IMPORTANCE_UNSPECIFIED); NotificationRecord r = getNotificationRecord(channel); int notificationImportance = r.getImportance(); extractor.process(r); assertEquals(r.getUserImportance(), NotificationManager.IMPORTANCE_UNSPECIFIED); assertEquals(NotificationManager.IMPORTANCE_UNSPECIFIED, r.getUserImportance()); assertEquals(notificationImportance, r.getImportance()); } @Test Loading
services/tests/notification/src/com/android/server/notification/NotificationRecordTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -288,6 +288,18 @@ public class NotificationRecordTest { assertEquals(NotificationManager.IMPORTANCE_LOW, record.getImportance()); } @Test public void testImportance_locked_unspecified_preUpgrade() throws Exception { defaultChannel.setImportance(NotificationManager.IMPORTANCE_UNSPECIFIED); defaultChannel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE); StatusBarNotification sbn = getNotification(true /*preO */, true /* noisy */, true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */, false /* lights */, false /*defaultLights */); NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel); assertEquals(NotificationManager.IMPORTANCE_HIGH, record.getImportance()); } @Test public void testImportance_upgrade() throws Exception { StatusBarNotification sbn = getNotification(false /*preO */, true /* noisy */, Loading