From caf56443607856b996d151a0f0364c7acba8f8c7 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Wed, 9 Dec 2009 17:11:48 -0800 Subject: [PATCH] Fix delay sending stuck mail after tapping "Send outgoing mail" * Fixes #2317429 * When "Send outgoing messages" is tapped in Outbox MessageList view, we clear the error state for all "stuck" messages * We didn't, however, clear the error state of the Mailbox, which doesn't clear itself until the end of a pingLoop, which can be up to 30 minutes * The fix is in two parts: * We clear the error state of the Outbox when a sync is requested by the UI * We don't set the error state of the mailbox for non-auth errors when sending, because we don't want to block OTHER messages from getting sent. Change-Id: I768138b6f31eb696811aa94f621b6fa758ec1a5e --- src/com/android/exchange/EasOutboxService.java | 8 ++++++-- src/com/android/exchange/SyncManager.java | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/com/android/exchange/EasOutboxService.java b/src/com/android/exchange/EasOutboxService.java index 4e1e61cfb..38c96030e 100644 --- a/src/com/android/exchange/EasOutboxService.java +++ b/src/com/android/exchange/EasOutboxService.java @@ -46,7 +46,7 @@ public class EasOutboxService extends EasSyncService { public static final int SEND_FAILED = 1; public static final String MAILBOX_KEY_AND_NOT_SEND_FAILED = - MessageColumns.MAILBOX_KEY + "=? and (" + SyncColumns.SERVER_ID + " is null or " + + MessageColumns.MAILBOX_KEY + "=? and (" + SyncColumns.SERVER_ID + " is null or " + SyncColumns.SERVER_ID + "!=" + SEND_FAILED + ')'; public static final String[] BODY_SOURCE_PROJECTION = new String[] {BodyColumns.SOURCE_MESSAGE_KEY}; @@ -150,9 +150,13 @@ public class EasOutboxService extends EasSyncService { ContentValues cv = new ContentValues(); cv.put(SyncColumns.SERVER_ID, SEND_FAILED); Message.update(mContext, Message.CONTENT_URI, msgId, cv); - result = EmailServiceStatus.REMOTE_EXCEPTION; + // We mark the result as SUCCESS on a non-auth failure since the message itself is + // already marked failed and we don't want to stop other messages from trying to + // send. if (isAuthError(code)) { result = EmailServiceStatus.LOGIN_FAILED; + } else { + result = EmailServiceStatus.SUCCESS; } sendCallback(msgId, null, result); diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java index 015e72c58..42dcc9a7a 100644 --- a/src/com/android/exchange/SyncManager.java +++ b/src/com/android/exchange/SyncManager.java @@ -290,7 +290,8 @@ public class SyncManager extends Service implements Runnable { cv.put(SyncColumns.SERVER_ID, 0); INSTANCE.getContentResolver().update(Message.CONTENT_URI, cv, WHERE_MAILBOX_KEY, new String[] {Long.toString(mailboxId)}); - + // Clear the error state; the Outbox sync will be started from checkMailboxes + INSTANCE.mSyncErrorMap.remove(mailboxId); kick("start outbox"); // Outbox can't be synced in EAS return;