Loading services/core/java/com/android/server/notification/PreferencesHelper.java +4 −0 Original line number Diff line number Diff line Loading @@ -440,6 +440,10 @@ public class PreferencesHelper implements RankingConfig { PackagePreferences r) { try { String id = parser.getAttributeValue(null, ATT_ID); if (!notificationClassification() && SYSTEM_RESERVED_IDS.contains(id)) { // delete bundle channels if flag is rolled back return; } String channelName = parser.getAttributeValue(null, ATT_NAME); int channelImportance = parser.getAttributeInt( null, ATT_IMPORTANCE, DEFAULT_IMPORTANCE); Loading services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -6390,6 +6390,30 @@ public class PreferencesHelperTest extends UiServiceTestCase { .isEqualTo(IMPORTANCE_LOW); } @Test @DisableFlags(FLAG_NOTIFICATION_CLASSIFICATION) public void testNotificationBundles_off_deletesData() throws Exception { String xml = "<ranking version=\"1\">\n" + "<package name=\"" + PKG_P + "\" uid=\"" + UID_P + "\">\n" + "<channel id=\"android.app.social\" name=\"Social\" importance=\"2\"/>\n" + "<channel id=\"android.app.news\" name=\"News\" importance=\"2\"/>\n" + "<channel id=\"android.app.recs\" name=\"Recs\" importance=\"2\"/>\n" + "<channel id=\"android.app.promotions\" name=\"Promos\" importance=\"2\"/>\n" + "<channel id=\"keep.me\" name=\"name\" importance=\"2\" " + "show_badge=\"true\" />\n" + "</package></ranking>\n"; loadByteArrayXml(xml.getBytes(), false, USER_SYSTEM); // verify 4 reserved channels are created assertThat(mXmlHelper.getNotificationChannel(PKG_P, UID_P, NEWS_ID, true)).isNull(); assertThat(mXmlHelper.getNotificationChannel(PKG_P, UID_P, PROMOTIONS_ID, true)).isNull(); assertThat(mXmlHelper.getNotificationChannel(PKG_P, UID_P, SOCIAL_MEDIA_ID, true)).isNull(); assertThat(mXmlHelper.getNotificationChannel(PKG_P, UID_P, RECS_ID, true)).isNull(); assertThat(mXmlHelper.getNotificationChannel(PKG_P, UID_P, "keep.me", false) .getImportance()).isEqualTo(IMPORTANCE_LOW); } @Test @EnableFlags(FLAG_NOTIFICATION_CLASSIFICATION) public void testNotificationBundles_appsCannotUpdate() { Loading Loading
services/core/java/com/android/server/notification/PreferencesHelper.java +4 −0 Original line number Diff line number Diff line Loading @@ -440,6 +440,10 @@ public class PreferencesHelper implements RankingConfig { PackagePreferences r) { try { String id = parser.getAttributeValue(null, ATT_ID); if (!notificationClassification() && SYSTEM_RESERVED_IDS.contains(id)) { // delete bundle channels if flag is rolled back return; } String channelName = parser.getAttributeValue(null, ATT_NAME); int channelImportance = parser.getAttributeInt( null, ATT_IMPORTANCE, DEFAULT_IMPORTANCE); Loading
services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +24 −0 Original line number Diff line number Diff line Loading @@ -6390,6 +6390,30 @@ public class PreferencesHelperTest extends UiServiceTestCase { .isEqualTo(IMPORTANCE_LOW); } @Test @DisableFlags(FLAG_NOTIFICATION_CLASSIFICATION) public void testNotificationBundles_off_deletesData() throws Exception { String xml = "<ranking version=\"1\">\n" + "<package name=\"" + PKG_P + "\" uid=\"" + UID_P + "\">\n" + "<channel id=\"android.app.social\" name=\"Social\" importance=\"2\"/>\n" + "<channel id=\"android.app.news\" name=\"News\" importance=\"2\"/>\n" + "<channel id=\"android.app.recs\" name=\"Recs\" importance=\"2\"/>\n" + "<channel id=\"android.app.promotions\" name=\"Promos\" importance=\"2\"/>\n" + "<channel id=\"keep.me\" name=\"name\" importance=\"2\" " + "show_badge=\"true\" />\n" + "</package></ranking>\n"; loadByteArrayXml(xml.getBytes(), false, USER_SYSTEM); // verify 4 reserved channels are created assertThat(mXmlHelper.getNotificationChannel(PKG_P, UID_P, NEWS_ID, true)).isNull(); assertThat(mXmlHelper.getNotificationChannel(PKG_P, UID_P, PROMOTIONS_ID, true)).isNull(); assertThat(mXmlHelper.getNotificationChannel(PKG_P, UID_P, SOCIAL_MEDIA_ID, true)).isNull(); assertThat(mXmlHelper.getNotificationChannel(PKG_P, UID_P, RECS_ID, true)).isNull(); assertThat(mXmlHelper.getNotificationChannel(PKG_P, UID_P, "keep.me", false) .getImportance()).isEqualTo(IMPORTANCE_LOW); } @Test @EnableFlags(FLAG_NOTIFICATION_CLASSIFICATION) public void testNotificationBundles_appsCannotUpdate() { Loading