Workaround for IllegalArgumentException in SyncManager

* There is a race condition in which the AccountManager listener
  isn't properly unregistered when SyncManager is shut down
* In this case, SyncManager tries to register a new listener
  (i.e. registering again), which causes an IllegalArgumentException
* The quick workaround is simply to catch and ignore this exception,
  as it's really more of a warning than a true error
* A bug will be filed for the underlying issue

Bug: 2631561
Change-Id: I139d24ae045d402d4d8cb006406ef96ccc768566
This commit is contained in:
Andrew Stadler 2010-04-30 12:39:08 -07:00
parent 47a59d883f
commit 14812a50a8

View File

@ -1811,8 +1811,14 @@ public class SyncManager extends Service implements Runnable {
ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS,
mSyncStatusObserver);
mAccountsUpdatedListener = new EasAccountsUpdatedListener();
// TODO Find and fix root cause of duplication
try {
AccountManager.get(getApplication())
.addOnAccountsUpdatedListener(mAccountsUpdatedListener, mHandler, true);
} catch (IllegalStateException e1) {
// This exception is more of a warning; we shouldn't be in the state in which we
// already have a listener.
}
// Set up receivers for ConnectivityManager
mConnectivityReceiver = new ConnectivityReceiver();