Make sure that Ping success removes mailbox from error list

* We keep track of sync errors and have an increasing backoff for
  failures.
* Make sure that a successful Ping (i.e. one that received a response
  at the specified timeout) clears the sync error state for the
  pinging mailbox

Change-Id: I35d188aa04618e7604bf6a7905e2ce6992ee3c54
diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java
index 6c1f039..d4c1bbb 100644
--- a/src/com/android/exchange/EasSyncService.java
+++ b/src/com/android/exchange/EasSyncService.java
@@ -1463,6 +1463,8 @@
                     }
 
                     if (code == HttpStatus.SC_OK) {
+                        // Make sure to clear out any pending sync errors
+                        SyncManager.removeFromSyncErrorMap(mMailboxId);
                         HttpEntity e = res.getEntity();
                         int len = (int)e.getContentLength();
                         InputStream is = res.getEntity().getContent();
diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java
index c2497ce..141ea17 100644
--- a/src/com/android/exchange/SyncManager.java
+++ b/src/com/android/exchange/SyncManager.java
@@ -2094,6 +2094,18 @@
     }
 
     /**
+     * Tell SyncManager to remove the mailbox from the map of mailboxes with sync errors
+     * @param mailboxId the id of the mailbox
+     */
+    static public void removeFromSyncErrorMap(long mailboxId) {
+        SyncManager syncManager = INSTANCE;
+        if (syncManager == null) return;
+        synchronized(sSyncToken) {
+            syncManager.mSyncErrorMap.remove(mailboxId);
+        }
+    }
+
+    /**
      * Sent by services indicating that their thread is finished; action depends on the exitStatus
      * of the service.
      *