summaryrefslogtreecommitdiffstats
path: root/core/java/android/service/notification
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2014-09-19 15:29:06 -0400
committerJohn Spurlock <jspurlock@google.com>2014-09-22 16:44:37 -0400
commit2dac62c2e985ce1848b0fff751d4ed2cc3885c0c (patch)
tree032908e3e1356b6ed99176a3809d76bf615bd535 /core/java/android/service/notification
parentee3ef2b8af94b118a91b2f7c454260d191153f7a (diff)
downloadframeworks_base-2dac62c2e985ce1848b0fff751d4ed2cc3885c0c.zip
frameworks_base-2dac62c2e985ce1848b0fff751d4ed2cc3885c0c.tar.gz
frameworks_base-2dac62c2e985ce1848b0fff751d4ed2cc3885c0c.tar.bz2
Zen: Add events as a new config attribute.
Decouple events from alarms in the zen interception function, and default the new allowEvents to true. Bug:17580878 Change-Id: Iff10df385206ad73c3423ff118c79e94a10918d9
Diffstat (limited to 'core/java/android/service/notification')
-rw-r--r--core/java/android/service/notification/ZenModeConfig.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java
index 9cbedab..882a3c8 100644
--- a/core/java/android/service/notification/ZenModeConfig.java
+++ b/core/java/android/service/notification/ZenModeConfig.java
@@ -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";
@@ -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";
@@ -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;
@@ -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();
}
@@ -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);
@@ -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)
@@ -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
@@ -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);
@@ -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);
@@ -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);