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

Commit c1b2d61d authored by Dmitry Dementyev's avatar Dmitry Dementyev
Browse files

Close AccountManagerService.session after timeout.

60 seconds delay was used in older Android versions.

Bug: 303905130
Test: manual

Change-Id: I3632c503097da771954aee460df49cbfab496a74
parent 7ddc262b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ public class AccountManagerService

    final MessageHandler mHandler;

    private static final int TIMEOUT_DELAY_MS = 1000 * 60;
    // Messages that can be sent on mHandler
    private static final int MESSAGE_TIMED_OUT = 3;
    private static final int MESSAGE_COPY_SHARED_ACCOUNT = 4;
@@ -4942,6 +4943,7 @@ public class AccountManagerService
            synchronized (mSessions) {
                mSessions.put(toString(), this);
            }
            scheduleTimeout();
            if (response != null) {
                try {
                    response.asBinder().linkToDeath(this, 0 /* flags */);
@@ -5109,6 +5111,11 @@ public class AccountManagerService
            }
        }

        private void scheduleTimeout() {
            mHandler.sendMessageDelayed(
                    mHandler.obtainMessage(MESSAGE_TIMED_OUT, this), TIMEOUT_DELAY_MS);
        }

        public void cancelTimeout() {
            mHandler.removeMessages(MESSAGE_TIMED_OUT, this);
        }
@@ -5146,6 +5153,9 @@ public class AccountManagerService

        public void onTimedOut() {
            IAccountManagerResponse response = getResponseAndClose();
            if (Log.isLoggable(TAG, Log.VERBOSE)) {
                Log.v(TAG, "Session.onTimedOut");
            }
            if (response != null) {
                try {
                    response.onError(AccountManager.ERROR_CODE_REMOTE_EXCEPTION,