Use original all-day flag when upsyncing exceptions

Bug: 3087410
Change-Id: I4bed0039758e98d4b85054876f192605eb00ee82
This commit is contained in:
Marc Blank 2010-10-12 19:08:05 -07:00
parent 9c293eb65a
commit 9ce8f4d2a3
3 changed files with 33 additions and 13 deletions

View File

@ -1428,18 +1428,12 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
// 2) Serialize attendees and reminders from subvalues
// 3) Look for exceptions and serialize with the top-level event
ContentValues entityValues = entity.getEntityValues();
boolean isException = (clientId == null);
final boolean isException = (clientId == null);
boolean hasAttendees = false;
boolean isChange = entityValues.containsKey(Events._SYNC_ID);
Double version = mService.mProtocolVersionDouble;
boolean allDay = false;
if (entityValues.containsKey(Events.ALL_DAY)) {
Integer ade = entityValues.getAsInteger(Events.ALL_DAY);
if (ade != null && ade != 0) {
allDay = true;
}
}
final boolean isChange = entityValues.containsKey(Events._SYNC_ID);
final Double version = mService.mProtocolVersionDouble;
final boolean allDay =
CalendarUtilities.getIntegerValueAsBoolean(entityValues, Events.ALL_DAY);
// NOTE: Exchange 2003 (EAS 2.5) seems to require the "exception deleted" and "exception
// start time" data before other data in exceptions. Failure to do so results in a
@ -1455,7 +1449,7 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
// If we're deleted, the UI will continue to show this exception until we mark
// it canceled, so we'll do that here...
if (isDeleted && !isCanceled) {
long eventId = entityValues.getAsLong(Events._ID);
final long eventId = entityValues.getAsLong(Events._ID);
ContentValues cv = new ContentValues();
cv.put(Events.STATUS, Events.STATUS_CANCELED);
mService.mContentResolver.update(
@ -1468,7 +1462,10 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
// TODO Add reminders to exceptions (allow them to be specified!)
Long originalTime = entityValues.getAsLong(Events.ORIGINAL_INSTANCE_TIME);
if (originalTime != null) {
if (allDay) {
final boolean originalAllDay =
CalendarUtilities.getIntegerValueAsBoolean(entityValues,
Events.ORIGINAL_ALL_DAY);
if (originalAllDay) {
// For all day events, we need our local all-day time
originalTime =
CalendarUtilities.getLocalAllDayCalendarTime(originalTime, mLocalTimeZone);

View File

@ -1737,4 +1737,16 @@ public class CalendarUtilities {
}
return null;
}
/**
* Return a boolean value for an integer ContentValues column
* @param values a ContentValues object
* @param columnName the name of a column to be found in the ContentValues
* @return a boolean representation of the value of columnName in values; null and 0 = false,
* other integers = true
*/
static public boolean getIntegerValueAsBoolean(ContentValues values, String columnName) {
Integer intValue = values.getAsInteger(columnName);
return (intValue != null && intValue != 0);
}
}

View File

@ -927,6 +927,17 @@ public class CalendarUtilitiesTests extends SyncAdapterTestCase<CalendarSyncAdap
// Milliseconds aren't zeroed out and may not be the same
assertEquals(convertedLocalTime/1000, correctLocalTime/1000);
}
public void testGetIntegerValueAsBoolean() {
ContentValues cv = new ContentValues();
cv.put("A", 1);
cv.put("B", 69);
cv.put("C", 0);
assertTrue(CalendarUtilities.getIntegerValueAsBoolean(cv, "A"));
assertTrue(CalendarUtilities.getIntegerValueAsBoolean(cv, "B"));
assertFalse(CalendarUtilities.getIntegerValueAsBoolean(cv, "C"));
assertFalse(CalendarUtilities.getIntegerValueAsBoolean(cv, "D"));
}
}
// TODO Planned unit tests