diff --git a/src/com/android/exchange/EasOutboxService.java b/src/com/android/exchange/EasOutboxService.java index 561e073b7..4e1e61cfb 100644 --- a/src/com/android/exchange/EasOutboxService.java +++ b/src/com/android/exchange/EasOutboxService.java @@ -52,6 +52,12 @@ public class EasOutboxService extends EasSyncService { new String[] {BodyColumns.SOURCE_MESSAGE_KEY}; public static final String WHERE_MESSAGE_KEY = Body.MESSAGE_KEY + "=?"; + // This needs to be long enough to send the longest reasonable message, without being so long + // as to effectively "hang" sending of mail. The standard 30 second timeout isn't long enough + // for pictures and the like. For now, we'll use 15 minutes, in the knowledge that any socket + // failure would probably generate an Exception before timing out anyway + public static final int SEND_MAIL_TIMEOUT = 15*MINUTES; + public EasOutboxService(Context _context, Mailbox _mailbox) { super(_context, _mailbox); } @@ -129,7 +135,7 @@ public class EasOutboxService extends EasSyncService { cmd += "&ItemId=" + itemId + "&CollectionId=" + collectionId + "&SaveInSent=T"; } userLog("Send cmd: " + cmd); - HttpResponse resp = sendHttpClientPost(cmd, inputEntity); + HttpResponse resp = sendHttpClientPost(cmd, inputEntity, SEND_MAIL_TIMEOUT); inputStream.close(); int code = resp.getStatusLine().getStatusCode(); @@ -167,7 +173,6 @@ public class EasOutboxService extends EasSyncService { @Override public void run() { setupService(); - File cacheDir = mContext.getCacheDir(); try { mDeviceId = SyncManager.getDeviceId(); diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java index 116198010..3b2a8a51e 100644 --- a/src/com/android/exchange/EasSyncService.java +++ b/src/com/android/exchange/EasSyncService.java @@ -111,7 +111,6 @@ public class EasSyncService extends AbstractSyncService { static private final int PING_HEARTBEAT_INCREMENT = 3*PING_MINUTES; static private final int PING_FORCE_HEARTBEAT = 2*PING_MINUTES; - static private final int PROTOCOL_PING_STATUS_UNAVAILABLE = -1; static private final int PROTOCOL_PING_STATUS_COMPLETED = 1; // Fallbacks (in minutes) for ping loop failures diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java index 2e0a226b0..8e6119a75 100644 --- a/src/com/android/exchange/SyncManager.java +++ b/src/com/android/exchange/SyncManager.java @@ -292,6 +292,11 @@ public class SyncManager extends Service implements Runnable { cv, WHERE_MAILBOX_KEY, new String[] {Long.toString(mailboxId)}); kick("start outbox"); + // Outbox can't be synced in EAS + return; + } else if (m.mType == Mailbox.TYPE_DRAFTS) { + // Drafts can't be synced in EAS + return; } startManualSync(mailboxId, SyncManager.SYNC_SERVICE_START_SYNC, null); } @@ -1139,6 +1144,11 @@ public class SyncManager extends Service implements Runnable { if (service != null) { Mailbox m = Mailbox.restoreMailboxWithId(INSTANCE, id); if (m != null) { + // We ignore drafts completely (doesn't sync). Changes in Outbox are handled + // in the checkMailboxes loop, so we can ignore these pings. + if (m.mType == Mailbox.TYPE_DRAFTS || m.mType == Mailbox.TYPE_OUTBOX) { + return; + } service.mAccount = Account.restoreAccountWithId(INSTANCE, m.mAccountKey); service.mMailbox = m; service.ping(); @@ -1629,6 +1639,12 @@ public class SyncManager extends Service implements Runnable { static public void serviceRequest(long mailboxId, long ms, int reason) { if (INSTANCE == null) return; + Mailbox m = Mailbox.restoreMailboxWithId(INSTANCE, mailboxId); + // Never allow manual start of Drafts or Outbox via serviceRequest + if (m == null || m.mType == Mailbox.TYPE_DRAFTS || m.mType == Mailbox.TYPE_OUTBOX) { + INSTANCE.log("Ignoring serviceRequest for drafts/outbox"); + return; + } try { AbstractSyncService service = INSTANCE.mServiceMap.get(mailboxId); if (service != null) {