Use original all-day flag when upsyncing exceptions
Bug: 3087410
Change-Id: I4bed0039758e98d4b85054876f192605eb00ee82
diff --git a/src/com/android/exchange/adapter/CalendarSyncAdapter.java b/src/com/android/exchange/adapter/CalendarSyncAdapter.java
index 9851231..503585a 100644
--- a/src/com/android/exchange/adapter/CalendarSyncAdapter.java
+++ b/src/com/android/exchange/adapter/CalendarSyncAdapter.java
@@ -1428,18 +1428,12 @@
// 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 @@
// 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 @@
// 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 3f7ce39..03a0a6d 100644
--- a/src/com/android/exchange/utility/CalendarUtilities.java
+++ b/src/com/android/exchange/utility/CalendarUtilities.java
@@ -1737,4 +1737,16 @@
}
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 0a217c5..9011a16 100644
--- a/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java
+++ b/tests/src/com/android/exchange/utility/CalendarUtilitiesTests.java
@@ -927,6 +927,17 @@
// 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