Loading core/java/android/service/notification/ZenModeConfig.java +23 −12 Original line number Diff line number Diff line Loading @@ -19,9 +19,11 @@ package android.service.notification; import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE; import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT; import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_NONE; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; 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.Nullable; import android.app.ActivityManager; Loading Loading @@ -79,7 +81,7 @@ public class ZenModeConfig implements Parcelable { public static final int SOURCE_CONTACT = Policy.PRIORITY_SENDERS_CONTACTS; public static final int SOURCE_STAR = Policy.PRIORITY_SENDERS_STARRED; public static final int MAX_SOURCE = SOURCE_STAR; private static final int DEFAULT_SOURCE = SOURCE_CONTACT; private static final int DEFAULT_SOURCE = SOURCE_STAR; private static final int DEFAULT_CALLS_SOURCE = SOURCE_STAR; public static final String MANUAL_RULE_ID = "MANUAL_RULE"; Loading @@ -103,14 +105,17 @@ public class ZenModeConfig implements Parcelable { private static final boolean DEFAULT_ALLOW_MEDIA = true; private static final boolean DEFAULT_ALLOW_SYSTEM = false; private static final boolean DEFAULT_ALLOW_CALLS = true; private static final boolean DEFAULT_ALLOW_MESSAGES = false; private static final boolean DEFAULT_ALLOW_MESSAGES = true; private static final boolean DEFAULT_ALLOW_REMINDERS = false; private static final boolean DEFAULT_ALLOW_EVENTS = false; private static final boolean DEFAULT_ALLOW_REPEAT_CALLERS = true; private static final boolean DEFAULT_ALLOW_CONV = false; private static final int DEFAULT_ALLOW_CONV_FROM = ZenPolicy.CONVERSATION_SENDERS_NONE; private static final boolean DEFAULT_ALLOW_CONV = true; private static final int DEFAULT_ALLOW_CONV_FROM = ZenPolicy.CONVERSATION_SENDERS_IMPORTANT; private static final boolean DEFAULT_CHANNELS_BYPASSING_DND = false; private static final int DEFAULT_SUPPRESSED_VISUAL_EFFECTS = 0; // Default setting here is 010011101 = 157 private static final int DEFAULT_SUPPRESSED_VISUAL_EFFECTS = SUPPRESSED_EFFECT_SCREEN_OFF | SUPPRESSED_EFFECT_FULL_SCREEN_INTENT | SUPPRESSED_EFFECT_LIGHTS | SUPPRESSED_EFFECT_PEEK | SUPPRESSED_EFFECT_AMBIENT; public static final int XML_VERSION = 8; public static final String ZEN_TAG = "zen"; Loading Loading @@ -568,16 +573,22 @@ public class ZenModeConfig implements Parcelable { // migrate old suppressed visual effects fields, if they still exist in the xml Boolean allowWhenScreenOff = unsafeBoolean(parser, ALLOW_ATT_SCREEN_OFF); if (allowWhenScreenOff != null) { Boolean allowWhenScreenOn = unsafeBoolean(parser, ALLOW_ATT_SCREEN_ON); if (allowWhenScreenOff != null || allowWhenScreenOn != null) { // If either setting exists, then reset the suppressed visual effects field // to 0 (all allowed) so that only the relevant bits are disallowed by // the migrated settings. readSuppressedEffects = true; rt.suppressedVisualEffects = 0; } if (allowWhenScreenOff != null) { if (!allowWhenScreenOff) { rt.suppressedVisualEffects |= SUPPRESSED_EFFECT_LIGHTS | SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; | SUPPRESSED_EFFECT_FULL_SCREEN_INTENT | SUPPRESSED_EFFECT_AMBIENT; } } Boolean allowWhenScreenOn = unsafeBoolean(parser, ALLOW_ATT_SCREEN_ON); if (allowWhenScreenOn != null) { readSuppressedEffects = true; if (!allowWhenScreenOn) { rt.suppressedVisualEffects |= SUPPRESSED_EFFECT_PEEK; } Loading Loading @@ -1001,7 +1012,7 @@ public class ZenModeConfig implements Parcelable { builder.showBadges( (suppressedVisualEffects & Policy.SUPPRESSED_EFFECT_BADGE) == 0); builder.showInAmbientDisplay( (suppressedVisualEffects & Policy.SUPPRESSED_EFFECT_AMBIENT) == 0); (suppressedVisualEffects & SUPPRESSED_EFFECT_AMBIENT) == 0); builder.showInNotificationList( (suppressedVisualEffects & Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST) == 0); } Loading Loading @@ -1085,7 +1096,7 @@ public class ZenModeConfig implements Parcelable { boolean suppressAmbient = !zenPolicy.isVisualEffectAllowed( ZenPolicy.VISUAL_EFFECT_AMBIENT, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_AMBIENT, isVisualEffectAllowed(SUPPRESSED_EFFECT_AMBIENT, defaultPolicy)); if (suppressFullScreenIntent && suppressLights && suppressAmbient) { Loading Loading @@ -1120,7 +1131,7 @@ public class ZenModeConfig implements Parcelable { } if (suppressAmbient) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_AMBIENT; suppressedVisualEffects |= SUPPRESSED_EFFECT_AMBIENT; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_NOTIFICATION_LIST, Loading core/res/res/xml/default_zen_mode_config.xml +6 −6 Original line number Diff line number Diff line Loading @@ -18,18 +18,18 @@ --> <!-- Default configuration for zen mode. See android.service.notification.ZenModeConfig. --> <zen version="9"> <allow alarms="true" media="true" system="false" calls="true" callsFrom="2" messages="false" reminders="false" events="false" repeatCallers="true" convos="false" convosFrom="3"/> <zen version="10"> <allow alarms="true" media="true" system="false" calls="true" callsFrom="2" messages="true" messagesFrom="2" reminders="false" events="false" repeatCallers="true" convos="true" convosFrom="2"/> <automatic ruleId="EVENTS_DEFAULT_RULE" enabled="false" snoozing="false" name="Event" zen="1" component="android/com.android.server.notification.EventConditionProvider" conditionId="condition://android/event?userId=-10000&calendar=&reply=1"/> <automatic ruleId="EVERY_NIGHT_DEFAULT_RULE" enabled="false" snoozing="false" name="Sleeping" zen="1" component="android/com.android.server.notification.ScheduleConditionProvider" conditionId="condition://android/schedule?days=1.2.3.4.5.6.7&start=22.0&end=7.0&exitAtAlarm=true"/> <!-- all visual effects that exist as of P --> <disallow visualEffects="511" /> <!-- everything when screen off (for old target sdks); fullscreen; lights; peek; ambient --> <disallow visualEffects="157" /> <!-- whether there are notification channels that can bypass dnd --> <state areChannelsBypassingDnd="false" /> </zen> services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +5 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CA import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM; import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_ANY; import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_STARRED; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; Loading Loading @@ -1263,6 +1264,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { assertEquals(SUPPRESSED_EFFECT_FULL_SCREEN_INTENT | SUPPRESSED_EFFECT_LIGHTS | SUPPRESSED_EFFECT_AMBIENT | SUPPRESSED_EFFECT_PEEK, mZenModeHelperSpy.mConfig.suppressedVisualEffects); Loading Loading @@ -1296,7 +1298,9 @@ public class ZenModeHelperTest extends UiServiceTestCase { parser.nextTag(); mZenModeHelperSpy.readXml(parser, false, UserHandle.USER_ALL); assertEquals(SUPPRESSED_EFFECT_FULL_SCREEN_INTENT | SUPPRESSED_EFFECT_LIGHTS, assertEquals(SUPPRESSED_EFFECT_FULL_SCREEN_INTENT | SUPPRESSED_EFFECT_LIGHTS | SUPPRESSED_EFFECT_AMBIENT, mZenModeHelperSpy.mConfig.suppressedVisualEffects); } Loading Loading
core/java/android/service/notification/ZenModeConfig.java +23 −12 Original line number Diff line number Diff line Loading @@ -19,9 +19,11 @@ package android.service.notification; import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_ANYONE; import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_IMPORTANT; import static android.app.NotificationManager.Policy.CONVERSATION_SENDERS_NONE; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; 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.Nullable; import android.app.ActivityManager; Loading Loading @@ -79,7 +81,7 @@ public class ZenModeConfig implements Parcelable { public static final int SOURCE_CONTACT = Policy.PRIORITY_SENDERS_CONTACTS; public static final int SOURCE_STAR = Policy.PRIORITY_SENDERS_STARRED; public static final int MAX_SOURCE = SOURCE_STAR; private static final int DEFAULT_SOURCE = SOURCE_CONTACT; private static final int DEFAULT_SOURCE = SOURCE_STAR; private static final int DEFAULT_CALLS_SOURCE = SOURCE_STAR; public static final String MANUAL_RULE_ID = "MANUAL_RULE"; Loading @@ -103,14 +105,17 @@ public class ZenModeConfig implements Parcelable { private static final boolean DEFAULT_ALLOW_MEDIA = true; private static final boolean DEFAULT_ALLOW_SYSTEM = false; private static final boolean DEFAULT_ALLOW_CALLS = true; private static final boolean DEFAULT_ALLOW_MESSAGES = false; private static final boolean DEFAULT_ALLOW_MESSAGES = true; private static final boolean DEFAULT_ALLOW_REMINDERS = false; private static final boolean DEFAULT_ALLOW_EVENTS = false; private static final boolean DEFAULT_ALLOW_REPEAT_CALLERS = true; private static final boolean DEFAULT_ALLOW_CONV = false; private static final int DEFAULT_ALLOW_CONV_FROM = ZenPolicy.CONVERSATION_SENDERS_NONE; private static final boolean DEFAULT_ALLOW_CONV = true; private static final int DEFAULT_ALLOW_CONV_FROM = ZenPolicy.CONVERSATION_SENDERS_IMPORTANT; private static final boolean DEFAULT_CHANNELS_BYPASSING_DND = false; private static final int DEFAULT_SUPPRESSED_VISUAL_EFFECTS = 0; // Default setting here is 010011101 = 157 private static final int DEFAULT_SUPPRESSED_VISUAL_EFFECTS = SUPPRESSED_EFFECT_SCREEN_OFF | SUPPRESSED_EFFECT_FULL_SCREEN_INTENT | SUPPRESSED_EFFECT_LIGHTS | SUPPRESSED_EFFECT_PEEK | SUPPRESSED_EFFECT_AMBIENT; public static final int XML_VERSION = 8; public static final String ZEN_TAG = "zen"; Loading Loading @@ -568,16 +573,22 @@ public class ZenModeConfig implements Parcelable { // migrate old suppressed visual effects fields, if they still exist in the xml Boolean allowWhenScreenOff = unsafeBoolean(parser, ALLOW_ATT_SCREEN_OFF); if (allowWhenScreenOff != null) { Boolean allowWhenScreenOn = unsafeBoolean(parser, ALLOW_ATT_SCREEN_ON); if (allowWhenScreenOff != null || allowWhenScreenOn != null) { // If either setting exists, then reset the suppressed visual effects field // to 0 (all allowed) so that only the relevant bits are disallowed by // the migrated settings. readSuppressedEffects = true; rt.suppressedVisualEffects = 0; } if (allowWhenScreenOff != null) { if (!allowWhenScreenOff) { rt.suppressedVisualEffects |= SUPPRESSED_EFFECT_LIGHTS | SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; | SUPPRESSED_EFFECT_FULL_SCREEN_INTENT | SUPPRESSED_EFFECT_AMBIENT; } } Boolean allowWhenScreenOn = unsafeBoolean(parser, ALLOW_ATT_SCREEN_ON); if (allowWhenScreenOn != null) { readSuppressedEffects = true; if (!allowWhenScreenOn) { rt.suppressedVisualEffects |= SUPPRESSED_EFFECT_PEEK; } Loading Loading @@ -1001,7 +1012,7 @@ public class ZenModeConfig implements Parcelable { builder.showBadges( (suppressedVisualEffects & Policy.SUPPRESSED_EFFECT_BADGE) == 0); builder.showInAmbientDisplay( (suppressedVisualEffects & Policy.SUPPRESSED_EFFECT_AMBIENT) == 0); (suppressedVisualEffects & SUPPRESSED_EFFECT_AMBIENT) == 0); builder.showInNotificationList( (suppressedVisualEffects & Policy.SUPPRESSED_EFFECT_NOTIFICATION_LIST) == 0); } Loading Loading @@ -1085,7 +1096,7 @@ public class ZenModeConfig implements Parcelable { boolean suppressAmbient = !zenPolicy.isVisualEffectAllowed( ZenPolicy.VISUAL_EFFECT_AMBIENT, isVisualEffectAllowed(Policy.SUPPRESSED_EFFECT_AMBIENT, isVisualEffectAllowed(SUPPRESSED_EFFECT_AMBIENT, defaultPolicy)); if (suppressFullScreenIntent && suppressLights && suppressAmbient) { Loading Loading @@ -1120,7 +1131,7 @@ public class ZenModeConfig implements Parcelable { } if (suppressAmbient) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_AMBIENT; suppressedVisualEffects |= SUPPRESSED_EFFECT_AMBIENT; } if (!zenPolicy.isVisualEffectAllowed(ZenPolicy.VISUAL_EFFECT_NOTIFICATION_LIST, Loading
core/res/res/xml/default_zen_mode_config.xml +6 −6 Original line number Diff line number Diff line Loading @@ -18,18 +18,18 @@ --> <!-- Default configuration for zen mode. See android.service.notification.ZenModeConfig. --> <zen version="9"> <allow alarms="true" media="true" system="false" calls="true" callsFrom="2" messages="false" reminders="false" events="false" repeatCallers="true" convos="false" convosFrom="3"/> <zen version="10"> <allow alarms="true" media="true" system="false" calls="true" callsFrom="2" messages="true" messagesFrom="2" reminders="false" events="false" repeatCallers="true" convos="true" convosFrom="2"/> <automatic ruleId="EVENTS_DEFAULT_RULE" enabled="false" snoozing="false" name="Event" zen="1" component="android/com.android.server.notification.EventConditionProvider" conditionId="condition://android/event?userId=-10000&calendar=&reply=1"/> <automatic ruleId="EVERY_NIGHT_DEFAULT_RULE" enabled="false" snoozing="false" name="Sleeping" zen="1" component="android/com.android.server.notification.ScheduleConditionProvider" conditionId="condition://android/schedule?days=1.2.3.4.5.6.7&start=22.0&end=7.0&exitAtAlarm=true"/> <!-- all visual effects that exist as of P --> <disallow visualEffects="511" /> <!-- everything when screen off (for old target sdks); fullscreen; lights; peek; ambient --> <disallow visualEffects="157" /> <!-- whether there are notification channels that can bypass dnd --> <state areChannelsBypassingDnd="false" /> </zen>
services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +5 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_REPEAT_CA import static android.app.NotificationManager.Policy.PRIORITY_CATEGORY_SYSTEM; import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_ANY; import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_STARRED; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_AMBIENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_BADGE; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_FULL_SCREEN_INTENT; import static android.app.NotificationManager.Policy.SUPPRESSED_EFFECT_LIGHTS; Loading Loading @@ -1263,6 +1264,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { assertEquals(SUPPRESSED_EFFECT_FULL_SCREEN_INTENT | SUPPRESSED_EFFECT_LIGHTS | SUPPRESSED_EFFECT_AMBIENT | SUPPRESSED_EFFECT_PEEK, mZenModeHelperSpy.mConfig.suppressedVisualEffects); Loading Loading @@ -1296,7 +1298,9 @@ public class ZenModeHelperTest extends UiServiceTestCase { parser.nextTag(); mZenModeHelperSpy.readXml(parser, false, UserHandle.USER_ALL); assertEquals(SUPPRESSED_EFFECT_FULL_SCREEN_INTENT | SUPPRESSED_EFFECT_LIGHTS, assertEquals(SUPPRESSED_EFFECT_FULL_SCREEN_INTENT | SUPPRESSED_EFFECT_LIGHTS | SUPPRESSED_EFFECT_AMBIENT, mZenModeHelperSpy.mConfig.suppressedVisualEffects); } Loading