Loading services/core/java/com/android/server/notification/RankingHelper.java +2 −1 Original line number Diff line number Diff line Loading @@ -152,7 +152,8 @@ public class RankingHelper implements RankingConfig { if (type != XmlPullParser.START_TAG) return; String tag = parser.getName(); if (!TAG_RANKING.equals(tag)) return; mRecords.clear(); // Clobber groups and channels with the xml, but don't delete other data that wasn't present // at the time of serialization. mRestoredWithoutUids.clear(); while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) { tag = parser.getName(); Loading services/tests/notification/src/com/android/server/notification/RankingHelperTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -489,6 +489,19 @@ public class RankingHelperTest { NotificationChannel.DEFAULT_CHANNEL_ID, false)); } @Test public void testLoadingOldChannelsDoesNotDeleteNewlyCreatedChannels() throws Exception { ByteArrayOutputStream baos = writeXmlAndPurge(PKG, UID, false, NotificationChannel.DEFAULT_CHANNEL_ID, "bananas"); mHelper.createNotificationChannel(PKG, UID, new NotificationChannel("bananas", "bananas", IMPORTANCE_LOW), true); loadStreamXml(baos); // Should still have the newly created channel that wasn't in the xml. assertTrue(mHelper.getNotificationChannel(PKG, UID, "bananas", false) != null); } @Test public void testCreateChannel_blocked() throws Exception { mHelper.setImportance(PKG, UID, NotificationManager.IMPORTANCE_NONE); Loading Loading
services/core/java/com/android/server/notification/RankingHelper.java +2 −1 Original line number Diff line number Diff line Loading @@ -152,7 +152,8 @@ public class RankingHelper implements RankingConfig { if (type != XmlPullParser.START_TAG) return; String tag = parser.getName(); if (!TAG_RANKING.equals(tag)) return; mRecords.clear(); // Clobber groups and channels with the xml, but don't delete other data that wasn't present // at the time of serialization. mRestoredWithoutUids.clear(); while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) { tag = parser.getName(); Loading
services/tests/notification/src/com/android/server/notification/RankingHelperTest.java +13 −0 Original line number Diff line number Diff line Loading @@ -489,6 +489,19 @@ public class RankingHelperTest { NotificationChannel.DEFAULT_CHANNEL_ID, false)); } @Test public void testLoadingOldChannelsDoesNotDeleteNewlyCreatedChannels() throws Exception { ByteArrayOutputStream baos = writeXmlAndPurge(PKG, UID, false, NotificationChannel.DEFAULT_CHANNEL_ID, "bananas"); mHelper.createNotificationChannel(PKG, UID, new NotificationChannel("bananas", "bananas", IMPORTANCE_LOW), true); loadStreamXml(baos); // Should still have the newly created channel that wasn't in the xml. assertTrue(mHelper.getNotificationChannel(PKG, UID, "bananas", false) != null); } @Test public void testCreateChannel_blocked() throws Exception { mHelper.setImportance(PKG, UID, NotificationManager.IMPORTANCE_NONE); Loading