Fix the concurrency issue when 'linkToDeath' in AccountManagerService that leads to JE

Move the ref of 'mResponse' after the completion of 'linkToDeath' to avoid concurrency issues caused by 'unlinkToDeath' being triggered in different thread

Test: MTBF
Bug: 291856266

Change-Id: Ifc5af9f85aac83be56afec9a1fb32501a6f32ebc
Signed-off-by: zhuning3 <zhuning3@xiaomi.corp-partner.google.com>
This commit is contained in:
zhuning3
2023-07-19 14:12:21 +08:00
committed by ning zhu
parent 14b1b59266
commit 166e569b7a

View File

@@ -4854,7 +4854,6 @@ public class AccountManagerService
if (accountType == null) throw new IllegalArgumentException("accountType is null");
mAccounts = accounts;
mStripAuthTokenFromResult = stripAuthTokenFromResult;
mResponse = response;
mAccountType = accountType;
mExpectActivityLaunch = expectActivityLaunch;
mCreationTime = SystemClock.elapsedRealtime();
@@ -4868,8 +4867,8 @@ public class AccountManagerService
if (response != null) {
try {
response.asBinder().linkToDeath(this, 0 /* flags */);
mResponse = response;
} catch (RemoteException e) {
mResponse = null;
binderDied();
}
}