diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 913debde2..861d45f07 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -8,6 +8,7 @@
+
accountsWithNewMail = new HashMap();
+ private WakeLock wakeLock = null;
+
+ // wakelock strategy is to be very conservative. If there is any reason to release, then release
+ // don't want to take the chance of running wild
+ public synchronized void wakeLockAcquire() {
+ if (wakeLock == null) {
+ PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+ wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Email");
+ wakeLock.setReferenceCounted(false);
+ wakeLock.acquire(Email.WAKE_LOCK_TIMEOUT);
+ }
+ }
+
+ public synchronized void wakeLockRelease() {
+ if (wakeLock != null) {
+ wakeLock.release();
+ wakeLock = null;
+ }
+ }
@Override
public void checkMailStarted(Context context, Account account) {
@@ -133,6 +155,7 @@ public class MailService extends Service {
@Override
public void checkMailFailed(Context context, Account account, String reason) {
reschedule();
+ wakeLockRelease();
stopSelf(mStartId);
}
@@ -187,6 +210,7 @@ public class MailService extends Service {
}
reschedule();
+ wakeLockRelease();
stopSelf(mStartId);
}
}