From 2ce7955da7dffec7819ed38be85e72df8a6f33dc Mon Sep 17 00:00:00 2001 From: RoboErik Date: Fri, 3 Jun 2011 09:46:30 -0700 Subject: [PATCH] Support cleanup of Calendar.java -replaced refs to columns interfaces with the class where possible -added support for selection/selection args in instance queries -further cleanup Change-Id: I97ee0c7ed1703696166fd4a007e232a42cece376 --- .../providers/calendar/CalendarDebug.java | 8 +- .../calendar/CalendarInstancesHelper.java | 9 +- .../providers/calendar/CalendarProvider2.java | 185 +++++++++++------- .../calendar/CalendarProvider2Test.java | 35 ++-- 4 files changed, 139 insertions(+), 98 deletions(-) diff --git a/src/com/android/providers/calendar/CalendarDebug.java b/src/com/android/providers/calendar/CalendarDebug.java index 97c8e600..8d973cfa 100644 --- a/src/com/android/providers/calendar/CalendarDebug.java +++ b/src/com/android/providers/calendar/CalendarDebug.java @@ -95,9 +95,9 @@ protected List> doInBackground(Void... params) { String displayName = cursor.getString(INDEX_DISPLAY_NAME); // Compute number of events in the calendar - String where = Calendar.EventsColumns.CALENDAR_ID + "=" + id; + String where = Calendar.Events.CALENDAR_ID + "=" + id; Cursor eventCursor = Calendar.Events.query(mContentResolver, - EVENTS_PROJECTION, where, null); + EVENTS_PROJECTION, where, null, null); try { eventCount = eventCursor.getCount(); } finally { @@ -105,10 +105,10 @@ protected List> doInBackground(Void... params) { } // Compute number of dirty events in the calendar - String dirtyWhere = Calendar.EventsColumns.CALENDAR_ID + "=" + id + String dirtyWhere = Calendar.Events.CALENDAR_ID + "=" + id + " AND " + Calendar.Events.DIRTY + "=1"; Cursor dirtyCursor = Calendar.Events.query(mContentResolver, - EVENTS_PROJECTION, dirtyWhere, null); + EVENTS_PROJECTION, dirtyWhere, null, null); try { dirtyCount = dirtyCursor.getCount(); } finally { diff --git a/src/com/android/providers/calendar/CalendarInstancesHelper.java b/src/com/android/providers/calendar/CalendarInstancesHelper.java index 057e5420..8ed8115c 100644 --- a/src/com/android/providers/calendar/CalendarInstancesHelper.java +++ b/src/com/android/providers/calendar/CalendarInstancesHelper.java @@ -25,7 +25,6 @@ import android.os.Debug; import android.pim.EventRecurrence; import android.pim.RecurrenceSet; -import android.provider.BaseColumns; import android.provider.Calendar.Calendars; import android.provider.Calendar.Events; import android.provider.Calendar.Instances; @@ -74,8 +73,8 @@ public static final class InstancesList extends ArrayList { " WHERE " + CalendarProvider2.SQL_WHERE_ID; private static final String SQL_WHERE_ID_FROM_INSTANCES_NOT_SYNCED = - BaseColumns._ID + " IN " + - "(SELECT " + Tables.INSTANCES + "." + BaseColumns._ID + " as _id" + + Instances._ID + " IN " + + "(SELECT " + Tables.INSTANCES + "." + Instances._ID + " as _id" + " FROM " + Tables.INSTANCES + " INNER JOIN " + Tables.EVENTS + " ON (" + @@ -84,8 +83,8 @@ public static final class InstancesList extends ArrayList { " WHERE " + Tables.EVENTS + "." + Events._ID + "=?)"; private static final String SQL_WHERE_ID_FROM_INSTANCES_SYNCED = - BaseColumns._ID + " IN " + - "(SELECT " + Tables.INSTANCES + "." + BaseColumns._ID + " as _id" + + Instances._ID + " IN " + + "(SELECT " + Tables.INSTANCES + "." + Instances._ID + " as _id" + " FROM " + Tables.INSTANCES + " INNER JOIN " + Tables.EVENTS + " ON (" + diff --git a/src/com/android/providers/calendar/CalendarProvider2.java b/src/com/android/providers/calendar/CalendarProvider2.java index ad6bec6f..ba0dac22 100644 --- a/src/com/android/providers/calendar/CalendarProvider2.java +++ b/src/com/android/providers/calendar/CalendarProvider2.java @@ -51,6 +51,7 @@ import android.provider.Calendar.Events; import android.provider.Calendar.Instances; import android.provider.Calendar.Reminders; +import android.provider.Calendar.SyncState; import android.text.TextUtils; import android.text.format.DateUtils; import android.text.format.Time; @@ -58,6 +59,7 @@ import android.util.TimeFormatException; import android.util.TimeUtils; +import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -77,10 +79,6 @@ public class CalendarProvider2 extends SQLiteContentProvider implements OnAccoun protected static final String TAG = "CalendarProvider2"; private static final String TIMEZONE_GMT = "GMT"; - // Allows for a calendar that isn't associated with an account on the - // device - private static final String ACCOUNT_TYPE_LOCAL = "LOCAL"; - private static final String ACCOUNT_SELECTION_PREFIX = Calendars.ACCOUNT_NAME + "=? AND " + Calendars.ACCOUNT_TYPE + "=?"; @@ -144,22 +142,22 @@ public class CalendarProvider2 extends SQLiteContentProvider implements OnAccoun "CalendarSyncAdapter#originalTimezone"; private static final String SQL_SELECT_EVENTSRAWTIMES = "SELECT " + - Calendar.EventsRawTimesColumns.EVENT_ID + ", " + - Calendar.EventsRawTimesColumns.DTSTART_2445 + ", " + - Calendar.EventsRawTimesColumns.DTEND_2445 + ", " + + Calendar.EventsRawTimes.EVENT_ID + ", " + + Calendar.EventsRawTimes.DTSTART_2445 + ", " + + Calendar.EventsRawTimes.DTEND_2445 + ", " + Events.EVENT_TIMEZONE + " FROM " + Tables.EVENTS_RAW_TIMES + ", " + Tables.EVENTS + " WHERE " + - Calendar.EventsRawTimesColumns.EVENT_ID + " = " + Tables.EVENTS + "." + Events._ID; + Calendar.EventsRawTimes.EVENT_ID + " = " + Tables.EVENTS + "." + Events._ID; private static final String SQL_UPDATE_EVENT_SET_DIRTY = "UPDATE " + Tables.EVENTS + " SET " + Events.DIRTY + "=1" + " WHERE " + Events._ID + "=?"; - protected static final String SQL_WHERE_ID = BaseColumns._ID + "=?"; + protected static final String SQL_WHERE_ID = Events._ID + "=?"; private static final String SQL_WHERE_EVENT_ID = "event_id=?"; private static final String SQL_WHERE_ORIGINAL_EVENT = Events.ORIGINAL_SYNC_ID + "=?"; private static final String SQL_WHERE_ATTENDEES_ID = @@ -171,11 +169,11 @@ public class CalendarProvider2 extends SQLiteContentProvider implements OnAccoun Tables.EVENTS + "." + Events._ID + "=" + Tables.REMINDERS + "." + Reminders.EVENT_ID; private static final String SQL_WHERE_CALENDAR_ALERT = - Views.EVENTS + "." + BaseColumns._ID + "=" + + Views.EVENTS + "." + Events._ID + "=" + Tables.CALENDAR_ALERTS + "." + CalendarAlerts.EVENT_ID; private static final String SQL_WHERE_CALENDAR_ALERT_ID = - Views.EVENTS + "." + BaseColumns._ID + "=" + + Views.EVENTS + "." + Events._ID + "=" + Tables.CALENDAR_ALERTS + "." + CalendarAlerts.EVENT_ID + " AND " + Tables.CALENDAR_ALERTS + "." + CalendarAlerts._ID + "=?"; @@ -184,8 +182,8 @@ public class CalendarProvider2 extends SQLiteContentProvider implements OnAccoun Tables.EXTENDED_PROPERTIES + "." + Calendar.ExtendedProperties._ID + "=?"; private static final String SQL_DELETE_FROM_CALENDARS = "DELETE FROM " + Tables.CALENDARS + - " WHERE " + Calendar.SyncColumns.ACCOUNT_NAME + "=? AND " + - Calendar.SyncColumns.ACCOUNT_TYPE + "=?"; + " WHERE " + Calendars.ACCOUNT_NAME + "=? AND " + + Calendars.ACCOUNT_TYPE + "=?"; private static final String SQL_SELECT_COUNT_FOR_SYNC_ID = "SELECT COUNT(*) FROM " + Tables.EVENTS + " WHERE " + Events._SYNC_ID + "=?"; @@ -236,10 +234,18 @@ public class CalendarProvider2 extends SQLiteContentProvider implements OnAccoun private static final int INSTANCES_INDEX_ALL_DAY = 4; /** - * A regex for describing how we split search queries into tokens. - * Keeps quoted phrases as one token. - * - * "one \"two three\"" ==> ["one" "two three"] + * The sort order is: events with an earlier start time occur first and if + * the start times are the same, then events with a later end time occur + * first. The later end time is ordered first so that long-running events in + * the calendar views appear first. If the start and end times of two events + * are the same then we sort alphabetically on the title. This isn't + * required for correctness, it just adds a nice touch. + */ + public static final String SORT_CALENDAR_VIEW = "begin ASC, end DESC, title ASC"; + + /** + * A regex for describing how we split search queries into tokens. Keeps + * quoted phrases as one token. "one \"two three\"" ==> ["one" "two three"] */ private static final Pattern SEARCH_TOKEN_PATTERN = Pattern.compile("[^\\s\"'.?!,]+|" // first part matches unquoted words @@ -645,11 +651,11 @@ private void regenerateInstancesTable() { cursor = handleInstanceQuery(new SQLiteQueryBuilder(), begin, end, new String[] { Instances._ID }, - null /* selection */, null /* sort */, + null /* selection */, null, + null /* sort */, false /* searchByDayInsteadOfMillis */, true /* force Instances deletion and expansion */, - instancesTimezone, - isHomeTimezone()); + instancesTimezone, isHomeTimezone()); } finally { if (cursor != null) { cursor.close(); @@ -739,9 +745,8 @@ public Cursor query(Uri uri, String[] projection, String selection, String[] sel + uri.getPathSegments().get(3)); } instancesTimezone = mCalendarCache.readTimezoneInstances(); - return handleInstanceQuery(qb, begin, end, projection, - selection, sortOrder, match == INSTANCES_BY_DAY, - false /* do not force Instances deletion and expansion */, + return handleInstanceQuery(qb, begin, end, projection, selection, selectionArgs, + sortOrder, match == INSTANCES_BY_DAY, false /* don't force an expansion */, instancesTimezone, isHomeTimezone()); case INSTANCES_SEARCH: case INSTANCES_SEARCH_BY_DAY: @@ -760,8 +765,8 @@ public Cursor query(Uri uri, String[] projection, String selection, String[] sel instancesTimezone = mCalendarCache.readTimezoneInstances(); // this is already decoded String query = uri.getPathSegments().get(4); - return handleInstanceSearchQuery(qb, begin, end, query, projection, - selection, sortOrder, match == INSTANCES_SEARCH_BY_DAY, + return handleInstanceSearchQuery(qb, begin, end, query, projection, selection, + selectionArgs, sortOrder, match == INSTANCES_SEARCH_BY_DAY, instancesTimezone, isHomeTimezone()); case EVENT_DAYS: int startDay; @@ -882,9 +887,9 @@ private Cursor query(final SQLiteDatabase db, SQLiteQueryBuilder qb, String[] pr * @return */ private Cursor handleInstanceQuery(SQLiteQueryBuilder qb, long rangeBegin, - long rangeEnd, String[] projection, String selection, String sort, - boolean searchByDay, boolean forceExpansion, String instancesTimezone, - boolean isHomeTimezone) { + long rangeEnd, String[] projection, String selection, String[] selectionArgs, + String sort, boolean searchByDay, boolean forceExpansion, + String instancesTimezone, boolean isHomeTimezone) { qb.setTables(INSTANCE_QUERY_TABLES); qb.setProjectionMap(sInstancesProjectionMap); @@ -906,12 +911,46 @@ private Cursor handleInstanceQuery(SQLiteQueryBuilder qb, long rangeBegin, forceExpansion, instancesTimezone, isHomeTimezone); qb.appendWhere(SQL_WHERE_INSTANCES_BETWEEN); } - String selectionArgs[] = new String[] {String.valueOf(rangeEnd), + + String[] newSelectionArgs = new String[] {String.valueOf(rangeEnd), String.valueOf(rangeBegin)}; + if (selectionArgs == null) { + selectionArgs = newSelectionArgs; + } else { + // The appendWhere pieces get added first, so put the + // newSelectionArgs first. + selectionArgs = combine(newSelectionArgs, selectionArgs); + } return qb.query(mDb, projection, selection, selectionArgs, null /* groupBy */, null /* having */, sort); } + /** + * Combine a set of arrays in the order they are passed in. All arrays must + * be of the same type. + */ + private static T[] combine(T[]... arrays) { + if (arrays.length == 0) { + throw new IllegalArgumentException("Must supply at least 1 array to combine"); + } + + int totalSize = 0; + for (T[] array : arrays) { + totalSize += array.length; + } + + T[] finalArray = (T[]) (Array.newInstance(arrays[0].getClass().getComponentType(), + totalSize)); + + int currentPos = 0; + for (T[] array : arrays) { + int length = array.length; + System.arraycopy(array, 0, finalArray, currentPos, length); + currentPos += array.length; + } + return finalArray; + } + /** * Escape any special characters in the search token * @param token the token to escape @@ -1013,13 +1052,20 @@ String[] constructSearchArgs(String[] tokens, long rangeBegin, long rangeEnd) { private Cursor handleInstanceSearchQuery(SQLiteQueryBuilder qb, long rangeBegin, long rangeEnd, String query, String[] projection, - String selection, String sort, boolean searchByDay, String instancesTimezone, - boolean isHomeTimezone) { + String selection, String[] selectionArgs, String sort, boolean searchByDay, + String instancesTimezone, boolean isHomeTimezone) { qb.setTables(INSTANCE_SEARCH_QUERY_TABLES); qb.setProjectionMap(sInstancesProjectionMap); String[] tokens = tokenizeSearchQuery(query); - String[] selectionArgs = constructSearchArgs(tokens, rangeBegin, rangeEnd); + String[] newSelectionArgs = constructSearchArgs(tokens, rangeBegin, rangeEnd); + if (selectionArgs == null) { + selectionArgs = newSelectionArgs; + } else { + // The appendWhere pieces get added first, so put the + // newSelectionArgs first. + selectionArgs = combine(newSelectionArgs, selectionArgs); + } // we pass this in as a HAVING instead of a WHERE so the filtering // happens after the grouping String searchWhere = constructSearchWhere(tokens); @@ -1578,7 +1624,6 @@ protected Uri insertInTransaction(Uri uri, ContentValues values, boolean callerI setEventDirty(values.getAsInteger(Calendar.ExtendedProperties.EVENT_ID)); } break; - case DELETED_EVENTS: case EVENTS_ID: case REMINDERS_ID: case CALENDAR_ALERTS_ID: @@ -1984,13 +2029,13 @@ private void updateEventRawTimesLocked(long eventId, ContentValues values) { Long dtstartMillis = values.getAsLong(Events.DTSTART); if (dtstartMillis != null) { time.set(dtstartMillis); - rawValues.put(Calendar.EventsRawTimesColumns.DTSTART_2445, time.format2445()); + rawValues.put(Calendar.EventsRawTimes.DTSTART_2445, time.format2445()); } Long dtendMillis = values.getAsLong(Events.DTEND); if (dtendMillis != null) { time.set(dtendMillis); - rawValues.put(Calendar.EventsRawTimesColumns.DTEND_2445, time.format2445()); + rawValues.put(Calendar.EventsRawTimes.DTEND_2445, time.format2445()); } Long originalInstanceMillis = values.getAsLong(Events.ORIGINAL_INSTANCE_TIME); @@ -2003,7 +2048,7 @@ private void updateEventRawTimesLocked(long eventId, ContentValues values) { time.allDay = allDayInteger != 0; } time.set(originalInstanceMillis); - rawValues.put(Calendar.EventsRawTimesColumns.ORIGINAL_INSTANCE_TIME_2445, + rawValues.put(Calendar.EventsRawTimes.ORIGINAL_INSTANCE_TIME_2445, time.format2445()); } @@ -2011,7 +2056,7 @@ private void updateEventRawTimesLocked(long eventId, ContentValues values) { if (lastDateMillis != null) { time.allDay = allDay; time.set(lastDateMillis); - rawValues.put(Calendar.EventsRawTimesColumns.LAST_DATE_2445, time.format2445()); + rawValues.put(Calendar.EventsRawTimes.LAST_DATE_2445, time.format2445()); } mDbHelper.eventsRawTimesReplace(rawValues); @@ -2032,7 +2077,7 @@ protected int deleteInTransaction(Uri uri, String selection, String[] selectionA return mDbHelper.getSyncState().delete(mDb, selection, selectionArgs); case SYNCSTATE_ID: - String selectionWithId = (BaseColumns._ID + "=?") + String selectionWithId = (SyncState._ID + "=?") + (selection == null ? "" : " AND (" + selection + ")"); // Prepend id to selectionArgs selectionArgs = insertSelectionArg(selectionArgs, @@ -2158,10 +2203,8 @@ protected int deleteInTransaction(Uri uri, String selection, String[] selectionA return mDb.delete(Tables.CALENDAR_ALERTS, SQL_WHERE_ID, new String[] {String.valueOf(id)}); } - case DELETED_EVENTS: - throw new UnsupportedOperationException("Cannot delete that URL: " + uri); case CALENDARS_ID: - StringBuilder selectionSb = new StringBuilder(BaseColumns._ID + "="); + StringBuilder selectionSb = new StringBuilder(Calendars._ID + "="); selectionSb.append(uri.getPathSegments().get(1)); if (!TextUtils.isEmpty(selection)) { selectionSb.append(" AND ("); @@ -2414,7 +2457,7 @@ protected int updateInTransaction(Uri uri, ContentValues values, String selectio case SYNCSTATE_ID: { selection = appendAccountToSelection(uri, selection); - String selectionWithId = (BaseColumns._ID + "=?") + String selectionWithId = (SyncState._ID + "=?") + (selection == null ? "" : " AND (" + selection + ")"); // Prepend id to selectionArgs selectionArgs = insertSelectionArg(selectionArgs, @@ -3071,32 +3114,31 @@ private void doSendUpdateNotification() { private static final int EVENTS = 1; private static final int EVENTS_ID = 2; private static final int INSTANCES = 3; - private static final int DELETED_EVENTS = 4; - private static final int CALENDARS = 5; - private static final int CALENDARS_ID = 6; - private static final int ATTENDEES = 7; - private static final int ATTENDEES_ID = 8; - private static final int REMINDERS = 9; - private static final int REMINDERS_ID = 10; - private static final int EXTENDED_PROPERTIES = 11; - private static final int EXTENDED_PROPERTIES_ID = 12; - private static final int CALENDAR_ALERTS = 13; - private static final int CALENDAR_ALERTS_ID = 14; - private static final int CALENDAR_ALERTS_BY_INSTANCE = 15; - private static final int INSTANCES_BY_DAY = 16; - private static final int SYNCSTATE = 17; - private static final int SYNCSTATE_ID = 18; - private static final int EVENT_ENTITIES = 19; - private static final int EVENT_ENTITIES_ID = 20; - private static final int EVENT_DAYS = 21; - private static final int SCHEDULE_ALARM = 22; - private static final int SCHEDULE_ALARM_REMOVE = 23; - private static final int TIME = 24; - private static final int CALENDAR_ENTITIES = 25; - private static final int CALENDAR_ENTITIES_ID = 26; - private static final int INSTANCES_SEARCH = 27; - private static final int INSTANCES_SEARCH_BY_DAY = 28; - private static final int PROVIDER_PROPERTIES = 29; + private static final int CALENDARS = 4; + private static final int CALENDARS_ID = 5; + private static final int ATTENDEES = 6; + private static final int ATTENDEES_ID = 7; + private static final int REMINDERS = 8; + private static final int REMINDERS_ID = 9; + private static final int EXTENDED_PROPERTIES = 10; + private static final int EXTENDED_PROPERTIES_ID = 11; + private static final int CALENDAR_ALERTS = 12; + private static final int CALENDAR_ALERTS_ID = 13; + private static final int CALENDAR_ALERTS_BY_INSTANCE = 14; + private static final int INSTANCES_BY_DAY = 15; + private static final int SYNCSTATE = 16; + private static final int SYNCSTATE_ID = 17; + private static final int EVENT_ENTITIES = 18; + private static final int EVENT_ENTITIES_ID = 19; + private static final int EVENT_DAYS = 20; + private static final int SCHEDULE_ALARM = 21; + private static final int SCHEDULE_ALARM_REMOVE = 22; + private static final int TIME = 23; + private static final int CALENDAR_ENTITIES = 24; + private static final int CALENDAR_ENTITIES_ID = 25; + private static final int INSTANCES_SEARCH = 26; + private static final int INSTANCES_SEARCH_BY_DAY = 27; + private static final int PROVIDER_PROPERTIES = 28; private static final UriMatcher sUriMatcher = new UriMatcher(UriMatcher.NO_MATCH); private static final HashMap sInstancesProjectionMap; @@ -3123,7 +3165,6 @@ private void doSendUpdateNotification() { sUriMatcher.addURI(Calendar.AUTHORITY, "calendars/#", CALENDARS_ID); sUriMatcher.addURI(Calendar.AUTHORITY, "calendar_entities", CALENDAR_ENTITIES); sUriMatcher.addURI(Calendar.AUTHORITY, "calendar_entities/#", CALENDAR_ENTITIES_ID); - sUriMatcher.addURI(Calendar.AUTHORITY, "deleted_events", DELETED_EVENTS); sUriMatcher.addURI(Calendar.AUTHORITY, "attendees", ATTENDEES); sUriMatcher.addURI(Calendar.AUTHORITY, "attendees/#", ATTENDEES_ID); sUriMatcher.addURI(Calendar.AUTHORITY, "reminders", REMINDERS); @@ -3330,9 +3371,9 @@ public void onAccountsUpdated(Account[] accounts) { // Find all the accounts the calendar DB knows about, mark the ones that aren't // in the valid set for deletion. Cursor c = mDb.rawQuery("SELECT DISTINCT " + - Calendar.SyncColumns.ACCOUNT_NAME + + Calendars.ACCOUNT_NAME + "," + - Calendar.SyncColumns.ACCOUNT_TYPE + + Calendars.ACCOUNT_TYPE + " FROM " + table, null); while (c.moveToNext()) { // ACCOUNT_TYPE_LOCAL is to store calendars not associated @@ -3340,7 +3381,7 @@ public void onAccountsUpdated(Account[] accounts) { // associated with an account on the device or it will be // deleted. if (c.getString(0) != null && c.getString(1) != null && - !TextUtils.equals(c.getString(1), ACCOUNT_TYPE_LOCAL)) { + !TextUtils.equals(c.getString(1), Calendar.ACCOUNT_TYPE_LOCAL)) { Account currAccount = new Account(c.getString(0), c.getString(1)); if (!validAccounts.contains(currAccount)) { accountsToDelete.add(currAccount); diff --git a/tests/src/com/android/providers/calendar/CalendarProvider2Test.java b/tests/src/com/android/providers/calendar/CalendarProvider2Test.java index 4a86dac7..fa5303ba 100644 --- a/tests/src/com/android/providers/calendar/CalendarProvider2Test.java +++ b/tests/src/com/android/providers/calendar/CalendarProvider2Test.java @@ -231,7 +231,7 @@ public void execute() { ContentValues map = new ContentValues(); for (KeyValue pair : pairs) { String value = pair.value; - if (Calendar.EventsColumns.STATUS.equals(pair.key)) { + if (Calendar.Events.STATUS.equals(pair.key)) { // Do type conversion for STATUS map.put(pair.key, Integer.parseInt(value)); } else { @@ -816,8 +816,8 @@ public InstanceInfo(String eventName, String startDate, String endDate, int expe "2008-05-20T13:00:00", }), new Insert("cancel0"), new Update("cancel0", new KeyValue[] { - new KeyValue(Calendar.EventsColumns.STATUS, - "" + Calendar.EventsColumns.STATUS_CANCELED), + new KeyValue(Calendar.Events.STATUS, + Integer.toString(Calendar.Events.STATUS_CANCELED)), }), new VerifyAllInstances("2008-05-01T00:00:00", "2008-05-22T00:01:00", new String[] {"2008-05-06T13:00:00", @@ -879,7 +879,8 @@ public InstanceInfo(String eventName, String startDate, String endDate, int expe // It would be nice for the provider to handle this automatically, // but for now simulate the server-side cancel. new Update("except1", new KeyValue[] { - new KeyValue(Calendar.EventsColumns.STATUS, "" + Calendar.EventsColumns.STATUS_CANCELED), + new KeyValue(Calendar.Events.STATUS, + Integer.toString(Calendar.Events.STATUS_CANCELED)), }), // Verify that the recurrence exception does not appear. new VerifyAllInstances("2008-05-01T00:00:00", "2008-05-04T00:01:00", @@ -1149,7 +1150,7 @@ private int updateMatchingEvents(String title, ContentValues values) { || values.containsKey(Events.DURATION) || values.containsKey(Events.ALL_DAY) || values.containsKey(Events.RRULE) || values.containsKey(Events.EVENT_TIMEZONE) - || values.containsKey(Calendar.EventsColumns.STATUS)) { + || values.containsKey(Calendar.Events.STATUS)) { long dtstart = cursor.getLong(1); long dtend = cursor.getLong(2); String duration = cursor.getString(3); @@ -1523,7 +1524,7 @@ public void testInstanceSearchQuery() throws Exception { Events.GUESTS_CAN_MODIFY, // 18 }; - String orderBy = Instances.SORT_CALENDAR_VIEW; + String orderBy = CalendarProvider2.SORT_CALENDAR_VIEW; String where = Instances.SELF_ATTENDEE_STATUS + "!=" + Calendar.Attendees.ATTENDEE_STATUS_DECLINED; @@ -1569,7 +1570,7 @@ public void testInstanceSearchQuery() throws Exception { cursor = Instances.query(mResolver, PROJECTION, startMs - DateUtils.YEAR_IN_MILLIS, startMs + DateUtils.HOUR_IN_MILLIS, - "search", where, orderBy); + "search", where, null, orderBy); assertEquals(2, cursor.getCount()); } finally { if (cursor != null) { @@ -1581,7 +1582,7 @@ public void testInstanceSearchQuery() throws Exception { cursor = Instances.query(mResolver, PROJECTION, startMs - DateUtils.YEAR_IN_MILLIS, startMs + DateUtils.HOUR_IN_MILLIS, - "purple", where, orderBy); + "purple", where, null, orderBy); assertEquals(1, cursor.getCount()); } finally { if (cursor != null) { @@ -1593,7 +1594,7 @@ public void testInstanceSearchQuery() throws Exception { cursor = Instances.query(mResolver, PROJECTION, startMs - DateUtils.YEAR_IN_MILLIS, startMs + DateUtils.HOUR_IN_MILLIS, - "puurple", where, orderBy); + "puurple", where, null, orderBy); assertEquals(0, cursor.getCount()); } finally { if (cursor != null) { @@ -1605,7 +1606,7 @@ public void testInstanceSearchQuery() throws Exception { cursor = Instances.query(mResolver, PROJECTION, startMs - DateUtils.YEAR_IN_MILLIS, startMs + DateUtils.HOUR_IN_MILLIS, - "purple lasers", where, orderBy); + "purple lasers", where, null, orderBy); assertEquals(1, cursor.getCount()); } finally { if (cursor != null) { @@ -1617,7 +1618,7 @@ public void testInstanceSearchQuery() throws Exception { cursor = Instances.query(mResolver, PROJECTION, startMs - DateUtils.YEAR_IN_MILLIS, startMs + DateUtils.HOUR_IN_MILLIS, - "lasers kapow", where, orderBy); + "lasers kapow", where, null, orderBy); assertEquals(0, cursor.getCount()); } finally { if (cursor != null) { @@ -1629,7 +1630,7 @@ public void testInstanceSearchQuery() throws Exception { cursor = Instances.query(mResolver, PROJECTION, startMs - DateUtils.YEAR_IN_MILLIS, startMs + DateUtils.HOUR_IN_MILLIS, - "\"search purple\"", where, orderBy); + "\"search purple\"", where, null, orderBy); assertEquals(1, cursor.getCount()); } finally { if (cursor != null) { @@ -1641,7 +1642,7 @@ public void testInstanceSearchQuery() throws Exception { cursor = Instances.query(mResolver, PROJECTION, startMs - DateUtils.YEAR_IN_MILLIS, startMs + DateUtils.HOUR_IN_MILLIS, - "\"purple search\"", where, orderBy); + "\"purple search\"", where, null, orderBy); assertEquals(0, cursor.getCount()); } finally { if (cursor != null) { @@ -1653,7 +1654,7 @@ public void testInstanceSearchQuery() throws Exception { cursor = Instances.query(mResolver, PROJECTION, startMs - DateUtils.YEAR_IN_MILLIS, startMs + DateUtils.HOUR_IN_MILLIS, - "%", where, orderBy); + "%", where, null, orderBy); assertEquals(0, cursor.getCount()); } finally { if (cursor != null) { @@ -2322,7 +2323,7 @@ public void testInstanceQuery() throws Exception { Events.GUESTS_CAN_MODIFY, // 18 }; - String orderBy = Instances.SORT_CALENDAR_VIEW; + String orderBy = CalendarProvider2.SORT_CALENDAR_VIEW; String where = Instances.SELF_ATTENDEE_STATUS + "!=" + Calendar.Attendees.ATTENDEE_STATUS_DECLINED; int calId = insertCal("Calendar0", DEFAULT_TIMEZONE); @@ -2344,7 +2345,7 @@ public void testInstanceQuery() throws Exception { // Query is more than 2 months so the range won't get extended by the provider. Cursor cursor = Instances.query(mResolver, PROJECTION, startMs - DateUtils.YEAR_IN_MILLIS, startMs + DateUtils.HOUR_IN_MILLIS, - where, orderBy); + where, null, orderBy); try { assertEquals(1, cursor.getCount()); } finally { @@ -2354,7 +2355,7 @@ public void testInstanceQuery() throws Exception { // Now expand the instance range. The event overlaps the new part of the range. cursor = Instances.query(mResolver, PROJECTION, startMs - DateUtils.YEAR_IN_MILLIS, startMs + 2 * DateUtils.HOUR_IN_MILLIS, - where, orderBy); + where, null, orderBy); try { assertEquals(1, cursor.getCount()); } finally {