From 7afbeee47e1a82680c815f2fb8cfdba32d6b0b84 Mon Sep 17 00:00:00 2001 From: Martin Hibdon Date: Thu, 10 Jul 2014 15:08:29 -0700 Subject: [PATCH] Update IEmailService Add version support Change deleteAccountPIMData to deleteExternalAccountPIMData. Data kept inside the EmailProvider can be deleted from within the Email app. Only external data (e.g. contacts and calendar) need to be deleted by the service which has protocol specific knowlege. Change-Id: I875d3051d0cfdbaf52775ec20eb114a345894a93 --- .../service/EmailServiceProxy.java | 23 ++++++++++++++++--- .../service/EmailServiceVersion.java | 10 ++++++++ .../emailcommon/service/IEmailService.aidl | 5 ++-- .../android/email/provider/EmailProvider.java | 6 ++--- .../email/service/EmailServiceStub.java | 12 ++++++---- .../email/service/EmailServiceUtils.java | 6 ++++- 6 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 emailcommon/src/com/android/emailcommon/service/EmailServiceVersion.java diff --git a/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java b/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java index eefa5743d..1c1f0ebc9 100644 --- a/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java +++ b/emailcommon/src/com/android/emailcommon/service/EmailServiceProxy.java @@ -33,7 +33,7 @@ import java.io.IOException; /** * The EmailServiceProxy class provides a simple interface for the UI to call into the various - * EmailService classes (e.g. ExchangeService for EAS). It wraps the service connect/disconnect + * EmailService classes (e.g. EasService for EAS). It wraps the service connect/disconnect * process so that the caller need not be concerned with it. * * Use the class like this: @@ -256,11 +256,11 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { * @param emailAddress the email address for the account whose data should be deleted */ @Override - public void deleteAccountPIMData(final String emailAddress) throws RemoteException { + public void deleteExternalAccountPIMData(final String emailAddress) throws RemoteException { setTask(new ProxyTask() { @Override public void run() throws RemoteException { - mService.deleteAccountPIMData(emailAddress); + mService.deleteExternalAccountPIMData(emailAddress); } }, "deleteAccountPIMData"); // This can be called when deleting accounts. After making this call, the caller will @@ -352,4 +352,21 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService { public IBinder asBinder() { return null; } + + public int getApiVersion() { + setTask(new ProxyTask() { + @Override + public void run() throws RemoteException{ + mReturn = mService.getApiVersion(); + } + }, "getApiVersion"); + waitForCompletion(); + if (mReturn == null) { + // This occurs if there is a timeout or remote exception. Is not expected to happen. + LogUtils.wtf(TAG, "failed to get api version"); + return -1; + } else { + return (Integer) mReturn; + } + } } diff --git a/emailcommon/src/com/android/emailcommon/service/EmailServiceVersion.java b/emailcommon/src/com/android/emailcommon/service/EmailServiceVersion.java new file mode 100644 index 000000000..8a959a1ce --- /dev/null +++ b/emailcommon/src/com/android/emailcommon/service/EmailServiceVersion.java @@ -0,0 +1,10 @@ +package com.android.emailcommon.service; + +public class EmailServiceVersion { + // Initial version + public static final int L_PLATFORM = 1; + + public static final int CURRENT = L_PLATFORM; + + // For each following version, add a comment explaining what apis where added or removed. +} diff --git a/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl b/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl index f2212bbde..a6f49dc6c 100644 --- a/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl +++ b/emailcommon/src/com/android/emailcommon/service/IEmailService.aidl @@ -60,6 +60,7 @@ interface IEmailService { // trigger the service to reload the flags. oneway void setLogging(int flags); - // Needs to get moved into Email since this is NOT a client-server command. - void deleteAccountPIMData(String emailAddress); + void deleteExternalAccountPIMData(String emailAddress); + + int getApiVersion(); } diff --git a/src/com/android/email/provider/EmailProvider.java b/src/com/android/email/provider/EmailProvider.java index 961195ddc..360b30185 100644 --- a/src/com/android/email/provider/EmailProvider.java +++ b/src/com/android/email/provider/EmailProvider.java @@ -5630,8 +5630,8 @@ public class EmailProvider extends ContentProvider return; } - LogUtils.d(TAG, "Setting sync interval for account " + accountId + " to " + syncInterval + - " minutes"); + LogUtils.d(TAG, "Setting sync interval for account %s to %d minutes", + accountId, syncInterval); // First remove all existing periodic syncs. final List syncs = @@ -5973,7 +5973,7 @@ public class EmailProvider extends ContentProvider EmailServiceUtils.getServiceForAccount(context, accountId); if (service != null) { try { - service.deleteAccountPIMData(emailAddress); + service.deleteExternalAccountPIMData(emailAddress); } catch (final RemoteException e) { // Can't do anything about this } diff --git a/src/com/android/email/service/EmailServiceStub.java b/src/com/android/email/service/EmailServiceStub.java index b64abdcd5..85f1716f7 100644 --- a/src/com/android/email/service/EmailServiceStub.java +++ b/src/com/android/email/service/EmailServiceStub.java @@ -28,7 +28,6 @@ import android.os.RemoteException; 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.service.EmailServiceUtils.EmailServiceInfo; import com.android.email2.ui.MailActivityEmail; import com.android.emailcommon.Logging; @@ -53,6 +52,7 @@ import com.android.emailcommon.provider.EmailContent.MailboxColumns; import com.android.emailcommon.provider.EmailContent.MessageColumns; import com.android.emailcommon.provider.Mailbox; 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; @@ -389,8 +389,8 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm } @Override - public void deleteAccountPIMData(final String emailAddress) throws RemoteException { - AccountReconciler.reconcileAccounts(mContext); + public void deleteExternalAccountPIMData(final String emailAddress) throws RemoteException { + // No need to do anything here, for IMAP and POP accounts none of our data is external. } @Override @@ -433,7 +433,7 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm final ContentResolver resolver = context.getContentResolver(); final Cursor c = resolver.query(EmailContent.Message.CONTENT_URI, EmailContent.Message.ID_COLUMN_PROJECTION, - MessageColumns.MAILBOX_KEY + "=?", new String[] { Long.toString(outboxId) }, + MessageColumns.MAILBOX_KEY + "=?", new String[] { Long.toString(outboxId)}, null); try { // 2. exit early @@ -515,4 +515,8 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm c.close(); } } + + public int getApiVersion() { + return EmailServiceVersion.CURRENT; + } } diff --git a/src/com/android/email/service/EmailServiceUtils.java b/src/com/android/email/service/EmailServiceUtils.java index 518c3c443..54dcdd826 100644 --- a/src/com/android/email/service/EmailServiceUtils.java +++ b/src/com/android/email/service/EmailServiceUtils.java @@ -54,6 +54,7 @@ import com.android.emailcommon.provider.EmailContent.HostAuthColumns; import com.android.emailcommon.provider.HostAuth; 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; @@ -681,7 +682,7 @@ public class EmailServiceUtils { } @Override - public void deleteAccountPIMData(final String emailAddress) throws RemoteException { + public void deleteExternalAccountPIMData(final String emailAddress) throws RemoteException { } @Override @@ -703,5 +704,8 @@ public class EmailServiceUtils { return EmailServiceStatus.SUCCESS; } + public int getApiVersion() { + return EmailServiceVersion.CURRENT; + } } }