summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/notification/PreferencesHelper.java4
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java24
2 files changed, 28 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java
index c9edc4106943..964a5d002bf2 100644
--- a/services/core/java/com/android/server/notification/PreferencesHelper.java
+++ b/services/core/java/com/android/server/notification/PreferencesHelper.java
@@ -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);
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
index b92bdb5f3e6e..36fa1b82fe69 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java
@@ -6391,6 +6391,30 @@ public class PreferencesHelperTest extends UiServiceTestCase {
}
@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() {
// do something that triggers settings creation for an app