Loading core/java/android/service/notification/ZenDeviceEffects.java +10 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,16 @@ public final class ZenDeviceEffects implements Parcelable { return mMaximizeDoze; } /** * Whether any of the effects are set up. * @hide */ public boolean hasEffects() { return mGrayscale || mSuppressAmbientDisplay || mDimWallpaper || mNightMode || mDisableAutoBrightness || mDisableTapToWake || mDisableTiltToWake || mDisableTouch || mMinimizeRadioUsage || mMaximizeDoze; } /** {@link Parcelable.Creator} that instantiates {@link ZenDeviceEffects} objects. */ @NonNull public static final Creator<ZenDeviceEffects> CREATOR = new Creator<ZenDeviceEffects>() { Loading core/java/android/service/notification/ZenModeConfig.java +82 −3 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF; import android.annotation.FlaggedApi; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AlarmManager; Loading Loading @@ -185,6 +186,18 @@ public class ZenModeConfig implements Parcelable { private static final String RULE_ATT_ICON = "rule_icon"; private static final String RULE_ATT_TRIGGER_DESC = "triggerDesc"; private static final String DEVICE_EFFECT_DISPLAY_GRAYSCALE = "zdeDisplayGrayscale"; private static final String DEVICE_EFFECT_SUPPRESS_AMBIENT_DISPLAY = "zdeSuppressAmbientDisplay"; private static final String DEVICE_EFFECT_DIM_WALLPAPER = "zdeDimWallpaper"; private static final String DEVICE_EFFECT_USE_NIGHT_MODE = "zdeUseNightMode"; private static final String DEVICE_EFFECT_DISABLE_AUTO_BRIGHTNESS = "zdeDisableAutoBrightness"; private static final String DEVICE_EFFECT_DISABLE_TAP_TO_WAKE = "zdeDisableTapToWake"; private static final String DEVICE_EFFECT_DISABLE_TILT_TO_WAKE = "zdeDisableTiltToWake"; private static final String DEVICE_EFFECT_DISABLE_TOUCH = "zdeDisableTouch"; private static final String DEVICE_EFFECT_MINIMIZE_RADIO_USAGE = "zdeMinimizeRadioUsage"; private static final String DEVICE_EFFECT_MAXIMIZE_DOZE = "zdeMaximizeDoze"; @UnsupportedAppUsage public boolean allowAlarms = DEFAULT_ALLOW_ALARMS; public boolean allowMedia = DEFAULT_ALLOW_MEDIA; Loading Loading @@ -630,6 +643,7 @@ public class ZenModeConfig implements Parcelable { rt.modified = safeBoolean(parser, RULE_ATT_MODIFIED, false); rt.zenPolicy = readZenPolicyXml(parser); if (Flags.modesApi()) { rt.zenDeviceEffects = readZenDeviceEffectsXml(parser); rt.allowManualInvocation = safeBoolean(parser, RULE_ATT_ALLOW_MANUAL, false); rt.iconResId = safeInt(parser, RULE_ATT_ICON, 0); rt.triggerDescription = parser.getAttributeValue(null, RULE_ATT_TRIGGER_DESC); Loading Loading @@ -667,6 +681,9 @@ public class ZenModeConfig implements Parcelable { if (rule.zenPolicy != null) { writeZenPolicyXml(rule.zenPolicy, out); } if (Flags.modesApi() && rule.zenDeviceEffects != null) { writeZenDeviceEffectsXml(rule.zenDeviceEffects, out); } out.attributeBoolean(null, RULE_ATT_MODIFIED, rule.modified); if (Flags.modesApi()) { out.attributeBoolean(null, RULE_ATT_ALLOW_MANUAL, rule.allowManualInvocation); Loading Loading @@ -859,6 +876,57 @@ public class ZenModeConfig implements Parcelable { } } @Nullable private static ZenDeviceEffects readZenDeviceEffectsXml(TypedXmlPullParser parser) { ZenDeviceEffects deviceEffects = new ZenDeviceEffects.Builder() .setShouldDisplayGrayscale( safeBoolean(parser, DEVICE_EFFECT_DISPLAY_GRAYSCALE, false)) .setShouldSuppressAmbientDisplay( safeBoolean(parser, DEVICE_EFFECT_SUPPRESS_AMBIENT_DISPLAY, false)) .setShouldDimWallpaper(safeBoolean(parser, DEVICE_EFFECT_DIM_WALLPAPER, false)) .setShouldUseNightMode(safeBoolean(parser, DEVICE_EFFECT_USE_NIGHT_MODE, false)) .setShouldDisableAutoBrightness( safeBoolean(parser, DEVICE_EFFECT_DISABLE_AUTO_BRIGHTNESS, false)) .setShouldDisableTapToWake( safeBoolean(parser, DEVICE_EFFECT_DISABLE_TAP_TO_WAKE, false)) .setShouldDisableTiltToWake( safeBoolean(parser, DEVICE_EFFECT_DISABLE_TILT_TO_WAKE, false)) .setShouldDisableTouch(safeBoolean(parser, DEVICE_EFFECT_DISABLE_TOUCH, false)) .setShouldMinimizeRadioUsage( safeBoolean(parser, DEVICE_EFFECT_MINIMIZE_RADIO_USAGE, false)) .setShouldMaximizeDoze(safeBoolean(parser, DEVICE_EFFECT_MAXIMIZE_DOZE, false)) .build(); return deviceEffects.hasEffects() ? deviceEffects : null; } private static void writeZenDeviceEffectsXml(ZenDeviceEffects deviceEffects, TypedXmlSerializer out) throws IOException { writeBooleanIfTrue(out, DEVICE_EFFECT_DISPLAY_GRAYSCALE, deviceEffects.shouldDisplayGrayscale()); writeBooleanIfTrue(out, DEVICE_EFFECT_SUPPRESS_AMBIENT_DISPLAY, deviceEffects.shouldSuppressAmbientDisplay()); writeBooleanIfTrue(out, DEVICE_EFFECT_DIM_WALLPAPER, deviceEffects.shouldDimWallpaper()); writeBooleanIfTrue(out, DEVICE_EFFECT_USE_NIGHT_MODE, deviceEffects.shouldUseNightMode()); writeBooleanIfTrue(out, DEVICE_EFFECT_DISABLE_AUTO_BRIGHTNESS, deviceEffects.shouldDisableAutoBrightness()); writeBooleanIfTrue(out, DEVICE_EFFECT_DISABLE_TAP_TO_WAKE, deviceEffects.shouldDisableTapToWake()); writeBooleanIfTrue(out, DEVICE_EFFECT_DISABLE_TILT_TO_WAKE, deviceEffects.shouldDisableTiltToWake()); writeBooleanIfTrue(out, DEVICE_EFFECT_DISABLE_TOUCH, deviceEffects.shouldDisableTouch()); writeBooleanIfTrue(out, DEVICE_EFFECT_MINIMIZE_RADIO_USAGE, deviceEffects.shouldMinimizeRadioUsage()); writeBooleanIfTrue(out, DEVICE_EFFECT_MAXIMIZE_DOZE, deviceEffects.shouldMaximizeDoze()); } private static void writeBooleanIfTrue(TypedXmlSerializer out, String att, boolean value) throws IOException { if (value) { out.attributeBoolean(null, att, true); } } public static boolean isValidHour(int val) { return val >= 0 && val < 24; } Loading Loading @@ -1755,6 +1823,8 @@ public class ZenModeConfig implements Parcelable { // package name, only used for manual rules when they have turned DND on. public String enabler; public ZenPolicy zenPolicy; @FlaggedApi(Flags.FLAG_MODES_API) @Nullable public ZenDeviceEffects zenDeviceEffects; public boolean modified; // rule has been modified from initial creation public String pkg; public int type = AutomaticZenRule.TYPE_UNKNOWN; Loading Loading @@ -1784,6 +1854,9 @@ public class ZenModeConfig implements Parcelable { enabler = source.readString(); } zenPolicy = source.readParcelable(null, android.service.notification.ZenPolicy.class); if (Flags.modesApi()) { zenDeviceEffects = source.readParcelable(null, ZenDeviceEffects.class); } modified = source.readInt() == 1; pkg = source.readString(); if (Flags.modesApi()) { Loading Loading @@ -1828,6 +1901,9 @@ public class ZenModeConfig implements Parcelable { dest.writeInt(0); } dest.writeParcelable(zenPolicy, 0); if (Flags.modesApi()) { dest.writeParcelable(zenDeviceEffects, 0); } dest.writeInt(modified ? 1 : 0); dest.writeString(pkg); if (Flags.modesApi()) { Loading Loading @@ -1859,7 +1935,8 @@ public class ZenModeConfig implements Parcelable { .append(",condition=").append(condition); if (Flags.modesApi()) { sb.append(",allowManualInvocation=").append(allowManualInvocation) sb.append(",deviceEffects=").append(zenDeviceEffects) .append(",allowManualInvocation=").append(allowManualInvocation) .append(",iconResId=").append(iconResId) .append(",triggerDescription=").append(triggerDescription) .append(",type=").append(type); Loading Loading @@ -1917,6 +1994,7 @@ public class ZenModeConfig implements Parcelable { if (Flags.modesApi()) { return finalEquals && Objects.equals(other.zenDeviceEffects, zenDeviceEffects) && other.allowManualInvocation == allowManualInvocation && other.iconResId == iconResId && Objects.equals(other.triggerDescription, triggerDescription) Loading @@ -1930,8 +2008,9 @@ public class ZenModeConfig implements Parcelable { public int hashCode() { if (Flags.modesApi()) { return Objects.hash(enabled, snoozing, name, zenMode, conditionId, condition, component, configurationActivity, pkg, id, enabler, zenPolicy, modified, allowManualInvocation, iconResId, triggerDescription, type); component, configurationActivity, pkg, id, enabler, zenPolicy, zenDeviceEffects, modified, allowManualInvocation, iconResId, triggerDescription, type); } return Objects.hash(enabled, snoozing, name, zenMode, conditionId, condition, component, configurationActivity, pkg, id, enabler, zenPolicy, modified); Loading core/java/android/service/notification/ZenModeDiff.java +21 −14 Original line number Diff line number Diff line Loading @@ -452,11 +452,12 @@ public class ZenModeDiff { public static final String FIELD_CREATION_TIME = "creationTime"; public static final String FIELD_ENABLER = "enabler"; public static final String FIELD_ZEN_POLICY = "zenPolicy"; public static final String FIELD_ZEN_DEVICE_EFFECTS = "zenDeviceEffects"; public static final String FIELD_MODIFIED = "modified"; public static final String FIELD_PKG = "pkg"; public static final String FIELD_ALLOW_MANUAL = "allowManualInvocation"; public static final String FIELD_ICON_RES = "iconResId"; public static final String FIELD_TRIGGER = "triggerDescription"; public static final String FIELD_TRIGGER_DESCRIPTION = "triggerDescription"; public static final String FIELD_TYPE = "type"; // NOTE: new field strings must match the variable names in ZenModeConfig.ZenRule Loading Loading @@ -534,8 +535,13 @@ public class ZenModeDiff { if (!Objects.equals(from.pkg, to.pkg)) { addField(FIELD_PKG, new FieldDiff<>(from.pkg, to.pkg)); } if (android.app.Flags.modesApi()) { if (!Objects.equals(from.zenDeviceEffects, to.zenDeviceEffects)) { addField(FIELD_ZEN_DEVICE_EFFECTS, new FieldDiff<>(from.zenDeviceEffects, to.zenDeviceEffects)); } if (!Objects.equals(from.triggerDescription, to.triggerDescription)) { addField(FIELD_TRIGGER, addField(FIELD_TRIGGER_DESCRIPTION, new FieldDiff<>(from.triggerDescription, to.triggerDescription)); } if (from.type != to.type) { Loading @@ -546,7 +552,8 @@ public class ZenModeDiff { new FieldDiff<>(from.allowManualInvocation, to.allowManualInvocation)); } if (!Objects.equals(from.iconResId, to.iconResId)) { addField(FIELD_ICON_RES, new FieldDiff(from.iconResId, to.iconResId)); addField(FIELD_ICON_RES, new FieldDiff<>(from.iconResId, to.iconResId)); } } } Loading services/core/java/com/android/server/notification/ZenModeHelper.java +4 −0 Original line number Diff line number Diff line Loading @@ -860,6 +860,9 @@ public class ZenModeHelper { rule.enabled = automaticZenRule.isEnabled(); rule.modified = automaticZenRule.isModified(); rule.zenPolicy = automaticZenRule.getZenPolicy(); if (Flags.modesApi()) { rule.zenDeviceEffects = automaticZenRule.getDeviceEffects(); } rule.zenMode = NotificationManager.zenModeFromInterruptionFilter( automaticZenRule.getInterruptionFilter(), Global.ZEN_MODE_OFF); rule.configurationActivity = automaticZenRule.getConfigurationActivity(); Loading Loading @@ -888,6 +891,7 @@ public class ZenModeHelper { .setIconResId(rule.iconResId) .setType(rule.type) .setZenPolicy(rule.zenPolicy) .setDeviceEffects(rule.zenDeviceEffects) .setEnabled(rule.enabled) .setInterruptionFilter( NotificationManager.zenModeToInterruptionFilter(rule.zenMode)) Loading services/tests/uiservicestests/src/com/android/server/notification/ZenDeviceEffectsTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -102,4 +102,18 @@ public class ZenDeviceEffectsTest extends UiServiceTestCase { assertThat(copy.shouldSuppressAmbientDisplay()).isTrue(); assertThat(copy.shouldDisplayGrayscale()).isFalse(); } @Test public void hasEffects_none_returnsFalse() { ZenDeviceEffects effects = new ZenDeviceEffects.Builder().build(); assertThat(effects.hasEffects()).isFalse(); } @Test public void hasEffects_some_returnsTrue() { ZenDeviceEffects effects = new ZenDeviceEffects.Builder() .setShouldDimWallpaper(true) .build(); assertThat(effects.hasEffects()).isTrue(); } } Loading
core/java/android/service/notification/ZenDeviceEffects.java +10 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,16 @@ public final class ZenDeviceEffects implements Parcelable { return mMaximizeDoze; } /** * Whether any of the effects are set up. * @hide */ public boolean hasEffects() { return mGrayscale || mSuppressAmbientDisplay || mDimWallpaper || mNightMode || mDisableAutoBrightness || mDisableTapToWake || mDisableTiltToWake || mDisableTouch || mMinimizeRadioUsage || mMaximizeDoze; } /** {@link Parcelable.Creator} that instantiates {@link ZenDeviceEffects} objects. */ @NonNull public static final Creator<ZenDeviceEffects> CREATOR = new Creator<ZenDeviceEffects>() { Loading
core/java/android/service/notification/ZenModeConfig.java +82 −3 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_PEEK; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF; import android.annotation.FlaggedApi; import android.annotation.Nullable; import android.app.ActivityManager; import android.app.AlarmManager; Loading Loading @@ -185,6 +186,18 @@ public class ZenModeConfig implements Parcelable { private static final String RULE_ATT_ICON = "rule_icon"; private static final String RULE_ATT_TRIGGER_DESC = "triggerDesc"; private static final String DEVICE_EFFECT_DISPLAY_GRAYSCALE = "zdeDisplayGrayscale"; private static final String DEVICE_EFFECT_SUPPRESS_AMBIENT_DISPLAY = "zdeSuppressAmbientDisplay"; private static final String DEVICE_EFFECT_DIM_WALLPAPER = "zdeDimWallpaper"; private static final String DEVICE_EFFECT_USE_NIGHT_MODE = "zdeUseNightMode"; private static final String DEVICE_EFFECT_DISABLE_AUTO_BRIGHTNESS = "zdeDisableAutoBrightness"; private static final String DEVICE_EFFECT_DISABLE_TAP_TO_WAKE = "zdeDisableTapToWake"; private static final String DEVICE_EFFECT_DISABLE_TILT_TO_WAKE = "zdeDisableTiltToWake"; private static final String DEVICE_EFFECT_DISABLE_TOUCH = "zdeDisableTouch"; private static final String DEVICE_EFFECT_MINIMIZE_RADIO_USAGE = "zdeMinimizeRadioUsage"; private static final String DEVICE_EFFECT_MAXIMIZE_DOZE = "zdeMaximizeDoze"; @UnsupportedAppUsage public boolean allowAlarms = DEFAULT_ALLOW_ALARMS; public boolean allowMedia = DEFAULT_ALLOW_MEDIA; Loading Loading @@ -630,6 +643,7 @@ public class ZenModeConfig implements Parcelable { rt.modified = safeBoolean(parser, RULE_ATT_MODIFIED, false); rt.zenPolicy = readZenPolicyXml(parser); if (Flags.modesApi()) { rt.zenDeviceEffects = readZenDeviceEffectsXml(parser); rt.allowManualInvocation = safeBoolean(parser, RULE_ATT_ALLOW_MANUAL, false); rt.iconResId = safeInt(parser, RULE_ATT_ICON, 0); rt.triggerDescription = parser.getAttributeValue(null, RULE_ATT_TRIGGER_DESC); Loading Loading @@ -667,6 +681,9 @@ public class ZenModeConfig implements Parcelable { if (rule.zenPolicy != null) { writeZenPolicyXml(rule.zenPolicy, out); } if (Flags.modesApi() && rule.zenDeviceEffects != null) { writeZenDeviceEffectsXml(rule.zenDeviceEffects, out); } out.attributeBoolean(null, RULE_ATT_MODIFIED, rule.modified); if (Flags.modesApi()) { out.attributeBoolean(null, RULE_ATT_ALLOW_MANUAL, rule.allowManualInvocation); Loading Loading @@ -859,6 +876,57 @@ public class ZenModeConfig implements Parcelable { } } @Nullable private static ZenDeviceEffects readZenDeviceEffectsXml(TypedXmlPullParser parser) { ZenDeviceEffects deviceEffects = new ZenDeviceEffects.Builder() .setShouldDisplayGrayscale( safeBoolean(parser, DEVICE_EFFECT_DISPLAY_GRAYSCALE, false)) .setShouldSuppressAmbientDisplay( safeBoolean(parser, DEVICE_EFFECT_SUPPRESS_AMBIENT_DISPLAY, false)) .setShouldDimWallpaper(safeBoolean(parser, DEVICE_EFFECT_DIM_WALLPAPER, false)) .setShouldUseNightMode(safeBoolean(parser, DEVICE_EFFECT_USE_NIGHT_MODE, false)) .setShouldDisableAutoBrightness( safeBoolean(parser, DEVICE_EFFECT_DISABLE_AUTO_BRIGHTNESS, false)) .setShouldDisableTapToWake( safeBoolean(parser, DEVICE_EFFECT_DISABLE_TAP_TO_WAKE, false)) .setShouldDisableTiltToWake( safeBoolean(parser, DEVICE_EFFECT_DISABLE_TILT_TO_WAKE, false)) .setShouldDisableTouch(safeBoolean(parser, DEVICE_EFFECT_DISABLE_TOUCH, false)) .setShouldMinimizeRadioUsage( safeBoolean(parser, DEVICE_EFFECT_MINIMIZE_RADIO_USAGE, false)) .setShouldMaximizeDoze(safeBoolean(parser, DEVICE_EFFECT_MAXIMIZE_DOZE, false)) .build(); return deviceEffects.hasEffects() ? deviceEffects : null; } private static void writeZenDeviceEffectsXml(ZenDeviceEffects deviceEffects, TypedXmlSerializer out) throws IOException { writeBooleanIfTrue(out, DEVICE_EFFECT_DISPLAY_GRAYSCALE, deviceEffects.shouldDisplayGrayscale()); writeBooleanIfTrue(out, DEVICE_EFFECT_SUPPRESS_AMBIENT_DISPLAY, deviceEffects.shouldSuppressAmbientDisplay()); writeBooleanIfTrue(out, DEVICE_EFFECT_DIM_WALLPAPER, deviceEffects.shouldDimWallpaper()); writeBooleanIfTrue(out, DEVICE_EFFECT_USE_NIGHT_MODE, deviceEffects.shouldUseNightMode()); writeBooleanIfTrue(out, DEVICE_EFFECT_DISABLE_AUTO_BRIGHTNESS, deviceEffects.shouldDisableAutoBrightness()); writeBooleanIfTrue(out, DEVICE_EFFECT_DISABLE_TAP_TO_WAKE, deviceEffects.shouldDisableTapToWake()); writeBooleanIfTrue(out, DEVICE_EFFECT_DISABLE_TILT_TO_WAKE, deviceEffects.shouldDisableTiltToWake()); writeBooleanIfTrue(out, DEVICE_EFFECT_DISABLE_TOUCH, deviceEffects.shouldDisableTouch()); writeBooleanIfTrue(out, DEVICE_EFFECT_MINIMIZE_RADIO_USAGE, deviceEffects.shouldMinimizeRadioUsage()); writeBooleanIfTrue(out, DEVICE_EFFECT_MAXIMIZE_DOZE, deviceEffects.shouldMaximizeDoze()); } private static void writeBooleanIfTrue(TypedXmlSerializer out, String att, boolean value) throws IOException { if (value) { out.attributeBoolean(null, att, true); } } public static boolean isValidHour(int val) { return val >= 0 && val < 24; } Loading Loading @@ -1755,6 +1823,8 @@ public class ZenModeConfig implements Parcelable { // package name, only used for manual rules when they have turned DND on. public String enabler; public ZenPolicy zenPolicy; @FlaggedApi(Flags.FLAG_MODES_API) @Nullable public ZenDeviceEffects zenDeviceEffects; public boolean modified; // rule has been modified from initial creation public String pkg; public int type = AutomaticZenRule.TYPE_UNKNOWN; Loading Loading @@ -1784,6 +1854,9 @@ public class ZenModeConfig implements Parcelable { enabler = source.readString(); } zenPolicy = source.readParcelable(null, android.service.notification.ZenPolicy.class); if (Flags.modesApi()) { zenDeviceEffects = source.readParcelable(null, ZenDeviceEffects.class); } modified = source.readInt() == 1; pkg = source.readString(); if (Flags.modesApi()) { Loading Loading @@ -1828,6 +1901,9 @@ public class ZenModeConfig implements Parcelable { dest.writeInt(0); } dest.writeParcelable(zenPolicy, 0); if (Flags.modesApi()) { dest.writeParcelable(zenDeviceEffects, 0); } dest.writeInt(modified ? 1 : 0); dest.writeString(pkg); if (Flags.modesApi()) { Loading Loading @@ -1859,7 +1935,8 @@ public class ZenModeConfig implements Parcelable { .append(",condition=").append(condition); if (Flags.modesApi()) { sb.append(",allowManualInvocation=").append(allowManualInvocation) sb.append(",deviceEffects=").append(zenDeviceEffects) .append(",allowManualInvocation=").append(allowManualInvocation) .append(",iconResId=").append(iconResId) .append(",triggerDescription=").append(triggerDescription) .append(",type=").append(type); Loading Loading @@ -1917,6 +1994,7 @@ public class ZenModeConfig implements Parcelable { if (Flags.modesApi()) { return finalEquals && Objects.equals(other.zenDeviceEffects, zenDeviceEffects) && other.allowManualInvocation == allowManualInvocation && other.iconResId == iconResId && Objects.equals(other.triggerDescription, triggerDescription) Loading @@ -1930,8 +2008,9 @@ public class ZenModeConfig implements Parcelable { public int hashCode() { if (Flags.modesApi()) { return Objects.hash(enabled, snoozing, name, zenMode, conditionId, condition, component, configurationActivity, pkg, id, enabler, zenPolicy, modified, allowManualInvocation, iconResId, triggerDescription, type); component, configurationActivity, pkg, id, enabler, zenPolicy, zenDeviceEffects, modified, allowManualInvocation, iconResId, triggerDescription, type); } return Objects.hash(enabled, snoozing, name, zenMode, conditionId, condition, component, configurationActivity, pkg, id, enabler, zenPolicy, modified); Loading
core/java/android/service/notification/ZenModeDiff.java +21 −14 Original line number Diff line number Diff line Loading @@ -452,11 +452,12 @@ public class ZenModeDiff { public static final String FIELD_CREATION_TIME = "creationTime"; public static final String FIELD_ENABLER = "enabler"; public static final String FIELD_ZEN_POLICY = "zenPolicy"; public static final String FIELD_ZEN_DEVICE_EFFECTS = "zenDeviceEffects"; public static final String FIELD_MODIFIED = "modified"; public static final String FIELD_PKG = "pkg"; public static final String FIELD_ALLOW_MANUAL = "allowManualInvocation"; public static final String FIELD_ICON_RES = "iconResId"; public static final String FIELD_TRIGGER = "triggerDescription"; public static final String FIELD_TRIGGER_DESCRIPTION = "triggerDescription"; public static final String FIELD_TYPE = "type"; // NOTE: new field strings must match the variable names in ZenModeConfig.ZenRule Loading Loading @@ -534,8 +535,13 @@ public class ZenModeDiff { if (!Objects.equals(from.pkg, to.pkg)) { addField(FIELD_PKG, new FieldDiff<>(from.pkg, to.pkg)); } if (android.app.Flags.modesApi()) { if (!Objects.equals(from.zenDeviceEffects, to.zenDeviceEffects)) { addField(FIELD_ZEN_DEVICE_EFFECTS, new FieldDiff<>(from.zenDeviceEffects, to.zenDeviceEffects)); } if (!Objects.equals(from.triggerDescription, to.triggerDescription)) { addField(FIELD_TRIGGER, addField(FIELD_TRIGGER_DESCRIPTION, new FieldDiff<>(from.triggerDescription, to.triggerDescription)); } if (from.type != to.type) { Loading @@ -546,7 +552,8 @@ public class ZenModeDiff { new FieldDiff<>(from.allowManualInvocation, to.allowManualInvocation)); } if (!Objects.equals(from.iconResId, to.iconResId)) { addField(FIELD_ICON_RES, new FieldDiff(from.iconResId, to.iconResId)); addField(FIELD_ICON_RES, new FieldDiff<>(from.iconResId, to.iconResId)); } } } Loading
services/core/java/com/android/server/notification/ZenModeHelper.java +4 −0 Original line number Diff line number Diff line Loading @@ -860,6 +860,9 @@ public class ZenModeHelper { rule.enabled = automaticZenRule.isEnabled(); rule.modified = automaticZenRule.isModified(); rule.zenPolicy = automaticZenRule.getZenPolicy(); if (Flags.modesApi()) { rule.zenDeviceEffects = automaticZenRule.getDeviceEffects(); } rule.zenMode = NotificationManager.zenModeFromInterruptionFilter( automaticZenRule.getInterruptionFilter(), Global.ZEN_MODE_OFF); rule.configurationActivity = automaticZenRule.getConfigurationActivity(); Loading Loading @@ -888,6 +891,7 @@ public class ZenModeHelper { .setIconResId(rule.iconResId) .setType(rule.type) .setZenPolicy(rule.zenPolicy) .setDeviceEffects(rule.zenDeviceEffects) .setEnabled(rule.enabled) .setInterruptionFilter( NotificationManager.zenModeToInterruptionFilter(rule.zenMode)) Loading
services/tests/uiservicestests/src/com/android/server/notification/ZenDeviceEffectsTest.java +14 −0 Original line number Diff line number Diff line Loading @@ -102,4 +102,18 @@ public class ZenDeviceEffectsTest extends UiServiceTestCase { assertThat(copy.shouldSuppressAmbientDisplay()).isTrue(); assertThat(copy.shouldDisplayGrayscale()).isFalse(); } @Test public void hasEffects_none_returnsFalse() { ZenDeviceEffects effects = new ZenDeviceEffects.Builder().build(); assertThat(effects.hasEffects()).isFalse(); } @Test public void hasEffects_some_returnsTrue() { ZenDeviceEffects effects = new ZenDeviceEffects.Builder() .setShouldDimWallpaper(true) .build(); assertThat(effects.hasEffects()).isTrue(); } }