diff --git a/src/com/android/exchange/adapter/CalendarSyncAdapter.java b/src/com/android/exchange/adapter/CalendarSyncAdapter.java index 9851231d5..503585a37 100644 --- a/src/com/android/exchange/adapter/CalendarSyncAdapter.java +++ b/src/com/android/exchange/adapter/CalendarSyncAdapter.java @@ -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); diff --git a/src/com/android/exchange/utility/CalendarUtilities.java b/src/com/android/exchange/utility/CalendarUtilities.java index 3f7ce39b0..03a0a6d99 100644 --- a/src/com/android/exchange/utility/CalendarUtilities.java +++ b/src/com/android/exchange/utility/CalendarUtilities.java @@ -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); + } } diff --git a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java index 0a217c5ff..9011a16bc 100644 --- a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java +++ b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java @@ -927,6 +927,17 @@ public class CalendarUtilitiesTests extends SyncAdapterTestCase