Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f33db37d authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Clean up created data when flag rolled back

Test: PreferencesHelperTest
Bug: 375032330
Flag: EXEMPT intentionally unflagged
Change-Id: I54f37b0558c0de8217a017d9fa2535ddd5be7589
parent 4eb9e0fa
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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);
+24 −0
Original line number Diff line number Diff line
@@ -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() {