Loading core/java/android/service/notification/ZenModeConfig.java +11 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,8 @@ public class ZenModeConfig implements Parcelable { private static final int MINUTES_MS = 60 * SECONDS_MS; private static final int ZERO_VALUE_MS = 20 * SECONDS_MS; private static final boolean DEFAULT_ALLOW_EVENTS = true; private static final int XML_VERSION = 1; private static final String ZEN_TAG = "zen"; private static final String ZEN_ATT_VERSION = "version"; Loading @@ -68,6 +70,7 @@ public class ZenModeConfig implements Parcelable { private static final String ALLOW_ATT_CALLS = "calls"; private static final String ALLOW_ATT_MESSAGES = "messages"; private static final String ALLOW_ATT_FROM = "from"; private static final String ALLOW_ATT_EVENTS = "events"; private static final String SLEEP_TAG = "sleep"; private static final String SLEEP_ATT_MODE = "mode"; Loading @@ -91,6 +94,7 @@ public class ZenModeConfig implements Parcelable { public boolean allowCalls; public boolean allowMessages; public boolean allowEvents = DEFAULT_ALLOW_EVENTS; public int allowFrom = SOURCE_ANYONE; public String sleepMode; Loading @@ -108,6 +112,7 @@ public class ZenModeConfig implements Parcelable { public ZenModeConfig(Parcel source) { allowCalls = source.readInt() == 1; allowMessages = source.readInt() == 1; allowEvents = source.readInt() == 1; if (source.readInt() == 1) { sleepMode = source.readString(); } Loading @@ -134,6 +139,7 @@ public class ZenModeConfig implements Parcelable { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(allowCalls ? 1 : 0); dest.writeInt(allowMessages ? 1 : 0); dest.writeInt(allowEvents ? 1 : 0); if (sleepMode != null) { dest.writeInt(1); dest.writeString(sleepMode); Loading Loading @@ -167,6 +173,7 @@ public class ZenModeConfig implements Parcelable { .append("allowCalls=").append(allowCalls) .append(",allowMessages=").append(allowMessages) .append(",allowFrom=").append(sourceToString(allowFrom)) .append(",allowEvents=").append(allowEvents) .append(",sleepMode=").append(sleepMode) .append(",sleepStart=").append(sleepStartHour).append('.').append(sleepStartMinute) .append(",sleepEnd=").append(sleepEndHour).append('.').append(sleepEndMinute) Loading Loading @@ -200,6 +207,7 @@ public class ZenModeConfig implements Parcelable { return other.allowCalls == allowCalls && other.allowMessages == allowMessages && other.allowFrom == allowFrom && other.allowEvents == allowEvents && Objects.equals(other.sleepMode, sleepMode) && other.sleepStartHour == sleepStartHour && other.sleepStartMinute == sleepStartMinute Loading @@ -213,7 +221,7 @@ public class ZenModeConfig implements Parcelable { @Override public int hashCode() { return Objects.hash(allowCalls, allowMessages, allowFrom, sleepMode, return Objects.hash(allowCalls, allowMessages, allowFrom, allowEvents, sleepMode, sleepStartHour, sleepStartMinute, sleepEndHour, sleepEndMinute, Arrays.hashCode(conditionComponents), Arrays.hashCode(conditionIds), exitCondition, exitConditionComponent); Loading Loading @@ -281,6 +289,7 @@ public class ZenModeConfig implements Parcelable { if (ALLOW_TAG.equals(tag)) { rt.allowCalls = safeBoolean(parser, ALLOW_ATT_CALLS, false); rt.allowMessages = safeBoolean(parser, ALLOW_ATT_MESSAGES, false); rt.allowEvents = safeBoolean(parser, ALLOW_ATT_EVENTS, DEFAULT_ALLOW_EVENTS); rt.allowFrom = safeInt(parser, ALLOW_ATT_FROM, SOURCE_ANYONE); if (rt.allowFrom < SOURCE_ANYONE || rt.allowFrom > MAX_SOURCE) { throw new IndexOutOfBoundsException("bad source in config:" + rt.allowFrom); Loading Loading @@ -323,6 +332,7 @@ public class ZenModeConfig implements Parcelable { out.startTag(null, ALLOW_TAG); out.attribute(null, ALLOW_ATT_CALLS, Boolean.toString(allowCalls)); out.attribute(null, ALLOW_ATT_MESSAGES, Boolean.toString(allowMessages)); out.attribute(null, ALLOW_ATT_EVENTS, Boolean.toString(allowEvents)); out.attribute(null, ALLOW_ATT_FROM, Integer.toString(allowFrom)); out.endTag(null, ALLOW_TAG); Loading services/core/java/com/android/server/notification/ZenModeHelper.java +12 −3 Original line number Diff line number Diff line Loading @@ -182,6 +182,12 @@ public class ZenModeHelper { } return shouldInterceptAudience(record); } if (isEvent(record)) { if (!mConfig.allowEvents) { ZenLog.traceIntercepted(record, "!allowEvents"); return true; } } ZenLog.traceIntercepted(record, "!allowed"); return true; } Loading Loading @@ -328,17 +334,20 @@ public class ZenModeHelper { } } private boolean isSystem(NotificationRecord record) { private static boolean isSystem(NotificationRecord record) { return record.isCategory(Notification.CATEGORY_SYSTEM); } private boolean isAlarm(NotificationRecord record) { private static boolean isAlarm(NotificationRecord record) { return record.isCategory(Notification.CATEGORY_ALARM) || record.isCategory(Notification.CATEGORY_EVENT) || record.isAudioStream(AudioManager.STREAM_ALARM) || record.isAudioAttributesUsage(AudioAttributes.USAGE_ALARM); } private static boolean isEvent(NotificationRecord record) { return record.isCategory(Notification.CATEGORY_EVENT); } private boolean isCall(NotificationRecord record) { return isDefaultPhoneApp(record.sbn.getPackageName()) || record.isCategory(Notification.CATEGORY_CALL); Loading Loading
core/java/android/service/notification/ZenModeConfig.java +11 −1 Original line number Diff line number Diff line Loading @@ -61,6 +61,8 @@ public class ZenModeConfig implements Parcelable { private static final int MINUTES_MS = 60 * SECONDS_MS; private static final int ZERO_VALUE_MS = 20 * SECONDS_MS; private static final boolean DEFAULT_ALLOW_EVENTS = true; private static final int XML_VERSION = 1; private static final String ZEN_TAG = "zen"; private static final String ZEN_ATT_VERSION = "version"; Loading @@ -68,6 +70,7 @@ public class ZenModeConfig implements Parcelable { private static final String ALLOW_ATT_CALLS = "calls"; private static final String ALLOW_ATT_MESSAGES = "messages"; private static final String ALLOW_ATT_FROM = "from"; private static final String ALLOW_ATT_EVENTS = "events"; private static final String SLEEP_TAG = "sleep"; private static final String SLEEP_ATT_MODE = "mode"; Loading @@ -91,6 +94,7 @@ public class ZenModeConfig implements Parcelable { public boolean allowCalls; public boolean allowMessages; public boolean allowEvents = DEFAULT_ALLOW_EVENTS; public int allowFrom = SOURCE_ANYONE; public String sleepMode; Loading @@ -108,6 +112,7 @@ public class ZenModeConfig implements Parcelable { public ZenModeConfig(Parcel source) { allowCalls = source.readInt() == 1; allowMessages = source.readInt() == 1; allowEvents = source.readInt() == 1; if (source.readInt() == 1) { sleepMode = source.readString(); } Loading @@ -134,6 +139,7 @@ public class ZenModeConfig implements Parcelable { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(allowCalls ? 1 : 0); dest.writeInt(allowMessages ? 1 : 0); dest.writeInt(allowEvents ? 1 : 0); if (sleepMode != null) { dest.writeInt(1); dest.writeString(sleepMode); Loading Loading @@ -167,6 +173,7 @@ public class ZenModeConfig implements Parcelable { .append("allowCalls=").append(allowCalls) .append(",allowMessages=").append(allowMessages) .append(",allowFrom=").append(sourceToString(allowFrom)) .append(",allowEvents=").append(allowEvents) .append(",sleepMode=").append(sleepMode) .append(",sleepStart=").append(sleepStartHour).append('.').append(sleepStartMinute) .append(",sleepEnd=").append(sleepEndHour).append('.').append(sleepEndMinute) Loading Loading @@ -200,6 +207,7 @@ public class ZenModeConfig implements Parcelable { return other.allowCalls == allowCalls && other.allowMessages == allowMessages && other.allowFrom == allowFrom && other.allowEvents == allowEvents && Objects.equals(other.sleepMode, sleepMode) && other.sleepStartHour == sleepStartHour && other.sleepStartMinute == sleepStartMinute Loading @@ -213,7 +221,7 @@ public class ZenModeConfig implements Parcelable { @Override public int hashCode() { return Objects.hash(allowCalls, allowMessages, allowFrom, sleepMode, return Objects.hash(allowCalls, allowMessages, allowFrom, allowEvents, sleepMode, sleepStartHour, sleepStartMinute, sleepEndHour, sleepEndMinute, Arrays.hashCode(conditionComponents), Arrays.hashCode(conditionIds), exitCondition, exitConditionComponent); Loading Loading @@ -281,6 +289,7 @@ public class ZenModeConfig implements Parcelable { if (ALLOW_TAG.equals(tag)) { rt.allowCalls = safeBoolean(parser, ALLOW_ATT_CALLS, false); rt.allowMessages = safeBoolean(parser, ALLOW_ATT_MESSAGES, false); rt.allowEvents = safeBoolean(parser, ALLOW_ATT_EVENTS, DEFAULT_ALLOW_EVENTS); rt.allowFrom = safeInt(parser, ALLOW_ATT_FROM, SOURCE_ANYONE); if (rt.allowFrom < SOURCE_ANYONE || rt.allowFrom > MAX_SOURCE) { throw new IndexOutOfBoundsException("bad source in config:" + rt.allowFrom); Loading Loading @@ -323,6 +332,7 @@ public class ZenModeConfig implements Parcelable { out.startTag(null, ALLOW_TAG); out.attribute(null, ALLOW_ATT_CALLS, Boolean.toString(allowCalls)); out.attribute(null, ALLOW_ATT_MESSAGES, Boolean.toString(allowMessages)); out.attribute(null, ALLOW_ATT_EVENTS, Boolean.toString(allowEvents)); out.attribute(null, ALLOW_ATT_FROM, Integer.toString(allowFrom)); out.endTag(null, ALLOW_TAG); Loading
services/core/java/com/android/server/notification/ZenModeHelper.java +12 −3 Original line number Diff line number Diff line Loading @@ -182,6 +182,12 @@ public class ZenModeHelper { } return shouldInterceptAudience(record); } if (isEvent(record)) { if (!mConfig.allowEvents) { ZenLog.traceIntercepted(record, "!allowEvents"); return true; } } ZenLog.traceIntercepted(record, "!allowed"); return true; } Loading Loading @@ -328,17 +334,20 @@ public class ZenModeHelper { } } private boolean isSystem(NotificationRecord record) { private static boolean isSystem(NotificationRecord record) { return record.isCategory(Notification.CATEGORY_SYSTEM); } private boolean isAlarm(NotificationRecord record) { private static boolean isAlarm(NotificationRecord record) { return record.isCategory(Notification.CATEGORY_ALARM) || record.isCategory(Notification.CATEGORY_EVENT) || record.isAudioStream(AudioManager.STREAM_ALARM) || record.isAudioAttributesUsage(AudioAttributes.USAGE_ALARM); } private static boolean isEvent(NotificationRecord record) { return record.isCategory(Notification.CATEGORY_EVENT); } private boolean isCall(NotificationRecord record) { return isDefaultPhoneApp(record.sbn.getPackageName()) || record.isCategory(Notification.CATEGORY_CALL); Loading