Loading core/java/android/service/notification/ZenModeConfig.java +2 −0 Original line number Diff line number Diff line Loading @@ -1046,6 +1046,8 @@ public class ZenModeConfig implements Parcelable { DEFAULT_SUPPRESSED_VISUAL_EFFECTS); } else if (MANUAL_TAG.equals(tag)) { rt.manualRule = readRuleXml(parser); // manualRule.enabled can never be false, but it was broken in some builds. rt.manualRule.enabled = true; // Manual rule may be present prior to modes_ui if it were on, but in that // case it would not have a set policy, so make note of the need to set // it up later. Loading services/core/java/com/android/server/notification/ZenModeConditions.java +1 −1 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ public class ZenModeConditions implements ConditionProviders.Callback { } // empty rule? disable and bail early if (rule.component == null && rule.enabler == null) { if (!android.app.Flags.modesUi() || (android.app.Flags.modesUi() && !isManual)) { if (!isManual) { Log.w(TAG, "No component found for automatic rule: " + rule.conditionId); rule.enabled = false; } Loading services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static android.service.notification.Condition.STATE_FALSE; import static android.service.notification.Condition.STATE_TRUE; import static android.service.notification.NotificationListenerService.SUPPRESSED_EFFECT_SCREEN_ON; import static android.service.notification.ZenModeConfig.XML_VERSION_MODES_API; import static android.service.notification.ZenModeConfig.XML_VERSION_MODES_UI; import static android.service.notification.ZenModeConfig.ZEN_TAG; import static android.service.notification.ZenModeConfig.ZenRule.OVERRIDE_DEACTIVATE; import static android.service.notification.ZenModeConfig.ZenRule.OVERRIDE_NONE; Loading Loading @@ -1169,6 +1170,23 @@ public class ZenModeConfigTest extends UiServiceTestCase { assertThat(suppressedEffectsOf(result)).isEqualTo(suppressedEffectsOf(policy)); } @Test public void readXml_fixesWronglyDisabledManualRule() throws Exception { ZenModeConfig config = getCustomConfig(); if (!Flags.modesUi()) { config.manualRule = new ZenModeConfig.ZenRule(); config.manualRule.zenMode = ZEN_MODE_IMPORTANT_INTERRUPTIONS; } config.manualRule.enabled = false; ByteArrayOutputStream baos = new ByteArrayOutputStream(); writeConfigXml(config, XML_VERSION_MODES_UI, /* forBackup= */ false, baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ZenModeConfig fromXml = readConfigXml(bais); assertThat(fromXml.manualRule.enabled).isTrue(); } private static String suppressedEffectsOf(Policy policy) { return suppressedEffectsToString(policy.suppressedVisualEffects) + "(" + policy.suppressedVisualEffects + ")"; Loading Loading
core/java/android/service/notification/ZenModeConfig.java +2 −0 Original line number Diff line number Diff line Loading @@ -1046,6 +1046,8 @@ public class ZenModeConfig implements Parcelable { DEFAULT_SUPPRESSED_VISUAL_EFFECTS); } else if (MANUAL_TAG.equals(tag)) { rt.manualRule = readRuleXml(parser); // manualRule.enabled can never be false, but it was broken in some builds. rt.manualRule.enabled = true; // Manual rule may be present prior to modes_ui if it were on, but in that // case it would not have a set policy, so make note of the need to set // it up later. Loading
services/core/java/com/android/server/notification/ZenModeConditions.java +1 −1 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ public class ZenModeConditions implements ConditionProviders.Callback { } // empty rule? disable and bail early if (rule.component == null && rule.enabler == null) { if (!android.app.Flags.modesUi() || (android.app.Flags.modesUi() && !isManual)) { if (!isManual) { Log.w(TAG, "No component found for automatic rule: " + rule.conditionId); rule.enabled = false; } Loading
services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import static android.service.notification.Condition.STATE_FALSE; import static android.service.notification.Condition.STATE_TRUE; import static android.service.notification.NotificationListenerService.SUPPRESSED_EFFECT_SCREEN_ON; import static android.service.notification.ZenModeConfig.XML_VERSION_MODES_API; import static android.service.notification.ZenModeConfig.XML_VERSION_MODES_UI; import static android.service.notification.ZenModeConfig.ZEN_TAG; import static android.service.notification.ZenModeConfig.ZenRule.OVERRIDE_DEACTIVATE; import static android.service.notification.ZenModeConfig.ZenRule.OVERRIDE_NONE; Loading Loading @@ -1169,6 +1170,23 @@ public class ZenModeConfigTest extends UiServiceTestCase { assertThat(suppressedEffectsOf(result)).isEqualTo(suppressedEffectsOf(policy)); } @Test public void readXml_fixesWronglyDisabledManualRule() throws Exception { ZenModeConfig config = getCustomConfig(); if (!Flags.modesUi()) { config.manualRule = new ZenModeConfig.ZenRule(); config.manualRule.zenMode = ZEN_MODE_IMPORTANT_INTERRUPTIONS; } config.manualRule.enabled = false; ByteArrayOutputStream baos = new ByteArrayOutputStream(); writeConfigXml(config, XML_VERSION_MODES_UI, /* forBackup= */ false, baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ZenModeConfig fromXml = readConfigXml(bais); assertThat(fromXml.manualRule.enabled).isTrue(); } private static String suppressedEffectsOf(Policy policy) { return suppressedEffectsToString(policy.suppressedVisualEffects) + "(" + policy.suppressedVisualEffects + ")"; Loading