Fix #2420732 (crash in Google Services Framework)

* Exchange calendar sync created Event records for exceptions
  that didn't have a _sync_id
* This caused google calendar sync to try to upload these
  Events as new, which caused an Exception to be thrown
* Fixed EAS calendar sync adapter to generate a _sync_id for
  exceptions in the form <parentId>_<exception start time>

Bug: 2420732
Change-Id: I46769175ca89ffa4cec4fe8b0c35ef2242536185
This commit is contained in:
Marc Blank 2010-02-04 15:23:09 -08:00
parent 8f8179f07e
commit 0bbe34bce5

View File

@ -19,7 +19,6 @@ package com.android.exchange.adapter;
import com.android.email.Email; import com.android.email.Email;
import com.android.email.provider.EmailContent.Mailbox; import com.android.email.provider.EmailContent.Mailbox;
import com.android.exchange.Eas;
import com.android.exchange.EasSyncService; import com.android.exchange.EasSyncService;
import com.android.exchange.utility.CalendarUtilities; import com.android.exchange.utility.CalendarUtilities;
import com.android.exchange.utility.Duration; import com.android.exchange.utility.Duration;
@ -440,11 +439,13 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
// TODO Make sure calendar knows this isn't globally unique!! // TODO Make sure calendar knows this isn't globally unique!!
cv.put(Events.ORIGINAL_EVENT, parentCv.getAsString(Events._SYNC_ID)); cv.put(Events.ORIGINAL_EVENT, parentCv.getAsString(Events._SYNC_ID));
String exceptionStartTime = "_noStartTime";
while (nextTag(Tags.SYNC_APPLICATION_DATA) != END) { while (nextTag(Tags.SYNC_APPLICATION_DATA) != END) {
switch (tag) { switch (tag) {
case Tags.CALENDAR_EXCEPTION_START_TIME: case Tags.CALENDAR_EXCEPTION_START_TIME:
exceptionStartTime = getValue();
cv.put(Events.ORIGINAL_INSTANCE_TIME, cv.put(Events.ORIGINAL_INSTANCE_TIME,
CalendarUtilities.parseDateTimeToMillis(getValue())); CalendarUtilities.parseDateTimeToMillis(exceptionStartTime));
break; break;
case Tags.CALENDAR_EXCEPTION_IS_DELETED: case Tags.CALENDAR_EXCEPTION_IS_DELETED:
if (getValueInt() == 1) { if (getValueInt() == 1) {
@ -501,6 +502,10 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
} }
} }
// We need a _sync_id, but it can't be the parent's id, so we generate one
cv.put(Events._SYNC_ID, parentCv.getAsString(Events._SYNC_ID) + '_' +
exceptionStartTime);
if (!cv.containsKey(Events.DTSTART)) { if (!cv.containsKey(Events.DTSTART)) {
cv.put(Events.DTSTART, parentCv.getAsLong(Events.DTSTART)); cv.put(Events.DTSTART, parentCv.getAsLong(Events.DTSTART));
} }