From 81d68b842ed5bb07aed05cfc57b0d99cd5910356 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Sun, 30 Jan 2011 16:00:05 -0800 Subject: [PATCH] Delete calendar properly on commanded wipe * CalendarProvider2 has unusual semantics for its delete operation on Calendars; this caused the user's calendar NOT to be deleted when the server commanded a wipe of calendar data. The result was duplication of events after the subsequent resync Bug: 3361000 Change-Id: I672034a7a444eb7ebdea60cd6dc66a31087cc6f7 --- src/com/android/exchange/adapter/CalendarSyncAdapter.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/com/android/exchange/adapter/CalendarSyncAdapter.java b/src/com/android/exchange/adapter/CalendarSyncAdapter.java index 197cdcff2..bb392d2de 100644 --- a/src/com/android/exchange/adapter/CalendarSyncAdapter.java +++ b/src/com/android/exchange/adapter/CalendarSyncAdapter.java @@ -38,6 +38,7 @@ import android.content.Entity.NamedContentValues; import android.content.EntityIterator; import android.content.OperationApplicationException; import android.database.Cursor; +import android.database.DatabaseUtils; import android.net.Uri; import android.os.RemoteException; import android.provider.Calendar; @@ -192,8 +193,11 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter { @Override public void wipe() { // Delete the calendar associated with this account - mContentResolver.delete(Calendars.CONTENT_URI, CALENDAR_SELECTION, - new String[] {mEmailAddress, Email.EXCHANGE_ACCOUNT_MANAGER_TYPE}); + // CalendarProvider2 does NOT handle selection arguments in deletions + mContentResolver.delete(Calendars.CONTENT_URI, Calendars._SYNC_ACCOUNT + + "=" + DatabaseUtils.sqlEscapeString(mEmailAddress) + " AND " + + Calendars._SYNC_ACCOUNT_TYPE + "=" + + DatabaseUtils.sqlEscapeString(Email.EXCHANGE_ACCOUNT_MANAGER_TYPE), null); } @Override