Loading api/current.txt +11 −4 Original line number Diff line number Diff line Loading @@ -5752,8 +5752,15 @@ package android.app { field public static final int PRIORITY_SENDERS_ANY = 0; // 0x0 field public static final int PRIORITY_SENDERS_CONTACTS = 1; // 0x1 field public static final int PRIORITY_SENDERS_STARRED = 2; // 0x2 field public static final int SUPPRESSED_EFFECT_SCREEN_OFF = 1; // 0x1 field public static final int SUPPRESSED_EFFECT_SCREEN_ON = 2; // 0x2 field public static final int SUPPRESSED_EFFECT_AMBIENT = 128; // 0x80 field public static final int SUPPRESSED_EFFECT_BADGE = 64; // 0x40 field public static final int SUPPRESSED_EFFECT_FULL_SCREEN_INTENT = 4; // 0x4 field public static final int SUPPRESSED_EFFECT_LIGHTS = 8; // 0x8 field public static final int SUPPRESSED_EFFECT_NOTIFICATION_LIST = 256; // 0x100 field public static final int SUPPRESSED_EFFECT_PEEK = 16; // 0x10 field public static final deprecated int SUPPRESSED_EFFECT_SCREEN_OFF = 1; // 0x1 field public static final deprecated int SUPPRESSED_EFFECT_SCREEN_ON = 2; // 0x2 field public static final int SUPPRESSED_EFFECT_STATUS_BAR = 32; // 0x20 field public final int priorityCallSenders; field public final int priorityCategories; field public final int priorityMessageSenders; Loading Loading @@ -40001,8 +40008,8 @@ package android.service.notification { field public static final int REASON_UNAUTOBUNDLED = 16; // 0x10 field public static final int REASON_USER_STOPPED = 6; // 0x6 field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationListenerService"; field public static final int SUPPRESSED_EFFECT_SCREEN_OFF = 1; // 0x1 field public static final int SUPPRESSED_EFFECT_SCREEN_ON = 2; // 0x2 field public static final deprecated int SUPPRESSED_EFFECT_SCREEN_OFF = 1; // 0x1 field public static final deprecated int SUPPRESSED_EFFECT_SCREEN_ON = 2; // 0x2 } public static class NotificationListenerService.Ranking { core/java/android/app/NotificationManager.java +127 −3 Original line number Diff line number Diff line Loading @@ -1072,20 +1072,77 @@ public class NotificationManager { * @hide */ public static final int SUPPRESSED_EFFECTS_UNSET = -1; /** * Whether notifications suppressed by DND should not interrupt visually (e.g. with * notification lights or by turning the screen on) when the screen is off. * * @deprecated use {@link #SUPPRESSED_EFFECT_FULL_SCREEN_INTENT} and * {@link #SUPPRESSED_EFFECT_AMBIENT} and {@link #SUPPRESSED_EFFECT_LIGHTS} individually. */ @Deprecated public static final int SUPPRESSED_EFFECT_SCREEN_OFF = 1 << 0; /** * Whether notifications suppressed by DND should not interrupt visually when the screen * is on (e.g. by peeking onto the screen). * * @deprecated use {@link #SUPPRESSED_EFFECT_PEEK}. */ @Deprecated public static final int SUPPRESSED_EFFECT_SCREEN_ON = 1 << 1; /** * Whether {@link Notification#fullScreenIntent full screen intents} from * notifications intercepted by DND are blocked. */ public static final int SUPPRESSED_EFFECT_FULL_SCREEN_INTENT = 1 << 2; /** * Whether {@link NotificationChannel#shouldShowLights() notification lights} from * notifications intercepted by DND are blocked. */ public static final int SUPPRESSED_EFFECT_LIGHTS = 1 << 3; /** * Whether notifications intercepted by DND are prevented from peeking. */ public static final int SUPPRESSED_EFFECT_PEEK = 1 << 4; /** * Whether notifications intercepted by DND are prevented from appearing in the status bar, * on devices that support status bars. */ public static final int SUPPRESSED_EFFECT_STATUS_BAR = 1 << 5; /** * Whether {@link NotificationChannel#canShowBadge() badges} from * notifications intercepted by DND are blocked on devices that support badging. */ public static final int SUPPRESSED_EFFECT_BADGE = 1 << 6; /** * Whether notification intercepted by DND are prevented from appearing on ambient displays * on devices that support ambient display. */ public static final int SUPPRESSED_EFFECT_AMBIENT = 1 << 7; /** * Whether notification intercepted by DND are prevented from appearing in notification * list views like the notification shade or lockscreen on devices that support those * views. */ public static final int SUPPRESSED_EFFECT_NOTIFICATION_LIST = 1 << 8; private static final int[] ALL_SUPPRESSED_EFFECTS = { SUPPRESSED_EFFECT_SCREEN_OFF, SUPPRESSED_EFFECT_SCREEN_ON, SUPPRESSED_EFFECT_FULL_SCREEN_INTENT, SUPPRESSED_EFFECT_LIGHTS, SUPPRESSED_EFFECT_PEEK, SUPPRESSED_EFFECT_STATUS_BAR, SUPPRESSED_EFFECT_BADGE, SUPPRESSED_EFFECT_AMBIENT, SUPPRESSED_EFFECT_NOTIFICATION_LIST }; /** Loading @@ -1097,6 +1154,12 @@ public class NotificationManager { /** * Constructs a policy for Do Not Disturb priority mode behavior. * * <p> * Apps that target API levels below {@link Build.VERSION_CODES#P} cannot * change user-designated values to allow or disallow * {@link Policy#PRIORITY_CATEGORY_ALARMS}, {@link Policy#PRIORITY_CATEGORY_SYSTEM}, and * {@link Policy#PRIORITY_CATEGORY_MEDIA} from bypassing dnd. * * @param priorityCategories bitmask of categories of notifications that can bypass DND. * @param priorityCallSenders which callers can bypass DND. * @param priorityMessageSenders which message senders can bypass DND. Loading @@ -1109,6 +1172,26 @@ public class NotificationManager { /** * Constructs a policy for Do Not Disturb priority mode behavior. * * <p> * Apps that target API levels below {@link Build.VERSION_CODES#P} cannot * change user-designated values to allow or disallow * {@link Policy#PRIORITY_CATEGORY_ALARMS}, {@link Policy#PRIORITY_CATEGORY_SYSTEM}, and * {@link Policy#PRIORITY_CATEGORY_MEDIA} from bypassing dnd. * <p> * Additionally, apps that target API levels below {@link Build.VERSION_CODES#P} can * only modify the {@link #SUPPRESSED_EFFECT_SCREEN_ON} and * {@link #SUPPRESSED_EFFECT_SCREEN_OFF} bits of the suppressed visual effects field. * All other suppressed effects will be ignored and reconstituted from the screen on * and screen off values. * <p> * Apps that target {@link Build.VERSION_CODES#P} or above can set any * suppressed visual effects. However, if any suppressed effects > * {@link #SUPPRESSED_EFFECT_SCREEN_ON} are set, {@link #SUPPRESSED_EFFECT_SCREEN_ON} * and {@link #SUPPRESSED_EFFECT_SCREEN_OFF} will be ignored and reconstituted from * the more specific suppressed visual effect bits. Apps should migrate to targeting * specific effects instead of the deprecated {@link #SUPPRESSED_EFFECT_SCREEN_ON} and * {@link #SUPPRESSED_EFFECT_SCREEN_OFF} effects. * * @param priorityCategories bitmask of categories of notifications that can bypass DND. * @param priorityCallSenders which callers can bypass DND. * @param priorityMessageSenders which message senders can bypass DND. Loading Loading @@ -1190,6 +1273,30 @@ public class NotificationManager { } } /** * @hide */ public static int getAllSuppressedVisualEffects() { int effects = 0; for (int i = 0; i < ALL_SUPPRESSED_EFFECTS.length; i++) { effects |= ALL_SUPPRESSED_EFFECTS[i]; } return effects; } /** * @hide */ public static boolean areAllVisualEffectsSuppressed(int effects) { for (int i = 0; i < ALL_SUPPRESSED_EFFECTS.length; i++) { final int effect = ALL_SUPPRESSED_EFFECTS[i]; if ((effects & effect) == 0) { return false; } } return true; } public static String suppressedEffectsToString(int effects) { if (effects <= 0) return ""; final StringBuilder sb = new StringBuilder(); Loading Loading @@ -1228,9 +1335,26 @@ public class NotificationManager { private static String effectToString(int effect) { switch (effect) { case SUPPRESSED_EFFECT_SCREEN_OFF: return "SUPPRESSED_EFFECT_SCREEN_OFF"; case SUPPRESSED_EFFECT_SCREEN_ON: return "SUPPRESSED_EFFECT_SCREEN_ON"; case SUPPRESSED_EFFECTS_UNSET: return "SUPPRESSED_EFFECTS_UNSET"; case SUPPRESSED_EFFECT_FULL_SCREEN_INTENT: return "SUPPRESSED_EFFECT_FULL_SCREEN_INTENT"; case SUPPRESSED_EFFECT_LIGHTS: return "SUPPRESSED_EFFECT_LIGHTS"; case SUPPRESSED_EFFECT_PEEK: return "SUPPRESSED_EFFECT_PEEK"; case SUPPRESSED_EFFECT_STATUS_BAR: return "SUPPRESSED_EFFECT_STATUS_BAR"; case SUPPRESSED_EFFECT_BADGE: return "SUPPRESSED_EFFECT_BADGE"; case SUPPRESSED_EFFECT_AMBIENT: return "SUPPRESSED_EFFECT_AMBIENT"; case SUPPRESSED_EFFECT_NOTIFICATION_LIST: return "SUPPRESSED_EFFECT_NOTIFICATION_LIST"; case SUPPRESSED_EFFECT_SCREEN_OFF: return "SUPPRESSED_EFFECT_SCREEN_OFF"; case SUPPRESSED_EFFECT_SCREEN_ON: return "SUPPRESSED_EFFECT_SCREEN_ON"; case SUPPRESSED_EFFECTS_UNSET: return "SUPPRESSED_EFFECTS_UNSET"; default: return "UNKNOWN_" + effect; } } Loading core/java/android/service/notification/NotificationListenerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -149,13 +149,19 @@ public abstract class NotificationListenerService extends Service { /** * Whether notification suppressed by DND should not interruption visually when the screen is * off. * * @deprecated Use the more specific visual effects in {@link NotificationManager.Policy}. */ @Deprecated public static final int SUPPRESSED_EFFECT_SCREEN_OFF = NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF; /** * Whether notification suppressed by DND should not interruption visually when the screen is * on. * * @deprecated Use the more specific visual effects in {@link NotificationManager.Policy}. */ @Deprecated public static final int SUPPRESSED_EFFECT_SCREEN_ON = NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON; Loading Loading @@ -1453,7 +1459,8 @@ public abstract class NotificationListenerService extends Service { /** * Returns the type(s) of visual effects that should be suppressed for this notification. * See {@link #SUPPRESSED_EFFECT_SCREEN_OFF}, {@link #SUPPRESSED_EFFECT_SCREEN_ON}. * See {@link NotificationManager.Policy}, e.g. * {@link NotificationManager.Policy#SUPPRESSED_EFFECT_LIGHTS}. */ public int getSuppressedVisualEffects() { return mSuppressedVisualEffects; Loading core/java/android/service/notification/ZenModeConfig.java +29 −16 Original line number Diff line number Diff line Loading @@ -92,10 +92,12 @@ public class ZenModeConfig implements Parcelable { private static final boolean DEFAULT_ALLOW_REMINDERS = false; private static final boolean DEFAULT_ALLOW_EVENTS = false; private static final boolean DEFAULT_ALLOW_REPEAT_CALLERS = false; private static final boolean DEFAULT_ALLOW_SCREEN_OFF = true; private static final boolean DEFAULT_ALLOW_SCREEN_ON = true; private static final boolean DEFAULT_ALLOW_SCREEN_OFF = false; private static final boolean DEFAULT_ALLOW_SCREEN_ON = false; private static final int DEFAULT_SUPPRESSED_VISUAL_EFFECTS = Policy.getAllSuppressedVisualEffects(); public static final int XML_VERSION = 4; public static final int XML_VERSION = 5; public static final String ZEN_TAG = "zen"; private static final String ZEN_ATT_VERSION = "version"; private static final String ZEN_ATT_USER = "user"; Loading @@ -113,6 +115,8 @@ public class ZenModeConfig implements Parcelable { private static final String ALLOW_ATT_EVENTS = "events"; private static final String ALLOW_ATT_SCREEN_OFF = "visualScreenOff"; private static final String ALLOW_ATT_SCREEN_ON = "visualScreenOn"; private static final String DISALLOW_TAG = "disallow"; private static final String DISALLOW_ATT_VISUAL_EFFECTS = "visualEffects"; private static final String CONDITION_ATT_ID = "id"; private static final String CONDITION_ATT_SUMMARY = "summary"; Loading Loading @@ -146,6 +150,7 @@ public class ZenModeConfig implements Parcelable { public int allowCallsFrom = DEFAULT_SOURCE; public int allowMessagesFrom = DEFAULT_SOURCE; public int user = UserHandle.USER_SYSTEM; public int suppressedVisualEffects = DEFAULT_SUPPRESSED_VISUAL_EFFECTS; public boolean allowWhenScreenOff = DEFAULT_ALLOW_SCREEN_OFF; public boolean allowWhenScreenOn = DEFAULT_ALLOW_SCREEN_ON; public int version; Loading Loading @@ -180,6 +185,7 @@ public class ZenModeConfig implements Parcelable { allowAlarms = source.readInt() == 1; allowMedia = source.readInt() == 1; allowSystem = source.readInt() == 1; suppressedVisualEffects = source.readInt(); } @Override Loading Loading @@ -212,6 +218,7 @@ public class ZenModeConfig implements Parcelable { dest.writeInt(allowAlarms ? 1 : 0); dest.writeInt(allowMedia ? 1 : 0); dest.writeInt(allowSystem ? 1 : 0); dest.writeInt(suppressedVisualEffects); } @Override Loading @@ -230,6 +237,7 @@ public class ZenModeConfig implements Parcelable { .append(",allowMessagesFrom=").append(sourceToString(allowMessagesFrom)) .append(",allowWhenScreenOff=").append(allowWhenScreenOff) .append(",allowWhenScreenOn=").append(allowWhenScreenOn) .append(",suppressedVisualEffects=").append(suppressedVisualEffects) .append(",automaticRules=").append(automaticRules) .append(",manualRule=").append(manualRule) .append(']').toString(); Loading Loading @@ -279,6 +287,10 @@ public class ZenModeConfig implements Parcelable { if (allowWhenScreenOn != to.allowWhenScreenOn) { d.addLine("allowWhenScreenOn", allowWhenScreenOn, to.allowWhenScreenOn); } if (suppressedVisualEffects != to.suppressedVisualEffects) { d.addLine("suppressedVisualEffects", suppressedVisualEffects, to.suppressedVisualEffects); } final ArraySet<String> allRules = new ArraySet<>(); addKeys(allRules, automaticRules); addKeys(allRules, to.automaticRules); Loading Loading @@ -383,7 +395,8 @@ public class ZenModeConfig implements Parcelable { && other.allowWhenScreenOn == allowWhenScreenOn && other.user == user && Objects.equals(other.automaticRules, automaticRules) && Objects.equals(other.manualRule, manualRule); && Objects.equals(other.manualRule, manualRule) && other.suppressedVisualEffects == suppressedVisualEffects; } @Override Loading @@ -391,7 +404,8 @@ public class ZenModeConfig implements Parcelable { return Objects.hash(allowAlarms, allowMedia, allowSystem, allowCalls, allowRepeatCallers, allowMessages, allowCallsFrom, allowMessagesFrom, allowReminders, allowEvents, allowWhenScreenOff, allowWhenScreenOn, user, automaticRules, manualRule); allowWhenScreenOff, allowWhenScreenOn, user, automaticRules, manualRule, suppressedVisualEffects); } private static String toDayList(int[] days) { Loading Loading @@ -474,6 +488,8 @@ public class ZenModeConfig implements Parcelable { rt.allowCallsFrom = DEFAULT_SOURCE; rt.allowMessagesFrom = DEFAULT_SOURCE; } // continue to read even though we now have suppressedVisualEffects, in case // we need to revert to users' previous settings rt.allowWhenScreenOff = safeBoolean(parser, ALLOW_ATT_SCREEN_OFF, DEFAULT_ALLOW_SCREEN_OFF); rt.allowWhenScreenOn = Loading @@ -482,6 +498,9 @@ public class ZenModeConfig implements Parcelable { rt.allowMedia = safeBoolean(parser, ALLOW_ATT_MEDIA, DEFAULT_ALLOW_MEDIA); rt.allowSystem = safeBoolean(parser, ALLOW_ATT_SYSTEM, DEFAULT_ALLOW_SYSTEM); } else if (DISALLOW_TAG.equals(tag)) { rt.suppressedVisualEffects = safeInt(parser, DISALLOW_ATT_VISUAL_EFFECTS, DEFAULT_SUPPRESSED_VISUAL_EFFECTS); } else if (MANUAL_TAG.equals(tag)) { rt.manualRule = readRuleXml(parser); } else if (AUTOMATIC_TAG.equals(tag)) { Loading Loading @@ -517,6 +536,10 @@ public class ZenModeConfig implements Parcelable { out.attribute(null, ALLOW_ATT_SYSTEM, Boolean.toString(allowSystem)); out.endTag(null, ALLOW_TAG); out.startTag(null, DISALLOW_TAG); out.attribute(null, DISALLOW_ATT_VISUAL_EFFECTS, Integer.toString(suppressedVisualEffects)); out.endTag(null, DISALLOW_TAG); if (manualRule != null) { out.startTag(null, MANUAL_TAG); writeRuleXml(manualRule, out); Loading Loading @@ -701,13 +724,6 @@ public class ZenModeConfig implements Parcelable { if (allowRepeatCallers) { priorityCategories |= Policy.PRIORITY_CATEGORY_REPEAT_CALLERS; } int suppressedVisualEffects = 0; if (!allowWhenScreenOff) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_SCREEN_OFF; } if (!allowWhenScreenOn) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_SCREEN_ON; } if (allowAlarms) { priorityCategories |= Policy.PRIORITY_CATEGORY_ALARMS; } Loading Loading @@ -770,10 +786,7 @@ public class ZenModeConfig implements Parcelable { allowMessagesFrom = prioritySendersToSource(policy.priorityMessageSenders, allowMessagesFrom); if (policy.suppressedVisualEffects != Policy.SUPPRESSED_EFFECTS_UNSET) { allowWhenScreenOff = (policy.suppressedVisualEffects & Policy.SUPPRESSED_EFFECT_SCREEN_OFF) == 0; allowWhenScreenOn = (policy.suppressedVisualEffects & Policy.SUPPRESSED_EFFECT_SCREEN_ON) == 0; suppressedVisualEffects = policy.suppressedVisualEffects; } } Loading core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2396,6 +2396,7 @@ <!-- depends on ImportanceExtractor--> <item>com.android.server.notification.NotificationIntrusivenessExtractor</item> <item>com.android.server.notification.VisibilityExtractor</item> <!-- Depends on ZenModeExtractor --> <item>com.android.server.notification.BadgeExtractor</item> </string-array> Loading Loading
api/current.txt +11 −4 Original line number Diff line number Diff line Loading @@ -5752,8 +5752,15 @@ package android.app { field public static final int PRIORITY_SENDERS_ANY = 0; // 0x0 field public static final int PRIORITY_SENDERS_CONTACTS = 1; // 0x1 field public static final int PRIORITY_SENDERS_STARRED = 2; // 0x2 field public static final int SUPPRESSED_EFFECT_SCREEN_OFF = 1; // 0x1 field public static final int SUPPRESSED_EFFECT_SCREEN_ON = 2; // 0x2 field public static final int SUPPRESSED_EFFECT_AMBIENT = 128; // 0x80 field public static final int SUPPRESSED_EFFECT_BADGE = 64; // 0x40 field public static final int SUPPRESSED_EFFECT_FULL_SCREEN_INTENT = 4; // 0x4 field public static final int SUPPRESSED_EFFECT_LIGHTS = 8; // 0x8 field public static final int SUPPRESSED_EFFECT_NOTIFICATION_LIST = 256; // 0x100 field public static final int SUPPRESSED_EFFECT_PEEK = 16; // 0x10 field public static final deprecated int SUPPRESSED_EFFECT_SCREEN_OFF = 1; // 0x1 field public static final deprecated int SUPPRESSED_EFFECT_SCREEN_ON = 2; // 0x2 field public static final int SUPPRESSED_EFFECT_STATUS_BAR = 32; // 0x20 field public final int priorityCallSenders; field public final int priorityCategories; field public final int priorityMessageSenders; Loading Loading @@ -40001,8 +40008,8 @@ package android.service.notification { field public static final int REASON_UNAUTOBUNDLED = 16; // 0x10 field public static final int REASON_USER_STOPPED = 6; // 0x6 field public static final java.lang.String SERVICE_INTERFACE = "android.service.notification.NotificationListenerService"; field public static final int SUPPRESSED_EFFECT_SCREEN_OFF = 1; // 0x1 field public static final int SUPPRESSED_EFFECT_SCREEN_ON = 2; // 0x2 field public static final deprecated int SUPPRESSED_EFFECT_SCREEN_OFF = 1; // 0x1 field public static final deprecated int SUPPRESSED_EFFECT_SCREEN_ON = 2; // 0x2 } public static class NotificationListenerService.Ranking {
core/java/android/app/NotificationManager.java +127 −3 Original line number Diff line number Diff line Loading @@ -1072,20 +1072,77 @@ public class NotificationManager { * @hide */ public static final int SUPPRESSED_EFFECTS_UNSET = -1; /** * Whether notifications suppressed by DND should not interrupt visually (e.g. with * notification lights or by turning the screen on) when the screen is off. * * @deprecated use {@link #SUPPRESSED_EFFECT_FULL_SCREEN_INTENT} and * {@link #SUPPRESSED_EFFECT_AMBIENT} and {@link #SUPPRESSED_EFFECT_LIGHTS} individually. */ @Deprecated public static final int SUPPRESSED_EFFECT_SCREEN_OFF = 1 << 0; /** * Whether notifications suppressed by DND should not interrupt visually when the screen * is on (e.g. by peeking onto the screen). * * @deprecated use {@link #SUPPRESSED_EFFECT_PEEK}. */ @Deprecated public static final int SUPPRESSED_EFFECT_SCREEN_ON = 1 << 1; /** * Whether {@link Notification#fullScreenIntent full screen intents} from * notifications intercepted by DND are blocked. */ public static final int SUPPRESSED_EFFECT_FULL_SCREEN_INTENT = 1 << 2; /** * Whether {@link NotificationChannel#shouldShowLights() notification lights} from * notifications intercepted by DND are blocked. */ public static final int SUPPRESSED_EFFECT_LIGHTS = 1 << 3; /** * Whether notifications intercepted by DND are prevented from peeking. */ public static final int SUPPRESSED_EFFECT_PEEK = 1 << 4; /** * Whether notifications intercepted by DND are prevented from appearing in the status bar, * on devices that support status bars. */ public static final int SUPPRESSED_EFFECT_STATUS_BAR = 1 << 5; /** * Whether {@link NotificationChannel#canShowBadge() badges} from * notifications intercepted by DND are blocked on devices that support badging. */ public static final int SUPPRESSED_EFFECT_BADGE = 1 << 6; /** * Whether notification intercepted by DND are prevented from appearing on ambient displays * on devices that support ambient display. */ public static final int SUPPRESSED_EFFECT_AMBIENT = 1 << 7; /** * Whether notification intercepted by DND are prevented from appearing in notification * list views like the notification shade or lockscreen on devices that support those * views. */ public static final int SUPPRESSED_EFFECT_NOTIFICATION_LIST = 1 << 8; private static final int[] ALL_SUPPRESSED_EFFECTS = { SUPPRESSED_EFFECT_SCREEN_OFF, SUPPRESSED_EFFECT_SCREEN_ON, SUPPRESSED_EFFECT_FULL_SCREEN_INTENT, SUPPRESSED_EFFECT_LIGHTS, SUPPRESSED_EFFECT_PEEK, SUPPRESSED_EFFECT_STATUS_BAR, SUPPRESSED_EFFECT_BADGE, SUPPRESSED_EFFECT_AMBIENT, SUPPRESSED_EFFECT_NOTIFICATION_LIST }; /** Loading @@ -1097,6 +1154,12 @@ public class NotificationManager { /** * Constructs a policy for Do Not Disturb priority mode behavior. * * <p> * Apps that target API levels below {@link Build.VERSION_CODES#P} cannot * change user-designated values to allow or disallow * {@link Policy#PRIORITY_CATEGORY_ALARMS}, {@link Policy#PRIORITY_CATEGORY_SYSTEM}, and * {@link Policy#PRIORITY_CATEGORY_MEDIA} from bypassing dnd. * * @param priorityCategories bitmask of categories of notifications that can bypass DND. * @param priorityCallSenders which callers can bypass DND. * @param priorityMessageSenders which message senders can bypass DND. Loading @@ -1109,6 +1172,26 @@ public class NotificationManager { /** * Constructs a policy for Do Not Disturb priority mode behavior. * * <p> * Apps that target API levels below {@link Build.VERSION_CODES#P} cannot * change user-designated values to allow or disallow * {@link Policy#PRIORITY_CATEGORY_ALARMS}, {@link Policy#PRIORITY_CATEGORY_SYSTEM}, and * {@link Policy#PRIORITY_CATEGORY_MEDIA} from bypassing dnd. * <p> * Additionally, apps that target API levels below {@link Build.VERSION_CODES#P} can * only modify the {@link #SUPPRESSED_EFFECT_SCREEN_ON} and * {@link #SUPPRESSED_EFFECT_SCREEN_OFF} bits of the suppressed visual effects field. * All other suppressed effects will be ignored and reconstituted from the screen on * and screen off values. * <p> * Apps that target {@link Build.VERSION_CODES#P} or above can set any * suppressed visual effects. However, if any suppressed effects > * {@link #SUPPRESSED_EFFECT_SCREEN_ON} are set, {@link #SUPPRESSED_EFFECT_SCREEN_ON} * and {@link #SUPPRESSED_EFFECT_SCREEN_OFF} will be ignored and reconstituted from * the more specific suppressed visual effect bits. Apps should migrate to targeting * specific effects instead of the deprecated {@link #SUPPRESSED_EFFECT_SCREEN_ON} and * {@link #SUPPRESSED_EFFECT_SCREEN_OFF} effects. * * @param priorityCategories bitmask of categories of notifications that can bypass DND. * @param priorityCallSenders which callers can bypass DND. * @param priorityMessageSenders which message senders can bypass DND. Loading Loading @@ -1190,6 +1273,30 @@ public class NotificationManager { } } /** * @hide */ public static int getAllSuppressedVisualEffects() { int effects = 0; for (int i = 0; i < ALL_SUPPRESSED_EFFECTS.length; i++) { effects |= ALL_SUPPRESSED_EFFECTS[i]; } return effects; } /** * @hide */ public static boolean areAllVisualEffectsSuppressed(int effects) { for (int i = 0; i < ALL_SUPPRESSED_EFFECTS.length; i++) { final int effect = ALL_SUPPRESSED_EFFECTS[i]; if ((effects & effect) == 0) { return false; } } return true; } public static String suppressedEffectsToString(int effects) { if (effects <= 0) return ""; final StringBuilder sb = new StringBuilder(); Loading Loading @@ -1228,9 +1335,26 @@ public class NotificationManager { private static String effectToString(int effect) { switch (effect) { case SUPPRESSED_EFFECT_SCREEN_OFF: return "SUPPRESSED_EFFECT_SCREEN_OFF"; case SUPPRESSED_EFFECT_SCREEN_ON: return "SUPPRESSED_EFFECT_SCREEN_ON"; case SUPPRESSED_EFFECTS_UNSET: return "SUPPRESSED_EFFECTS_UNSET"; case SUPPRESSED_EFFECT_FULL_SCREEN_INTENT: return "SUPPRESSED_EFFECT_FULL_SCREEN_INTENT"; case SUPPRESSED_EFFECT_LIGHTS: return "SUPPRESSED_EFFECT_LIGHTS"; case SUPPRESSED_EFFECT_PEEK: return "SUPPRESSED_EFFECT_PEEK"; case SUPPRESSED_EFFECT_STATUS_BAR: return "SUPPRESSED_EFFECT_STATUS_BAR"; case SUPPRESSED_EFFECT_BADGE: return "SUPPRESSED_EFFECT_BADGE"; case SUPPRESSED_EFFECT_AMBIENT: return "SUPPRESSED_EFFECT_AMBIENT"; case SUPPRESSED_EFFECT_NOTIFICATION_LIST: return "SUPPRESSED_EFFECT_NOTIFICATION_LIST"; case SUPPRESSED_EFFECT_SCREEN_OFF: return "SUPPRESSED_EFFECT_SCREEN_OFF"; case SUPPRESSED_EFFECT_SCREEN_ON: return "SUPPRESSED_EFFECT_SCREEN_ON"; case SUPPRESSED_EFFECTS_UNSET: return "SUPPRESSED_EFFECTS_UNSET"; default: return "UNKNOWN_" + effect; } } Loading
core/java/android/service/notification/NotificationListenerService.java +8 −1 Original line number Diff line number Diff line Loading @@ -149,13 +149,19 @@ public abstract class NotificationListenerService extends Service { /** * Whether notification suppressed by DND should not interruption visually when the screen is * off. * * @deprecated Use the more specific visual effects in {@link NotificationManager.Policy}. */ @Deprecated public static final int SUPPRESSED_EFFECT_SCREEN_OFF = NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_OFF; /** * Whether notification suppressed by DND should not interruption visually when the screen is * on. * * @deprecated Use the more specific visual effects in {@link NotificationManager.Policy}. */ @Deprecated public static final int SUPPRESSED_EFFECT_SCREEN_ON = NotificationManager.Policy.SUPPRESSED_EFFECT_SCREEN_ON; Loading Loading @@ -1453,7 +1459,8 @@ public abstract class NotificationListenerService extends Service { /** * Returns the type(s) of visual effects that should be suppressed for this notification. * See {@link #SUPPRESSED_EFFECT_SCREEN_OFF}, {@link #SUPPRESSED_EFFECT_SCREEN_ON}. * See {@link NotificationManager.Policy}, e.g. * {@link NotificationManager.Policy#SUPPRESSED_EFFECT_LIGHTS}. */ public int getSuppressedVisualEffects() { return mSuppressedVisualEffects; Loading
core/java/android/service/notification/ZenModeConfig.java +29 −16 Original line number Diff line number Diff line Loading @@ -92,10 +92,12 @@ public class ZenModeConfig implements Parcelable { private static final boolean DEFAULT_ALLOW_REMINDERS = false; private static final boolean DEFAULT_ALLOW_EVENTS = false; private static final boolean DEFAULT_ALLOW_REPEAT_CALLERS = false; private static final boolean DEFAULT_ALLOW_SCREEN_OFF = true; private static final boolean DEFAULT_ALLOW_SCREEN_ON = true; private static final boolean DEFAULT_ALLOW_SCREEN_OFF = false; private static final boolean DEFAULT_ALLOW_SCREEN_ON = false; private static final int DEFAULT_SUPPRESSED_VISUAL_EFFECTS = Policy.getAllSuppressedVisualEffects(); public static final int XML_VERSION = 4; public static final int XML_VERSION = 5; public static final String ZEN_TAG = "zen"; private static final String ZEN_ATT_VERSION = "version"; private static final String ZEN_ATT_USER = "user"; Loading @@ -113,6 +115,8 @@ public class ZenModeConfig implements Parcelable { private static final String ALLOW_ATT_EVENTS = "events"; private static final String ALLOW_ATT_SCREEN_OFF = "visualScreenOff"; private static final String ALLOW_ATT_SCREEN_ON = "visualScreenOn"; private static final String DISALLOW_TAG = "disallow"; private static final String DISALLOW_ATT_VISUAL_EFFECTS = "visualEffects"; private static final String CONDITION_ATT_ID = "id"; private static final String CONDITION_ATT_SUMMARY = "summary"; Loading Loading @@ -146,6 +150,7 @@ public class ZenModeConfig implements Parcelable { public int allowCallsFrom = DEFAULT_SOURCE; public int allowMessagesFrom = DEFAULT_SOURCE; public int user = UserHandle.USER_SYSTEM; public int suppressedVisualEffects = DEFAULT_SUPPRESSED_VISUAL_EFFECTS; public boolean allowWhenScreenOff = DEFAULT_ALLOW_SCREEN_OFF; public boolean allowWhenScreenOn = DEFAULT_ALLOW_SCREEN_ON; public int version; Loading Loading @@ -180,6 +185,7 @@ public class ZenModeConfig implements Parcelable { allowAlarms = source.readInt() == 1; allowMedia = source.readInt() == 1; allowSystem = source.readInt() == 1; suppressedVisualEffects = source.readInt(); } @Override Loading Loading @@ -212,6 +218,7 @@ public class ZenModeConfig implements Parcelable { dest.writeInt(allowAlarms ? 1 : 0); dest.writeInt(allowMedia ? 1 : 0); dest.writeInt(allowSystem ? 1 : 0); dest.writeInt(suppressedVisualEffects); } @Override Loading @@ -230,6 +237,7 @@ public class ZenModeConfig implements Parcelable { .append(",allowMessagesFrom=").append(sourceToString(allowMessagesFrom)) .append(",allowWhenScreenOff=").append(allowWhenScreenOff) .append(",allowWhenScreenOn=").append(allowWhenScreenOn) .append(",suppressedVisualEffects=").append(suppressedVisualEffects) .append(",automaticRules=").append(automaticRules) .append(",manualRule=").append(manualRule) .append(']').toString(); Loading Loading @@ -279,6 +287,10 @@ public class ZenModeConfig implements Parcelable { if (allowWhenScreenOn != to.allowWhenScreenOn) { d.addLine("allowWhenScreenOn", allowWhenScreenOn, to.allowWhenScreenOn); } if (suppressedVisualEffects != to.suppressedVisualEffects) { d.addLine("suppressedVisualEffects", suppressedVisualEffects, to.suppressedVisualEffects); } final ArraySet<String> allRules = new ArraySet<>(); addKeys(allRules, automaticRules); addKeys(allRules, to.automaticRules); Loading Loading @@ -383,7 +395,8 @@ public class ZenModeConfig implements Parcelable { && other.allowWhenScreenOn == allowWhenScreenOn && other.user == user && Objects.equals(other.automaticRules, automaticRules) && Objects.equals(other.manualRule, manualRule); && Objects.equals(other.manualRule, manualRule) && other.suppressedVisualEffects == suppressedVisualEffects; } @Override Loading @@ -391,7 +404,8 @@ public class ZenModeConfig implements Parcelable { return Objects.hash(allowAlarms, allowMedia, allowSystem, allowCalls, allowRepeatCallers, allowMessages, allowCallsFrom, allowMessagesFrom, allowReminders, allowEvents, allowWhenScreenOff, allowWhenScreenOn, user, automaticRules, manualRule); allowWhenScreenOff, allowWhenScreenOn, user, automaticRules, manualRule, suppressedVisualEffects); } private static String toDayList(int[] days) { Loading Loading @@ -474,6 +488,8 @@ public class ZenModeConfig implements Parcelable { rt.allowCallsFrom = DEFAULT_SOURCE; rt.allowMessagesFrom = DEFAULT_SOURCE; } // continue to read even though we now have suppressedVisualEffects, in case // we need to revert to users' previous settings rt.allowWhenScreenOff = safeBoolean(parser, ALLOW_ATT_SCREEN_OFF, DEFAULT_ALLOW_SCREEN_OFF); rt.allowWhenScreenOn = Loading @@ -482,6 +498,9 @@ public class ZenModeConfig implements Parcelable { rt.allowMedia = safeBoolean(parser, ALLOW_ATT_MEDIA, DEFAULT_ALLOW_MEDIA); rt.allowSystem = safeBoolean(parser, ALLOW_ATT_SYSTEM, DEFAULT_ALLOW_SYSTEM); } else if (DISALLOW_TAG.equals(tag)) { rt.suppressedVisualEffects = safeInt(parser, DISALLOW_ATT_VISUAL_EFFECTS, DEFAULT_SUPPRESSED_VISUAL_EFFECTS); } else if (MANUAL_TAG.equals(tag)) { rt.manualRule = readRuleXml(parser); } else if (AUTOMATIC_TAG.equals(tag)) { Loading Loading @@ -517,6 +536,10 @@ public class ZenModeConfig implements Parcelable { out.attribute(null, ALLOW_ATT_SYSTEM, Boolean.toString(allowSystem)); out.endTag(null, ALLOW_TAG); out.startTag(null, DISALLOW_TAG); out.attribute(null, DISALLOW_ATT_VISUAL_EFFECTS, Integer.toString(suppressedVisualEffects)); out.endTag(null, DISALLOW_TAG); if (manualRule != null) { out.startTag(null, MANUAL_TAG); writeRuleXml(manualRule, out); Loading Loading @@ -701,13 +724,6 @@ public class ZenModeConfig implements Parcelable { if (allowRepeatCallers) { priorityCategories |= Policy.PRIORITY_CATEGORY_REPEAT_CALLERS; } int suppressedVisualEffects = 0; if (!allowWhenScreenOff) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_SCREEN_OFF; } if (!allowWhenScreenOn) { suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_SCREEN_ON; } if (allowAlarms) { priorityCategories |= Policy.PRIORITY_CATEGORY_ALARMS; } Loading Loading @@ -770,10 +786,7 @@ public class ZenModeConfig implements Parcelable { allowMessagesFrom = prioritySendersToSource(policy.priorityMessageSenders, allowMessagesFrom); if (policy.suppressedVisualEffects != Policy.SUPPRESSED_EFFECTS_UNSET) { allowWhenScreenOff = (policy.suppressedVisualEffects & Policy.SUPPRESSED_EFFECT_SCREEN_OFF) == 0; allowWhenScreenOn = (policy.suppressedVisualEffects & Policy.SUPPRESSED_EFFECT_SCREEN_ON) == 0; suppressedVisualEffects = policy.suppressedVisualEffects; } } Loading
core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -2396,6 +2396,7 @@ <!-- depends on ImportanceExtractor--> <item>com.android.server.notification.NotificationIntrusivenessExtractor</item> <item>com.android.server.notification.VisibilityExtractor</item> <!-- Depends on ZenModeExtractor --> <item>com.android.server.notification.BadgeExtractor</item> </string-array> Loading