Update IEmailService

Add support for a version number
Correctly implement deleteAccountPIMData.

Change-Id: I4753db97a63eb63fc63519bc9be97f7fa878a737
diff --git a/src/com/android/exchange/eas/EasFullSyncOperation.java b/src/com/android/exchange/eas/EasFullSyncOperation.java
index 79b07a8..8714834 100644
--- a/src/com/android/exchange/eas/EasFullSyncOperation.java
+++ b/src/com/android/exchange/eas/EasFullSyncOperation.java
@@ -111,6 +111,7 @@
         final int mailboxType = mSyncExtras.getInt(Mailbox.SYNC_EXTRA_MAILBOX_TYPE,
                 Mailbox.TYPE_NONE);
 
+        final boolean isManual = mSyncExtras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false);
         // Push only means this sync request should only refresh the ping (either because
         // settings changed, or we need to restart it for some reason).
         final boolean pushOnly = Mailbox.isPushOnlyExtras(mSyncExtras);
@@ -171,13 +172,7 @@
         if (mailboxIds != null) {
             // Sync the mailbox that was explicitly requested.
             for (final long mailboxId : mailboxIds) {
-                // TODO: how to tell if a sync was user requested or not.
-                // We should be able to check the MANUAL flag in the sync extras, but right now
-                // all of our syncs are manual. This is because Calender and Contacts sync adapters
-                // actually just forward the request through the EmailSyncAdapterService.
-                // When this changes we can determine for certain whether or not this is a manual
-                // sync.
-                result = syncMailbox(mailboxId, hasCallbackMethod, true);
+                result = syncMailbox(mailboxId, hasCallbackMethod, isManual);
                 if (isFatal(result)) {
                     // This is a failure, abort the sync.
                     LogUtils.i(TAG, "Fatal result %d on syncMailbox", result);
diff --git a/src/com/android/exchange/eas/EasOperation.java b/src/com/android/exchange/eas/EasOperation.java
index 364115a..19dc149 100644
--- a/src/com/android/exchange/eas/EasOperation.java
+++ b/src/com/android/exchange/eas/EasOperation.java
@@ -750,14 +750,9 @@
             final String authority, final ArrayList<Long> mailboxIds) {
         final Bundle extras = Mailbox.createSyncBundle(mailboxIds);
         /**
-         * Please note that it is very possible that we are trying to send a request to the
-         * email sync adapter even though email push is turned off (i.e. this account might only
-         * be syncing calendar or contacts). In this situation we need to make sure that
-         * this request is marked as manual as to ensure that the sync manager does not drop it
-         * on the floor. Right now, this function is only called by EasPing, if it is every called
-         * by another caller, then we should reconsider if manual=true is the right thing to do.
+         * TODO: Right now, this function is only called by EasPing, should this function be
+         * moved there?
          */
-        extras.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
         ContentResolver.requestSync(amAccount, authority, extras);
         LogUtils.i(LOG_TAG, "EasOperation requestSyncForMailboxes  %s, %s",
                 amAccount.toString(), extras.toString());
diff --git a/src/com/android/exchange/service/EasService.java b/src/com/android/exchange/service/EasService.java
index b47fb3c..db6c05e 100644
--- a/src/com/android/exchange/service/EasService.java
+++ b/src/com/android/exchange/service/EasService.java
@@ -35,6 +35,7 @@
 import com.android.emailcommon.provider.Mailbox;
 import com.android.emailcommon.service.EmailServiceProxy;
 import com.android.emailcommon.service.EmailServiceStatus;
+import com.android.emailcommon.service.EmailServiceVersion;
 import com.android.emailcommon.service.HostAuthCompat;
 import com.android.emailcommon.service.IEmailService;
 import com.android.emailcommon.service.IEmailServiceCallback;
@@ -49,6 +50,8 @@
 import com.android.exchange.eas.EasSearch;
 import com.android.exchange.eas.EasSearchGal;
 import com.android.exchange.eas.EasSendMeetingResponse;
+import com.android.exchange.eas.EasSyncCalendar;
+import com.android.exchange.eas.EasSyncContacts;
 import com.android.exchange.provider.GalResult;
 import com.android.mail.utils.LogUtils;
 
@@ -203,9 +206,18 @@
         }
 
         @Override
-        public void deleteAccountPIMData(final String emailAddress) {
+        public void deleteExternalAccountPIMData(final String emailAddress) {
             LogUtils.d(TAG, "IEmailService.deleteAccountPIMData");
-            // TODO: remove this, move it completely to Email code.
+            if (emailAddress != null) {
+                // TODO: stop pings
+                final Context context = EasService.this;
+                EasSyncContacts.wipeAccountFromContentProvider(context, emailAddress);
+                EasSyncCalendar.wipeAccountFromContentProvider(context, emailAddress);
+            }
+        }
+
+        public int getApiVersion() {
+            return EmailServiceVersion.CURRENT;
         }
     };