am 8be9b893: am ea878be1: Make sure we hold WakeLock during mail sending (fixes #2180551)

Merge commit '8be9b8937be04cc50e7fd2e79d2d91c99aace1b5' into eclair-mr2-plus-aosp

* commit '8be9b8937be04cc50e7fd2e79d2d91c99aace1b5':
  Make sure we hold WakeLock during mail sending (fixes #2180551)
This commit is contained in:
Marc Blank 2009-10-12 10:24:41 -07:00 committed by Android Git Automerger
commit 42336c27d3

View File

@ -414,6 +414,7 @@ public class EasSyncService extends AbstractSyncService {
protected HttpResponse sendHttpClientPost(String cmd, HttpEntity entity, int timeout) protected HttpResponse sendHttpClientPost(String cmd, HttpEntity entity, int timeout)
throws IOException { throws IOException {
HttpClient client = getHttpClient(timeout); HttpClient client = getHttpClient(timeout);
boolean sleepAllowed = cmd.equals(PING_COMMAND);
// Split the mail sending commands // Split the mail sending commands
String extra = null; String extra = null;
@ -438,13 +439,17 @@ public class EasSyncService extends AbstractSyncService {
method.setEntity(entity); method.setEntity(entity);
synchronized(getSynchronizer()) { synchronized(getSynchronizer()) {
mPendingPost = method; mPendingPost = method;
if (sleepAllowed) {
SyncManager.runAsleep(mMailboxId, timeout+(10*SECONDS)); SyncManager.runAsleep(mMailboxId, timeout+(10*SECONDS));
} }
}
try { try {
return client.execute(method); return client.execute(method);
} finally { } finally {
synchronized(getSynchronizer()) { synchronized(getSynchronizer()) {
if (sleepAllowed) {
SyncManager.runAwake(mMailboxId); SyncManager.runAwake(mMailboxId);
}
mPendingPost = null; mPendingPost = null;
} }
} }