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

Commit 99c11c98 authored by Matías Hernández's avatar Matías Hernández
Browse files

Don't reset zenMode of ZenRules when reading XML

Since we now accept rules with other values of interruptionFilter.

Test: atest ZenModeConfigTest
Fixes: 325469168
Change-Id: Icb4ce9620c39d4b7eb9feba9603bf394d2f47968
parent fed62d90
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -813,9 +813,9 @@ public class ZenModeConfig implements Parcelable {
        rt.enabler = parser.getAttributeValue(null, RULE_ATT_ENABLER);
        rt.enabler = parser.getAttributeValue(null, RULE_ATT_ENABLER);
        rt.condition = readConditionXml(parser);
        rt.condition = readConditionXml(parser);


        // all default rules and user created rules updated to zenMode important interruptions
        if (!Flags.modesApi() && rt.zenMode != Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
        if (rt.zenMode != Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS
                && Condition.isValidId(rt.conditionId, SYSTEM_AUTHORITY)) {
                && Condition.isValidId(rt.conditionId, SYSTEM_AUTHORITY)) {
            // all default rules and user created rules updated to zenMode important interruptions
            Slog.i(TAG, "Updating zenMode of automatic rule " + rt.name);
            Slog.i(TAG, "Updating zenMode of automatic rule " + rt.name);
            rt.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
            rt.zenMode = Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS;
        }
        }
+15 −0
Original line number Original line Diff line number Diff line
@@ -624,6 +624,21 @@ public class ZenModeConfigTest extends UiServiceTestCase {
        assertEquals(rule.condition, fromXml.condition);
        assertEquals(rule.condition, fromXml.condition);
    }
    }


    @Test
    public void testRuleXml_customInterruptionFilter() throws Exception {
        ZenModeConfig.ZenRule rule = new ZenModeConfig.ZenRule();
        rule.zenMode = Settings.Global.ZEN_MODE_ALARMS;
        rule.conditionId = Uri.parse("condition://android/blah");
        assertThat(Condition.isValidId(rule.conditionId, ZenModeConfig.SYSTEM_AUTHORITY)).isTrue();

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        writeRuleXml(rule, baos);
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        ZenModeConfig.ZenRule fromXml = readRuleXml(bais);

        assertEquals(rule.zenMode, fromXml.zenMode);
    }

    @Test
    @Test
    public void testZenPolicyXml_allUnset() throws Exception {
    public void testZenPolicyXml_allUnset() throws Exception {
        ZenPolicy policy = new ZenPolicy.Builder().build();
        ZenPolicy policy = new ZenPolicy.Builder().build();