Update IEmailService
This is not yet finalized, but it's needed to fix push syncs
on exchange.
Change-Id: Iaff20aa0bdea9685ef6603de1f861d58fbab6ff1
(cherry picked from commit fb2a3a2f77
)
This commit is contained in:
parent
326566c9d9
commit
dfb7488d65
@ -298,14 +298,14 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
|
||||
if (mReturn == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return (Integer)mReturn;
|
||||
return (Integer) mReturn;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the service to send mail in the specified account's Outbox
|
||||
*
|
||||
* @param accountId the account whose outgoing mail should be sent
|
||||
* @param accountId the account whose outgoing mail should be sent.
|
||||
*/
|
||||
@Override
|
||||
public void sendMail(final long accountId) throws RemoteException {
|
||||
@ -329,16 +329,26 @@ public class EmailServiceProxy extends ServiceProxy implements IEmailService {
|
||||
public void run() throws RemoteException{
|
||||
mService.pushModify(accountId);
|
||||
}
|
||||
}, "sendMail");
|
||||
}, "pushModify");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFolders(final long accountId, final boolean updateFolderList,
|
||||
final long[] folders) {}
|
||||
|
||||
@Override
|
||||
public void syncMailboxType(final long accountId, final boolean updateFolderList,
|
||||
final int mailboxType) {}
|
||||
public int sync(final long accountId, final Bundle syncExtras) {
|
||||
setTask(new ProxyTask() {
|
||||
@Override
|
||||
public void run() throws RemoteException{
|
||||
mReturn = mService.sync(accountId, syncExtras);
|
||||
}
|
||||
}, "sync");
|
||||
waitForCompletion();
|
||||
if (mReturn == null) {
|
||||
// This occurs if sync times out.
|
||||
// TODO: Sync may take a long time, maybe we should extend the timeout here.
|
||||
return EmailServiceStatus.IO_ERROR;
|
||||
} else {
|
||||
return (Integer)mReturn;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder asBinder() {
|
||||
|
@ -51,6 +51,24 @@ public abstract class EmailServiceStatus {
|
||||
// Client certificates used to authenticate cannot be retrieved from the system.
|
||||
public static final int CLIENT_CERTIFICATE_ERROR = 0x21;
|
||||
|
||||
// Data is invalid on the client side, sync cannot proceed.
|
||||
public static final int HARD_DATA_ERROR = 0x22;
|
||||
|
||||
// Sync failed due to some type of IO error.
|
||||
public static final int IO_ERROR = 0x23;
|
||||
|
||||
// The sync call encountered a protocol error.
|
||||
public static final int PROTOCOL_ERROR = 0x24;
|
||||
|
||||
// The sync call encountered too many redirects.
|
||||
public static final int TOO_MANY_REDIRECTS = 0x25;
|
||||
|
||||
// The sync call encountered a provisioning error.
|
||||
public static final int PROVISIONING_ERROR = 0x26;
|
||||
|
||||
// We have encountered some sort of unexpected illegal state.
|
||||
public static final int INTERNAL_ERROR = 0x27;
|
||||
|
||||
// Keys for the sync extras Bundle that specify the callback.
|
||||
public static final String SYNC_EXTRAS_CALLBACK_URI = "callback_uri";
|
||||
public static final String SYNC_EXTRAS_CALLBACK_METHOD = "callback_method";
|
||||
@ -126,4 +144,5 @@ public abstract class EmailServiceStatus {
|
||||
syncResult, null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -26,15 +26,18 @@ import android.os.Bundle;
|
||||
|
||||
interface IEmailService {
|
||||
// Core email operations.
|
||||
// TODO: is sendMail really necessary, or should we standardize on sync(outbox)?
|
||||
void sendMail(long accountId);
|
||||
// Many of these functions return status codes. The valid status codes are defined in
|
||||
// EmailServiceStatus.java
|
||||
oneway void loadAttachment(IEmailServiceCallback cb, long accountId, long attachmentId,
|
||||
boolean background);
|
||||
oneway void updateFolderList(long accountId);
|
||||
|
||||
void syncFolders(long accountId, boolean updateFolderList, in long[] foldersToSync);
|
||||
void updateFolderList(long accountId);
|
||||
|
||||
void syncMailboxType(long accountId, boolean updateFolderList, int mailboxType);
|
||||
// TODO: For Eas, sync() will also sync the outbox. We should make IMAP and POP work the same
|
||||
// way and get rid of sendMail().
|
||||
void sendMail(long accountId);
|
||||
|
||||
int sync(long accountId, inout Bundle syncExtras);
|
||||
|
||||
// Push-related functionality.
|
||||
|
||||
@ -55,7 +58,9 @@ interface IEmailService {
|
||||
Bundle autoDiscover(String userName, String password);
|
||||
|
||||
// Service control operations (i.e. does not generate a client-server message).
|
||||
oneway void setLogging(int on);
|
||||
// TODO: We should store the logging flags in the contentProvider, and this call should just
|
||||
// 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);
|
||||
|
@ -281,9 +281,12 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFolderList(long accountId) throws RemoteException {
|
||||
public void updateFolderList(final long accountId) throws RemoteException {
|
||||
final Account account = Account.restoreAccountWithId(mContext, accountId);
|
||||
if (account == null) return;
|
||||
if (account == null) {
|
||||
LogUtils.e(LogUtils.TAG, "Account %d not found in updateFolderList", accountId);
|
||||
return;
|
||||
};
|
||||
long inboxId = -1;
|
||||
TrafficStats.setThreadStatsTag(TrafficFlags.getSyncFlags(mContext, account));
|
||||
Cursor localFolderCursor = null;
|
||||
@ -350,6 +353,9 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
|
||||
} catch (MessagingException me) {
|
||||
LogUtils.i(Logging.LOG_TAG, me, "Error in updateFolderList");
|
||||
// We'll hope this is temporary
|
||||
// TODO: Figure out what type of messaging exception it was and return an appropriate
|
||||
// result. If we start doing this from sync, it's important to let the sync manager
|
||||
// know if the failure was due to IO error or authentication errors.
|
||||
} finally {
|
||||
if (localFolderCursor != null) {
|
||||
localFolderCursor.close();
|
||||
@ -365,18 +371,20 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogging(int on) throws RemoteException {
|
||||
public void setLogging(final int flags) throws RemoteException {
|
||||
// Not required
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle autoDiscover(String userName, String password) throws RemoteException {
|
||||
public Bundle autoDiscover(final String userName, final String password)
|
||||
throws RemoteException {
|
||||
// Not required
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMeetingResponse(long messageId, int response) throws RemoteException {
|
||||
public void sendMeetingResponse(final long messageId, final int response)
|
||||
throws RemoteException {
|
||||
// Not required
|
||||
}
|
||||
|
||||
@ -386,32 +394,35 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
|
||||
}
|
||||
|
||||
@Override
|
||||
public int searchMessages(long accountId, SearchParams params, long destMailboxId)
|
||||
public int searchMessages(final long accountId, final SearchParams params,
|
||||
final long destMailboxId)
|
||||
throws RemoteException {
|
||||
// Not required
|
||||
return 0;
|
||||
return EmailServiceStatus.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushModify(long accountId) throws RemoteException {
|
||||
public void pushModify(final long accountId) throws RemoteException {
|
||||
LogUtils.e(Logging.LOG_TAG, "pushModify invalid for account type for %d", accountId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFolders(final long accountId, final boolean updateFolderList,
|
||||
final long[] folders) {}
|
||||
public int sync(final long accountId, final Bundle syncExtras) {
|
||||
return EmailServiceStatus.SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncMailboxType(final long accountId, final boolean updateFolderList,
|
||||
final int mailboxType) {}
|
||||
|
||||
@Override
|
||||
public void sendMail(long accountId) throws RemoteException {
|
||||
public void sendMail(final long accountId) throws RemoteException {
|
||||
sendMailImpl(mContext, accountId);
|
||||
}
|
||||
|
||||
public static void sendMailImpl(Context context, long accountId) {
|
||||
public static void sendMailImpl(final Context context, final long accountId) {
|
||||
final Account account = Account.restoreAccountWithId(context, accountId);
|
||||
if (account == null) {
|
||||
LogUtils.e(LogUtils.TAG, "account %d not found in sendMailImpl", accountId);
|
||||
return;
|
||||
}
|
||||
TrafficStats.setThreadStatsTag(TrafficFlags.getSmtpFlags(context, account));
|
||||
final NotificationController nc = NotificationController.getInstance(context);
|
||||
// 1. Loop through all messages in the account's outbox
|
||||
@ -503,6 +514,5 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
|
||||
} finally {
|
||||
c.close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ import com.android.emailcommon.provider.EmailContent.AccountColumns;
|
||||
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.IEmailService;
|
||||
import com.android.emailcommon.service.IEmailServiceCallback;
|
||||
import com.android.emailcommon.service.SearchParams;
|
||||
@ -663,11 +664,10 @@ public class EmailServiceUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFolderList(long accountId) throws RemoteException {
|
||||
}
|
||||
public void updateFolderList(long accountId) throws RemoteException {}
|
||||
|
||||
@Override
|
||||
public void setLogging(int on) throws RemoteException {
|
||||
public void setLogging(int flags) throws RemoteException {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -698,13 +698,8 @@ public class EmailServiceUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncFolders(final long accountId, final boolean updateFolderList,
|
||||
final long[] folders) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncMailboxType(final long accountId, final boolean updateFolderList,
|
||||
final int mailboxType) {
|
||||
public int sync(final long accountId, final Bundle syncExtras) {
|
||||
return EmailServiceStatus.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user