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

Merge commit 'ea878be11729cd793d9183fc264118241cd5a5b6' into eclair-mr2

* commit 'ea878be11729cd793d9183fc264118241cd5a5b6':
  Make sure we hold WakeLock during mail sending (fixes #2180551)
diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java
index 3b2a8a5..1b24799 100644
--- a/src/com/android/exchange/EasSyncService.java
+++ b/src/com/android/exchange/EasSyncService.java
@@ -414,6 +414,7 @@
     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;
@@ -438,13 +439,17 @@
         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;
             }
         }