Loading core/java/android/view/inputmethod/InputMethodManager.java +31 −20 Original line number Diff line number Diff line Loading @@ -317,7 +317,6 @@ 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. Loading Loading @@ -498,7 +497,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 // mServedInputConnection.finishComposingText. // mServedInputConnectionWrapper.finishComposingText(). if (checkFocusNoStartInput(mHasBeenInactive, false)) { final int reason = active ? InputMethodClient.START_INPUT_REASON_ACTIVATED_BY_IMMS : Loading Loading @@ -562,7 +561,9 @@ public final class InputMethodManager { @Override public String toString() { return "ControlledInputConnectionWrapper{mActive=" + mActive return "ControlledInputConnectionWrapper{" + "connection=" + getInputConnection() + " mActive=" + mActive + " mParentInputMethodManager.mActive=" + mParentInputMethodManager.mActive + "}"; } Loading Loading @@ -780,7 +781,8 @@ public final class InputMethodManager { */ public boolean isAcceptingText() { checkFocus(); return mServedInputConnection != null; return mServedInputConnectionWrapper != null && mServedInputConnectionWrapper.getInputConnection() != null; } /** Loading Loading @@ -815,7 +817,6 @@ public final class InputMethodManager { */ void clearConnectionLocked() { mCurrentTextBoxAttribute = null; mServedInputConnection = null; if (mServedInputConnectionWrapper != null) { mServedInputConnectionWrapper.deactivate(); mServedInputConnectionWrapper = null; Loading Loading @@ -848,7 +849,13 @@ public final class InputMethodManager { * Notifies the served view that the current InputConnection will no longer be used. */ private void notifyInputConnectionFinished() { if (mServedView != null && mServedInputConnection != null) { if (mServedView == null || mServedInputConnectionWrapper == null) { return; } final InputConnection inputConnection = mServedInputConnectionWrapper.getInputConnection(); if (inputConnection == null) { return; } // 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 Loading @@ -856,8 +863,7 @@ public final class InputMethodManager { ViewRootImpl viewRootImpl = mServedView.getViewRootImpl(); if (viewRootImpl != null) { // This will result in a call to reportFinishInputConnection() below. viewRootImpl.dispatchFinishInputConnection(mServedInputConnection); } viewRootImpl.dispatchFinishInputConnection(inputConnection); } } Loading @@ -866,7 +872,13 @@ public final class InputMethodManager { * @hide */ public void reportFinishInputConnection(InputConnection ic) { if (mServedInputConnection != ic) { final InputConnection currentConnection; if (mServedInputConnectionWrapper == null) { currentConnection = null; } else { currentConnection = mServedInputConnectionWrapper.getInputConnection(); } if (currentConnection != ic) { ic.finishComposingText(); // To avoid modifying the public InputConnection interface if (ic instanceof BaseInputConnection) { Loading Loading @@ -1242,7 +1254,6 @@ 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) { Loading Loading @@ -1413,7 +1424,7 @@ public final class InputMethodManager { return false; } InputConnection ic = null; final ControlledInputConnectionWrapper ic; synchronized (mH) { if (mServedView == mNextServedView && !forceNewFocus) { return false; Loading @@ -1433,7 +1444,7 @@ public final class InputMethodManager { return false; } ic = mServedInputConnection; ic = mServedInputConnectionWrapper; mServedView = mNextServedView; mCurrentTextBoxAttribute = null; Loading Loading @@ -2282,7 +2293,7 @@ public final class InputMethodManager { } else { p.println(" mCurrentTextBoxAttribute: null"); } p.println(" mServedInputConnection=" + mServedInputConnection); p.println(" mServedInputConnectionWrapper=" + mServedInputConnectionWrapper); p.println(" mCompletions=" + Arrays.toString(mCompletions)); p.println(" mCursorRect=" + mCursorRect); p.println(" mCursorSelStart=" + mCursorSelStart Loading core/java/com/android/internal/view/IInputConnectionWrapper.java +9 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ 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; Loading Loading @@ -57,7 +59,8 @@ 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; private WeakReference<InputConnection> mInputConnection; @NonNull private final WeakReference<InputConnection> mInputConnection; private Looper mMainLooper; private Handler mH; Loading Loading @@ -86,6 +89,11 @@ public abstract class IInputConnectionWrapper extends IInputContext.Stub { mH = new MyHandler(mMainLooper); } @Nullable public InputConnection getInputConnection() { return mInputConnection.get(); } abstract protected boolean isActive(); /** Loading Loading
core/java/android/view/inputmethod/InputMethodManager.java +31 −20 Original line number Diff line number Diff line Loading @@ -317,7 +317,6 @@ 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. Loading Loading @@ -498,7 +497,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 // mServedInputConnection.finishComposingText. // mServedInputConnectionWrapper.finishComposingText(). if (checkFocusNoStartInput(mHasBeenInactive, false)) { final int reason = active ? InputMethodClient.START_INPUT_REASON_ACTIVATED_BY_IMMS : Loading Loading @@ -562,7 +561,9 @@ public final class InputMethodManager { @Override public String toString() { return "ControlledInputConnectionWrapper{mActive=" + mActive return "ControlledInputConnectionWrapper{" + "connection=" + getInputConnection() + " mActive=" + mActive + " mParentInputMethodManager.mActive=" + mParentInputMethodManager.mActive + "}"; } Loading Loading @@ -780,7 +781,8 @@ public final class InputMethodManager { */ public boolean isAcceptingText() { checkFocus(); return mServedInputConnection != null; return mServedInputConnectionWrapper != null && mServedInputConnectionWrapper.getInputConnection() != null; } /** Loading Loading @@ -815,7 +817,6 @@ public final class InputMethodManager { */ void clearConnectionLocked() { mCurrentTextBoxAttribute = null; mServedInputConnection = null; if (mServedInputConnectionWrapper != null) { mServedInputConnectionWrapper.deactivate(); mServedInputConnectionWrapper = null; Loading Loading @@ -848,7 +849,13 @@ public final class InputMethodManager { * Notifies the served view that the current InputConnection will no longer be used. */ private void notifyInputConnectionFinished() { if (mServedView != null && mServedInputConnection != null) { if (mServedView == null || mServedInputConnectionWrapper == null) { return; } final InputConnection inputConnection = mServedInputConnectionWrapper.getInputConnection(); if (inputConnection == null) { return; } // 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 Loading @@ -856,8 +863,7 @@ public final class InputMethodManager { ViewRootImpl viewRootImpl = mServedView.getViewRootImpl(); if (viewRootImpl != null) { // This will result in a call to reportFinishInputConnection() below. viewRootImpl.dispatchFinishInputConnection(mServedInputConnection); } viewRootImpl.dispatchFinishInputConnection(inputConnection); } } Loading @@ -866,7 +872,13 @@ public final class InputMethodManager { * @hide */ public void reportFinishInputConnection(InputConnection ic) { if (mServedInputConnection != ic) { final InputConnection currentConnection; if (mServedInputConnectionWrapper == null) { currentConnection = null; } else { currentConnection = mServedInputConnectionWrapper.getInputConnection(); } if (currentConnection != ic) { ic.finishComposingText(); // To avoid modifying the public InputConnection interface if (ic instanceof BaseInputConnection) { Loading Loading @@ -1242,7 +1254,6 @@ 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) { Loading Loading @@ -1413,7 +1424,7 @@ public final class InputMethodManager { return false; } InputConnection ic = null; final ControlledInputConnectionWrapper ic; synchronized (mH) { if (mServedView == mNextServedView && !forceNewFocus) { return false; Loading @@ -1433,7 +1444,7 @@ public final class InputMethodManager { return false; } ic = mServedInputConnection; ic = mServedInputConnectionWrapper; mServedView = mNextServedView; mCurrentTextBoxAttribute = null; Loading Loading @@ -2282,7 +2293,7 @@ public final class InputMethodManager { } else { p.println(" mCurrentTextBoxAttribute: null"); } p.println(" mServedInputConnection=" + mServedInputConnection); p.println(" mServedInputConnectionWrapper=" + mServedInputConnectionWrapper); p.println(" mCompletions=" + Arrays.toString(mCompletions)); p.println(" mCursorRect=" + mCursorRect); p.println(" mCursorSelStart=" + mCursorSelStart Loading
core/java/com/android/internal/view/IInputConnectionWrapper.java +9 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ 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; Loading Loading @@ -57,7 +59,8 @@ 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; private WeakReference<InputConnection> mInputConnection; @NonNull private final WeakReference<InputConnection> mInputConnection; private Looper mMainLooper; private Handler mH; Loading Loading @@ -86,6 +89,11 @@ public abstract class IInputConnectionWrapper extends IInputContext.Stub { mH = new MyHandler(mMainLooper); } @Nullable public InputConnection getInputConnection() { return mInputConnection.get(); } abstract protected boolean isActive(); /** Loading