am 3b3b5b0f: Run the account reconciler every time we start SyncManager

Merge commit '3b3b5b0f2b65bf7efb9474ece2d8d2821beeadc2' into froyo-plus-aosp

* commit '3b3b5b0f2b65bf7efb9474ece2d8d2821beeadc2':
  Run the account reconciler every time we start SyncManager
This commit is contained in:
Andrew Stadler 2010-04-14 22:49:17 -07:00 committed by Android Git Automerger
commit a55d27bae1

View File

@ -921,24 +921,35 @@ public class SyncManager extends Service implements Runnable {
*/ */
public class EasAccountsUpdatedListener implements OnAccountsUpdateListener { public class EasAccountsUpdatedListener implements OnAccountsUpdateListener {
public void onAccountsUpdated(android.accounts.Account[] accounts) { public void onAccountsUpdated(android.accounts.Account[] accounts) {
SyncManager syncManager = INSTANCE;
if (syncManager != null) {
syncManager.runAccountReconciler();
}
}
}
/**
* Non-blocking call to run the account reconciler.
* Launches a worker thread, so it may be called from UI thread.
*/
private void runAccountReconciler() {
final SyncManager syncManager = this;
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
SyncManager syncManager = INSTANCE;
if (syncManager != null) {
android.accounts.Account[] accountMgrList = AccountManager.get(syncManager) android.accounts.Account[] accountMgrList = AccountManager.get(syncManager)
.getAccountsByType(Email.EXCHANGE_ACCOUNT_MANAGER_TYPE); .getAccountsByType(Email.EXCHANGE_ACCOUNT_MANAGER_TYPE);
synchronized (sAccountList) { synchronized (sAccountList) {
// Make sure we have an up-to-date sAccountList // Make sure we have an up-to-date sAccountList
if (mAccountObserver != null) {
mAccountObserver.onAccountChanged(); mAccountObserver.onAccountChanged();
}
reconcileAccountsWithAccountManager(syncManager, sAccountList, reconcileAccountsWithAccountManager(syncManager, sAccountList,
accountMgrList, false, mResolver); accountMgrList, false, mResolver);
} }
} }
}
}.start(); }.start();
} }
}
protected static void log(String str) { protected static void log(String str) {
if (Eas.USER_LOG) { if (Eas.USER_LOG) {
@ -1059,6 +1070,9 @@ public class SyncManager extends Service implements Runnable {
throw new RuntimeException(); throw new RuntimeException();
} }
} }
// Run the reconciler and clean up any mismatched accounts - if we weren't running when
// accounts were deleted, it won't have been called.
runAccountReconciler();
} }
@Override @Override