From ea878be11729cd793d9183fc264118241cd5a5b6 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Fri, 9 Oct 2009 11:27:27 -0700 Subject: [PATCH] Make sure we hold WakeLock during mail sending (fixes #2180551) * Don't runAsleep unless this is a Ping * Relates to #2178288 in that it's possible that the system could sleep while we're trying to send (not sure if this is possible; will check), so we prevent it by holding a WakeLock in this case Change-Id: Ib3f8786501b942e1cfcb7a0bbb07b8e3084e2a86 --- src/com/android/exchange/EasSyncService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java index dc510defc..a60466924 100644 --- a/src/com/android/exchange/EasSyncService.java +++ b/src/com/android/exchange/EasSyncService.java @@ -408,6 +408,7 @@ public class EasSyncService extends AbstractSyncService { protected HttpResponse sendHttpClientPost(String cmd, HttpEntity entity, int timeout) throws IOException { HttpClient client = getHttpClient(timeout); + boolean sleepAllowed = cmd.equals(PING_COMMAND); // Split the mail sending commands String extra = null; @@ -432,13 +433,17 @@ public class EasSyncService extends AbstractSyncService { method.setEntity(entity); synchronized(getSynchronizer()) { mPendingPost = method; - SyncManager.runAsleep(mMailboxId, timeout+(10*SECONDS)); + if (sleepAllowed) { + SyncManager.runAsleep(mMailboxId, timeout+(10*SECONDS)); + } } try { return client.execute(method); } finally { synchronized(getSynchronizer()) { - SyncManager.runAwake(mMailboxId); + if (sleepAllowed) { + SyncManager.runAwake(mMailboxId); + } mPendingPost = null; } }