Delete unused functions from IEmailService.aidl.

Change-Id: I131d2d3436a50c94d664fc57c6514481d9afbc97

Conflicts:
	src/com/android/email/service/ImapService.java
diff --git a/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java b/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java
index f2173c3..706e459 100644
--- a/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java
+++ b/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java
@@ -22,11 +22,9 @@
 import android.os.IBinder;
 import android.os.RemoteException;
 
-import com.android.emailcommon.Api;
 import com.android.emailcommon.Device;
 import com.android.emailcommon.TempDirectory;
 import com.android.emailcommon.mail.MessagingException;
-import com.android.emailcommon.provider.Account;
 import com.android.emailcommon.provider.HostAuth;
 import com.android.emailcommon.provider.Policy;
 import com.android.mail.utils.LogUtils;
@@ -103,11 +101,6 @@
         return isRemote;
     }
 
-    @Override
-    public int getApiLevel() {
-        return Api.LEVEL;
-    }
-
     /**
      * Request an attachment to be loaded; the service MUST give higher priority to
      * non-background loading.  The service MUST use the loadAttachmentStatus callback when
@@ -143,45 +136,6 @@
     }
 
     /**
-     * Request the sync of a mailbox; the service MUST send the syncMailboxStatus callback
-     * indicating "starting" and "finished" (or error), regardless of whether the mailbox is
-     * actually syncable.
-     * TODO: Remove this from IEmailService in favor of ContentResolver.requestSync.
-     *
-     * @param mailboxId the id of the mailbox record
-     * @param userRequest whether or not the user specifically asked for the sync
-     * @param deltaMessageCount amount by which to change the number of messages synced.
-     */
-    @Deprecated
-    @Override
-    public void startSync(final long mailboxId, final boolean userRequest,
-            final int deltaMessageCount) throws RemoteException {
-        setTask(new ProxyTask() {
-            @Override
-            public void run() throws RemoteException {
-                mService.startSync(mailboxId, userRequest, deltaMessageCount);
-            }
-        }, "startSync");
-    }
-
-    /**
-     * Request the immediate termination of a mailbox sync. Although the service is not required to
-     * acknowledge this request, it MUST send a "finished" (or error) syncMailboxStatus callback if
-     * the sync was started via the startSync service call.
-     *
-     * @param mailboxId the id of the mailbox record
-     */
-    @Override
-    public void stopSync(final long mailboxId) throws RemoteException {
-        setTask(new ProxyTask() {
-            @Override
-            public void run() throws RemoteException {
-                mService.stopSync(mailboxId);
-            }
-        }, "stopSync");
-    }
-
-    /**
      * Validate a user account, given a protocol, host address, port, ssl status, and credentials.
      * The result of this call is returned in a Bundle which MUST include a result code and MAY
      * include a PolicySet that is required by the account. A successful validation implies a host
@@ -276,23 +230,6 @@
     }
 
     /**
-     * Alert the sync adapter that the account's host information has (or may have) changed; the
-     * service MUST stop all in-process or pending syncs, clear error states related to the
-     * account and its mailboxes, and restart necessary sync adapters (e.g. pushed mailboxes)
-     *
-     * @param accountId the id of the account whose host information has changed
-     */
-    @Override
-    public void hostChanged(final long accountId) throws RemoteException {
-        setTask(new ProxyTask() {
-            @Override
-            public void run() throws RemoteException {
-                mService.hostChanged(accountId);
-            }
-        }, "hostChanged");
-    }
-
-    /**
      * Send a meeting response for the specified message
      *
      * @param messageId the id of the message containing the meeting request
@@ -310,56 +247,6 @@
     }
 
     /**
-     * Request the sync adapter to load a complete message
-     *
-     * @param messageId the id of the message to be loaded
-     */
-    @Override
-    public void loadMore(final long messageId) throws RemoteException {
-        setTask(new ProxyTask() {
-            @Override
-            public void run() throws RemoteException {
-                mService.loadMore(messageId);
-            }
-        }, "startSync");
-    }
-
-    /**
-     * Not yet used
-     *
-     * @param accountId the account in which the folder is to be created
-     * @param name the name of the folder to be created
-    */
-    @Override
-    public boolean createFolder(long accountId, String name) throws RemoteException {
-        return false;
-    }
-
-    /**
-     * Not yet used
-     *
-     * @param accountId the account in which the folder resides
-     * @param name the name of the folder to be deleted
-     */
-    @Override
-    public boolean deleteFolder(long accountId, String name) throws RemoteException {
-        return false;
-    }
-
-    /**
-     * Not yet used
-     *
-     * @param accountId the account in which the folder resides
-     * @param oldName the name of the existing folder
-     * @param newName the new name for the folder
-     */
-    @Override
-    public boolean renameFolder(long accountId, String oldName, String newName)
-            throws RemoteException {
-        return false;
-    }
-
-    /**
      * Request the service to delete the account's PIM (personal information management) data. This
      * data includes any data that is 1) associated with the account and 2) created/stored by the
      * service or its sync adapters and 3) not stored in the EmailProvider database (e.g. contact
@@ -423,29 +310,6 @@
         }, "sendMail");
     }
 
-    @Deprecated
-    @Override
-    public int getCapabilities(final Account acct) throws RemoteException {
-        //This function should not be used; see {@link EmailProvider#getCapabilities} instead.
-        return 0;
-    }
-    /**
-     * Request that the account be updated for this service; this call is synchronous
-     *
-     * @param emailAddress the email address of the account to be updated
-     */
-    @Override
-    public void serviceUpdated(final String emailAddress) throws RemoteException {
-        setTask(new ProxyTask() {
-            @Override
-            public void run() throws RemoteException{
-                mService.serviceUpdated(emailAddress);
-            }
-        }, "settingsUpdate");
-        waitForCompletion();
-    }
-
-
     @Override
     public IBinder asBinder() {
         return null;
diff --git a/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl b/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl
index 74a55e5..d8f550b 100644
--- a/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl
+++ b/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl
@@ -24,42 +24,25 @@
 import android.os.Bundle;
 
 interface IEmailService {
-    Bundle validate(in HostAuth hostauth);
-
-    oneway void startSync(long mailboxId, boolean userRequest, int deltaMessageCount);
-    oneway void stopSync(long mailboxId);
-
-    // TODO: loadMore appears to be unused; if so, delete it.
-    oneway void loadMore(long messageId);
+    // Core email operations.
+    // TODO: is sendMail really necessary, or should we standardize on sync(outbox)?
+    void sendMail(long accountId);
     oneway void loadAttachment(IEmailServiceCallback cb, long attachmentId, boolean background);
-
     oneway void updateFolderList(long accountId);
 
-    boolean createFolder(long accountId, String name);
-    boolean deleteFolder(long accountId, String name);
-    boolean renameFolder(long accountId, String oldName, String newName);
-
-    oneway void setLogging(int on);
-
-    oneway void hostChanged(long accountId);
-
-    Bundle autoDiscover(String userName, String password);
-
-    oneway void sendMeetingResponse(long messageId, int response);
-
-    // Must not be oneway; unless an exception is thrown, the caller is guaranteed that the action
-    // has been completed
-    void deleteAccountPIMData(String emailAddress);
-
-    int getApiLevel();
-
-    // API level 2
+    // Other email operations.
+    Bundle validate(in HostAuth hostauth);
     int searchMessages(long accountId, in SearchParams params, long destMailboxId);
 
-    void sendMail(long accountId);
+    // PIM functionality (not strictly EAS specific).
+    oneway void sendMeetingResponse(long messageId, int response);
 
-    // API level 3
-    int getCapabilities(in Account acct);
+    // Specific to EAS protocol.
+    Bundle autoDiscover(String userName, String password);
 
-    void serviceUpdated(String emailAddress);
+    // Service control operations (i.e. does not generate a client-server message).
+    oneway void setLogging(int on);
+
+    // Needs to get moved into Email since this is NOT a client-server command.
+    void deleteAccountPIMData(String emailAddress);
 }
diff --git a/src/com/android/email/service/EmailServiceStub.java b/src/com/android/email/service/EmailServiceStub.java
index 3943cf9..215d553 100644
--- a/src/com/android/email/service/EmailServiceStub.java
+++ b/src/com/android/email/service/EmailServiceStub.java
@@ -24,16 +24,13 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.RemoteException;
-import android.text.TextUtils;
 
 import com.android.email.NotificationController;
 import com.android.email.mail.Sender;
 import com.android.email.mail.Store;
 import com.android.email.provider.AccountReconciler;
-import com.android.email.provider.Utilities;
 import com.android.email.service.EmailServiceUtils.EmailServiceInfo;
 import com.android.email2.ui.MailActivityEmail;
-import com.android.emailcommon.Api;
 import com.android.emailcommon.Logging;
 import com.android.emailcommon.TrafficFlags;
 import com.android.emailcommon.internet.MimeBodyPart;
@@ -63,7 +60,6 @@
 import com.android.emailcommon.utility.AttachmentUtilities;
 import com.android.emailcommon.utility.Utility;
 import com.android.mail.providers.UIProvider;
-import com.android.mail.providers.UIProvider.DraftType;
 import com.android.mail.utils.LogUtils;
 
 import java.util.HashSet;
@@ -99,10 +95,7 @@
         return null;
     }
 
