Merge "Don't allow Exchange logger to recurse on failure" into froyo
diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java
index 4d8731a..1089d9b 100644
--- a/src/com/android/exchange/SyncManager.java
+++ b/src/com/android/exchange/SyncManager.java
@@ -1551,6 +1551,7 @@
         if (!blockExternalChanges && accountsDeleted) {
             AccountBackupRestore.backupAccounts(context);
             SecurityPolicy.getInstance(context).reducePolicies();
+            Email.setNotifyUiAccountsChanged(true);
         }
     }
 
diff --git a/src/com/android/exchange/adapter/CalendarSyncAdapter.java b/src/com/android/exchange/adapter/CalendarSyncAdapter.java
index f418309..3eab4fb 100644
--- a/src/com/android/exchange/adapter/CalendarSyncAdapter.java
+++ b/src/com/android/exchange/adapter/CalendarSyncAdapter.java
@@ -361,7 +361,6 @@
                     case Tags.CALENDAR_START_TIME:
                         startTime = Utility.parseDateTimeToMillis(getValue());
                         cv.put(Events.DTSTART, startTime);
-                        cv.put(Events.ORIGINAL_INSTANCE_TIME, startTime);
                         break;
                     case Tags.CALENDAR_END_TIME:
                         endTime = Utility.parseDateTimeToMillis(getValue());
@@ -455,7 +454,6 @@
                 cal.set(GregorianCalendar.MINUTE, 0);
                 cal.set(GregorianCalendar.SECOND, 0);
                 cv.put(Events.DTSTART, cal.getTimeInMillis());
-                cv.put(Events.ORIGINAL_INSTANCE_TIME, cal.getTimeInMillis());
             } else {
                 cv.put(Events.DURATION, "P" + ((endTime - startTime) / MINUTES) + "M");
             }
@@ -1552,6 +1550,15 @@
                                         (getInt(exValues, Events.STATUS) ==
                                             Events.STATUS_CANCELED)) {
                                     flag = Message.FLAG_OUTGOING_MEETING_CANCEL;
+                                    if (!selfOrganizer) {
+                                        // Send a cancellation notice to the organizer
+                                        // Since CalendarProvider2 sets the organizer of exceptions
+                                        // to the user, we have to reset it first to the original
+                                        // organizer
+                                        exValues.put(Events.ORGANIZER,
+                                                entityValues.getAsString(Events.ORGANIZER));
+                                        sendDeclinedEmail(exEntity, clientId);
+                                    }
                                 } else {
                                     flag = Message.FLAG_OUTGOING_MEETING_INVITE;
                                 }
@@ -1573,28 +1580,6 @@
                                             entityValues.getAsString(Events.EVENT_LOCATION));
                                 }
 
-                                if ((getInt(exValues, Events.DELETED) == 1) ||
-                                        (getInt(exValues, Events.STATUS) ==
-                                            Events.STATUS_CANCELED)) {
-                                    // Add the eventId of the exception to the proper list, so that
-                                    // the dirty bit is cleared or the event is deleted after the
-                                    // sync has completed
-                                    mDeletedIdList.add(exEventId);
-                                    flag = Message.FLAG_OUTGOING_MEETING_CANCEL;
-                                    if (!selfOrganizer) {
-                                        // Send a cancellation notice to the organizer
-                                        // Since CalendarProvider2 sets the organizer of exceptions
-                                        // to the user, we have to reset it first to the original
-                                        // organizer
-                                        exValues.put(Events.ORGANIZER,
-                                                entityValues.getAsString(Events.ORGANIZER));
-                                        sendDeclinedEmail(exEntity, clientId);
-                                    }
-                                } else {
-                                    mUploadedIdList.add(exEventId);
-                                    flag = Message.FLAG_OUTGOING_MEETING_INVITE;
-                                }
-
                                 if (selfOrganizer) {
                                     Message msg =
                                         CalendarUtilities.createMessageForEntity(mContext,