Use original all-day flag when upsyncing exceptions DO NOT MERGE

Bug: 3087410
Backport of: I4bed0039758e98d4b85054876f192605eb00ee82

Change-Id: Ibc875d58c2f6c5317ce8e4fee97b96c2fd6b2ecf
This commit is contained in:
Andy Stadler 2010-10-13 15:05:38 -07:00
parent 9c2baaabd2
commit efcde27bf7
3 changed files with 33 additions and 13 deletions

View File

@ -1423,18 +1423,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
@ -1450,7 +1444,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(
@ -1463,7 +1457,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

@ -1716,4 +1716,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

@ -882,6 +882,17 @@ public class CalendarUtilitiesTests extends AndroidTestCase {
// 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