diff options
author | Brandon Knitter <knitterb@gmail.com> | 2011-05-20 09:32:46 -0700 |
---|---|---|
committer | Brandon Knitter <knitterb@gmail.com> | 2011-05-20 09:32:46 -0700 |
commit | 42e4152c4ea9c406724befd2cffcf7820ee6251d (patch) | |
tree | e32b094fe3c68141fa5471dece7a407189a00a30 | |
parent | 400a1ffca7a5f9ecb90523f384785e44b66149de (diff) | |
download | android_packages_apps_Email-42e4152c4ea9c406724befd2cffcf7820ee6251d.tar.gz android_packages_apps_Email-42e4152c4ea9c406724befd2cffcf7820ee6251d.tar.bz2 android_packages_apps_Email-42e4152c4ea9c406724befd2cffcf7820ee6251d.zip |
Fix for emails stuck in the outbox (Upstream Issue 11669)
Change-Id: I02361b899e3eec1f16493919c740bddc319fa68f
-rw-r--r-- | src/com/android/exchange/EasOutboxService.java | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/src/com/android/exchange/EasOutboxService.java b/src/com/android/exchange/EasOutboxService.java index 34b6d7f4e..88a2dc6f2 100644 --- a/src/com/android/exchange/EasOutboxService.java +++ b/src/com/android/exchange/EasOutboxService.java @@ -81,7 +81,7 @@ public class EasOutboxService extends EasSyncService { * @throws IOException */ int sendMessage(File cacheDir, long msgId) throws IOException, MessagingException { - int result; + int result=EmailServiceStatus.SUCCESS; sendCallback(msgId, null, EmailServiceStatus.IN_PROGRESS); File tmpFile = File.createTempFile("eas_", "tmp", cacheDir); // Write the output to a temporary file @@ -148,18 +148,46 @@ public class EasOutboxService extends EasSyncService { sendCallback(-1, subject, EmailServiceStatus.SUCCESS); } else { userLog("Message sending failed, code: " + code); - ContentValues cv = new ContentValues(); - cv.put(SyncColumns.SERVER_ID, SEND_FAILED); - Message.update(mContext, Message.CONTENT_URI, msgId, cv); - // 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; + + boolean retrySuccess=false; + if (smartSend) { + userLog("Retrying without smartSend"); + cmd = "SendMail&SaveInSent=T"; + userLog("Send cmd: " + cmd); + + inputStream = new FileInputStream(tmpFile); + inputEntity = new InputStreamEntity(inputStream, tmpFile.length()); + + resp = sendHttpClientPost(cmd, inputEntity, SEND_MAIL_TIMEOUT); + + inputStream.close(); + code = resp.getStatusLine().getStatusCode(); + if (code == HttpStatus.SC_OK) { + userLog("Deleting message..."); + mContentResolver.delete(ContentUris.withAppendedId(Message.CONTENT_URI, msgId), + null, null); + result = EmailServiceStatus.SUCCESS; + sendCallback(-1, subject, EmailServiceStatus.SUCCESS); + retrySuccess=true; + } + } + + if (!retrySuccess) { + userLog("Message sending failed, code: " + code); + + ContentValues cv = new ContentValues(); + cv.put(SyncColumns.SERVER_ID, SEND_FAILED); + Message.update(mContext, Message.CONTENT_URI, msgId, cv); + // 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); } - sendCallback(msgId, null, result); } } catch (IOException e) { @@ -230,4 +258,4 @@ public class EasOutboxService extends EasSyncService { msg.save(context); } } -}
\ No newline at end of file +} |