Merge "Update IEmailService" into ub-mail-master

This commit is contained in:
Martin Hibdon 2014-07-14 18:06:20 +00:00 committed by Android (Google) Code Review
commit bb391e8018
6 changed files with 49 additions and 13 deletions

View File

@ -33,7 +33,7 @@ import java.io.IOException;
/** /**
* The EmailServiceProxy class provides a simple interface for the UI to call into the various * 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. * process so that the caller need not be concerned with it.
* *
* Use the class like this: * 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 * @param emailAddress the email address for the account whose data should be deleted
*/ */
@Override @Override
public void deleteAccountPIMData(final String emailAddress) throws RemoteException { public void deleteExternalAccountPIMData(final String emailAddress) throws RemoteException {
setTask(new ProxyTask() { setTask(new ProxyTask() {
@Override @Override
public void run() throws RemoteException { public void run() throws RemoteException {
mService.deleteAccountPIMData(emailAddress); mService.deleteExternalAccountPIMData(emailAddress);
} }
}, "deleteAccountPIMData"); }, "deleteAccountPIMData");
// This can be called when deleting accounts. After making this call, the caller will // 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() { public IBinder asBinder() {
return null; 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;
}
}
} }

View File

@ -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.
}

View File

@ -60,6 +60,7 @@ interface IEmailService {
// trigger the service to reload the flags. // trigger the service to reload the flags.
oneway void setLogging(int flags); oneway void setLogging(int flags);
// Needs to get moved into Email since this is NOT a client-server command. void deleteExternalAccountPIMData(String emailAddress);
void deleteAccountPIMData(String emailAddress);
int getApiVersion();
} }

View File

@ -5620,8 +5620,8 @@ public class EmailProvider extends ContentProvider
return; return;
} }
LogUtils.d(TAG, "Setting sync interval for account " + accountId + " to " + syncInterval + LogUtils.d(TAG, "Setting sync interval for account %s to %d minutes",
" minutes"); accountId, syncInterval);
// First remove all existing periodic syncs. // First remove all existing periodic syncs.
final List<PeriodicSync> syncs = final List<PeriodicSync> syncs =
@ -5963,7 +5963,7 @@ public class EmailProvider extends ContentProvider
EmailServiceUtils.getServiceForAccount(context, accountId); EmailServiceUtils.getServiceForAccount(context, accountId);
if (service != null) { if (service != null) {
try { try {
service.deleteAccountPIMData(emailAddress); service.deleteExternalAccountPIMData(emailAddress);
} catch (final RemoteException e) { } catch (final RemoteException e) {
// Can't do anything about this // Can't do anything about this
} }

View File

@ -28,7 +28,6 @@ import android.os.RemoteException;
import com.android.email.NotificationController; import com.android.email.NotificationController;
import com.android.email.mail.Sender; import com.android.email.mail.Sender;
import com.android.email.mail.Store; import com.android.email.mail.Store;
import com.android.email.provider.AccountReconciler;
import com.android.email.service.EmailServiceUtils.EmailServiceInfo; import com.android.email.service.EmailServiceUtils.EmailServiceInfo;
import com.android.email2.ui.MailActivityEmail; import com.android.email2.ui.MailActivityEmail;
import com.android.emailcommon.Logging; 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.EmailContent.MessageColumns;
import com.android.emailcommon.provider.Mailbox; import com.android.emailcommon.provider.Mailbox;
import com.android.emailcommon.service.EmailServiceStatus; import com.android.emailcommon.service.EmailServiceStatus;
import com.android.emailcommon.service.EmailServiceVersion;
import com.android.emailcommon.service.HostAuthCompat; import com.android.emailcommon.service.HostAuthCompat;
import com.android.emailcommon.service.IEmailService; import com.android.emailcommon.service.IEmailService;
import com.android.emailcommon.service.IEmailServiceCallback; import com.android.emailcommon.service.IEmailServiceCallback;
@ -389,8 +389,8 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
} }
@Override @Override
public void deleteAccountPIMData(final String emailAddress) throws RemoteException { public void deleteExternalAccountPIMData(final String emailAddress) throws RemoteException {
AccountReconciler.reconcileAccounts(mContext); // No need to do anything here, for IMAP and POP accounts none of our data is external.
} }
@Override @Override
@ -433,7 +433,7 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
final ContentResolver resolver = context.getContentResolver(); final ContentResolver resolver = context.getContentResolver();
final Cursor c = resolver.query(EmailContent.Message.CONTENT_URI, final Cursor c = resolver.query(EmailContent.Message.CONTENT_URI,
EmailContent.Message.ID_COLUMN_PROJECTION, EmailContent.Message.ID_COLUMN_PROJECTION,
MessageColumns.MAILBOX_KEY + "=?", new String[] { Long.toString(outboxId) }, MessageColumns.MAILBOX_KEY + "=?", new String[] { Long.toString(outboxId)},
null); null);
try { try {
// 2. exit early // 2. exit early
@ -516,4 +516,8 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
c.close(); c.close();
} }
} }
public int getApiVersion() {
return EmailServiceVersion.CURRENT;
}
} }

View File

@ -54,6 +54,7 @@ import com.android.emailcommon.provider.EmailContent.HostAuthColumns;
import com.android.emailcommon.provider.HostAuth; import com.android.emailcommon.provider.HostAuth;
import com.android.emailcommon.service.EmailServiceProxy; import com.android.emailcommon.service.EmailServiceProxy;
import com.android.emailcommon.service.EmailServiceStatus; import com.android.emailcommon.service.EmailServiceStatus;
import com.android.emailcommon.service.EmailServiceVersion;
import com.android.emailcommon.service.HostAuthCompat; import com.android.emailcommon.service.HostAuthCompat;
import com.android.emailcommon.service.IEmailService; import com.android.emailcommon.service.IEmailService;
import com.android.emailcommon.service.IEmailServiceCallback; import com.android.emailcommon.service.IEmailServiceCallback;
@ -681,7 +682,7 @@ public class EmailServiceUtils {
} }
@Override @Override
public void deleteAccountPIMData(final String emailAddress) throws RemoteException { public void deleteExternalAccountPIMData(final String emailAddress) throws RemoteException {
} }
@Override @Override
@ -703,5 +704,8 @@ public class EmailServiceUtils {
return EmailServiceStatus.SUCCESS; return EmailServiceStatus.SUCCESS;
} }
public int getApiVersion() {
return EmailServiceVersion.CURRENT;
}
} }
} }