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
* 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;
}
}
}

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.
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();
}

View File

@ -5620,8 +5620,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<PeriodicSync> syncs =
@ -5963,7 +5963,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
}

View File

@ -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
@ -516,4 +516,8 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
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.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;
}
}
}