Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13389cd4 authored by Peng Hu's avatar Peng Hu Committed by hupeng3
Browse files

Toast: Fix the concurrency problem of mAuthenticator



In terms of calling logic, there is concurrency when mAuthenticator is assigned,
which causes the phone to restart. We need to add a lock to protect him.

Bug: 256398179

Test: atest AccountManagerServiceTest

Signed-off-by: default avatarhupeng3 <hp121520@gmail.com>
Change-Id: I937f6e00c0ac7cca76f26b37a365b5f19171eac6
parent 9e7649d5
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -4794,6 +4794,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;
@@ -4959,11 +4960,13 @@ public class AccountManagerService
        }

        private void unbind() {
            synchronized (mSessionLock) {
                if (mAuthenticator != null) {
                    mAuthenticator = null;
                    mContext.unbindService(this);
                }
            }
        }

        public void cancelTimeout() {
            mHandler.removeMessages(MESSAGE_TIMED_OUT, this);
@@ -4971,6 +4974,7 @@ public class AccountManagerService

        @Override
        public void onServiceConnected(ComponentName name, IBinder service) {
            synchronized (mSessionLock) {
                mAuthenticator = IAccountAuthenticator.Stub.asInterface(service);
                try {
                    run();
@@ -4979,6 +4983,7 @@ public class AccountManagerService
                            "remote exception");
                }
            }
        }

        @Override
        public void onServiceDisconnected(ComponentName name) {