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

Commit e69a252c authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Move mCurTokenDisplayId from IMMS to InputMethodBindingController

With this commit mCurTokenDisplayId starts belonging to
InputMethodBindingController rather than InputMethodManagerService.

While this is not a mechanical change, that there is supposed to be no
observable behavior change.

Bug: 305849394
Fix: 341179600
Test: presubmit
Change-Id: If9cdc8ee7c9c0726e9712d0a36cf2e9b05b4099e
parent 5e6846e7
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.os.UserHandle;
import android.provider.Settings;
import android.util.EventLog;
import android.util.Slog;
import android.view.Display;
import android.view.WindowManager;
import android.view.inputmethod.InputMethod;
import android.view.inputmethod.InputMethodInfo;
@@ -78,6 +79,7 @@ final class InputMethodBindingController {
    @GuardedBy("ImfLock.class") @Nullable private IInputMethodInvoker mCurMethod;
    @GuardedBy("ImfLock.class") private int mCurMethodUid = Process.INVALID_UID;
    @GuardedBy("ImfLock.class") @Nullable private IBinder mCurToken;
    @GuardedBy("ImfLock.class") private int mCurTokenDisplayId = Display.INVALID_DISPLAY;
    @GuardedBy("ImfLock.class") private int mCurSeq;
    @GuardedBy("ImfLock.class") private boolean mVisibleBound;
    @GuardedBy("ImfLock.class") private boolean mSupportsStylusHw;
@@ -192,6 +194,17 @@ final class InputMethodBindingController {
        return mCurToken;
    }

    /**
     * Returns the displayId associated with {@link #getCurToken()}.
     *
     * @return the displayId associated with {@link #getCurToken()}. {@link Display#INVALID_DISPLAY}
     *         while {@link #getCurToken()} returns {@code null}
     */
    @GuardedBy("ImfLock.class")
    int getCurTokenDisplayId() {
        return mCurTokenDisplayId;
    }

    /**
     * The Intent used to connect to the current input method.
     */
@@ -412,15 +425,14 @@ final class InputMethodBindingController {

    @GuardedBy("ImfLock.class")
    private void removeCurrentToken() {
        int curTokenDisplayId = mService.getCurTokenDisplayIdLocked();

        if (DEBUG) {
            Slog.v(TAG,
                    "Removing window token: " + mCurToken + " for display: " + curTokenDisplayId);
                    "Removing window token: " + mCurToken + " for display: " + mCurTokenDisplayId);
        }
        mWindowManagerInternal.removeWindowToken(mCurToken, true /* removeWindows */,
                false /* animateExit */, curTokenDisplayId);
                false /* animateExit */, mCurTokenDisplayId);
        mCurToken = null;
        mCurTokenDisplayId = Display.INVALID_DISPLAY;
    }

    @GuardedBy("ImfLock.class")
@@ -445,7 +457,7 @@ final class InputMethodBindingController {

            final int displayIdToShowIme = mService.getDisplayIdToShowImeLocked();
            mCurToken = new Binder();
            mService.setCurTokenDisplayIdLocked(displayIdToShowIme);
            mCurTokenDisplayId = displayIdToShowIme;
            if (DEBUG) {
                Slog.v(TAG, "Adding window token: " + mCurToken + " for display: "
                        + displayIdToShowIme);
+2 −11
Original line number Diff line number Diff line
@@ -581,18 +581,10 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
     */
    @GuardedBy("ImfLock.class")
    int getCurTokenDisplayIdLocked() {
        return mCurTokenDisplayId;
    }

    @GuardedBy("ImfLock.class")
    void setCurTokenDisplayIdLocked(int curTokenDisplayId) {
        mCurTokenDisplayId = curTokenDisplayId;
        final var userData = mUserDataRepository.getOrCreate(mCurrentUserId);
        return userData.mBindingController.getCurTokenDisplayId();
    }

    @GuardedBy("ImfLock.class")
    @MultiUserUnawareField
    private int mCurTokenDisplayId = INVALID_DISPLAY;

    /**
     * The display ID of the input method indicates the fallback display which returned by
     * {@link #computeImeDisplayIdForTarget}.
@@ -2472,7 +2464,6 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
        mImeWindowVis = 0;
        mBackDisposition = InputMethodService.BACK_DISPOSITION_DEFAULT;
        updateSystemUiLocked(mImeWindowVis, mBackDisposition);
        mCurTokenDisplayId = INVALID_DISPLAY;
        mAutofillController.onResetSystemUi();
    }