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
This commit is contained in:
Marc Blank 2009-09-23 15:06:19 -07:00
parent 3e1c871f04
commit 5fed934083
3 changed files with 10 additions and 9 deletions

View File

@ -181,9 +181,7 @@
</intent-filter>
</receiver>
<receiver android:name=".service.BootReceiver"
android:enabled="false"
>
<receiver android:name=".service.BootReceiver" android:enabled="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>

View File

@ -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();

View File

@ -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);