-    @Deprecated
-    @Override
-    public void startSync(long mailboxId, boolean userRequest, int deltaMessageCount)
-            throws RemoteException {
+    protected void requestSync(long mailboxId, boolean userRequest, int deltaMessageCount) {
         final Mailbox mailbox = Mailbox.restoreMailboxWithId(mContext, mailboxId);
         if (mailbox == null) return;
         final Account account = Account.restoreAccountWithId(mContext, mailbox.mAccountKey);
@@ -126,66 +119,6 @@
     }
 
     @Override
-    public void stopSync(long mailboxId) throws RemoteException {
-        // Not required
-    }
-
-    @Override
-    public void loadMore(long messageId) throws RemoteException {
-        // Load a message for view...
-        try {
-            // 1. Resample the message, in case it disappeared or synced while
-            // this command was in queue
-            final EmailContent.Message message =
-                EmailContent.Message.restoreMessageWithId(mContext, messageId);
-            if (message == null) {
-                return;
-            }
-            if (message.mFlagLoaded == EmailContent.Message.FLAG_LOADED_COMPLETE) {
-                // We should NEVER get here
-                return;
-            }
-
-            // 2. Open the remote folder.
-            // TODO combine with common code in loadAttachment
-            final Account account = Account.restoreAccountWithId(mContext, message.mAccountKey);
-            final Mailbox mailbox = Mailbox.restoreMailboxWithId(mContext, message.mMailboxKey);
-            if (account == null || mailbox == null) {
-                //mListeners.loadMessageForViewFailed(messageId, "null account or mailbox");
-                return;
-            }
-            TrafficStats.setThreadStatsTag(TrafficFlags.getSyncFlags(mContext, account));
-
-            final Store remoteStore = Store.getInstance(account, mContext);
-            final String remoteServerId;
-            // If this is a search result, use the protocolSearchInfo field to get the
-            // correct remote location
-            if (!TextUtils.isEmpty(message.mProtocolSearchInfo)) {
-                remoteServerId = message.mProtocolSearchInfo;
-            } else {
-                remoteServerId = mailbox.mServerId;
-            }
-            final Folder remoteFolder = remoteStore.getFolder(remoteServerId);
-            remoteFolder.open(OpenMode.READ_WRITE);
-
-            // 3. Set up to download the entire message
-            final Message remoteMessage = remoteFolder.getMessage(message.mServerId);
-            final FetchProfile fp = new FetchProfile();
-            fp.add(FetchProfile.Item.BODY);
-            remoteFolder.fetch(new Message[] { remoteMessage }, fp, null);
-
-            // 4. Write to provider
-            Utilities.copyOneMessageToProvider(mContext, remoteMessage, account, mailbox,
-                    EmailContent.Message.FLAG_LOADED_COMPLETE);
-        } catch (MessagingException me) {
-            if (Logging.LOGD) LogUtils.v(Logging.LOG_TAG, "", me);
-
-        } catch (RuntimeException rte) {
-            LogUtils.d(Logging.LOG_TAG, "RTE During loadMore");
-        }
-    }
-
-    @Override
     public void loadAttachment(final IEmailServiceCallback cb, final long attachmentId,
             final boolean background) throws RemoteException {
         Folder remoteFolder = null;
@@ -419,41 +352,17 @@
             }
             // If we just created the inbox, sync it
             if (inboxId != -1) {
-                startSync(inboxId, true, 0);
+                requestSync(inboxId, true, 0);
             }
         }
     }
 
     @Override
