Increase chance of Push mail picking up messages when connectivity is

restored.
This commit is contained in:
Daniel Applebaum 2009-11-07 16:51:08 +00:00
parent b9642ee5f3
commit 90198382a4
3 changed files with 18 additions and 3 deletions

View file

@ -143,11 +143,11 @@ public class Email extends Application {
public static final int MANUAL_WAKE_LOCK_TIMEOUT = 120000;
public static final int PUSH_WAKE_LOCK_TIMEOUT = 30000;
public static final int PUSH_WAKE_LOCK_TIMEOUT = 40000;
public static final int MAIL_SERVICE_WAKE_LOCK_TIMEOUT = 30000;
public static final int BOOT_RECEIVER_WAKE_LOCK_TIMEOUT = 10000;
/**
* LED color used for the new email notitication
*/

View file

@ -1872,7 +1872,7 @@ public class ImapStore extends Store {
public void start() throws MessagingException
{
receiver.pushInProgress();
Runnable runner = new Runnable()
{
public void run()

View file

@ -4,6 +4,8 @@ package com.android.email.service;
import com.android.email.Email;
import android.net.ConnectivityManager;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
import android.util.Log;
import android.content.BroadcastReceiver;
@ -12,6 +14,13 @@ import android.content.Intent;
public class BootReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Email");
wakeLock.setReferenceCounted(false);
wakeLock.acquire(Email.BOOT_RECEIVER_WAKE_LOCK_TIMEOUT);
// TODO: For now, let the wakeLock expire on its own, don't release it at the end of this method,
// otherwise there's no point to it. We're trying to give the MailService some time to start.
Log.v(Email.LOG_TAG, "BootReceiver.onReceive" + intent);
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
@ -30,6 +39,12 @@ public class BootReceiver extends BroadcastReceiver {
else if (ConnectivityManager.ACTION_BACKGROUND_DATA_SETTING_CHANGED.equals(intent.getAction())) {
MailService.backgroundDataChanged(context);
}
// else if (Intent.ACTION_BATTERY_LOW.equals(intent.getAction())) {
// MailService.batteryStatusChange(context, true);
// }
// else if (Intent.ACTION_BATTERY_OKAY.equals(intent.getAction())) {
// MailService.batteryStatusChange(context, false);
// }
}
}