From 14812a50a8cacd1166cd2b0d0be0bf2bbeec662c Mon Sep 17 00:00:00 2001 From: Andrew Stadler Date: Fri, 30 Apr 2010 12:39:08 -0700 Subject: [PATCH] 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 --- src/com/android/exchange/SyncManager.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java index 523aab894..b451ef1f6 100644 --- a/src/com/android/exchange/SyncManager.java +++ b/src/com/android/exchange/SyncManager.java @@ -1811,8 +1811,14 @@ public class SyncManager extends Service implements Runnable { ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS, mSyncStatusObserver); mAccountsUpdatedListener = new EasAccountsUpdatedListener(); - AccountManager.get(getApplication()) - .addOnAccountsUpdatedListener(mAccountsUpdatedListener, mHandler, true); + // 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();