-    public boolean createFolder(long accountId, String name) throws RemoteException {
-        // Not required
-        return false;
-    }
-
-    @Override
-    public boolean deleteFolder(long accountId, String name) throws RemoteException {
-        // Not required
-        return false;
-    }
-
-    @Override
-    public boolean renameFolder(long accountId, String oldName, String newName)
-            throws RemoteException {
-        // Not required
-        return false;
-    }
-
-    @Override
     public void setLogging(int on) throws RemoteException {
         // Not required
     }
 
     @Override
-    public void hostChanged(long accountId) throws RemoteException {
-        // Not required
-    }
-
-    @Override
     public Bundle autoDiscover(String userName, String password) throws RemoteException {
         // Not required
        return null;
@@ -470,11 +379,6 @@
     }
 
     @Override
-    public int getApiLevel() throws RemoteException {
-        return Api.LEVEL;
-    }
-
-    @Override
     public int searchMessages(long accountId, SearchParams params, long destMailboxId)
             throws RemoteException {
         // Not required
diff --git a/src/com/android/email/service/EmailServiceUtils.java b/src/com/android/email/service/EmailServiceUtils.java
index c9b083b..03c83e0 100644
--- a/src/com/android/email/service/EmailServiceUtils.java
+++ b/src/com/android/email/service/EmailServiceUtils.java
@@ -634,19 +634,6 @@
         }
 
         @Override
