Workaround system peculiarity to fix #2134509
* Our AccountManager listener was getting unregistered due to the way ApplicationContext caches AccountManager in a static member * The result was that AccountManager registers its listeners against the FIRST context it is instantiated with! Future calls will all obtain this pre-initialized AccountManager. * In this case, AccountSetupOptions was the first caller (to create the AccountManager Account for Exchange) * The subsequent call to register a listener therefore had its registration tied to the context of AccountSetupOptions, and was therefore leaked when AccountSetupOptions finished! * This caused a chain of problems - the leaked receiver, an Exception in AccountManager when trying to ping the listener in an expired context, and eventually the bug referenced above, which became a P1 issue Change-Id: I478e28d21ca77419afa8011e4ed8101cdf67ab79
This commit is contained in:
parent
b2f71dac39
commit
4cf3252fb0
@ -202,7 +202,9 @@ public class AccountSetupOptions extends Activity implements OnClickListener {
|
|||||||
&& mAccount.mHostAuthRecv != null
|
&& mAccount.mHostAuthRecv != null
|
||||||
&& mAccount.mHostAuthRecv.mProtocol.equals("eas")) {
|
&& mAccount.mHostAuthRecv.mProtocol.equals("eas")) {
|
||||||
boolean alsoSyncContacts = mSyncContactsView.isChecked();
|
boolean alsoSyncContacts = mSyncContactsView.isChecked();
|
||||||
ExchangeStore.addSystemAccount(this, mAccount,
|
// NOTE: We must use the Application here, rather than the current context, because
|
||||||
|
// all future references to AccountManager will end up using the context passed in here!
|
||||||
|
ExchangeStore.addSystemAccount(getApplication(), mAccount,
|
||||||
alsoSyncContacts, mAccountManagerCallback);
|
alsoSyncContacts, mAccountManagerCallback);
|
||||||
} else {
|
} else {
|
||||||
finishOnDone();
|
finishOnDone();
|
||||||
|
@ -1333,8 +1333,8 @@ public class SyncManager extends Service implements Runnable {
|
|||||||
ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS,
|
ContentResolver.addStatusChangeListener(ContentResolver.SYNC_OBSERVER_TYPE_SETTINGS,
|
||||||
mSyncStatusObserver);
|
mSyncStatusObserver);
|
||||||
mAccountsUpdatedListener = new EasAccountsUpdatedListener();
|
mAccountsUpdatedListener = new EasAccountsUpdatedListener();
|
||||||
AccountManager.get(this).addOnAccountsUpdatedListener(mAccountsUpdatedListener,
|
AccountManager.get(getApplication())
|
||||||
mHandler, true);
|
.addOnAccountsUpdatedListener(mAccountsUpdatedListener, mHandler, true);
|
||||||
|
|
||||||
mConnectivityReceiver = new ConnectivityReceiver();
|
mConnectivityReceiver = new ConnectivityReceiver();
|
||||||
registerReceiver(mConnectivityReceiver,
|
registerReceiver(mConnectivityReceiver,
|
||||||
|
Loading…
Reference in New Issue
Block a user