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

Commit 0da9bb05 authored by Tim Yu's avatar Tim Yu Committed by Android (Google) Code Review
Browse files

Merge "Autofill Fix race condition with onSessionDestroyed" into main

parents 1d698831 9c26fbf0
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static android.view.autofill.AutofillManager.FLAG_ADD_CLIENT_ENABLED_FOR_
import static android.view.autofill.AutofillManager.NO_SESSION;
import static android.view.autofill.AutofillManager.RECEIVER_FLAG_SESSION_FOR_AUGMENTED_AUTOFILL_ONLY;

import static com.android.internal.util.function.pooled.PooledLambda.obtainMessage;
import static com.android.server.autofill.Helper.sDebug;
import static com.android.server.autofill.Helper.sVerbose;

@@ -761,16 +762,12 @@ final class AutofillManagerServiceImpl
        return false;
    }

    @GuardedBy("mLock")
    void removeSessionLocked(int sessionId) {
        mSessions.remove(sessionId);
        if (Flags.autofillSessionDestroyed()) {
    void callOnSessionDestroyed(int sessionId) {
        if (sVerbose) {
                Slog.v(
                        TAG,
                        "removeSessionLocked(): removed " + sessionId);
            Slog.v(TAG, "removeSessionLocked(): removed " + sessionId);
        }

        synchronized (mLock) {
            FillEventHistory history = null;

            if (AutofillFeatureFlags.isMultipleFillEventHistoryEnabled()
@@ -806,6 +803,16 @@ final class AutofillManagerServiceImpl
        }
    }

    @GuardedBy("mLock")
    void removeSessionLocked(int sessionId) {
        mSessions.remove(sessionId);
        if (Flags.autofillSessionDestroyed()) {
            mHandler.sendMessage(
                    obtainMessage(
                            AutofillManagerServiceImpl::callOnSessionDestroyed, this, sessionId));
        }
    }

    /**
     * Ges the previous sessions asked to be kept alive in a given activity task.
     *