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
This commit is contained in:
Marc Blank 2011-01-30 16:00:05 -08:00
parent fc902559c4
commit 81d68b842e

View File

@ -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