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

Commit 223db8b6 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Revert "Remove redundant IMM#mServedInputConnection."

This reverts commit afb6558c.

It turns out that this CL caused a serious regression Bug 27824691.

Bug: 25332806
Bug: 27824691
Change-Id: I16312592743a6673449c492ee5ba533256d343ea
parent 1fa5f594
Loading
Loading
Loading
Loading
+20 −31
Original line number Diff line number Diff line
@@ -317,6 +317,7 @@ public final class InputMethodManager {
    /**
     * The InputConnection that was last retrieved from the served view.
     */
    InputConnection mServedInputConnection;
    ControlledInputConnectionWrapper mServedInputConnectionWrapper;
    /**
     * The completions that were last provided by the served view.
@@ -497,7 +498,7 @@ public final class InputMethodManager {
                            // from a thread that created mServedView. That could happen
                            // the current activity is running in the system process.
                            // In that case, we really should not call
                            // mServedInputConnectionWrapper.finishComposingText().
                            // mServedInputConnection.finishComposingText.
                            if (checkFocusNoStartInput(mHasBeenInactive, false)) {
                                final int reason = active ?
                                        InputMethodClient.START_INPUT_REASON_ACTIVATED_BY_IMMS :
@@ -561,9 +562,7 @@ public final class InputMethodManager {

        @Override
        public String toString() {
            return "ControlledInputConnectionWrapper{"
                    + "connection=" + getInputConnection()
                    + " mActive=" + mActive
            return "ControlledInputConnectionWrapper{mActive=" + mActive
                    + " mParentInputMethodManager.mActive=" + mParentInputMethodManager.mActive
                    + "}";
        }
@@ -781,8 +780,7 @@ public final class InputMethodManager {
     */
    public boolean isAcceptingText() {
        checkFocus();
        return mServedInputConnectionWrapper != null &&
                mServedInputConnectionWrapper.getInputConnection() != null;
        return mServedInputConnection != null;
    }

    /**
@@ -817,6 +815,7 @@ public final class InputMethodManager {
     */
    void clearConnectionLocked() {
        mCurrentTextBoxAttribute = null;
        mServedInputConnection = null;
        if (mServedInputConnectionWrapper != null) {
            mServedInputConnectionWrapper.deactivate();
            mServedInputConnectionWrapper = null;
@@ -849,13 +848,7 @@ public final class InputMethodManager {
     * Notifies the served view that the current InputConnection will no longer be used.
     */
    private void notifyInputConnectionFinished() {
        if (mServedView == null || mServedInputConnectionWrapper == null) {
            return;
        }
        final InputConnection inputConnection = mServedInputConnectionWrapper.getInputConnection();
        if (inputConnection == null) {
            return;
        }
        if (mServedView != null && mServedInputConnection != null) {
            // We need to tell the previously served view that it is no
            // longer the input target, so it can reset its state.  Schedule
            // this call on its window's Handler so it will be on the correct
@@ -863,7 +856,8 @@ public final class InputMethodManager {
            ViewRootImpl viewRootImpl = mServedView.getViewRootImpl();
            if (viewRootImpl != null) {
                // This will result in a call to reportFinishInputConnection() below.
            viewRootImpl.dispatchFinishInputConnection(inputConnection);
                viewRootImpl.dispatchFinishInputConnection(mServedInputConnection);
            }
        }
    }

@@ -872,13 +866,7 @@ public final class InputMethodManager {
     * @hide
     */
    public void reportFinishInputConnection(InputConnection ic) {
        final InputConnection currentConnection;
        if (mServedInputConnectionWrapper == null) {
            currentConnection = null;
        } else {
            currentConnection = mServedInputConnectionWrapper.getInputConnection();
        }
        if (currentConnection != ic) {
        if (mServedInputConnection != ic) {
            ic.finishComposingText();
            // To avoid modifying the public InputConnection interface
            if (ic instanceof BaseInputConnection) {
@@ -1254,6 +1242,7 @@ public final class InputMethodManager {
            mServedConnecting = false;
            // Notify the served view that its previous input connection is finished
            notifyInputConnectionFinished();
            mServedInputConnection = ic;
            ControlledInputConnectionWrapper servedContext;
            final int missingMethodFlags;
            if (ic != null) {
@@ -1424,7 +1413,7 @@ public final class InputMethodManager {
            return false;
        }

        final ControlledInputConnectionWrapper ic;
        InputConnection ic = null;
        synchronized (mH) {
            if (mServedView == mNextServedView && !forceNewFocus) {
                return false;
@@ -1444,7 +1433,7 @@ public final class InputMethodManager {
                return false;
            }

            ic = mServedInputConnectionWrapper;
            ic = mServedInputConnection;

            mServedView = mNextServedView;
            mCurrentTextBoxAttribute = null;
@@ -2293,7 +2282,7 @@ public final class InputMethodManager {
        } else {
            p.println("  mCurrentTextBoxAttribute: null");
        }
        p.println("  mServedInputConnectionWrapper=" + mServedInputConnectionWrapper);
        p.println("  mServedInputConnection=" + mServedInputConnection);
        p.println("  mCompletions=" + Arrays.toString(mCompletions));
        p.println("  mCursorRect=" + mCursorRect);
        p.println("  mCursorSelStart=" + mCursorSelStart
+1 −9
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.internal.view;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -59,8 +57,7 @@ public abstract class IInputConnectionWrapper extends IInputContext.Stub {
    private static final int DO_CLEAR_META_KEY_STATES = 130;
    private static final int DO_REQUEST_UPDATE_CURSOR_ANCHOR_INFO = 140;

    @NonNull
    private final WeakReference<InputConnection> mInputConnection;
    private WeakReference<InputConnection> mInputConnection;

    private Looper mMainLooper;
    private Handler mH;
@@ -89,11 +86,6 @@ public abstract class IInputConnectionWrapper extends IInputContext.Stub {
        mH = new MyHandler(mMainLooper);
    }

    @Nullable
    public InputConnection getInputConnection() {
        return mInputConnection.get();
    }

    abstract protected boolean isActive();

    /**