-        public void startSync(long mailboxId, boolean userRequest, int deltaMessageCount)
-                throws RemoteException {
-        }
-
-        @Override
-        public void stopSync(long mailboxId) throws RemoteException {
-        }
-
-        @Override
-        public void loadMore(long messageId) throws RemoteException {
-        }
-
-        @Override
         public void loadAttachment(final IEmailServiceCallback cb, final long attachmentId,
                 final boolean background) throws RemoteException {
         }
@@ -656,30 +643,10 @@
         }
 
         @Override
-        public boolean createFolder(long accountId, String name) throws RemoteException {
-            return false;
-        }
-
-        @Override
-        public boolean deleteFolder(long accountId, String name) throws RemoteException {
-            return false;
-        }
-
-        @Override
-        public boolean renameFolder(long accountId, String oldName, String newName)
-                throws RemoteException {
-            return false;
-        }
-
-        @Override
         public void setLogging(int on) throws RemoteException {
         }
 
         @Override
-        public void hostChanged(long accountId) throws RemoteException {
-        }
-
-        @Override
         public Bundle autoDiscover(String userName, String password) throws RemoteException {
             return null;
         }
@@ -693,11 +660,6 @@
         }
 
         @Override
-        public int getApiLevel() throws RemoteException {
-            return Api.LEVEL;
-        }
-
-        @Override
         public int searchMessages(long accountId, SearchParams params, long destMailboxId)
                 throws RemoteException {
             return 0;
@@ -706,14 +668,5 @@
         @Override
         public void sendMail(long accountId) throws RemoteException {
         }
-
-        @Override
-        public void serviceUpdated(String emailAddress) throws RemoteException {
-        }
-
-        @Override
-        public int getCapabilities(Account acct) throws RemoteException {
-            return 0;
-        }
     }
 }
