Loading core/java/android/app/NotificationManager.java +1 −5 Original line number Diff line number Diff line Loading @@ -416,16 +416,12 @@ public class NotificationManager { * Creates a notification channel that notifications can be posted to. * * This can also be used to restore a deleted channel and to update an existing channel's * name, description, and/or importance. * name and description. * * <p>The name and description should only be changed if the locale changes * or in response to the user renaming this channel. For example, if a user has a channel * named 'John Doe' that represents messages from a 'John Doe', and 'John Doe' changes his name * to 'John Smith,' the channel can be renamed to match. * * <p>The importance of an existing channel will only be changed if the new importance is lower * than the current value and the user has not altered any settings on this channel. * * All other fields are ignored for channels that already exist. * * @param channel the channel to create. Note that the created channel may differ from this Loading services/core/java/com/android/server/notification/RankingHelper.java +0 −7 Original line number Diff line number Diff line Loading @@ -553,13 +553,6 @@ public class RankingHelper implements RankingConfig { existing.setDescription(channel.getDescription()); existing.setBlockableSystem(channel.isBlockableSystem()); // Apps are allowed to downgrade channel importance if the user has not changed any // fields on this channel yet. if (existing.getUserLockedFields() == 0 && channel.getImportance() < existing.getImportance()) { existing.setImportance(channel.getImportance()); } updateConfig(); return; } Loading services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java +0 −36 Original line number Diff line number Diff line Loading @@ -332,42 +332,6 @@ public class NotificationManagerServiceTest extends NotificationTestCase { assertTrue(mBinderService.getNotificationChannel(PKG, "id2") != null); } @Test public void testCreateNotificationChannels_SecondCreateDoesNotChangeImportance() throws Exception { final NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_DEFAULT); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(channel))); // Recreating the channel doesn't throw, but ignores importance. final NotificationChannel dupeChannel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(dupeChannel))); final NotificationChannel createdChannel = mBinderService.getNotificationChannel(PKG, "id"); assertEquals(NotificationManager.IMPORTANCE_DEFAULT, createdChannel.getImportance()); } @Test public void testCreateNotificationChannels_SecondCreateAllowedToDowngradeImportance() throws Exception { final NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_DEFAULT); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(channel))); // Recreating with a lower importance is allowed to modify the channel. final NotificationChannel dupeChannel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_LOW); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(dupeChannel))); final NotificationChannel createdChannel = mBinderService.getNotificationChannel(PKG, "id"); assertEquals(NotificationManager.IMPORTANCE_LOW, createdChannel.getImportance()); } @Test public void testCreateNotificationChannels_CannotDowngradeImportanceIfAlreadyUpdated() throws Exception { Loading Loading
core/java/android/app/NotificationManager.java +1 −5 Original line number Diff line number Diff line Loading @@ -416,16 +416,12 @@ public class NotificationManager { * Creates a notification channel that notifications can be posted to. * * This can also be used to restore a deleted channel and to update an existing channel's * name, description, and/or importance. * name and description. * * <p>The name and description should only be changed if the locale changes * or in response to the user renaming this channel. For example, if a user has a channel * named 'John Doe' that represents messages from a 'John Doe', and 'John Doe' changes his name * to 'John Smith,' the channel can be renamed to match. * * <p>The importance of an existing channel will only be changed if the new importance is lower * than the current value and the user has not altered any settings on this channel. * * All other fields are ignored for channels that already exist. * * @param channel the channel to create. Note that the created channel may differ from this Loading
services/core/java/com/android/server/notification/RankingHelper.java +0 −7 Original line number Diff line number Diff line Loading @@ -553,13 +553,6 @@ public class RankingHelper implements RankingConfig { existing.setDescription(channel.getDescription()); existing.setBlockableSystem(channel.isBlockableSystem()); // Apps are allowed to downgrade channel importance if the user has not changed any // fields on this channel yet. if (existing.getUserLockedFields() == 0 && channel.getImportance() < existing.getImportance()) { existing.setImportance(channel.getImportance()); } updateConfig(); return; } Loading
services/tests/notification/src/com/android/server/notification/NotificationManagerServiceTest.java +0 −36 Original line number Diff line number Diff line Loading @@ -332,42 +332,6 @@ public class NotificationManagerServiceTest extends NotificationTestCase { assertTrue(mBinderService.getNotificationChannel(PKG, "id2") != null); } @Test public void testCreateNotificationChannels_SecondCreateDoesNotChangeImportance() throws Exception { final NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_DEFAULT); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(channel))); // Recreating the channel doesn't throw, but ignores importance. final NotificationChannel dupeChannel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_HIGH); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(dupeChannel))); final NotificationChannel createdChannel = mBinderService.getNotificationChannel(PKG, "id"); assertEquals(NotificationManager.IMPORTANCE_DEFAULT, createdChannel.getImportance()); } @Test public void testCreateNotificationChannels_SecondCreateAllowedToDowngradeImportance() throws Exception { final NotificationChannel channel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_DEFAULT); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(channel))); // Recreating with a lower importance is allowed to modify the channel. final NotificationChannel dupeChannel = new NotificationChannel("id", "name", NotificationManager.IMPORTANCE_LOW); mBinderService.createNotificationChannels(PKG, new ParceledListSlice(Arrays.asList(dupeChannel))); final NotificationChannel createdChannel = mBinderService.getNotificationChannel(PKG, "id"); assertEquals(NotificationManager.IMPORTANCE_LOW, createdChannel.getImportance()); } @Test public void testCreateNotificationChannels_CannotDowngradeImportanceIfAlreadyUpdated() throws Exception { Loading