Merge "Toast: Fix the concurrency problem of mAuthenticator" am: a8438682f7 am: adfda7919a am: 087b916562

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2276161

Change-Id: I6088d6688e1afda926bd2f8446f76eff2ff3ef74
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Dmitry Dementyev
2022-11-07 20:48:06 +00:00
committed by Automerger Merge Worker

View File

@@ -4795,6 +4795,7 @@ public class AccountManagerService
private abstract class Session extends IAccountAuthenticatorResponse.Stub
implements IBinder.DeathRecipient, ServiceConnection {
private final Object mSessionLock = new Object();
IAccountManagerResponse mResponse;
final String mAccountType;
final boolean mExpectActivityLaunch;
@@ -4985,9 +4986,11 @@ public class AccountManagerService
}
private void unbind() {
if (mAuthenticator != null) {
mAuthenticator = null;
mContext.unbindService(this);
synchronized (mSessionLock) {
if (mAuthenticator != null) {
mAuthenticator = null;
mContext.unbindService(this);
}
}
}
@@ -4997,12 +5000,14 @@ public class AccountManagerService
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mAuthenticator = IAccountAuthenticator.Stub.asInterface(service);
try {
run();
} catch (RemoteException e) {
onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION,
"remote exception");
synchronized (mSessionLock) {
mAuthenticator = IAccountAuthenticator.Stub.asInterface(service);
try {
run();
} catch (RemoteException e) {
onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION,
"remote exception");
}
}
}