Loading core/java/android/app/AutomaticZenRule.java +9 −0 Original line number Diff line number Diff line Loading @@ -119,6 +119,7 @@ public final class AutomaticZenRule implements Parcelable { @IntDef(flag = true, prefix = { "FIELD_" }, value = { FIELD_NAME, FIELD_INTERRUPTION_FILTER, FIELD_ICON }) @Retention(RetentionPolicy.SOURCE) public @interface ModifiableField {} Loading @@ -133,6 +134,11 @@ public final class AutomaticZenRule implements Parcelable { */ @FlaggedApi(Flags.FLAG_MODES_API) public static final int FIELD_INTERRUPTION_FILTER = 1 << 1; /** * @hide */ @FlaggedApi(Flags.FLAG_MODES_API) public static final int FIELD_ICON = 1 << 2; private boolean enabled; private String name; Loading Loading @@ -579,6 +585,9 @@ public final class AutomaticZenRule implements Parcelable { if ((bitmask & FIELD_INTERRUPTION_FILTER) != 0) { modified.add("FIELD_INTERRUPTION_FILTER"); } if ((bitmask & FIELD_ICON) != 0) { modified.add("FIELD_ICON"); } return "{" + String.join(",", modified) + "}"; } Loading services/core/java/com/android/server/notification/ZenModeHelper.java +17 −4 Original line number Diff line number Diff line Loading @@ -1154,11 +1154,13 @@ public class ZenModeHelper { rule.allowManualInvocation = azr.isManualInvocationAllowed(); modified = true; } if (!Flags.modesUi()) { String iconResName = drawableResIdToResName(rule.pkg, azr.getIconResId()); if (!Objects.equals(rule.iconResName, iconResName)) { rule.iconResName = iconResName; modified = true; } } if (!Objects.equals(rule.triggerDescription, azr.getTriggerDescription())) { rule.triggerDescription = azr.getTriggerDescription(); modified = true; Loading Loading @@ -1210,6 +1212,17 @@ public class ZenModeHelper { modified = true; } if (Flags.modesUi()) { String iconResName = drawableResIdToResName(rule.pkg, azr.getIconResId()); if (!Objects.equals(rule.iconResName, iconResName)) { rule.iconResName = iconResName; if (updateBitmask) { rule.userModifiedFields |= AutomaticZenRule.FIELD_ICON; } modified = true; } } // Updates the bitmask and values for all policy fields, based on the origin. modified |= updatePolicy(rule, azr.getZenPolicy(), updateBitmask, isNew); Loading services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +9 −3 Original line number Diff line number Diff line Loading @@ -4361,7 +4361,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { azrBase, UPDATE_ORIGIN_APP, "reason", Process.SYSTEM_UID); AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId); // Modifies the filter, zen policy, and device effects // Modifies the filter, icon, zen policy, and device effects ZenPolicy policy = new ZenPolicy.Builder(rule.getZenPolicy()) .allowPriorityChannels(false) .build(); Loading @@ -4371,6 +4371,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { .build(); AutomaticZenRule azrUpdate = new AutomaticZenRule.Builder(rule) .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY) .setIconResId(ICON_RES_ID) .setZenPolicy(policy) .setDeviceEffects(deviceEffects) .build(); Loading @@ -4382,6 +4383,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { // UPDATE_ORIGIN_USER should change the bitmask and change the values. assertThat(rule.getInterruptionFilter()).isEqualTo(INTERRUPTION_FILTER_PRIORITY); assertThat(rule.getIconResId()).isEqualTo(ICON_RES_ID); assertThat(rule.getZenPolicy().getPriorityChannelsAllowed()).isEqualTo( ZenPolicy.STATE_DISALLOW); Loading @@ -4389,7 +4391,9 @@ public class ZenModeHelperTest extends UiServiceTestCase { ZenRule storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleId); assertThat(storedRule.userModifiedFields) .isEqualTo(AutomaticZenRule.FIELD_INTERRUPTION_FILTER); .isEqualTo(Flags.modesUi() ? AutomaticZenRule.FIELD_INTERRUPTION_FILTER | AutomaticZenRule.FIELD_ICON : AutomaticZenRule.FIELD_INTERRUPTION_FILTER); assertThat(storedRule.zenPolicyUserModifiedFields) .isEqualTo(ZenPolicy.FIELD_ALLOW_CHANNELS); assertThat(storedRule.zenDeviceEffectsUserModifiedFields) Loading @@ -4414,7 +4418,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { azrBase, UPDATE_ORIGIN_APP, "reason", Process.SYSTEM_UID); AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId); // Modifies the zen policy and device effects // Modifies the icon, zen policy and device effects ZenPolicy policy = new ZenPolicy.Builder(rule.getZenPolicy()) .allowReminders(true) .build(); Loading @@ -4424,6 +4428,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { .build(); AutomaticZenRule azrUpdate = new AutomaticZenRule.Builder(rule) .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY) .setIconResId(ICON_RES_ID) .setZenPolicy(policy) .setDeviceEffects(deviceEffects) .build(); Loading @@ -4434,6 +4439,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { rule = mZenModeHelper.getAutomaticZenRule(ruleId); // UPDATE_ORIGIN_SYSTEM_OR_SYSTEMUI should change the value but NOT update the bitmask. assertThat(rule.getIconResId()).isEqualTo(ICON_RES_ID); assertThat(rule.getZenPolicy().getPriorityCategoryReminders()) .isEqualTo(ZenPolicy.STATE_ALLOW); assertThat(rule.getDeviceEffects().shouldDisplayGrayscale()).isTrue(); Loading Loading
core/java/android/app/AutomaticZenRule.java +9 −0 Original line number Diff line number Diff line Loading @@ -119,6 +119,7 @@ public final class AutomaticZenRule implements Parcelable { @IntDef(flag = true, prefix = { "FIELD_" }, value = { FIELD_NAME, FIELD_INTERRUPTION_FILTER, FIELD_ICON }) @Retention(RetentionPolicy.SOURCE) public @interface ModifiableField {} Loading @@ -133,6 +134,11 @@ public final class AutomaticZenRule implements Parcelable { */ @FlaggedApi(Flags.FLAG_MODES_API) public static final int FIELD_INTERRUPTION_FILTER = 1 << 1; /** * @hide */ @FlaggedApi(Flags.FLAG_MODES_API) public static final int FIELD_ICON = 1 << 2; private boolean enabled; private String name; Loading Loading @@ -579,6 +585,9 @@ public final class AutomaticZenRule implements Parcelable { if ((bitmask & FIELD_INTERRUPTION_FILTER) != 0) { modified.add("FIELD_INTERRUPTION_FILTER"); } if ((bitmask & FIELD_ICON) != 0) { modified.add("FIELD_ICON"); } return "{" + String.join(",", modified) + "}"; } Loading
services/core/java/com/android/server/notification/ZenModeHelper.java +17 −4 Original line number Diff line number Diff line Loading @@ -1154,11 +1154,13 @@ public class ZenModeHelper { rule.allowManualInvocation = azr.isManualInvocationAllowed(); modified = true; } if (!Flags.modesUi()) { String iconResName = drawableResIdToResName(rule.pkg, azr.getIconResId()); if (!Objects.equals(rule.iconResName, iconResName)) { rule.iconResName = iconResName; modified = true; } } if (!Objects.equals(rule.triggerDescription, azr.getTriggerDescription())) { rule.triggerDescription = azr.getTriggerDescription(); modified = true; Loading Loading @@ -1210,6 +1212,17 @@ public class ZenModeHelper { modified = true; } if (Flags.modesUi()) { String iconResName = drawableResIdToResName(rule.pkg, azr.getIconResId()); if (!Objects.equals(rule.iconResName, iconResName)) { rule.iconResName = iconResName; if (updateBitmask) { rule.userModifiedFields |= AutomaticZenRule.FIELD_ICON; } modified = true; } } // Updates the bitmask and values for all policy fields, based on the origin. modified |= updatePolicy(rule, azr.getZenPolicy(), updateBitmask, isNew); Loading
services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +9 −3 Original line number Diff line number Diff line Loading @@ -4361,7 +4361,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { azrBase, UPDATE_ORIGIN_APP, "reason", Process.SYSTEM_UID); AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId); // Modifies the filter, zen policy, and device effects // Modifies the filter, icon, zen policy, and device effects ZenPolicy policy = new ZenPolicy.Builder(rule.getZenPolicy()) .allowPriorityChannels(false) .build(); Loading @@ -4371,6 +4371,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { .build(); AutomaticZenRule azrUpdate = new AutomaticZenRule.Builder(rule) .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY) .setIconResId(ICON_RES_ID) .setZenPolicy(policy) .setDeviceEffects(deviceEffects) .build(); Loading @@ -4382,6 +4383,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { // UPDATE_ORIGIN_USER should change the bitmask and change the values. assertThat(rule.getInterruptionFilter()).isEqualTo(INTERRUPTION_FILTER_PRIORITY); assertThat(rule.getIconResId()).isEqualTo(ICON_RES_ID); assertThat(rule.getZenPolicy().getPriorityChannelsAllowed()).isEqualTo( ZenPolicy.STATE_DISALLOW); Loading @@ -4389,7 +4391,9 @@ public class ZenModeHelperTest extends UiServiceTestCase { ZenRule storedRule = mZenModeHelper.mConfig.automaticRules.get(ruleId); assertThat(storedRule.userModifiedFields) .isEqualTo(AutomaticZenRule.FIELD_INTERRUPTION_FILTER); .isEqualTo(Flags.modesUi() ? AutomaticZenRule.FIELD_INTERRUPTION_FILTER | AutomaticZenRule.FIELD_ICON : AutomaticZenRule.FIELD_INTERRUPTION_FILTER); assertThat(storedRule.zenPolicyUserModifiedFields) .isEqualTo(ZenPolicy.FIELD_ALLOW_CHANNELS); assertThat(storedRule.zenDeviceEffectsUserModifiedFields) Loading @@ -4414,7 +4418,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { azrBase, UPDATE_ORIGIN_APP, "reason", Process.SYSTEM_UID); AutomaticZenRule rule = mZenModeHelper.getAutomaticZenRule(ruleId); // Modifies the zen policy and device effects // Modifies the icon, zen policy and device effects ZenPolicy policy = new ZenPolicy.Builder(rule.getZenPolicy()) .allowReminders(true) .build(); Loading @@ -4424,6 +4428,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { .build(); AutomaticZenRule azrUpdate = new AutomaticZenRule.Builder(rule) .setInterruptionFilter(INTERRUPTION_FILTER_PRIORITY) .setIconResId(ICON_RES_ID) .setZenPolicy(policy) .setDeviceEffects(deviceEffects) .build(); Loading @@ -4434,6 +4439,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { rule = mZenModeHelper.getAutomaticZenRule(ruleId); // UPDATE_ORIGIN_SYSTEM_OR_SYSTEMUI should change the value but NOT update the bitmask. assertThat(rule.getIconResId()).isEqualTo(ICON_RES_ID); assertThat(rule.getZenPolicy().getPriorityCategoryReminders()) .isEqualTo(ZenPolicy.STATE_ALLOW); assertThat(rule.getDeviceEffects().shouldDisplayGrayscale()).isTrue(); Loading