Loading api/current.txt +2 −1 Original line number Diff line number Diff line Loading @@ -5745,10 +5745,11 @@ package android.app { field public static final int PRIORITY_CATEGORY_ALARMS = 32; // 0x20 field public static final int PRIORITY_CATEGORY_CALLS = 8; // 0x8 field public static final int PRIORITY_CATEGORY_EVENTS = 2; // 0x2 field public static final int PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER = 64; // 0x40 field public static final int PRIORITY_CATEGORY_MEDIA = 64; // 0x40 field public static final int PRIORITY_CATEGORY_MESSAGES = 4; // 0x4 field public static final int PRIORITY_CATEGORY_REMINDERS = 1; // 0x1 field public static final int PRIORITY_CATEGORY_REPEAT_CALLERS = 16; // 0x10 field public static final int PRIORITY_CATEGORY_SYSTEM = 128; // 0x80 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 core/java/android/app/NotificationManager.java +12 −6 Original line number Diff line number Diff line Loading @@ -1031,12 +1031,18 @@ public class NotificationManager { public static final int PRIORITY_CATEGORY_REPEAT_CALLERS = 1 << 4; /** Alarms are prioritized */ public static final int PRIORITY_CATEGORY_ALARMS = 1 << 5; /** Media, system, game (catch-all for non-never suppressible sounds) are prioritized */ public static final int PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER = 1 << 6; /** Media, game, voice navigation are prioritized */ public static final int PRIORITY_CATEGORY_MEDIA = 1 << 6; /**System (catch-all for non-never suppressible sounds) are prioritized */ public static final int PRIORITY_CATEGORY_SYSTEM = 1 << 7; private static final int[] ALL_PRIORITY_CATEGORIES = { /** * @hide */ public static final int[] ALL_PRIORITY_CATEGORIES = { PRIORITY_CATEGORY_ALARMS, PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER, PRIORITY_CATEGORY_MEDIA, PRIORITY_CATEGORY_SYSTEM, PRIORITY_CATEGORY_REMINDERS, PRIORITY_CATEGORY_EVENTS, PRIORITY_CATEGORY_MESSAGES, Loading Loading @@ -1237,8 +1243,8 @@ public class NotificationManager { case PRIORITY_CATEGORY_CALLS: return "PRIORITY_CATEGORY_CALLS"; case PRIORITY_CATEGORY_REPEAT_CALLERS: return "PRIORITY_CATEGORY_REPEAT_CALLERS"; case PRIORITY_CATEGORY_ALARMS: return "PRIORITY_CATEGORY_ALARMS"; case PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER: return "PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER"; case PRIORITY_CATEGORY_MEDIA: return "PRIORITY_CATEGORY_MEDIA"; case PRIORITY_CATEGORY_SYSTEM: return "PRIORITY_CATEGORY_SYSTEM"; default: return "PRIORITY_CATEGORY_UNKNOWN_" + priorityCategory; } } Loading core/java/android/preference/SeekBarVolumizer.java +8 −8 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba private NotificationManager.Policy mNotificationPolicy; private boolean mAllowAlarms; private boolean mAllowMediaSystem; private boolean mAllowMedia; private boolean mAllowRinger; public SeekBarVolumizer(Context context, int streamType, Uri defaultUri, Callback callback) { Loading @@ -100,8 +100,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba mNotificationPolicy = mNotificationManager.getNotificationPolicy(); mAllowAlarms = (mNotificationPolicy.priorityCategories & NotificationManager.Policy .PRIORITY_CATEGORY_ALARMS) != 0; mAllowMediaSystem = (mNotificationPolicy.priorityCategories & NotificationManager.Policy .PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) != 0; mAllowMedia = (mNotificationPolicy.priorityCategories & NotificationManager.Policy .PRIORITY_CATEGORY_MEDIA) != 0; mAllowRinger = !ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted( mNotificationPolicy); mStreamType = streamType; Loading Loading @@ -139,8 +139,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba return stream == AudioManager.STREAM_ALARM; } private static boolean isMediaOrSystemStream(int stream) { return stream == AudioManager.STREAM_MUSIC || stream == AudioManager.STREAM_SYSTEM; private static boolean isMediaStream(int stream) { return stream == AudioManager.STREAM_MUSIC; } public void setSeekBar(SeekBar seekBar) { Loading @@ -159,7 +159,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba || mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS || (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS && ((!mAllowAlarms && isAlarmsStream(mStreamType)) || (!mAllowMediaSystem && isMediaOrSystemStream(mStreamType)) || (!mAllowMedia && isMediaStream(mStreamType)) || (!mAllowRinger && isNotificationOrRing(mStreamType)))); } Loading Loading @@ -454,8 +454,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba mNotificationPolicy = mNotificationManager.getNotificationPolicy(); mAllowAlarms = (mNotificationPolicy.priorityCategories & NotificationManager.Policy .PRIORITY_CATEGORY_ALARMS) != 0; mAllowMediaSystem = (mNotificationPolicy.priorityCategories & NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) != 0; mAllowMedia = (mNotificationPolicy.priorityCategories & NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA) != 0; mAllowRinger = !ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted( mNotificationPolicy); updateSlider(); Loading core/java/android/provider/Settings.java +1 −1 Original line number Diff line number Diff line Loading @@ -3132,7 +3132,7 @@ public final class Settings { public static final String ALWAYS_FINISH_ACTIVITIES = Global.ALWAYS_FINISH_ACTIVITIES; /** * Determines which streams are affected by ringer mode changes. The * Determines which streams are affected by ringer and zen mode changes. The * stream type's bit should be set to 1 if it should be muted when going * into an inaudible ringer mode. */ Loading core/java/android/service/notification/ZenModeConfig.java +37 −21 Original line number Diff line number Diff line Loading @@ -85,7 +85,8 @@ public class ZenModeConfig implements Parcelable { // Default allow categories set in readXml() from default_zen_mode_config.xml, fallback values: private static final boolean DEFAULT_ALLOW_ALARMS = true; private static final boolean DEFAULT_ALLOW_MEDIA_SYSTEM_OTHER = true; private static final boolean DEFAULT_ALLOW_MEDIA = true; private static final boolean DEFAULT_ALLOW_SYSTEM = false; private static final boolean DEFAULT_ALLOW_CALLS = false; private static final boolean DEFAULT_ALLOW_MESSAGES = false; private static final boolean DEFAULT_ALLOW_REMINDERS = false; Loading @@ -94,13 +95,14 @@ public class ZenModeConfig implements Parcelable { private static final boolean DEFAULT_ALLOW_SCREEN_OFF = true; private static final boolean DEFAULT_ALLOW_SCREEN_ON = true; public static final int XML_VERSION = 3; public static final int XML_VERSION = 4; public static final String ZEN_TAG = "zen"; private static final String ZEN_ATT_VERSION = "version"; private static final String ZEN_ATT_USER = "user"; private static final String ALLOW_TAG = "allow"; private static final String ALLOW_ATT_ALARMS = "alarms"; private static final String ALLOW_ATT_MEDIA_SYSTEM_OTHER = "media_system_other"; private static final String ALLOW_ATT_MEDIA = "media"; private static final String ALLOW_ATT_SYSTEM = "system"; private static final String ALLOW_ATT_CALLS = "calls"; private static final String ALLOW_ATT_REPEAT_CALLERS = "repeatCallers"; private static final String ALLOW_ATT_MESSAGES = "messages"; Loading Loading @@ -134,7 +136,8 @@ public class ZenModeConfig implements Parcelable { private static final String RULE_ATT_ENABLER = "enabler"; public boolean allowAlarms = DEFAULT_ALLOW_ALARMS; public boolean allowMediaSystemOther = DEFAULT_ALLOW_MEDIA_SYSTEM_OTHER; public boolean allowMedia = DEFAULT_ALLOW_MEDIA; public boolean allowSystem = DEFAULT_ALLOW_SYSTEM; public boolean allowCalls = DEFAULT_ALLOW_CALLS; public boolean allowRepeatCallers = DEFAULT_ALLOW_REPEAT_CALLERS; public boolean allowMessages = DEFAULT_ALLOW_MESSAGES; Loading Loading @@ -175,7 +178,8 @@ public class ZenModeConfig implements Parcelable { allowWhenScreenOff = source.readInt() == 1; allowWhenScreenOn = source.readInt() == 1; allowAlarms = source.readInt() == 1; allowMediaSystemOther = source.readInt() == 1; allowMedia = source.readInt() == 1; allowSystem = source.readInt() == 1; } @Override Loading Loading @@ -206,7 +210,8 @@ public class ZenModeConfig implements Parcelable { dest.writeInt(allowWhenScreenOff ? 1 : 0); dest.writeInt(allowWhenScreenOn ? 1 : 0); dest.writeInt(allowAlarms ? 1 : 0); dest.writeInt(allowMediaSystemOther ? 1 : 0); dest.writeInt(allowMedia ? 1 : 0); dest.writeInt(allowSystem ? 1 : 0); } @Override Loading @@ -214,7 +219,8 @@ public class ZenModeConfig implements Parcelable { return new StringBuilder(ZenModeConfig.class.getSimpleName()).append('[') .append("user=").append(user) .append(",allowAlarms=").append(allowAlarms) .append(",allowMediaSystemOther=").append(allowMediaSystemOther) .append(",allowMedia=").append(allowMedia) .append(",allowSystem=").append(allowSystem) .append(",allowReminders=").append(allowReminders) .append(",allowEvents=").append(allowEvents) .append(",allowCalls=").append(allowCalls) Loading @@ -240,8 +246,11 @@ public class ZenModeConfig implements Parcelable { if (allowAlarms != to.allowAlarms) { d.addLine("allowAlarms", allowAlarms, to.allowAlarms); } if (allowMediaSystemOther != to.allowMediaSystemOther) { d.addLine("allowMediaSystemOther", allowMediaSystemOther, to.allowMediaSystemOther); if (allowMedia != to.allowMedia) { d.addLine("allowMedia", allowMedia, to.allowMedia); } if (allowSystem != to.allowSystem) { d.addLine("allowSystem", allowSystem, to.allowSystem); } if (allowCalls != to.allowCalls) { d.addLine("allowCalls", allowCalls, to.allowCalls); Loading Loading @@ -361,7 +370,8 @@ public class ZenModeConfig implements Parcelable { if (o == this) return true; final ZenModeConfig other = (ZenModeConfig) o; return other.allowAlarms == allowAlarms && other.allowMediaSystemOther == allowMediaSystemOther && other.allowMedia == allowMedia && other.allowSystem == allowSystem && other.allowCalls == allowCalls && other.allowRepeatCallers == allowRepeatCallers && other.allowMessages == allowMessages Loading @@ -378,7 +388,7 @@ public class ZenModeConfig implements Parcelable { @Override public int hashCode() { return Objects.hash(allowAlarms, allowMediaSystemOther, allowCalls, return Objects.hash(allowAlarms, allowMedia, allowSystem, allowCalls, allowRepeatCallers, allowMessages, allowCallsFrom, allowMessagesFrom, allowReminders, allowEvents, allowWhenScreenOff, allowWhenScreenOn, user, automaticRules, manualRule); Loading Loading @@ -469,8 +479,9 @@ public class ZenModeConfig implements Parcelable { rt.allowWhenScreenOn = safeBoolean(parser, ALLOW_ATT_SCREEN_ON, DEFAULT_ALLOW_SCREEN_ON); rt.allowAlarms = safeBoolean(parser, ALLOW_ATT_ALARMS, DEFAULT_ALLOW_ALARMS); rt.allowMediaSystemOther = safeBoolean(parser, ALLOW_ATT_MEDIA_SYSTEM_OTHER, DEFAULT_ALLOW_MEDIA_SYSTEM_OTHER); rt.allowMedia = safeBoolean(parser, ALLOW_ATT_MEDIA, DEFAULT_ALLOW_MEDIA); rt.allowSystem = safeBoolean(parser, ALLOW_ATT_SYSTEM, DEFAULT_ALLOW_SYSTEM); } else if (MANUAL_TAG.equals(tag)) { rt.manualRule = readRuleXml(parser); } else if (AUTOMATIC_TAG.equals(tag)) { Loading Loading @@ -502,7 +513,8 @@ public class ZenModeConfig implements Parcelable { out.attribute(null, ALLOW_ATT_SCREEN_OFF, Boolean.toString(allowWhenScreenOff)); out.attribute(null, ALLOW_ATT_SCREEN_ON, Boolean.toString(allowWhenScreenOn)); out.attribute(null, ALLOW_ATT_ALARMS, Boolean.toString(allowAlarms)); out.attribute(null, ALLOW_ATT_MEDIA_SYSTEM_OTHER, Boolean.toString(allowMediaSystemOther)); out.attribute(null, ALLOW_ATT_MEDIA, Boolean.toString(allowMedia)); out.attribute(null, ALLOW_ATT_SYSTEM, Boolean.toString(allowSystem)); out.endTag(null, ALLOW_TAG); if (manualRule != null) { Loading Loading @@ -699,8 +711,11 @@ public class ZenModeConfig implements Parcelable { if (allowAlarms) { priorityCategories |= Policy.PRIORITY_CATEGORY_ALARMS; } if (allowMediaSystemOther) { priorityCategories |= Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER; if (allowMedia) { priorityCategories |= Policy.PRIORITY_CATEGORY_MEDIA; } if (allowSystem) { priorityCategories |= Policy.PRIORITY_CATEGORY_SYSTEM; } priorityCallSenders = sourceToPrioritySenders(allowCallsFrom, priorityCallSenders); priorityMessageSenders = sourceToPrioritySenders(allowMessagesFrom, priorityMessageSenders); Loading Loading @@ -743,8 +758,8 @@ public class ZenModeConfig implements Parcelable { public void applyNotificationPolicy(Policy policy) { if (policy == null) return; allowAlarms = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_ALARMS) != 0; allowMediaSystemOther = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) != 0; allowMedia = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_MEDIA) != 0; allowSystem = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_SYSTEM) != 0; allowEvents = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_EVENTS) != 0; allowReminders = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_REMINDERS) != 0; allowCalls = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_CALLS) != 0; Loading Loading @@ -1415,7 +1430,8 @@ public class ZenModeConfig implements Parcelable { } /** * Determines whether dnd behavior should mute all notification sounds * Determines whether dnd behavior should mute all notification/ringer sounds * (sounds associated with ringer volume discluding system) */ public static boolean areAllPriorityOnlyNotificationZenSoundsMuted(NotificationManager.Policy policy) { Loading @@ -1434,7 +1450,7 @@ public class ZenModeConfig implements Parcelable { } /** * Determines whether dnd behavior should mute all notification sounds * Determines whether dnd behavior should mute all sounds controlled by ringer */ public static boolean areAllPriorityOnlyNotificationZenSoundsMuted(ZenModeConfig config) { return !config.allowReminders && !config.allowCalls && !config.allowMessages Loading @@ -1445,7 +1461,7 @@ public class ZenModeConfig implements Parcelable { * Determines whether all dnd mutes all sounds */ public static boolean areAllZenBehaviorSoundsMuted(ZenModeConfig config) { return !config.allowAlarms && !config.allowMediaSystemOther return !config.allowAlarms && !config.allowMedia && !config.allowSystem && areAllPriorityOnlyNotificationZenSoundsMuted(config); } Loading Loading
api/current.txt +2 −1 Original line number Diff line number Diff line Loading @@ -5745,10 +5745,11 @@ package android.app { field public static final int PRIORITY_CATEGORY_ALARMS = 32; // 0x20 field public static final int PRIORITY_CATEGORY_CALLS = 8; // 0x8 field public static final int PRIORITY_CATEGORY_EVENTS = 2; // 0x2 field public static final int PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER = 64; // 0x40 field public static final int PRIORITY_CATEGORY_MEDIA = 64; // 0x40 field public static final int PRIORITY_CATEGORY_MESSAGES = 4; // 0x4 field public static final int PRIORITY_CATEGORY_REMINDERS = 1; // 0x1 field public static final int PRIORITY_CATEGORY_REPEAT_CALLERS = 16; // 0x10 field public static final int PRIORITY_CATEGORY_SYSTEM = 128; // 0x80 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
core/java/android/app/NotificationManager.java +12 −6 Original line number Diff line number Diff line Loading @@ -1031,12 +1031,18 @@ public class NotificationManager { public static final int PRIORITY_CATEGORY_REPEAT_CALLERS = 1 << 4; /** Alarms are prioritized */ public static final int PRIORITY_CATEGORY_ALARMS = 1 << 5; /** Media, system, game (catch-all for non-never suppressible sounds) are prioritized */ public static final int PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER = 1 << 6; /** Media, game, voice navigation are prioritized */ public static final int PRIORITY_CATEGORY_MEDIA = 1 << 6; /**System (catch-all for non-never suppressible sounds) are prioritized */ public static final int PRIORITY_CATEGORY_SYSTEM = 1 << 7; private static final int[] ALL_PRIORITY_CATEGORIES = { /** * @hide */ public static final int[] ALL_PRIORITY_CATEGORIES = { PRIORITY_CATEGORY_ALARMS, PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER, PRIORITY_CATEGORY_MEDIA, PRIORITY_CATEGORY_SYSTEM, PRIORITY_CATEGORY_REMINDERS, PRIORITY_CATEGORY_EVENTS, PRIORITY_CATEGORY_MESSAGES, Loading Loading @@ -1237,8 +1243,8 @@ public class NotificationManager { case PRIORITY_CATEGORY_CALLS: return "PRIORITY_CATEGORY_CALLS"; case PRIORITY_CATEGORY_REPEAT_CALLERS: return "PRIORITY_CATEGORY_REPEAT_CALLERS"; case PRIORITY_CATEGORY_ALARMS: return "PRIORITY_CATEGORY_ALARMS"; case PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER: return "PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER"; case PRIORITY_CATEGORY_MEDIA: return "PRIORITY_CATEGORY_MEDIA"; case PRIORITY_CATEGORY_SYSTEM: return "PRIORITY_CATEGORY_SYSTEM"; default: return "PRIORITY_CATEGORY_UNKNOWN_" + priorityCategory; } } Loading
core/java/android/preference/SeekBarVolumizer.java +8 −8 Original line number Diff line number Diff line Loading @@ -90,7 +90,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba private NotificationManager.Policy mNotificationPolicy; private boolean mAllowAlarms; private boolean mAllowMediaSystem; private boolean mAllowMedia; private boolean mAllowRinger; public SeekBarVolumizer(Context context, int streamType, Uri defaultUri, Callback callback) { Loading @@ -100,8 +100,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba mNotificationPolicy = mNotificationManager.getNotificationPolicy(); mAllowAlarms = (mNotificationPolicy.priorityCategories & NotificationManager.Policy .PRIORITY_CATEGORY_ALARMS) != 0; mAllowMediaSystem = (mNotificationPolicy.priorityCategories & NotificationManager.Policy .PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) != 0; mAllowMedia = (mNotificationPolicy.priorityCategories & NotificationManager.Policy .PRIORITY_CATEGORY_MEDIA) != 0; mAllowRinger = !ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted( mNotificationPolicy); mStreamType = streamType; Loading Loading @@ -139,8 +139,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba return stream == AudioManager.STREAM_ALARM; } private static boolean isMediaOrSystemStream(int stream) { return stream == AudioManager.STREAM_MUSIC || stream == AudioManager.STREAM_SYSTEM; private static boolean isMediaStream(int stream) { return stream == AudioManager.STREAM_MUSIC; } public void setSeekBar(SeekBar seekBar) { Loading @@ -159,7 +159,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba || mZenMode == Global.ZEN_MODE_NO_INTERRUPTIONS || (mZenMode == Global.ZEN_MODE_IMPORTANT_INTERRUPTIONS && ((!mAllowAlarms && isAlarmsStream(mStreamType)) || (!mAllowMediaSystem && isMediaOrSystemStream(mStreamType)) || (!mAllowMedia && isMediaStream(mStreamType)) || (!mAllowRinger && isNotificationOrRing(mStreamType)))); } Loading Loading @@ -454,8 +454,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba mNotificationPolicy = mNotificationManager.getNotificationPolicy(); mAllowAlarms = (mNotificationPolicy.priorityCategories & NotificationManager.Policy .PRIORITY_CATEGORY_ALARMS) != 0; mAllowMediaSystem = (mNotificationPolicy.priorityCategories & NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) != 0; mAllowMedia = (mNotificationPolicy.priorityCategories & NotificationManager.Policy.PRIORITY_CATEGORY_MEDIA) != 0; mAllowRinger = !ZenModeConfig.areAllPriorityOnlyNotificationZenSoundsMuted( mNotificationPolicy); updateSlider(); Loading
core/java/android/provider/Settings.java +1 −1 Original line number Diff line number Diff line Loading @@ -3132,7 +3132,7 @@ public final class Settings { public static final String ALWAYS_FINISH_ACTIVITIES = Global.ALWAYS_FINISH_ACTIVITIES; /** * Determines which streams are affected by ringer mode changes. The * Determines which streams are affected by ringer and zen mode changes. The * stream type's bit should be set to 1 if it should be muted when going * into an inaudible ringer mode. */ Loading
core/java/android/service/notification/ZenModeConfig.java +37 −21 Original line number Diff line number Diff line Loading @@ -85,7 +85,8 @@ public class ZenModeConfig implements Parcelable { // Default allow categories set in readXml() from default_zen_mode_config.xml, fallback values: private static final boolean DEFAULT_ALLOW_ALARMS = true; private static final boolean DEFAULT_ALLOW_MEDIA_SYSTEM_OTHER = true; private static final boolean DEFAULT_ALLOW_MEDIA = true; private static final boolean DEFAULT_ALLOW_SYSTEM = false; private static final boolean DEFAULT_ALLOW_CALLS = false; private static final boolean DEFAULT_ALLOW_MESSAGES = false; private static final boolean DEFAULT_ALLOW_REMINDERS = false; Loading @@ -94,13 +95,14 @@ public class ZenModeConfig implements Parcelable { private static final boolean DEFAULT_ALLOW_SCREEN_OFF = true; private static final boolean DEFAULT_ALLOW_SCREEN_ON = true; public static final int XML_VERSION = 3; public static final int XML_VERSION = 4; public static final String ZEN_TAG = "zen"; private static final String ZEN_ATT_VERSION = "version"; private static final String ZEN_ATT_USER = "user"; private static final String ALLOW_TAG = "allow"; private static final String ALLOW_ATT_ALARMS = "alarms"; private static final String ALLOW_ATT_MEDIA_SYSTEM_OTHER = "media_system_other"; private static final String ALLOW_ATT_MEDIA = "media"; private static final String ALLOW_ATT_SYSTEM = "system"; private static final String ALLOW_ATT_CALLS = "calls"; private static final String ALLOW_ATT_REPEAT_CALLERS = "repeatCallers"; private static final String ALLOW_ATT_MESSAGES = "messages"; Loading Loading @@ -134,7 +136,8 @@ public class ZenModeConfig implements Parcelable { private static final String RULE_ATT_ENABLER = "enabler"; public boolean allowAlarms = DEFAULT_ALLOW_ALARMS; public boolean allowMediaSystemOther = DEFAULT_ALLOW_MEDIA_SYSTEM_OTHER; public boolean allowMedia = DEFAULT_ALLOW_MEDIA; public boolean allowSystem = DEFAULT_ALLOW_SYSTEM; public boolean allowCalls = DEFAULT_ALLOW_CALLS; public boolean allowRepeatCallers = DEFAULT_ALLOW_REPEAT_CALLERS; public boolean allowMessages = DEFAULT_ALLOW_MESSAGES; Loading Loading @@ -175,7 +178,8 @@ public class ZenModeConfig implements Parcelable { allowWhenScreenOff = source.readInt() == 1; allowWhenScreenOn = source.readInt() == 1; allowAlarms = source.readInt() == 1; allowMediaSystemOther = source.readInt() == 1; allowMedia = source.readInt() == 1; allowSystem = source.readInt() == 1; } @Override Loading Loading @@ -206,7 +210,8 @@ public class ZenModeConfig implements Parcelable { dest.writeInt(allowWhenScreenOff ? 1 : 0); dest.writeInt(allowWhenScreenOn ? 1 : 0); dest.writeInt(allowAlarms ? 1 : 0); dest.writeInt(allowMediaSystemOther ? 1 : 0); dest.writeInt(allowMedia ? 1 : 0); dest.writeInt(allowSystem ? 1 : 0); } @Override Loading @@ -214,7 +219,8 @@ public class ZenModeConfig implements Parcelable { return new StringBuilder(ZenModeConfig.class.getSimpleName()).append('[') .append("user=").append(user) .append(",allowAlarms=").append(allowAlarms) .append(",allowMediaSystemOther=").append(allowMediaSystemOther) .append(",allowMedia=").append(allowMedia) .append(",allowSystem=").append(allowSystem) .append(",allowReminders=").append(allowReminders) .append(",allowEvents=").append(allowEvents) .append(",allowCalls=").append(allowCalls) Loading @@ -240,8 +246,11 @@ public class ZenModeConfig implements Parcelable { if (allowAlarms != to.allowAlarms) { d.addLine("allowAlarms", allowAlarms, to.allowAlarms); } if (allowMediaSystemOther != to.allowMediaSystemOther) { d.addLine("allowMediaSystemOther", allowMediaSystemOther, to.allowMediaSystemOther); if (allowMedia != to.allowMedia) { d.addLine("allowMedia", allowMedia, to.allowMedia); } if (allowSystem != to.allowSystem) { d.addLine("allowSystem", allowSystem, to.allowSystem); } if (allowCalls != to.allowCalls) { d.addLine("allowCalls", allowCalls, to.allowCalls); Loading Loading @@ -361,7 +370,8 @@ public class ZenModeConfig implements Parcelable { if (o == this) return true; final ZenModeConfig other = (ZenModeConfig) o; return other.allowAlarms == allowAlarms && other.allowMediaSystemOther == allowMediaSystemOther && other.allowMedia == allowMedia && other.allowSystem == allowSystem && other.allowCalls == allowCalls && other.allowRepeatCallers == allowRepeatCallers && other.allowMessages == allowMessages Loading @@ -378,7 +388,7 @@ public class ZenModeConfig implements Parcelable { @Override public int hashCode() { return Objects.hash(allowAlarms, allowMediaSystemOther, allowCalls, return Objects.hash(allowAlarms, allowMedia, allowSystem, allowCalls, allowRepeatCallers, allowMessages, allowCallsFrom, allowMessagesFrom, allowReminders, allowEvents, allowWhenScreenOff, allowWhenScreenOn, user, automaticRules, manualRule); Loading Loading @@ -469,8 +479,9 @@ public class ZenModeConfig implements Parcelable { rt.allowWhenScreenOn = safeBoolean(parser, ALLOW_ATT_SCREEN_ON, DEFAULT_ALLOW_SCREEN_ON); rt.allowAlarms = safeBoolean(parser, ALLOW_ATT_ALARMS, DEFAULT_ALLOW_ALARMS); rt.allowMediaSystemOther = safeBoolean(parser, ALLOW_ATT_MEDIA_SYSTEM_OTHER, DEFAULT_ALLOW_MEDIA_SYSTEM_OTHER); rt.allowMedia = safeBoolean(parser, ALLOW_ATT_MEDIA, DEFAULT_ALLOW_MEDIA); rt.allowSystem = safeBoolean(parser, ALLOW_ATT_SYSTEM, DEFAULT_ALLOW_SYSTEM); } else if (MANUAL_TAG.equals(tag)) { rt.manualRule = readRuleXml(parser); } else if (AUTOMATIC_TAG.equals(tag)) { Loading Loading @@ -502,7 +513,8 @@ public class ZenModeConfig implements Parcelable { out.attribute(null, ALLOW_ATT_SCREEN_OFF, Boolean.toString(allowWhenScreenOff)); out.attribute(null, ALLOW_ATT_SCREEN_ON, Boolean.toString(allowWhenScreenOn)); out.attribute(null, ALLOW_ATT_ALARMS, Boolean.toString(allowAlarms)); out.attribute(null, ALLOW_ATT_MEDIA_SYSTEM_OTHER, Boolean.toString(allowMediaSystemOther)); out.attribute(null, ALLOW_ATT_MEDIA, Boolean.toString(allowMedia)); out.attribute(null, ALLOW_ATT_SYSTEM, Boolean.toString(allowSystem)); out.endTag(null, ALLOW_TAG); if (manualRule != null) { Loading Loading @@ -699,8 +711,11 @@ public class ZenModeConfig implements Parcelable { if (allowAlarms) { priorityCategories |= Policy.PRIORITY_CATEGORY_ALARMS; } if (allowMediaSystemOther) { priorityCategories |= Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER; if (allowMedia) { priorityCategories |= Policy.PRIORITY_CATEGORY_MEDIA; } if (allowSystem) { priorityCategories |= Policy.PRIORITY_CATEGORY_SYSTEM; } priorityCallSenders = sourceToPrioritySenders(allowCallsFrom, priorityCallSenders); priorityMessageSenders = sourceToPrioritySenders(allowMessagesFrom, priorityMessageSenders); Loading Loading @@ -743,8 +758,8 @@ public class ZenModeConfig implements Parcelable { public void applyNotificationPolicy(Policy policy) { if (policy == null) return; allowAlarms = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_ALARMS) != 0; allowMediaSystemOther = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_MEDIA_SYSTEM_OTHER) != 0; allowMedia = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_MEDIA) != 0; allowSystem = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_SYSTEM) != 0; allowEvents = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_EVENTS) != 0; allowReminders = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_REMINDERS) != 0; allowCalls = (policy.priorityCategories & Policy.PRIORITY_CATEGORY_CALLS) != 0; Loading Loading @@ -1415,7 +1430,8 @@ public class ZenModeConfig implements Parcelable { } /** * Determines whether dnd behavior should mute all notification sounds * Determines whether dnd behavior should mute all notification/ringer sounds * (sounds associated with ringer volume discluding system) */ public static boolean areAllPriorityOnlyNotificationZenSoundsMuted(NotificationManager.Policy policy) { Loading @@ -1434,7 +1450,7 @@ public class ZenModeConfig implements Parcelable { } /** * Determines whether dnd behavior should mute all notification sounds * Determines whether dnd behavior should mute all sounds controlled by ringer */ public static boolean areAllPriorityOnlyNotificationZenSoundsMuted(ZenModeConfig config) { return !config.allowReminders && !config.allowCalls && !config.allowMessages Loading @@ -1445,7 +1461,7 @@ public class ZenModeConfig implements Parcelable { * Determines whether all dnd mutes all sounds */ public static boolean areAllZenBehaviorSoundsMuted(ZenModeConfig config) { return !config.allowAlarms && !config.allowMediaSystemOther return !config.allowAlarms && !config.allowMedia && !config.allowSystem && areAllPriorityOnlyNotificationZenSoundsMuted(config); } Loading