summaryrefslogtreecommitdiffstats
path: root/core/java/android/service
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2015-05-28 22:13:03 -0400
committerJohn Spurlock <jspurlock@google.com>2015-05-28 22:13:03 -0400
commit995a749f278b45a2931b2846a60a8231dfd755b4 (patch)
treebfda222f3a3c9d38ed2a1490f5bfadaaa3762041 /core/java/android/service
parent35ef0a626c89af03d40df1a4eda73aa6725c0941 (diff)
downloadframeworks_base-995a749f278b45a2931b2846a60a8231dfd755b4.zip
frameworks_base-995a749f278b45a2931b2846a60a8231dfd755b4.tar.gz
frameworks_base-995a749f278b45a2931b2846a60a8231dfd755b4.tar.bz2
Zen: Use account name instead of calendar id in event conditions.
- Migrate the existing calendar attribute in the event condition from a long calendar id to the calendar account name. More portable across a backup/restore. - Also skip restoring transient state (like the current condition state) from restored automatic rules. Bug: 17755700 Change-Id: I9bdb421d2209e3ce90873008665c254d67c788d2
Diffstat (limited to 'core/java/android/service')
-rw-r--r--core/java/android/service/notification/ZenModeConfig.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java
index 1da46d0..db19f7a 100644
--- a/core/java/android/service/notification/ZenModeConfig.java
+++ b/core/java/android/service/notification/ZenModeConfig.java
@@ -410,10 +410,10 @@ public class ZenModeConfig implements Parcelable {
rt.allowMessagesFrom = DEFAULT_SOURCE;
}
} else if (MANUAL_TAG.equals(tag)) {
- rt.manualRule = readRuleXml(parser, false /*conditionRequired*/);
+ rt.manualRule = readRuleXml(parser);
} else if (AUTOMATIC_TAG.equals(tag)) {
final String id = parser.getAttributeValue(null, RULE_ATT_ID);
- final ZenRule automaticRule = readRuleXml(parser, true /*conditionRequired*/);
+ final ZenRule automaticRule = readRuleXml(parser);
if (id != null && automaticRule != null) {
rt.automaticRules.put(id, automaticRule);
}
@@ -455,7 +455,7 @@ public class ZenModeConfig implements Parcelable {
out.endTag(null, ZEN_TAG);
}
- public static ZenRule readRuleXml(XmlPullParser parser, boolean conditionRequired) {
+ public static ZenRule readRuleXml(XmlPullParser parser) {
final ZenRule rt = new ZenRule();
rt.enabled = safeBoolean(parser, RULE_ATT_ENABLED, true);
rt.snoozing = safeBoolean(parser, RULE_ATT_SNOOZING, false);
@@ -801,7 +801,7 @@ public class ZenModeConfig implements Parcelable {
.authority(SYSTEM_AUTHORITY)
.appendPath(EVENT_PATH)
.appendQueryParameter("userId", Long.toString(event.userId))
- .appendQueryParameter("calendar", Long.toString(event.calendar))
+ .appendQueryParameter("calendar", event.calendar != null ? event.calendar : "")
.appendQueryParameter("reply", Integer.toString(event.reply))
.build();
}
@@ -819,21 +819,21 @@ public class ZenModeConfig implements Parcelable {
if (!isEvent) return null;
final EventInfo rt = new EventInfo();
rt.userId = tryParseInt(conditionId.getQueryParameter("userId"), UserHandle.USER_NULL);
- rt.calendar = tryParseLong(conditionId.getQueryParameter("calendar"),
- EventInfo.ANY_CALENDAR);
+ rt.calendar = conditionId.getQueryParameter("calendar");
+ if (TextUtils.isEmpty(rt.calendar) || tryParseLong(rt.calendar, -1L) != -1L) {
+ rt.calendar = null;
+ }
rt.reply = tryParseInt(conditionId.getQueryParameter("reply"), 0);
return rt;
}
public static class EventInfo {
- public static final long ANY_CALENDAR = 0;
-
public static final int REPLY_ANY_EXCEPT_NO = 0;
public static final int REPLY_YES_OR_MAYBE = 1;
public static final int REPLY_YES = 2;
public int userId = UserHandle.USER_NULL; // USER_NULL = unspecified - use current user
- public long calendar = ANY_CALENDAR; // CalendarContract.Calendars._ID, or ANY_CALENDAR
+ public String calendar; // CalendarContract.Calendars.OWNER_ACCOUNT, or null for any
public int reply;
@Override
@@ -846,7 +846,7 @@ public class ZenModeConfig implements Parcelable {
if (!(o instanceof EventInfo)) return false;
final EventInfo other = (EventInfo) o;
return userId == other.userId
- && calendar == other.calendar
+ && Objects.equals(calendar, other.calendar)
&& reply == other.reply;
}
@@ -860,7 +860,6 @@ public class ZenModeConfig implements Parcelable {
public static int resolveUserId(int userId) {
return userId == UserHandle.USER_NULL ? ActivityManager.getCurrentUser() : userId;
-
}
}