Loading core/api/current.txt +2 −5 Original line number Diff line number Diff line Loading @@ -40512,7 +40512,6 @@ package android.service.notification { public final class ZenPolicy implements android.os.Parcelable { method public int describeContents(); method @FlaggedApi("android.app.modes_api") public int getAllowedChannels(); method public int getPriorityCallSenders(); method public int getPriorityCategoryAlarms(); method public int getPriorityCategoryCalls(); Loading @@ -40523,6 +40522,7 @@ package android.service.notification { method public int getPriorityCategoryReminders(); method public int getPriorityCategoryRepeatCallers(); method public int getPriorityCategorySystem(); method @FlaggedApi("android.app.modes_api") public int getPriorityChannels(); method public int getPriorityConversationSenders(); method public int getPriorityMessageSenders(); method public int getVisualEffectAmbient(); Loading @@ -40533,9 +40533,6 @@ package android.service.notification { method public int getVisualEffectPeek(); method public int getVisualEffectStatusBar(); method public void writeToParcel(android.os.Parcel, int); field @FlaggedApi("android.app.modes_api") public static final int CHANNEL_TYPE_NONE = 2; // 0x2 field @FlaggedApi("android.app.modes_api") public static final int CHANNEL_TYPE_PRIORITY = 1; // 0x1 field @FlaggedApi("android.app.modes_api") public static final int CHANNEL_TYPE_UNSET = 0; // 0x0 field public static final int CONVERSATION_SENDERS_ANYONE = 1; // 0x1 field public static final int CONVERSATION_SENDERS_IMPORTANT = 2; // 0x2 field public static final int CONVERSATION_SENDERS_NONE = 3; // 0x3 Loading @@ -40556,11 +40553,11 @@ package android.service.notification { method @NonNull public android.service.notification.ZenPolicy.Builder allowAlarms(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowAllSounds(); method @NonNull public android.service.notification.ZenPolicy.Builder allowCalls(int); method @FlaggedApi("android.app.modes_api") @NonNull public android.service.notification.ZenPolicy.Builder allowChannels(int); method @NonNull public android.service.notification.ZenPolicy.Builder allowConversations(int); method @NonNull public android.service.notification.ZenPolicy.Builder allowEvents(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowMedia(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowMessages(int); method @FlaggedApi("android.app.modes_api") @NonNull public android.service.notification.ZenPolicy.Builder allowPriorityChannels(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowReminders(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowRepeatCallers(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowSystem(boolean); core/java/android/service/notification/ZenModeConfig.java +8 −27 Original line number Diff line number Diff line Loading @@ -205,7 +205,7 @@ public class ZenModeConfig implements Parcelable { private static final String ALLOW_ATT_SCREEN_ON = "visualScreenOn"; private static final String ALLOW_ATT_CONV = "convos"; private static final String ALLOW_ATT_CONV_FROM = "convosFrom"; private static final String ALLOW_ATT_CHANNELS = "channels"; private static final String ALLOW_ATT_CHANNELS = "priorityChannels"; private static final String USER_MODIFIED_FIELDS = "policyUserModifiedFields"; private static final String DISALLOW_TAG = "disallow"; private static final String DISALLOW_ATT_VISUAL_EFFECTS = "visualEffects"; Loading Loading @@ -919,9 +919,9 @@ public class ZenModeConfig implements Parcelable { final int events = safeInt(parser, ALLOW_ATT_EVENTS, ZenPolicy.STATE_UNSET); final int reminders = safeInt(parser, ALLOW_ATT_REMINDERS, ZenPolicy.STATE_UNSET); if (Flags.modesApi()) { final int channels = safeInt(parser, ALLOW_ATT_CHANNELS, ZenPolicy.CHANNEL_TYPE_UNSET); if (channels != ZenPolicy.CHANNEL_TYPE_UNSET) { builder.allowChannels(channels); final int channels = safeInt(parser, ALLOW_ATT_CHANNELS, ZenPolicy.STATE_UNSET); if (channels != ZenPolicy.STATE_UNSET) { builder.allowPriorityChannels(channels == ZenPolicy.STATE_ALLOW); policySet = true; } builder.setUserModifiedFields(safeInt(parser, USER_MODIFIED_FIELDS, 0)); Loading Loading @@ -1036,7 +1036,7 @@ public class ZenModeConfig implements Parcelable { out); if (Flags.modesApi()) { writeZenPolicyState(ALLOW_ATT_CHANNELS, policy.getAllowedChannels(), out); writeZenPolicyState(ALLOW_ATT_CHANNELS, policy.getPriorityChannels(), out); out.attributeInt(null, USER_MODIFIED_FIELDS, policy.getUserModifiedFields()); } } Loading @@ -1053,7 +1053,7 @@ public class ZenModeConfig implements Parcelable { out.attributeInt(null, attr, val); } } else if (Flags.modesApi() && Objects.equals(attr, ALLOW_ATT_CHANNELS)) { if (val != ZenPolicy.CHANNEL_TYPE_UNSET) { if (val != ZenPolicy.STATE_UNSET) { out.attributeInt(null, attr, val); } } else { Loading Loading @@ -1238,8 +1238,7 @@ public class ZenModeConfig implements Parcelable { } if (Flags.modesApi()) { builder.allowChannels(allowPriorityChannels ? ZenPolicy.CHANNEL_TYPE_PRIORITY : ZenPolicy.CHANNEL_TYPE_NONE); builder.allowPriorityChannels(allowPriorityChannels); } return builder.build(); } Loading Loading @@ -1369,7 +1368,7 @@ public class ZenModeConfig implements Parcelable { int state = defaultPolicy.state; if (Flags.modesApi()) { state = Policy.policyState(defaultPolicy.hasPriorityChannels(), getAllowPriorityChannelsWithDefault(zenPolicy.getAllowedChannels(), ZenPolicy.stateToBoolean(zenPolicy.getPriorityChannels(), DEFAULT_ALLOW_PRIORITY_CHANNELS)); } Loading Loading @@ -1411,24 +1410,6 @@ public class ZenModeConfig implements Parcelable { } } /** * Gets whether priority channels are permitted by this channel type, with the specified * default if the value is unset. This effectively converts the channel enum to a boolean, * where "true" indicates priority channels are allowed to break through and "false" means * they are not. */ public static boolean getAllowPriorityChannelsWithDefault( @ZenPolicy.ChannelType int channelType, boolean defaultAllowChannels) { switch (channelType) { case ZenPolicy.CHANNEL_TYPE_PRIORITY: return true; case ZenPolicy.CHANNEL_TYPE_NONE: return false; default: return defaultAllowChannels; } } /** * Maps NotificationManager.Policy senders type to ZenPolicy.PeopleType */ Loading core/java/android/service/notification/ZenPolicy.java +42 −39 Original line number Diff line number Diff line Loading @@ -184,7 +184,8 @@ public final class ZenPolicy implements Parcelable { private @PeopleType int mPriorityMessages = PEOPLE_TYPE_UNSET; private @PeopleType int mPriorityCalls = PEOPLE_TYPE_UNSET; private @ConversationSenders int mConversationSenders = CONVERSATION_SENDERS_UNSET; private @ChannelType int mAllowChannels = CHANNEL_TYPE_UNSET; @FlaggedApi(Flags.FLAG_MODES_API) private @ChannelType int mAllowChannels = CHANNEL_POLICY_UNSET; private final @ModifiableField int mUserModifiedFields; // Bitwise representation /** @hide */ Loading Loading @@ -354,35 +355,34 @@ public final class ZenPolicy implements Parcelable { */ public static final int STATE_DISALLOW = 2; /** @hide */ @IntDef(prefix = { "CHANNEL_TYPE_" }, value = { CHANNEL_TYPE_UNSET, CHANNEL_TYPE_PRIORITY, CHANNEL_TYPE_NONE, @IntDef(prefix = { "CHANNEL_POLICY_" }, value = { CHANNEL_POLICY_UNSET, CHANNEL_POLICY_PRIORITY, CHANNEL_POLICY_NONE, }) @Retention(RetentionPolicy.SOURCE) public @interface ChannelType {} private @interface ChannelType {} /** * Indicates no explicit setting for which channels may bypass DND when this policy is active. * Defaults to {@link #CHANNEL_TYPE_PRIORITY}. * Defaults to {@link #CHANNEL_POLICY_PRIORITY}. */ @FlaggedApi(Flags.FLAG_MODES_API) public static final int CHANNEL_TYPE_UNSET = 0; private static final int CHANNEL_POLICY_UNSET = 0; /** * Indicates that channels marked as {@link NotificationChannel#canBypassDnd()} can bypass DND * when this policy is active. */ @FlaggedApi(Flags.FLAG_MODES_API) public static final int CHANNEL_TYPE_PRIORITY = 1; private static final int CHANNEL_POLICY_PRIORITY = 1; /** * Indicates that no channels can bypass DND when this policy is active, even those marked as * {@link NotificationChannel#canBypassDnd()}. */ @FlaggedApi(Flags.FLAG_MODES_API) public static final int CHANNEL_TYPE_NONE = 2; private static final int CHANNEL_POLICY_NONE = 2; /** @hide */ public ZenPolicy() { Loading Loading @@ -584,16 +584,21 @@ public final class ZenPolicy implements Parcelable { } /** * Which types of {@link NotificationChannel channels} this policy allows to bypass DND. When * this value is {@link #CHANNEL_TYPE_PRIORITY priority} channels, any channel with * canBypassDnd() may bypass DND; when it is {@link #CHANNEL_TYPE_NONE none}, even channels * with canBypassDnd() will be intercepted. * @return {@link #CHANNEL_TYPE_UNSET}, {@link #CHANNEL_TYPE_PRIORITY}, or * {@link #CHANNEL_TYPE_NONE} * Whether this policy allows {@link NotificationChannel channels} marked as * {@link NotificationChannel#canBypassDnd()} to bypass DND. If {@link #STATE_ALLOW}, these * channels may bypass; if {@link #STATE_DISALLOW}, then even notifications from channels * with {@link NotificationChannel#canBypassDnd()} will be intercepted. */ @FlaggedApi(Flags.FLAG_MODES_API) public @ChannelType int getAllowedChannels() { return mAllowChannels; public @State int getPriorityChannels() { switch (mAllowChannels) { case CHANNEL_POLICY_PRIORITY: return STATE_ALLOW; case CHANNEL_POLICY_NONE: return STATE_DISALLOW; default: return STATE_UNSET; } } /** Loading Loading @@ -1016,8 +1021,8 @@ public final class ZenPolicy implements Parcelable { * Set whether priority channels are permitted to break through DND. */ @FlaggedApi(Flags.FLAG_MODES_API) public @NonNull Builder allowChannels(@ChannelType int channelType) { mZenPolicy.mAllowChannels = channelType; public @NonNull Builder allowPriorityChannels(boolean allow) { mZenPolicy.mAllowChannels = allow ? CHANNEL_POLICY_PRIORITY : CHANNEL_POLICY_NONE; return this; } Loading Loading @@ -1305,11 +1310,11 @@ public final class ZenPolicy implements Parcelable { @FlaggedApi(Flags.FLAG_MODES_API) public static String channelTypeToString(@ChannelType int channelType) { switch (channelType) { case CHANNEL_TYPE_UNSET: case CHANNEL_POLICY_UNSET: return "unset"; case CHANNEL_TYPE_PRIORITY: case CHANNEL_POLICY_PRIORITY: return "priority"; case CHANNEL_TYPE_NONE: case CHANNEL_POLICY_NONE: return "none"; } return "invalidChannelType{" + channelType + "}"; Loading Loading @@ -1389,11 +1394,11 @@ public final class ZenPolicy implements Parcelable { } /** @hide */ public boolean isCategoryAllowed(@PriorityCategory int category, boolean defaultVal) { switch (getZenPolicyPriorityCategoryState(category)) { case ZenPolicy.STATE_ALLOW: public static boolean stateToBoolean(@State int state, boolean defaultVal) { switch (state) { case STATE_ALLOW: return true; case ZenPolicy.STATE_DISALLOW: case STATE_DISALLOW: return false; default: return defaultVal; Loading @@ -1401,15 +1406,13 @@ public final class ZenPolicy implements Parcelable { } /** @hide */ public boolean isVisualEffectAllowed(@VisualEffect int effect, boolean defaultVal) { switch (getZenPolicyVisualEffectState(effect)) { case ZenPolicy.STATE_ALLOW: return true; case ZenPolicy.STATE_DISALLOW: return false; default: return defaultVal; public boolean isCategoryAllowed(@PriorityCategory int category, boolean defaultVal) { return stateToBoolean(getZenPolicyPriorityCategoryState(category), defaultVal); } /** @hide */ public boolean isVisualEffectAllowed(@VisualEffect int effect, boolean defaultVal) { return stateToBoolean(getZenPolicyVisualEffectState(effect), defaultVal); } /** Loading Loading @@ -1463,8 +1466,8 @@ public final class ZenPolicy implements Parcelable { // apply allowed channels if (Flags.modesApi()) { // if no channels are allowed, can't newly allow them if (mAllowChannels != CHANNEL_TYPE_NONE && policyToApply.mAllowChannels != CHANNEL_TYPE_UNSET) { if (mAllowChannels != CHANNEL_POLICY_NONE && policyToApply.mAllowChannels != CHANNEL_POLICY_UNSET) { mAllowChannels = policyToApply.mAllowChannels; } } Loading Loading @@ -1530,7 +1533,7 @@ public final class ZenPolicy implements Parcelable { proto.write(DNDPolicyProto.ALLOW_CONVERSATIONS_FROM, getPriorityConversationSenders()); if (Flags.modesApi()) { proto.write(DNDPolicyProto.ALLOW_CHANNELS, getAllowedChannels()); proto.write(DNDPolicyProto.ALLOW_CHANNELS, getPriorityChannels()); } proto.flush(); Loading core/proto/android/service/notification.proto +5 −5 Original line number Diff line number Diff line Loading @@ -360,7 +360,7 @@ message DNDPolicyProto { optional ConversationType allow_conversations_from = 19; optional ChannelType allow_channels = 20; optional ChannelPolicy allow_channels = 20; } // Enum identifying the type of rule that changed; values set to match ones used in the Loading @@ -373,8 +373,8 @@ enum RuleType { // Enum used in DNDPolicyProto to indicate the type of channels permitted to // break through DND. Mirrors values in ZenPolicy. enum ChannelType { CHANNEL_TYPE_UNSET = 0; CHANNEL_TYPE_PRIORITY = 1; CHANNEL_TYPE_NONE = 2; enum ChannelPolicy { CHANNEL_POLICY_UNSET = 0; CHANNEL_POLICY_PRIORITY = 1; CHANNEL_POLICY_NONE = 2; } services/core/java/com/android/server/notification/ZenAdapters.java +1 −3 Original line number Diff line number Diff line Loading @@ -59,9 +59,7 @@ class ZenAdapters { } if (Flags.modesApi()) { zenPolicyBuilder.allowChannels( policy.allowPriorityChannels() ? ZenPolicy.CHANNEL_TYPE_PRIORITY : ZenPolicy.CHANNEL_TYPE_NONE); zenPolicyBuilder.allowPriorityChannels(policy.allowPriorityChannels()); } return zenPolicyBuilder.build(); Loading Loading
core/api/current.txt +2 −5 Original line number Diff line number Diff line Loading @@ -40512,7 +40512,6 @@ package android.service.notification { public final class ZenPolicy implements android.os.Parcelable { method public int describeContents(); method @FlaggedApi("android.app.modes_api") public int getAllowedChannels(); method public int getPriorityCallSenders(); method public int getPriorityCategoryAlarms(); method public int getPriorityCategoryCalls(); Loading @@ -40523,6 +40522,7 @@ package android.service.notification { method public int getPriorityCategoryReminders(); method public int getPriorityCategoryRepeatCallers(); method public int getPriorityCategorySystem(); method @FlaggedApi("android.app.modes_api") public int getPriorityChannels(); method public int getPriorityConversationSenders(); method public int getPriorityMessageSenders(); method public int getVisualEffectAmbient(); Loading @@ -40533,9 +40533,6 @@ package android.service.notification { method public int getVisualEffectPeek(); method public int getVisualEffectStatusBar(); method public void writeToParcel(android.os.Parcel, int); field @FlaggedApi("android.app.modes_api") public static final int CHANNEL_TYPE_NONE = 2; // 0x2 field @FlaggedApi("android.app.modes_api") public static final int CHANNEL_TYPE_PRIORITY = 1; // 0x1 field @FlaggedApi("android.app.modes_api") public static final int CHANNEL_TYPE_UNSET = 0; // 0x0 field public static final int CONVERSATION_SENDERS_ANYONE = 1; // 0x1 field public static final int CONVERSATION_SENDERS_IMPORTANT = 2; // 0x2 field public static final int CONVERSATION_SENDERS_NONE = 3; // 0x3 Loading @@ -40556,11 +40553,11 @@ package android.service.notification { method @NonNull public android.service.notification.ZenPolicy.Builder allowAlarms(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowAllSounds(); method @NonNull public android.service.notification.ZenPolicy.Builder allowCalls(int); method @FlaggedApi("android.app.modes_api") @NonNull public android.service.notification.ZenPolicy.Builder allowChannels(int); method @NonNull public android.service.notification.ZenPolicy.Builder allowConversations(int); method @NonNull public android.service.notification.ZenPolicy.Builder allowEvents(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowMedia(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowMessages(int); method @FlaggedApi("android.app.modes_api") @NonNull public android.service.notification.ZenPolicy.Builder allowPriorityChannels(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowReminders(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowRepeatCallers(boolean); method @NonNull public android.service.notification.ZenPolicy.Builder allowSystem(boolean);
core/java/android/service/notification/ZenModeConfig.java +8 −27 Original line number Diff line number Diff line Loading @@ -205,7 +205,7 @@ public class ZenModeConfig implements Parcelable { private static final String ALLOW_ATT_SCREEN_ON = "visualScreenOn"; private static final String ALLOW_ATT_CONV = "convos"; private static final String ALLOW_ATT_CONV_FROM = "convosFrom"; private static final String ALLOW_ATT_CHANNELS = "channels"; private static final String ALLOW_ATT_CHANNELS = "priorityChannels"; private static final String USER_MODIFIED_FIELDS = "policyUserModifiedFields"; private static final String DISALLOW_TAG = "disallow"; private static final String DISALLOW_ATT_VISUAL_EFFECTS = "visualEffects"; Loading Loading @@ -919,9 +919,9 @@ public class ZenModeConfig implements Parcelable { final int events = safeInt(parser, ALLOW_ATT_EVENTS, ZenPolicy.STATE_UNSET); final int reminders = safeInt(parser, ALLOW_ATT_REMINDERS, ZenPolicy.STATE_UNSET); if (Flags.modesApi()) { final int channels = safeInt(parser, ALLOW_ATT_CHANNELS, ZenPolicy.CHANNEL_TYPE_UNSET); if (channels != ZenPolicy.CHANNEL_TYPE_UNSET) { builder.allowChannels(channels); final int channels = safeInt(parser, ALLOW_ATT_CHANNELS, ZenPolicy.STATE_UNSET); if (channels != ZenPolicy.STATE_UNSET) { builder.allowPriorityChannels(channels == ZenPolicy.STATE_ALLOW); policySet = true; } builder.setUserModifiedFields(safeInt(parser, USER_MODIFIED_FIELDS, 0)); Loading Loading @@ -1036,7 +1036,7 @@ public class ZenModeConfig implements Parcelable { out); if (Flags.modesApi()) { writeZenPolicyState(ALLOW_ATT_CHANNELS, policy.getAllowedChannels(), out); writeZenPolicyState(ALLOW_ATT_CHANNELS, policy.getPriorityChannels(), out); out.attributeInt(null, USER_MODIFIED_FIELDS, policy.getUserModifiedFields()); } } Loading @@ -1053,7 +1053,7 @@ public class ZenModeConfig implements Parcelable { out.attributeInt(null, attr, val); } } else if (Flags.modesApi() && Objects.equals(attr, ALLOW_ATT_CHANNELS)) { if (val != ZenPolicy.CHANNEL_TYPE_UNSET) { if (val != ZenPolicy.STATE_UNSET) { out.attributeInt(null, attr, val); } } else { Loading Loading @@ -1238,8 +1238,7 @@ public class ZenModeConfig implements Parcelable { } if (Flags.modesApi()) { builder.allowChannels(allowPriorityChannels ? ZenPolicy.CHANNEL_TYPE_PRIORITY : ZenPolicy.CHANNEL_TYPE_NONE); builder.allowPriorityChannels(allowPriorityChannels); } return builder.build(); } Loading Loading @@ -1369,7 +1368,7 @@ public class ZenModeConfig implements Parcelable { int state = defaultPolicy.state; if (Flags.modesApi()) { state = Policy.policyState(defaultPolicy.hasPriorityChannels(), getAllowPriorityChannelsWithDefault(zenPolicy.getAllowedChannels(), ZenPolicy.stateToBoolean(zenPolicy.getPriorityChannels(), DEFAULT_ALLOW_PRIORITY_CHANNELS)); } Loading Loading @@ -1411,24 +1410,6 @@ public class ZenModeConfig implements Parcelable { } } /** * Gets whether priority channels are permitted by this channel type, with the specified * default if the value is unset. This effectively converts the channel enum to a boolean, * where "true" indicates priority channels are allowed to break through and "false" means * they are not. */ public static boolean getAllowPriorityChannelsWithDefault( @ZenPolicy.ChannelType int channelType, boolean defaultAllowChannels) { switch (channelType) { case ZenPolicy.CHANNEL_TYPE_PRIORITY: return true; case ZenPolicy.CHANNEL_TYPE_NONE: return false; default: return defaultAllowChannels; } } /** * Maps NotificationManager.Policy senders type to ZenPolicy.PeopleType */ Loading
core/java/android/service/notification/ZenPolicy.java +42 −39 Original line number Diff line number Diff line Loading @@ -184,7 +184,8 @@ public final class ZenPolicy implements Parcelable { private @PeopleType int mPriorityMessages = PEOPLE_TYPE_UNSET; private @PeopleType int mPriorityCalls = PEOPLE_TYPE_UNSET; private @ConversationSenders int mConversationSenders = CONVERSATION_SENDERS_UNSET; private @ChannelType int mAllowChannels = CHANNEL_TYPE_UNSET; @FlaggedApi(Flags.FLAG_MODES_API) private @ChannelType int mAllowChannels = CHANNEL_POLICY_UNSET; private final @ModifiableField int mUserModifiedFields; // Bitwise representation /** @hide */ Loading Loading @@ -354,35 +355,34 @@ public final class ZenPolicy implements Parcelable { */ public static final int STATE_DISALLOW = 2; /** @hide */ @IntDef(prefix = { "CHANNEL_TYPE_" }, value = { CHANNEL_TYPE_UNSET, CHANNEL_TYPE_PRIORITY, CHANNEL_TYPE_NONE, @IntDef(prefix = { "CHANNEL_POLICY_" }, value = { CHANNEL_POLICY_UNSET, CHANNEL_POLICY_PRIORITY, CHANNEL_POLICY_NONE, }) @Retention(RetentionPolicy.SOURCE) public @interface ChannelType {} private @interface ChannelType {} /** * Indicates no explicit setting for which channels may bypass DND when this policy is active. * Defaults to {@link #CHANNEL_TYPE_PRIORITY}. * Defaults to {@link #CHANNEL_POLICY_PRIORITY}. */ @FlaggedApi(Flags.FLAG_MODES_API) public static final int CHANNEL_TYPE_UNSET = 0; private static final int CHANNEL_POLICY_UNSET = 0; /** * Indicates that channels marked as {@link NotificationChannel#canBypassDnd()} can bypass DND * when this policy is active. */ @FlaggedApi(Flags.FLAG_MODES_API) public static final int CHANNEL_TYPE_PRIORITY = 1; private static final int CHANNEL_POLICY_PRIORITY = 1; /** * Indicates that no channels can bypass DND when this policy is active, even those marked as * {@link NotificationChannel#canBypassDnd()}. */ @FlaggedApi(Flags.FLAG_MODES_API) public static final int CHANNEL_TYPE_NONE = 2; private static final int CHANNEL_POLICY_NONE = 2; /** @hide */ public ZenPolicy() { Loading Loading @@ -584,16 +584,21 @@ public final class ZenPolicy implements Parcelable { } /** * Which types of {@link NotificationChannel channels} this policy allows to bypass DND. When * this value is {@link #CHANNEL_TYPE_PRIORITY priority} channels, any channel with * canBypassDnd() may bypass DND; when it is {@link #CHANNEL_TYPE_NONE none}, even channels * with canBypassDnd() will be intercepted. * @return {@link #CHANNEL_TYPE_UNSET}, {@link #CHANNEL_TYPE_PRIORITY}, or * {@link #CHANNEL_TYPE_NONE} * Whether this policy allows {@link NotificationChannel channels} marked as * {@link NotificationChannel#canBypassDnd()} to bypass DND. If {@link #STATE_ALLOW}, these * channels may bypass; if {@link #STATE_DISALLOW}, then even notifications from channels * with {@link NotificationChannel#canBypassDnd()} will be intercepted. */ @FlaggedApi(Flags.FLAG_MODES_API) public @ChannelType int getAllowedChannels() { return mAllowChannels; public @State int getPriorityChannels() { switch (mAllowChannels) { case CHANNEL_POLICY_PRIORITY: return STATE_ALLOW; case CHANNEL_POLICY_NONE: return STATE_DISALLOW; default: return STATE_UNSET; } } /** Loading Loading @@ -1016,8 +1021,8 @@ public final class ZenPolicy implements Parcelable { * Set whether priority channels are permitted to break through DND. */ @FlaggedApi(Flags.FLAG_MODES_API) public @NonNull Builder allowChannels(@ChannelType int channelType) { mZenPolicy.mAllowChannels = channelType; public @NonNull Builder allowPriorityChannels(boolean allow) { mZenPolicy.mAllowChannels = allow ? CHANNEL_POLICY_PRIORITY : CHANNEL_POLICY_NONE; return this; } Loading Loading @@ -1305,11 +1310,11 @@ public final class ZenPolicy implements Parcelable { @FlaggedApi(Flags.FLAG_MODES_API) public static String channelTypeToString(@ChannelType int channelType) { switch (channelType) { case CHANNEL_TYPE_UNSET: case CHANNEL_POLICY_UNSET: return "unset"; case CHANNEL_TYPE_PRIORITY: case CHANNEL_POLICY_PRIORITY: return "priority"; case CHANNEL_TYPE_NONE: case CHANNEL_POLICY_NONE: return "none"; } return "invalidChannelType{" + channelType + "}"; Loading Loading @@ -1389,11 +1394,11 @@ public final class ZenPolicy implements Parcelable { } /** @hide */ public boolean isCategoryAllowed(@PriorityCategory int category, boolean defaultVal) { switch (getZenPolicyPriorityCategoryState(category)) { case ZenPolicy.STATE_ALLOW: public static boolean stateToBoolean(@State int state, boolean defaultVal) { switch (state) { case STATE_ALLOW: return true; case ZenPolicy.STATE_DISALLOW: case STATE_DISALLOW: return false; default: return defaultVal; Loading @@ -1401,15 +1406,13 @@ public final class ZenPolicy implements Parcelable { } /** @hide */ public boolean isVisualEffectAllowed(@VisualEffect int effect, boolean defaultVal) { switch (getZenPolicyVisualEffectState(effect)) { case ZenPolicy.STATE_ALLOW: return true; case ZenPolicy.STATE_DISALLOW: return false; default: return defaultVal; public boolean isCategoryAllowed(@PriorityCategory int category, boolean defaultVal) { return stateToBoolean(getZenPolicyPriorityCategoryState(category), defaultVal); } /** @hide */ public boolean isVisualEffectAllowed(@VisualEffect int effect, boolean defaultVal) { return stateToBoolean(getZenPolicyVisualEffectState(effect), defaultVal); } /** Loading Loading @@ -1463,8 +1466,8 @@ public final class ZenPolicy implements Parcelable { // apply allowed channels if (Flags.modesApi()) { // if no channels are allowed, can't newly allow them if (mAllowChannels != CHANNEL_TYPE_NONE && policyToApply.mAllowChannels != CHANNEL_TYPE_UNSET) { if (mAllowChannels != CHANNEL_POLICY_NONE && policyToApply.mAllowChannels != CHANNEL_POLICY_UNSET) { mAllowChannels = policyToApply.mAllowChannels; } } Loading Loading @@ -1530,7 +1533,7 @@ public final class ZenPolicy implements Parcelable { proto.write(DNDPolicyProto.ALLOW_CONVERSATIONS_FROM, getPriorityConversationSenders()); if (Flags.modesApi()) { proto.write(DNDPolicyProto.ALLOW_CHANNELS, getAllowedChannels()); proto.write(DNDPolicyProto.ALLOW_CHANNELS, getPriorityChannels()); } proto.flush(); Loading
core/proto/android/service/notification.proto +5 −5 Original line number Diff line number Diff line Loading @@ -360,7 +360,7 @@ message DNDPolicyProto { optional ConversationType allow_conversations_from = 19; optional ChannelType allow_channels = 20; optional ChannelPolicy allow_channels = 20; } // Enum identifying the type of rule that changed; values set to match ones used in the Loading @@ -373,8 +373,8 @@ enum RuleType { // Enum used in DNDPolicyProto to indicate the type of channels permitted to // break through DND. Mirrors values in ZenPolicy. enum ChannelType { CHANNEL_TYPE_UNSET = 0; CHANNEL_TYPE_PRIORITY = 1; CHANNEL_TYPE_NONE = 2; enum ChannelPolicy { CHANNEL_POLICY_UNSET = 0; CHANNEL_POLICY_PRIORITY = 1; CHANNEL_POLICY_NONE = 2; }
services/core/java/com/android/server/notification/ZenAdapters.java +1 −3 Original line number Diff line number Diff line Loading @@ -59,9 +59,7 @@ class ZenAdapters { } if (Flags.modesApi()) { zenPolicyBuilder.allowChannels( policy.allowPriorityChannels() ? ZenPolicy.CHANNEL_TYPE_PRIORITY : ZenPolicy.CHANNEL_TYPE_NONE); zenPolicyBuilder.allowPriorityChannels(policy.allowPriorityChannels()); } return zenPolicyBuilder.build(); Loading