Adding new column 'uid2445' to Events table to support future handling of ical/ics format.
Bug:7029852
Change-Id: Ie2e5c0126583a68d2da81b6cc7c0101e29eb0649
diff --git a/src/com/android/providers/calendar/CalendarDatabaseHelper.java b/src/com/android/providers/calendar/CalendarDatabaseHelper.java
index 1548a67..7db2594 100644
--- a/src/com/android/providers/calendar/CalendarDatabaseHelper.java
+++ b/src/com/android/providers/calendar/CalendarDatabaseHelper.java
@@ -73,7 +73,7 @@
// 5xx for JB MR1
// 6xx for K
// Bump this to the next hundred at each major release.
- static final int DATABASE_VERSION = 501;
+ static final int DATABASE_VERSION = 502;
private static final int PRE_FROYO_SYNC_STATE_VERSION = 3;
@@ -114,7 +114,8 @@
Events.ORGANIZER + "," +
Events.IS_ORGANIZER + "," +
Events.CUSTOM_APP_PACKAGE + "," +
- Events.CUSTOM_APP_URI;
+ Events.CUSTOM_APP_URI + "," +
+ Events.UID_2445;
// columns used to duplicate a reminder row
private static final String LAST_SYNCED_REMINDER_COLUMNS =
@@ -565,6 +566,7 @@
CalendarContract.Events.EVENT_END_TIMEZONE + " TEXT," +
CalendarContract.Events.CUSTOM_APP_PACKAGE + " TEXT," +
CalendarContract.Events.CUSTOM_APP_URI + " TEXT," +
+ CalendarContract.Events.UID_2445 + " TEXT," +
// SYNC_DATAX columns are available for use by sync adapters
CalendarContract.Events.SYNC_DATA1 + " TEXT," +
CalendarContract.Events.SYNC_DATA2 + " TEXT," +
@@ -1389,15 +1391,19 @@
}
if (oldVersion == 402) {
upgradeToVersion403(db);
- createEventsView = true; // This is needed if the calendars or events schema changed
+ createEventsView = true;
oldVersion = 403;
}
-
if (oldVersion == 403) {
upgradeToVersion501(db);
- createEventsView = true; // This is needed if the calendars or events schema changed
+ createEventsView = true;
oldVersion = 501;
}
+ if (oldVersion == 501) {
+ upgradeToVersion502(db);
+ createEventsView = true; // This is needed if the calendars or events schema changed
+ oldVersion = 502;
+ }
if (createEventsView) {
createEventsView(db);
@@ -1488,6 +1494,14 @@
db.execSQL("ALTER TABLE Calendars ADD COLUMN isPrimary INTEGER;");
}
+ private void upgradeToVersion502(SQLiteDatabase db) {
+ /*
+ * Changes from version 501 to 502:
+ * - add UID for events added from the RFC 2445 iCalendar format.
+ */
+ db.execSQL("ALTER TABLE Events ADD COLUMN uid2445 TEXT;");
+ }
+
/**********************************************************/
/* 4xx db version is for J release
/**********************************************************/
@@ -3167,6 +3181,7 @@
+ ") AS " + Events.IS_ORGANIZER + ","
+ CalendarContract.Events.CUSTOM_APP_PACKAGE + ","
+ CalendarContract.Events.CUSTOM_APP_URI + ","
+ + CalendarContract.Events.UID_2445 + ","
+ CalendarContract.Events.SYNC_DATA1 + ","
+ CalendarContract.Events.SYNC_DATA2 + ","
+ CalendarContract.Events.SYNC_DATA3 + ","
diff --git a/src/com/android/providers/calendar/CalendarProvider2.java b/src/com/android/providers/calendar/CalendarProvider2.java
index cf96f26..3edbf7a 100644
--- a/src/com/android/providers/calendar/CalendarProvider2.java
+++ b/src/com/android/providers/calendar/CalendarProvider2.java
@@ -413,6 +413,7 @@
ALLOWED_IN_EXCEPTION.add(Events.ORGANIZER);
ALLOWED_IN_EXCEPTION.add(Events.CUSTOM_APP_PACKAGE);
ALLOWED_IN_EXCEPTION.add(Events.CUSTOM_APP_URI);
+ ALLOWED_IN_EXCEPTION.add(Events.UID_2445);
// deleted, original_id, alerts
}
@@ -4698,6 +4699,7 @@
sEventsProjectionMap.put(Events.IS_ORGANIZER, Events.IS_ORGANIZER);
sEventsProjectionMap.put(Events.CUSTOM_APP_PACKAGE, Events.CUSTOM_APP_PACKAGE);
sEventsProjectionMap.put(Events.CUSTOM_APP_URI, Events.CUSTOM_APP_URI);
+ sEventsProjectionMap.put(Events.UID_2445, Events.UID_2445);
sEventsProjectionMap.put(Events.DELETED, Events.DELETED);
sEventsProjectionMap.put(Events._SYNC_ID, Events._SYNC_ID);
@@ -4790,6 +4792,7 @@
sEventEntitiesProjectionMap.put(Events.IS_ORGANIZER, Events.IS_ORGANIZER);
sEventEntitiesProjectionMap.put(Events.CUSTOM_APP_PACKAGE, Events.CUSTOM_APP_PACKAGE);
sEventEntitiesProjectionMap.put(Events.CUSTOM_APP_URI, Events.CUSTOM_APP_URI);
+ sEventEntitiesProjectionMap.put(Events.UID_2445, Events.UID_2445);
sEventEntitiesProjectionMap.put(Events.DELETED, Events.DELETED);
sEventEntitiesProjectionMap.put(Events._ID, Events._ID);
sEventEntitiesProjectionMap.put(Events._SYNC_ID, Events._SYNC_ID);
diff --git a/tests/src/com/android/providers/calendar/CalendarProvider2Test.java b/tests/src/com/android/providers/calendar/CalendarProvider2Test.java
index 597bf29..8cb23dc 100644
--- a/tests/src/com/android/providers/calendar/CalendarProvider2Test.java
+++ b/tests/src/com/android/providers/calendar/CalendarProvider2Test.java
@@ -500,6 +500,7 @@
int mSyncId;
String mCustomAppPackage;
String mCustomAppUri;
+ String mUid2445;
// Constructor for normal events, using the default timezone
public EventInfo(String title, String startDate, String endDate,
@@ -532,6 +533,7 @@
mAllDay = allDay;
mCustomAppPackage = "CustomAppPackage-" + mTitle;
mCustomAppUri = "CustomAppUri-" + mTitle;
+ mUid2445 = null;
}
// Constructor for repeating events, using the default timezone
@@ -580,22 +582,23 @@
// Constructor for recurrence exceptions, using the default timezone
public EventInfo(String originalTitle, String originalInstance, String title,
String description, String startDate, String endDate, boolean allDay,
- String customPackageName, String customPackageUri) {
+ String customPackageName, String customPackageUri, String mUid2445) {
init(originalTitle, originalInstance,
title, description, startDate, endDate, allDay, DEFAULT_TIMEZONE,
- customPackageName, customPackageUri);
+ customPackageName, customPackageUri, mUid2445);
}
public void init(String originalTitle, String originalInstance,
String title, String description, String startDate, String endDate,
boolean allDay, String timezone, String customPackageName,
- String customPackageUri) {
+ String customPackageUri, String uid2445) {
mOriginalTitle = originalTitle;
Time time = new Time(timezone);
time.parse3339(originalInstance);
mOriginalInstance = time.toMillis(false /* use isDst */);
mCustomAppPackage = customPackageName;
mCustomAppUri = customPackageUri;
+ mUid2445 = uid2445;
init(title, description, startDate, endDate, null /* rrule */, allDay, timezone);
}
}
@@ -669,19 +672,24 @@
"FREQ=MONTHLY;WKST=SU;BYMONTHDAY=31", false),
new EventInfo("daily0", "2008-05-01T00:00:00",
"except0", "daily0 exception for 5/1/2008 12am, change to 5/1/2008 2am to 3am",
- "2008-05-01T02:00:00", "2008-05-01T01:03:00", false, "AppPkg1", "AppUri1"),
+ "2008-05-01T02:00:00", "2008-05-01T01:03:00", false, "AppPkg1", "AppUri1",
+ "uid2445-1"),
new EventInfo("daily0", "2008-05-03T00:00:00",
"except1", "daily0 exception for 5/3/2008 12am, change to 5/3/2008 2am to 3am",
- "2008-05-03T02:00:00", "2008-05-03T01:03:00", false, "AppPkg2", "AppUri2"),
+ "2008-05-03T02:00:00", "2008-05-03T01:03:00", false, "AppPkg2", "AppUri2",
+ null),
new EventInfo("daily0", "2008-05-02T00:00:00",
"except2", "daily0 exception for 5/2/2008 12am, change to 1/2/2008",
- "2008-01-02T00:00:00", "2008-01-02T01:00:00", false, "AppPkg3", "AppUri3"),
+ "2008-01-02T00:00:00", "2008-01-02T01:00:00", false, "AppPkg3", "AppUri3",
+ "12345@uid2445"),
new EventInfo("weekly0", "2008-05-13T13:00:00",
"except3", "daily0 exception for 5/11/2008 1pm, change to 12/11/2008 1pm",
- "2008-12-11T13:00:00", "2008-12-11T14:00:00", false, "AppPkg4", "AppUri4"),
+ "2008-12-11T13:00:00", "2008-12-11T14:00:00", false, "AppPkg4", "AppUri4",
+ null),
new EventInfo("weekly0", "2008-05-13T13:00:00",
"cancel0", "weekly0 exception for 5/13/2008 1pm",
- "2008-05-13T13:00:00", "2008-05-13T14:00:00", false, "AppPkg5", "AppUri5"),
+ "2008-05-13T13:00:00", "2008-05-13T14:00:00", false, "AppPkg5", "AppUri5",
+ null),
new EventInfo("yearly0", "yearly on 5/1/2008 from 1pm to 2pm",
"2008-05-01T13:00:00", "2008-05-01T14:00:00",
"FREQ=YEARLY;WKST=SU", false),
@@ -1182,6 +1190,9 @@
if (event.mCustomAppUri != null) {
m.put(Events.CUSTOM_APP_URI, event.mCustomAppUri);
}
+ if (event.mUid2445 != null) {
+ m.put(Events.UID_2445, event.mUid2445);
+ }
if (event.mOriginalTitle != null) {
// This is a recurrence exception.
@@ -1873,7 +1884,7 @@
assertEquals(0, deletes);
}
-
+
public void testCalendarAlerts() throws Exception {
// This projection is from AlertActivity; want to make sure it works.
String[] projection = new String[] {