From 5fed93408390ba154f0c9d493e259caaa7a3c124 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Wed, 23 Sep 2009 15:06:19 -0700 Subject: [PATCH] Make sure we call setServicesEnabled in the BootReceiver * Otherwise, there's a chance that various activities will be disabled (like MessageCompose), even if there are existing accounts. * Enable BootReceiver by default Change-Id: Id4669c41a846545d8bac5ad85736e1508074864a --- AndroidManifest.xml | 4 +--- src/com/android/email/Email.java | 5 +++-- src/com/android/email/service/BootReceiver.java | 10 ++++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 3f87b7e8b..54cc166e9 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -181,9 +181,7 @@ - + diff --git a/src/com/android/email/Email.java b/src/com/android/email/Email.java index 86355e9ee..4a6b90b5c 100644 --- a/src/com/android/email/Email.java +++ b/src/com/android/email/Email.java @@ -140,9 +140,9 @@ public class Email extends Application { /** * Called throughout the application when the number of accounts has changed. This method * enables or disables the Compose activity, the boot receiver and the service based on - * whether any accounts are configured. + * whether any accounts are configured. Returns true if there are any accounts configured. */ - public static void setServicesEnabled(Context context) { + public static boolean setServicesEnabled(Context context) { Cursor c = null; try { c = context.getContentResolver().query( @@ -151,6 +151,7 @@ public class Email extends Application { null, null, null); boolean enable = c.getCount() > 0; setServicesEnabled(context, enable); + return enable; } finally { if (c != null) { c.close(); diff --git a/src/com/android/email/service/BootReceiver.java b/src/com/android/email/service/BootReceiver.java index 4659819c7..74d569f07 100644 --- a/src/com/android/email/service/BootReceiver.java +++ b/src/com/android/email/service/BootReceiver.java @@ -16,18 +16,20 @@ package com.android.email.service; -import com.android.exchange.SyncManager; +import com.android.email.Email; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class BootReceiver extends BroadcastReceiver { + @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { - MailService.actionReschedule(context); - // TODO Remove when Exchange is running on its own - context.startService(new Intent(context, SyncManager.class)); + // Returns true if there are any accounts + if (Email.setServicesEnabled(context)) { + MailService.actionReschedule(context); + } } else if (Intent.ACTION_DEVICE_STORAGE_LOW.equals(intent.getAction())) { MailService.actionCancel(context);