diff --git a/src/com/android/email/service/ImapService.java b/src/com/android/email/service/ImapService.java
index 1cdd326..106a518 100644
--- a/src/com/android/email/service/ImapService.java
+++ b/src/com/android/email/service/ImapService.java
@@ -26,7 +26,6 @@
 import android.net.TrafficStats;
 import android.net.Uri;
 import android.os.IBinder;
-import android.os.RemoteException;
 import android.os.SystemClock;
 import android.text.TextUtils;
 import android.text.format.DateUtils;
@@ -60,7 +59,6 @@
 import com.android.emailcommon.service.SearchParams;
 import com.android.emailcommon.utility.AttachmentUtilities;
 import com.android.mail.providers.UIProvider;
-import com.android.mail.providers.UIProvider.AccountCapabilities;
 import com.android.mail.utils.LogUtils;
 
 import java.util.ArrayList;
@@ -115,11 +113,6 @@
      */
     private final EmailServiceStub mBinder = new EmailServiceStub() {
         @Override
-        public void loadMore(long messageId) throws RemoteException {
-            // We don't do "loadMore" for IMAP messages; the sync should handle this
-        }
-
-        @Override
         public int searchMessages(long accountId, SearchParams searchParams, long destMailboxId) {
             try {
                 return searchMailboxImpl(getApplicationContext(), accountId, searchParams,
@@ -129,19 +122,6 @@
             }
             return 0;
         }
-
-        @Override
-        public int getCapabilities(Account acct) throws RemoteException {
-            return AccountCapabilities.SYNCABLE_FOLDERS |
-                    AccountCapabilities.FOLDER_SERVER_SEARCH |
-                    AccountCapabilities.UNDO |
-                    AccountCapabilities.DISCARD_CONVERSATION_DRAFTS;
-        }
-
-        @Override
-        public void serviceUpdated(String emailAddress) throws RemoteException {
-            // Not needed
-        }
     };
 
     @Override
diff --git a/src/com/android/email/service/Pop3Service.java b/src/com/android/email/service/Pop3Service.java
index 07f4a24..7bff800 100644
--- a/src/com/android/email/service/Pop3Service.java
+++ b/src/com/android/email/service/Pop3Service.java
@@ -52,7 +52,6 @@
 import com.android.emailcommon.service.IEmailServiceCallback;
 import com.android.emailcommon.utility.AttachmentUtilities;
 import com.android.mail.providers.UIProvider;
-import com.android.mail.providers.UIProvider.AccountCapabilities;
 import com.android.mail.providers.UIProvider.AttachmentState;
 import com.android.mail.utils.LogUtils;
 
@@ -77,12 +76,6 @@
      */
     private final EmailServiceStub mBinder = new EmailServiceStub() {
         @Override
-        public int getCapabilities(Account acct) throws RemoteException {
-            return AccountCapabilities.UNDO |
-                    AccountCapabilities.DISCARD_CONVERSATION_DRAFTS;
-        }
-
-        @Override
         public void loadAttachment(final IEmailServiceCallback callback, final long attachmentId,
                 final boolean background) throws RemoteException {
             Attachment att = Attachment.restoreAttachmentWithId(mContext, attachmentId);
@@ -90,12 +83,7 @@
             long inboxId = Mailbox.findMailboxOfType(mContext, att.mAccountKey, Mailbox.TYPE_INBOX);
             if (inboxId == Mailbox.NO_MAILBOX) return;
             // We load attachments during a sync
-            startSync(inboxId, true, 0);
-        }
-
-        @Override
-        public void serviceUpdated(String emailAddress) throws RemoteException {
-            // Not required for POP3
+            requestSync(inboxId, true, 0);
         }
     };