Make sure account upgrade code always runs before reconciling

b/11240251

Change-Id: Id6d6ad98b729757991b19c8dcd84822d6216f9a0
This commit is contained in:
Tony Mantler 2013-10-16 15:57:25 -07:00
parent 85d2190552
commit 7acf30e9ab
1 changed files with 13 additions and 0 deletions

View File

@ -146,6 +146,11 @@ public class EmailBroadcastProcessorService extends IntentService {
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}
private boolean isComponentDisabled(final Class<?> klass) {
return getPackageManager().getComponentEnabledSetting(new ComponentName(this, klass))
== PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
}
private void updateAccountManagerAccountsOfType(final String amAccountType,
final Map<String, String> protocolMap) {
final android.accounts.Account[] amAccounts =
@ -227,6 +232,9 @@ public class EmailBroadcastProcessorService extends IntentService {
}
private void onAppUpgrade() {
if (isComponentDisabled(EmailUpgradeBroadcastReceiver.class)) {
return;
}
// TODO: Only do this for Email2Google.
// When upgrading to Email2Google, we need to essentially rename the account manager
// type for all existing accounts, so we add new ones and delete the old.
@ -270,6 +278,11 @@ public class EmailBroadcastProcessorService extends IntentService {
}
private void reconcileAndStartServices() {
/**
* We can get here before the ACTION_UPGRADE_BROADCAST is received, so make sure the
* accounts are converted otherwise terrible, horrible things will happen.
*/
onAppUpgrade();
// Reconcile accounts
AccountReconciler.reconcileAccounts(this);
// Starts remote services, if any