Fix #2300147 (mistakenly reporting connection error)

* When a mailbox sync is stopped intentionally (for example, if account
  settings change), we report a connection error by mistake
* Handle this case properly, reporting "success" (i.e. no error state)
* Remove obsolete comment

Change-Id: I9bec1244267cd2240c369b9b7f905948381a0f91
diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java
index ee52bf6..f26a21f 100644
--- a/src/com/android/exchange/EasSyncService.java
+++ b/src/com/android/exchange/EasSyncService.java
@@ -1138,19 +1138,23 @@
         } catch (Exception e) {
             userLog("Uncaught exception in EasSyncService", e);
         } finally {
+            int status;
+
             if (!mStop) {
                 userLog("Sync finished");
                 SyncManager.done(this);
-                // If this is the account mailbox, wake up SyncManager
-                // Because this box has a "push" interval, it will be restarted immediately
-                // which will cause the folder list to be reloaded...
-                int status;
                 switch (mExitStatus) {
                     case EXIT_IO_ERROR:
                         status = EmailServiceStatus.CONNECTION_ERROR;
                         break;
                     case EXIT_DONE:
                         status = EmailServiceStatus.SUCCESS;
+                        ContentValues cv = new ContentValues();
+                        cv.put(Mailbox.SYNC_TIME, System.currentTimeMillis());
+                        String s = "S" + mSyncReason + ':' + status + ':' + mChangeCount;
+                        cv.put(Mailbox.SYNC_STATUS, s);
+                        mContentResolver.update(ContentUris.withAppendedId(Mailbox.CONTENT_URI,
+                                mMailboxId), cv, null, null);
                         break;
                     case EXIT_LOGIN_FAILURE:
                         status = EmailServiceStatus.LOGIN_FAILED;
@@ -1160,24 +1164,15 @@
                         errorLog("Sync ended due to an exception.");
                         break;
                 }
-
-                try {
-                    SyncManager.callback().syncMailboxStatus(mMailboxId, status, 0);
-                } catch (RemoteException e1) {
-                    // Don't care if this fails
-                }
-
-                if (mExitStatus == EXIT_DONE) {
-                    // Save the sync time and status
-                    ContentValues cv = new ContentValues();
-                    cv.put(Mailbox.SYNC_TIME, System.currentTimeMillis());
-                    String s = "S" + mSyncReason + ':' + status + ':' + mChangeCount;
-                    cv.put(Mailbox.SYNC_STATUS, s);
-                    mContentResolver.update(ContentUris.withAppendedId(Mailbox.CONTENT_URI,
-                            mMailboxId), cv, null, null);
-                }
             } else {
                 userLog("Stopped sync finished.");
+                status = EmailServiceStatus.SUCCESS;
+            }
+
+            try {
+                SyncManager.callback().syncMailboxStatus(mMailboxId, status, 0);
+            } catch (RemoteException e1) {
+                // Don't care if this fails
             }
 
             // Make sure SyncManager knows about this