diff options
author | Fred Quintana <fredq@google.com> | 2009-10-07 16:36:48 -0700 |
---|---|---|
committer | Fred Quintana <fredq@google.com> | 2009-10-07 16:36:48 -0700 |
commit | ea48361d47a2d566922ef26a41ea12d719347618 (patch) | |
tree | e83350d059089bf00a9b1c76e6d4b3554c217d5c /core | |
parent | f038004f4a5e4fab18df9c87573ba1e82790c30f (diff) | |
download | frameworks_base-ea48361d47a2d566922ef26a41ea12d719347618.zip frameworks_base-ea48361d47a2d566922ef26a41ea12d719347618.tar.gz frameworks_base-ea48361d47a2d566922ef26a41ea12d719347618.tar.bz2 |
fix an NPE on a race condition that occurs when unbinding from an authenticator at the samer time that its process dies: bug 2171204
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/accounts/AuthenticatorBindHelper.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/core/java/android/accounts/AuthenticatorBindHelper.java b/core/java/android/accounts/AuthenticatorBindHelper.java index 91e23ab..2ca1f0e 100644 --- a/core/java/android/accounts/AuthenticatorBindHelper.java +++ b/core/java/android/accounts/AuthenticatorBindHelper.java @@ -146,7 +146,7 @@ public class AuthenticatorBindHelper { Log.v(TAG, "there are no more callbacks for service " + authenticatorType + ", unbinding service"); } - unbindFromService(authenticatorType); + unbindFromServiceLocked(authenticatorType); } else { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "leaving service " + authenticatorType @@ -161,7 +161,10 @@ public class AuthenticatorBindHelper { } } - private void unbindFromService(String authenticatorType) { + /** + * You must synchronized on mServiceConnections before calling this + */ + private void unbindFromServiceLocked(String authenticatorType) { if (Log.isLoggable(TAG, Log.VERBOSE)) { Log.v(TAG, "unbindService from " + authenticatorType); } @@ -217,15 +220,18 @@ public class AuthenticatorBindHelper { // post a message for each service user to tell them that the service is disconnected, // and unbind from the service. synchronized (mServiceConnections) { - for (Callback callback : mServiceUsers.get(mAuthenticatorType)) { - if (Log.isLoggable(TAG, Log.VERBOSE)) { - Log.v(TAG, "the service became disconnected, scheduling a " - + "disconnected message for " - + mAuthenticatorType); + final ArrayList<Callback> callbackList = mServiceUsers.get(mAuthenticatorType); + if (callbackList != null) { + for (Callback callback : callbackList) { + if (Log.isLoggable(TAG, Log.VERBOSE)) { + Log.v(TAG, "the service became disconnected, scheduling a " + + "disconnected message for " + + mAuthenticatorType); + } + mHandler.obtainMessage(mMessageWhatDisconnected, callback).sendToTarget(); } - mHandler.obtainMessage(mMessageWhatDisconnected, callback).sendToTarget(); + unbindFromServiceLocked(mAuthenticatorType); } - unbindFromService(mAuthenticatorType); } } } |