From e893ec4f8d71f2cbc98ea3368203d92a19d4a0e2 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Mon, 6 Jun 2022 12:48:14 -0700 Subject: [PATCH] Rename IInputContext to IRemoteInputConnection IInputContext is the IPC interface name used behind InputConnection, which was named in the initial development of IME API for Android 1.5. To make it more descriptive and consistent with other classes such as RemoteInputConnection, let's rename it to IRemoteInputConnection. This CL also renames IInputContextInvoker to IRemoteInputConnectionInvoker for consistency. This is a rename of internal IPC interface. There should be no user/developer observable impact. Bug: 234882948 Test: presubmit Change-Id: Iae82d5a26f0746161c2bf91a421b97f0f238aafd --- .../IInputMethodSessionWrapper.java | 9 +- .../IInputMethodWrapper.java | 18 +- .../InputMethodService.java | 6 +- .../RemoteInputConnection.java | 18 +- .../view/inputmethod/InputMethodManager.java | 4 +- .../view/inputmethod/InputMethodSession.java | 8 +- .../InputMethodSessionWrapper.java | 7 +- .../IRemoteInputConnection.aidl} | 5 +- ...ava => IRemoteInputConnectionInvoker.java} | 200 +++++++++--------- .../InputConnectionCommandHeader.java | 9 +- .../RemoteInputConnectionImpl.java | 11 +- .../android/internal/view/IInputMethod.aidl | 4 +- .../internal/view/IInputMethodManager.aidl | 6 +- .../internal/view/IInputMethodSession.aidl | 5 +- .../inputmethod/IInputMethodInvoker.java | 8 +- .../InputMethodManagerService.java | 41 ++-- 16 files changed, 187 insertions(+), 172 deletions(-) rename core/java/com/android/internal/{view/IInputContext.aidl => inputmethod/IRemoteInputConnection.aidl} (98%) rename core/java/com/android/internal/inputmethod/{IInputContextInvoker.java => IRemoteInputConnectionInvoker.java} (71%) diff --git a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java index 9a7ccc64efcd1..48373148ccec1 100644 --- a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java +++ b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java @@ -36,9 +36,9 @@ import android.view.inputmethod.EditorInfo; import android.view.inputmethod.ExtractedText; import android.view.inputmethod.InputMethodSession; +import com.android.internal.inputmethod.IRemoteInputConnection; import com.android.internal.os.HandlerCaller; import com.android.internal.os.SomeArgs; -import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodSession; class IInputMethodSessionWrapper extends IInputMethodSession.Stub @@ -144,7 +144,7 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub final SomeArgs args = (SomeArgs) msg.obj; try { mInputMethodSession.invalidateInputInternal((EditorInfo) args.arg1, - (IInputContext) args.arg2, msg.arg1); + (IRemoteInputConnection) args.arg2, msg.arg1); } finally { args.recycle(); } @@ -221,9 +221,10 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub } @Override - public void invalidateInput(EditorInfo editorInfo, IInputContext inputContext, int sessionId) { + public void invalidateInput(EditorInfo editorInfo, IRemoteInputConnection inputConnection, + int sessionId) { mCaller.executeOrSendMessage(mCaller.obtainMessageIOO( - DO_INVALIDATE_INPUT, sessionId, editorInfo, inputContext)); + DO_INVALIDATE_INPUT, sessionId, editorInfo, inputConnection)); } @Override diff --git a/core/java/android/inputmethodservice/IInputMethodWrapper.java b/core/java/android/inputmethodservice/IInputMethodWrapper.java index 3f49b73a78fcb..bb3a19d58499c 100644 --- a/core/java/android/inputmethodservice/IInputMethodWrapper.java +++ b/core/java/android/inputmethodservice/IInputMethodWrapper.java @@ -41,11 +41,11 @@ import android.window.ImeOnBackInvokedDispatcher; import com.android.internal.inputmethod.CancellationGroup; import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; +import com.android.internal.inputmethod.IRemoteInputConnection; import com.android.internal.inputmethod.InputMethodNavButtonFlags; import com.android.internal.os.HandlerCaller; import com.android.internal.os.SomeArgs; import com.android.internal.view.IInlineSuggestionsRequestCallback; -import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethod; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.IInputSessionCallback; @@ -98,7 +98,7 @@ class IInputMethodWrapper extends IInputMethod.Stub * *

This field must be set and cleared only from the binder thread(s), where the system * guarantees that {@link #bindInput(InputBinding)}, - * {@link #startInput(IBinder, IInputContext, int, EditorInfo, boolean, boolean)}, and + * {@link #startInput(IBinder, IRemoteInputConnection, int, EditorInfo, boolean, boolean)}, and * {@link #unbindInput()} are called with the same order as the original calls * in {@link com.android.server.inputmethod.InputMethodManagerService}. * See {@link IBinder#FLAG_ONEWAY} for detailed semantics.

@@ -195,7 +195,8 @@ class IInputMethodWrapper extends IInputMethod.Stub case DO_START_INPUT: { final SomeArgs args = (SomeArgs) msg.obj; final IBinder startInputToken = (IBinder) args.arg1; - final IInputContext inputContext = (IInputContext) ((SomeArgs) args.arg2).arg1; + final IRemoteInputConnection remoteIc = + (IRemoteInputConnection) ((SomeArgs) args.arg2).arg1; final ImeOnBackInvokedDispatcher imeDispatcher = (ImeOnBackInvokedDispatcher) ((SomeArgs) args.arg2).arg2; final EditorInfo info = (EditorInfo) args.arg3; @@ -203,8 +204,8 @@ class IInputMethodWrapper extends IInputMethod.Stub final boolean restarting = args.argi5 == 1; @InputMethodNavButtonFlags final int navButtonFlags = args.argi6; - final InputConnection ic = inputContext != null - ? new RemoteInputConnection(mTarget, inputContext, cancellationGroup) + final InputConnection ic = remoteIc != null + ? new RemoteInputConnection(mTarget, remoteIc, cancellationGroup) : null; info.makeCompatible(mTargetSdkVersion); inputMethod.dispatchStartInputWithToken(ic, info, restarting, startInputToken, @@ -329,7 +330,8 @@ class IInputMethodWrapper extends IInputMethod.Stub } mCancellationGroup = new CancellationGroup(); InputConnection ic = new RemoteInputConnection(mTarget, - IInputContext.Stub.asInterface(binding.getConnectionToken()), mCancellationGroup); + IRemoteInputConnection.Stub.asInterface(binding.getConnectionToken()), + mCancellationGroup); InputBinding nu = new InputBinding(ic, binding); mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_INPUT_CONTEXT, nu)); } @@ -349,7 +351,7 @@ class IInputMethodWrapper extends IInputMethod.Stub @BinderThread @Override - public void startInput(IBinder startInputToken, IInputContext inputContext, + public void startInput(IBinder startInputToken, IRemoteInputConnection inputConnection, EditorInfo attribute, boolean restarting, @InputMethodNavButtonFlags int navButtonFlags, @NonNull ImeOnBackInvokedDispatcher imeDispatcher) { @@ -358,7 +360,7 @@ class IInputMethodWrapper extends IInputMethod.Stub mCancellationGroup = new CancellationGroup(); } SomeArgs args = SomeArgs.obtain(); - args.arg1 = inputContext; + args.arg1 = inputConnection; args.arg2 = imeDispatcher; mCaller.executeOrSendMessage(mCaller.obtainMessageOOOOII(DO_START_INPUT, startInputToken, args, attribute, mCancellationGroup, restarting ? 1 : 0, navButtonFlags)); diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 04f39a0e986a9..29bf3e7b4fd31 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -143,6 +143,7 @@ import android.window.WindowMetricsHelper; import com.android.internal.annotations.GuardedBy; import com.android.internal.inputmethod.IInputContentUriToken; import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; +import com.android.internal.inputmethod.IRemoteInputConnection; import com.android.internal.inputmethod.ImeTracing; import com.android.internal.inputmethod.InputMethodNavButtonFlags; import com.android.internal.inputmethod.InputMethodPrivilegedOperations; @@ -150,7 +151,6 @@ import com.android.internal.inputmethod.InputMethodPrivilegedOperationsRegistry; import com.android.internal.inputmethod.SoftInputShowHideReason; import com.android.internal.util.RingBuffer; import com.android.internal.view.IInlineSuggestionsRequestCallback; -import com.android.internal.view.IInputContext; import com.android.internal.view.InlineSuggestionsRequestInfo; import java.io.FileDescriptor; @@ -1255,10 +1255,10 @@ public class InputMethodService extends AbstractInputMethodService { */ @Override public final void invalidateInputInternal(@NonNull EditorInfo editorInfo, - @NonNull IInputContext inputContext, int sessionId) { + @NonNull IRemoteInputConnection inputConnection, int sessionId) { if (mStartedInputConnection instanceof RemoteInputConnection) { final RemoteInputConnection ric = (RemoteInputConnection) mStartedInputConnection; - if (!ric.isSameConnection(inputContext)) { + if (!ric.isSameConnection(inputConnection)) { // This is not an error, and can be safely ignored. if (DEBUG) { Log.d(TAG, "ignoring invalidateInput() due to context mismatch."); diff --git a/core/java/android/inputmethodservice/RemoteInputConnection.java b/core/java/android/inputmethodservice/RemoteInputConnection.java index 86e59e9dcf2f5..d13da3fb3ce22 100644 --- a/core/java/android/inputmethodservice/RemoteInputConnection.java +++ b/core/java/android/inputmethodservice/RemoteInputConnection.java @@ -35,10 +35,10 @@ import android.view.inputmethod.TextAttribute; import com.android.internal.inputmethod.CancellationGroup; import com.android.internal.inputmethod.CompletableFutureUtil; -import com.android.internal.inputmethod.IInputContextInvoker; +import com.android.internal.inputmethod.IRemoteInputConnection; +import com.android.internal.inputmethod.IRemoteInputConnectionInvoker; import com.android.internal.inputmethod.ImeTracing; import com.android.internal.inputmethod.InputConnectionProtoDumper; -import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethod; import java.lang.ref.WeakReference; @@ -51,8 +51,8 @@ import java.util.concurrent.CompletableFuture; * {@link com.android.internal.inputmethod.RemoteInputConnectionImpl} running on the IME client * (editor app) process then waits replies as needed.

* - *

See also {@link IInputContext} for the actual {@link android.os.Binder} IPC protocols under - * the hood.

+ *

See also {@link IRemoteInputConnection} for the actual {@link android.os.Binder} IPC protocols + * under the hood.

*/ final class RemoteInputConnection implements InputConnection { private static final String TAG = "RemoteInputConnection"; @@ -60,7 +60,7 @@ final class RemoteInputConnection implements InputConnection { private static final int MAX_WAIT_TIME_MILLIS = 2000; @NonNull - private final IInputContextInvoker mInvoker; + private final IRemoteInputConnectionInvoker mInvoker; private static final class InputMethodServiceInternalHolder { @NonNull @@ -97,15 +97,15 @@ final class RemoteInputConnection implements InputConnection { RemoteInputConnection( @NonNull WeakReference inputMethodService, - IInputContext inputContext, @NonNull CancellationGroup cancellationGroup) { + IRemoteInputConnection inputConnection, @NonNull CancellationGroup cancellationGroup) { mImsInternal = new InputMethodServiceInternalHolder(inputMethodService); - mInvoker = IInputContextInvoker.create(inputContext); + mInvoker = IRemoteInputConnectionInvoker.create(inputConnection); mCancellationGroup = cancellationGroup; } @AnyThread - public boolean isSameConnection(@NonNull IInputContext inputContext) { - return mInvoker.isSameConnection(inputContext); + public boolean isSameConnection(@NonNull IRemoteInputConnection inputConnection) { + return mInvoker.isSameConnection(inputConnection); } RemoteInputConnection(@NonNull RemoteInputConnection original, int sessionId) { diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 39b97ebfe3044..1e426a4063839 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -108,7 +108,6 @@ import com.android.internal.inputmethod.StartInputFlags; import com.android.internal.inputmethod.StartInputReason; import com.android.internal.inputmethod.UnbindReason; import com.android.internal.os.SomeArgs; -import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodSession; @@ -283,7 +282,8 @@ public final class InputMethodManager { /** * Provide this to {@link IInputMethodManager#startInputOrWindowGainedFocus( - * int, IInputMethodClient, IBinder, int, int, int, EditorInfo, IInputContext, int)} to receive + * int, IInputMethodClient, IBinder, int, int, int, EditorInfo, + * com.android.internal.inputmethod.IRemoteInputConnection, int)} to receive * {@link android.window.OnBackInvokedCallback} registrations from IME. */ private final ImeOnBackInvokedDispatcher mImeDispatcher = diff --git a/core/java/android/view/inputmethod/InputMethodSession.java b/core/java/android/view/inputmethod/InputMethodSession.java index 28c44507e43cb..af6af14472db9 100644 --- a/core/java/android/view/inputmethod/InputMethodSession.java +++ b/core/java/android/view/inputmethod/InputMethodSession.java @@ -22,7 +22,7 @@ import android.os.Bundle; import android.view.KeyEvent; import android.view.MotionEvent; -import com.android.internal.view.IInputContext; +import com.android.internal.inputmethod.IRemoteInputConnection; /** * The InputMethodSession interface provides the per-client functionality @@ -207,12 +207,12 @@ public interface InputMethodSession { * {@link InputConnection} due to a stale callback.

* * @param editorInfo {@link EditorInfo} to be used - * @param inputContext specifies which {@link InputConnection} is being updated. + * @param inputConnection specifies which {@link InputConnection} is being updated. * @param sessionId the ID to be specified to * {@link com.android.internal.inputmethod.InputConnectionCommandHeader}. * @hide */ - default void invalidateInputInternal(EditorInfo editorInfo, IInputContext inputContext, - int sessionId) { + default void invalidateInputInternal(EditorInfo editorInfo, + IRemoteInputConnection inputConnection, int sessionId) { } } diff --git a/core/java/android/view/inputmethod/InputMethodSessionWrapper.java b/core/java/android/view/inputmethod/InputMethodSessionWrapper.java index ee22b65085494..081a6e6388f7f 100644 --- a/core/java/android/view/inputmethod/InputMethodSessionWrapper.java +++ b/core/java/android/view/inputmethod/InputMethodSessionWrapper.java @@ -24,7 +24,7 @@ import android.os.Bundle; import android.os.RemoteException; import android.util.Log; -import com.android.internal.view.IInputContext; +import com.android.internal.inputmethod.IRemoteInputConnection; import com.android.internal.view.IInputMethodSession; /** @@ -135,9 +135,10 @@ final class InputMethodSessionWrapper { } @AnyThread - void invalidateInput(EditorInfo editorInfo, IInputContext inputContext, int sessionId) { + void invalidateInput(EditorInfo editorInfo, IRemoteInputConnection inputConnection, + int sessionId) { try { - mSession.invalidateInput(editorInfo, inputContext, sessionId); + mSession.invalidateInput(editorInfo, inputConnection, sessionId); } catch (RemoteException e) { Log.w(TAG, "IME died", e); } diff --git a/core/java/com/android/internal/view/IInputContext.aidl b/core/java/com/android/internal/inputmethod/IRemoteInputConnection.aidl similarity index 98% rename from core/java/com/android/internal/view/IInputContext.aidl rename to core/java/com/android/internal/inputmethod/IRemoteInputConnection.aidl index 909a5379993c5..a7dd6f13b02de 100644 --- a/core/java/com/android/internal/view/IInputContext.aidl +++ b/core/java/com/android/internal/inputmethod/IRemoteInputConnection.aidl @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.internal.view; +package com.android.internal.inputmethod; import android.os.Bundle; import android.view.KeyEvent; @@ -30,9 +30,8 @@ import com.android.internal.inputmethod.InputConnectionCommandHeader; /** * Interface from an input method to the application, allowing it to perform * edits on the current input field and other interactions with the application. - * {@hide} */ - oneway interface IInputContext { + oneway interface IRemoteInputConnection { void getTextBeforeCursor(in InputConnectionCommandHeader header, int length, int flags, in AndroidFuture future /* T=CharSequence */); diff --git a/core/java/com/android/internal/inputmethod/IInputContextInvoker.java b/core/java/com/android/internal/inputmethod/IRemoteInputConnectionInvoker.java similarity index 71% rename from core/java/com/android/internal/inputmethod/IInputContextInvoker.java rename to core/java/com/android/internal/inputmethod/IRemoteInputConnectionInvoker.java index e8838c8bfcaea..b10a8c8f96d2c 100644 --- a/core/java/com/android/internal/inputmethod/IInputContextInvoker.java +++ b/core/java/com/android/internal/inputmethod/IRemoteInputConnectionInvoker.java @@ -31,58 +31,60 @@ import android.view.inputmethod.SurroundingText; import android.view.inputmethod.TextAttribute; import com.android.internal.infra.AndroidFuture; -import com.android.internal.view.IInputContext; import java.util.Objects; /** - * A stateless wrapper of {@link com.android.internal.view.IInputContext} to encapsulate boilerplate - * code around {@link AndroidFuture} and {@link RemoteException}. + * A stateless wrapper of {@link com.android.internal.inputmethod.IRemoteInputConnection} to + * encapsulate boilerplate code around {@link AndroidFuture} and {@link RemoteException}. */ -public final class IInputContextInvoker { +public final class IRemoteInputConnectionInvoker { @NonNull - private final IInputContext mIInputContext; + private final IRemoteInputConnection mConnection; private final int mSessionId; - private IInputContextInvoker(@NonNull IInputContext inputContext, int sessionId) { - mIInputContext = inputContext; + private IRemoteInputConnectionInvoker(@NonNull IRemoteInputConnection inputConnection, + int sessionId) { + mConnection = inputConnection; mSessionId = sessionId; } /** - * Creates a new instance of {@link IInputContextInvoker} for the given {@link IInputContext}. + * Creates a new instance of {@link IRemoteInputConnectionInvoker} for the given + * {@link IRemoteInputConnection}. * - * @param inputContext {@link IInputContext} to be wrapped. - * @return A new instance of {@link IInputContextInvoker}. + * @param connection {@link IRemoteInputConnection} to be wrapped. + * @return A new instance of {@link IRemoteInputConnectionInvoker}. */ - public static IInputContextInvoker create(@NonNull IInputContext inputContext) { - Objects.requireNonNull(inputContext); - return new IInputContextInvoker(inputContext, 0); + public static IRemoteInputConnectionInvoker create(@NonNull IRemoteInputConnection connection) { + Objects.requireNonNull(connection); + return new IRemoteInputConnectionInvoker(connection, 0); } /** - * Creates a new instance of {@link IInputContextInvoker} with the given {@code sessionId}. + * Creates a new instance of {@link IRemoteInputConnectionInvoker} with the given + * {@code sessionId}. * * @param sessionId the new session ID to be used. - * @return A new instance of {@link IInputContextInvoker}. + * @return A new instance of {@link IRemoteInputConnectionInvoker}. */ @NonNull - public IInputContextInvoker cloneWithSessionId(int sessionId) { - return new IInputContextInvoker(mIInputContext, sessionId); + public IRemoteInputConnectionInvoker cloneWithSessionId(int sessionId) { + return new IRemoteInputConnectionInvoker(mConnection, sessionId); } /** - * @param inputContext {@code IInputContext} to be compared with - * @return {@code true} if the underlying {@code IInputContext} is the same. {@code false} if - * {@code inputContext} is {@code null}. + * @param connection {@code IRemoteInputConnection} to be compared with + * @return {@code true} if the underlying {@code IRemoteInputConnection} is the same. + * {@code false} if {@code inputContext} is {@code null}. */ @AnyThread - public boolean isSameConnection(@NonNull IInputContext inputContext) { - if (inputContext == null) { + public boolean isSameConnection(@NonNull IRemoteInputConnection connection) { + if (connection == null) { return false; } - return mIInputContext.asBinder() == inputContext.asBinder(); + return mConnection.asBinder() == connection.asBinder(); } @NonNull @@ -91,8 +93,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#getTextAfterCursor(InputConnectionCommandHeader, int, int, - * AndroidFuture)}. + * Invokes {@link IRemoteInputConnection#getTextAfterCursor(InputConnectionCommandHeader, int, + * int, AndroidFuture)}. * * @param length {@code length} parameter to be passed. * @param flags {@code flags} parameter to be passed. @@ -104,7 +106,7 @@ public final class IInputContextInvoker { public AndroidFuture getTextAfterCursor(int length, int flags) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getTextAfterCursor(createHeader(), length, flags, future); + mConnection.getTextAfterCursor(createHeader(), length, flags, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -112,8 +114,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#getTextBeforeCursor(InputConnectionCommandHeader, int, int, - * AndroidFuture)}. + * Invokes {@link IRemoteInputConnection#getTextBeforeCursor(InputConnectionCommandHeader, int, + * int, AndroidFuture)}. * * @param length {@code length} parameter to be passed. * @param flags {@code flags} parameter to be passed. @@ -125,7 +127,7 @@ public final class IInputContextInvoker { public AndroidFuture getTextBeforeCursor(int length, int flags) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getTextBeforeCursor(createHeader(), length, flags, future); + mConnection.getTextBeforeCursor(createHeader(), length, flags, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -133,8 +135,8 @@ public final class IInputContextInvoker { } /** - * Invokes - * {@link IInputContext#getSelectedText(InputConnectionCommandHeader, int, AndroidFuture)}. + * Invokes {@link IRemoteInputConnection#getSelectedText(InputConnectionCommandHeader, int, + * AndroidFuture)}. * * @param flags {@code flags} parameter to be passed. * @return {@link AndroidFuture} that can be used to retrieve the invocation @@ -145,7 +147,7 @@ public final class IInputContextInvoker { public AndroidFuture getSelectedText(int flags) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getSelectedText(createHeader(), flags, future); + mConnection.getSelectedText(createHeader(), flags, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -154,7 +156,7 @@ public final class IInputContextInvoker { /** * Invokes - * {@link IInputContext#getSurroundingText(InputConnectionCommandHeader, int, int, int, + * {@link IRemoteInputConnection#getSurroundingText(InputConnectionCommandHeader, int, int, int, * AndroidFuture)}. * * @param beforeLength {@code beforeLength} parameter to be passed. @@ -169,7 +171,7 @@ public final class IInputContextInvoker { int flags) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getSurroundingText(createHeader(), beforeLength, afterLength, flags, + mConnection.getSurroundingText(createHeader(), beforeLength, afterLength, flags, future); } catch (RemoteException e) { future.completeExceptionally(e); @@ -178,8 +180,8 @@ public final class IInputContextInvoker { } /** - * Invokes - * {@link IInputContext#getCursorCapsMode(InputConnectionCommandHeader, int, AndroidFuture)}. + * Invokes {@link IRemoteInputConnection#getCursorCapsMode(InputConnectionCommandHeader, int, + * AndroidFuture)}. * * @param reqModes {@code reqModes} parameter to be passed. * @return {@link AndroidFuture} that can be used to retrieve the invocation @@ -190,7 +192,7 @@ public final class IInputContextInvoker { public AndroidFuture getCursorCapsMode(int reqModes) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getCursorCapsMode(createHeader(), reqModes, future); + mConnection.getCursorCapsMode(createHeader(), reqModes, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -198,7 +200,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#getExtractedText(InputConnectionCommandHeader, + * Invokes {@link IRemoteInputConnection#getExtractedText(InputConnectionCommandHeader, * ExtractedTextRequest, int, AndroidFuture)}. * * @param request {@code request} parameter to be passed. @@ -212,7 +214,7 @@ public final class IInputContextInvoker { int flags) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getExtractedText(createHeader(), request, flags, future); + mConnection.getExtractedText(createHeader(), request, flags, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -220,7 +222,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#commitText(InputConnectionCommandHeader, CharSequence, int)}. + * Invokes + * {@link IRemoteInputConnection#commitText(InputConnectionCommandHeader, CharSequence, int)}. * * @param text {@code text} parameter to be passed. * @param newCursorPosition {@code newCursorPosition} parameter to be passed. @@ -230,7 +233,7 @@ public final class IInputContextInvoker { @AnyThread public boolean commitText(CharSequence text, int newCursorPosition) { try { - mIInputContext.commitText(createHeader(), text, newCursorPosition); + mConnection.commitText(createHeader(), text, newCursorPosition); return true; } catch (RemoteException e) { return false; @@ -238,8 +241,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#commitTextWithTextAttribute(InputConnectionCommandHeader, int, - * CharSequence)}. + * Invokes {@link IRemoteInputConnection#commitTextWithTextAttribute( + * InputConnectionCommandHeader, int, CharSequence)}. * * @param text {@code text} parameter to be passed. * @param newCursorPosition {@code newCursorPosition} parameter to be passed. @@ -251,7 +254,7 @@ public final class IInputContextInvoker { public boolean commitText(CharSequence text, int newCursorPosition, @Nullable TextAttribute textAttribute) { try { - mIInputContext.commitTextWithTextAttribute( + mConnection.commitTextWithTextAttribute( createHeader(), text, newCursorPosition, textAttribute); return true; } catch (RemoteException e) { @@ -260,7 +263,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#commitCompletion(InputConnectionCommandHeader, CompletionInfo)}. + * Invokes {@link IRemoteInputConnection#commitCompletion(InputConnectionCommandHeader, + * CompletionInfo)}. * * @param text {@code text} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -269,7 +273,7 @@ public final class IInputContextInvoker { @AnyThread public boolean commitCompletion(CompletionInfo text) { try { - mIInputContext.commitCompletion(createHeader(), text); + mConnection.commitCompletion(createHeader(), text); return true; } catch (RemoteException e) { return false; @@ -277,7 +281,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#commitCorrection(InputConnectionCommandHeader, CorrectionInfo)}. + * Invokes {@link IRemoteInputConnection#commitCorrection(InputConnectionCommandHeader, + * CorrectionInfo)}. * * @param correctionInfo {@code correctionInfo} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -286,7 +291,7 @@ public final class IInputContextInvoker { @AnyThread public boolean commitCorrection(CorrectionInfo correctionInfo) { try { - mIInputContext.commitCorrection(createHeader(), correctionInfo); + mConnection.commitCorrection(createHeader(), correctionInfo); return true; } catch (RemoteException e) { return false; @@ -294,7 +299,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#setSelection(InputConnectionCommandHeader, int, int)}. + * Invokes {@link IRemoteInputConnection#setSelection(InputConnectionCommandHeader, int, int)}. * * @param start {@code start} parameter to be passed. * @param end {@code start} parameter to be passed. @@ -304,7 +309,7 @@ public final class IInputContextInvoker { @AnyThread public boolean setSelection(int start, int end) { try { - mIInputContext.setSelection(createHeader(), start, end); + mConnection.setSelection(createHeader(), start, end); return true; } catch (RemoteException e) { return false; @@ -312,7 +317,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#performEditorAction(InputConnectionCommandHeader, int)}. + * Invokes + * {@link IRemoteInputConnection#performEditorAction(InputConnectionCommandHeader, int)}. * * @param actionCode {@code start} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -321,7 +327,7 @@ public final class IInputContextInvoker { @AnyThread public boolean performEditorAction(int actionCode) { try { - mIInputContext.performEditorAction(createHeader(), actionCode); + mConnection.performEditorAction(createHeader(), actionCode); return true; } catch (RemoteException e) { return false; @@ -329,7 +335,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#performContextMenuAction(InputConnectionCommandHeader, int)}. + * Invokes + * {@link IRemoteInputConnection#performContextMenuAction(InputConnectionCommandHeader, int)}. * * @param id {@code id} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -338,7 +345,7 @@ public final class IInputContextInvoker { @AnyThread public boolean performContextMenuAction(int id) { try { - mIInputContext.performContextMenuAction(createHeader(), id); + mConnection.performContextMenuAction(createHeader(), id); return true; } catch (RemoteException e) { return false; @@ -346,7 +353,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#setComposingRegion(InputConnectionCommandHeader, int, int)}. + * Invokes + * {@link IRemoteInputConnection#setComposingRegion(InputConnectionCommandHeader, int, int)}. * * @param start {@code id} parameter to be passed. * @param end {@code id} parameter to be passed. @@ -356,7 +364,7 @@ public final class IInputContextInvoker { @AnyThread public boolean setComposingRegion(int start, int end) { try { - mIInputContext.setComposingRegion(createHeader(), start, end); + mConnection.setComposingRegion(createHeader(), start, end); return true; } catch (RemoteException e) { return false; @@ -364,7 +372,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#setComposingRegionWithTextAttribute( + * Invokes {@link IRemoteInputConnection#setComposingRegionWithTextAttribute( * InputConnectionCommandHeader, int, int, TextAttribute)}. * * @param start {@code id} parameter to be passed. @@ -376,7 +384,7 @@ public final class IInputContextInvoker { @AnyThread public boolean setComposingRegion(int start, int end, @Nullable TextAttribute textAttribute) { try { - mIInputContext.setComposingRegionWithTextAttribute( + mConnection.setComposingRegionWithTextAttribute( createHeader(), start, end, textAttribute); return true; } catch (RemoteException e) { @@ -385,8 +393,8 @@ public final class IInputContextInvoker { } /** - * Invokes - * {@link IInputContext#setComposingText(InputConnectionCommandHeader, CharSequence, int)}. + * Invokes {@link IRemoteInputConnection#setComposingText(InputConnectionCommandHeader, + * CharSequence, int)}. * * @param text {@code text} parameter to be passed. * @param newCursorPosition {@code newCursorPosition} parameter to be passed. @@ -396,7 +404,7 @@ public final class IInputContextInvoker { @AnyThread public boolean setComposingText(CharSequence text, int newCursorPosition) { try { - mIInputContext.setComposingText(createHeader(), text, newCursorPosition); + mConnection.setComposingText(createHeader(), text, newCursorPosition); return true; } catch (RemoteException e) { return false; @@ -404,8 +412,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#setComposingTextWithTextAttribute(InputConnectionCommandHeader, - * CharSequence, int, TextAttribute)}. + * Invokes {@link IRemoteInputConnection#setComposingTextWithTextAttribute( + * InputConnectionCommandHeader, CharSequence, int, TextAttribute)}. * * @param text {@code text} parameter to be passed. * @param newCursorPosition {@code newCursorPosition} parameter to be passed. @@ -417,7 +425,7 @@ public final class IInputContextInvoker { public boolean setComposingText(CharSequence text, int newCursorPosition, @Nullable TextAttribute textAttribute) { try { - mIInputContext.setComposingTextWithTextAttribute( + mConnection.setComposingTextWithTextAttribute( createHeader(), text, newCursorPosition, textAttribute); return true; } catch (RemoteException e) { @@ -426,7 +434,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#finishComposingText(InputConnectionCommandHeader)}. + * Invokes {@link IRemoteInputConnection#finishComposingText(InputConnectionCommandHeader)}. * * @return {@code true} if the invocation is completed without {@link RemoteException}. * {@code false} otherwise. @@ -434,7 +442,7 @@ public final class IInputContextInvoker { @AnyThread public boolean finishComposingText() { try { - mIInputContext.finishComposingText(createHeader()); + mConnection.finishComposingText(createHeader()); return true; } catch (RemoteException e) { return false; @@ -442,7 +450,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#beginBatchEdit(InputConnectionCommandHeader)}. + * Invokes {@link IRemoteInputConnection#beginBatchEdit(InputConnectionCommandHeader)}. * * @return {@code true} if the invocation is completed without {@link RemoteException}. * {@code false} otherwise. @@ -450,7 +458,7 @@ public final class IInputContextInvoker { @AnyThread public boolean beginBatchEdit() { try { - mIInputContext.beginBatchEdit(createHeader()); + mConnection.beginBatchEdit(createHeader()); return true; } catch (RemoteException e) { return false; @@ -458,7 +466,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#endBatchEdit(InputConnectionCommandHeader)}. + * Invokes {@link IRemoteInputConnection#endBatchEdit(InputConnectionCommandHeader)}. * * @return {@code true} if the invocation is completed without {@link RemoteException}. * {@code false} otherwise. @@ -466,7 +474,7 @@ public final class IInputContextInvoker { @AnyThread public boolean endBatchEdit() { try { - mIInputContext.endBatchEdit(createHeader()); + mConnection.endBatchEdit(createHeader()); return true; } catch (RemoteException e) { return false; @@ -474,7 +482,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#sendKeyEvent(InputConnectionCommandHeader, KeyEvent)}. + * Invokes {@link IRemoteInputConnection#sendKeyEvent(InputConnectionCommandHeader, KeyEvent)}. * * @param event {@code event} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -483,7 +491,7 @@ public final class IInputContextInvoker { @AnyThread public boolean sendKeyEvent(KeyEvent event) { try { - mIInputContext.sendKeyEvent(createHeader(), event); + mConnection.sendKeyEvent(createHeader(), event); return true; } catch (RemoteException e) { return false; @@ -491,7 +499,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#clearMetaKeyStates(InputConnectionCommandHeader, int)}. + * Invokes {@link IRemoteInputConnection#clearMetaKeyStates(InputConnectionCommandHeader, int)}. * * @param states {@code states} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -500,7 +508,7 @@ public final class IInputContextInvoker { @AnyThread public boolean clearMetaKeyStates(int states) { try { - mIInputContext.clearMetaKeyStates(createHeader(), states); + mConnection.clearMetaKeyStates(createHeader(), states); return true; } catch (RemoteException e) { return false; @@ -508,7 +516,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#deleteSurroundingText(InputConnectionCommandHeader, int, int)}. + * Invokes + * {@link IRemoteInputConnection#deleteSurroundingText(InputConnectionCommandHeader, int, int)}. * * @param beforeLength {@code beforeLength} parameter to be passed. * @param afterLength {@code afterLength} parameter to be passed. @@ -518,7 +527,7 @@ public final class IInputContextInvoker { @AnyThread public boolean deleteSurroundingText(int beforeLength, int afterLength) { try { - mIInputContext.deleteSurroundingText(createHeader(), beforeLength, afterLength); + mConnection.deleteSurroundingText(createHeader(), beforeLength, afterLength); return true; } catch (RemoteException e) { return false; @@ -526,8 +535,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#deleteSurroundingTextInCodePoints(InputConnectionCommandHeader, - * int, int)}. + * Invokes {@link IRemoteInputConnection#deleteSurroundingTextInCodePoints( + * InputConnectionCommandHeader, int, int)}. * * @param beforeLength {@code beforeLength} parameter to be passed. * @param afterLength {@code afterLength} parameter to be passed. @@ -537,7 +546,7 @@ public final class IInputContextInvoker { @AnyThread public boolean deleteSurroundingTextInCodePoints(int beforeLength, int afterLength) { try { - mIInputContext.deleteSurroundingTextInCodePoints(createHeader(), beforeLength, + mConnection.deleteSurroundingTextInCodePoints(createHeader(), beforeLength, afterLength); return true; } catch (RemoteException e) { @@ -546,7 +555,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#performSpellCheck(InputConnectionCommandHeader)}. + * Invokes {@link IRemoteInputConnection#performSpellCheck(InputConnectionCommandHeader)}. * * @return {@code true} if the invocation is completed without {@link RemoteException}. * {@code false} otherwise. @@ -554,7 +563,7 @@ public final class IInputContextInvoker { @AnyThread public boolean performSpellCheck() { try { - mIInputContext.performSpellCheck(createHeader()); + mConnection.performSpellCheck(createHeader()); return true; } catch (RemoteException e) { return false; @@ -562,8 +571,8 @@ public final class IInputContextInvoker { } /** - * Invokes - * {@link IInputContext#performPrivateCommand(InputConnectionCommandHeader, String, Bundle)}. + * Invokes {@link IRemoteInputConnection#performPrivateCommand(InputConnectionCommandHeader, + * String, Bundle)}. * * @param action {@code action} parameter to be passed. * @param data {@code data} parameter to be passed. @@ -573,7 +582,7 @@ public final class IInputContextInvoker { @AnyThread public boolean performPrivateCommand(String action, Bundle data) { try { - mIInputContext.performPrivateCommand(createHeader(), action, data); + mConnection.performPrivateCommand(createHeader(), action, data); return true; } catch (RemoteException e) { return false; @@ -581,8 +590,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#requestCursorUpdates(InputConnectionCommandHeader, int, int, - * AndroidFuture)}. + * Invokes {@link IRemoteInputConnection#requestCursorUpdates(InputConnectionCommandHeader, int, + * int, AndroidFuture)}. * * @param cursorUpdateMode {@code cursorUpdateMode} parameter to be passed. * @param imeDisplayId the display ID that is associated with the IME. @@ -594,7 +603,7 @@ public final class IInputContextInvoker { public AndroidFuture requestCursorUpdates(int cursorUpdateMode, int imeDisplayId) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.requestCursorUpdates(createHeader(), cursorUpdateMode, imeDisplayId, + mConnection.requestCursorUpdates(createHeader(), cursorUpdateMode, imeDisplayId, future); } catch (RemoteException e) { future.completeExceptionally(e); @@ -603,8 +612,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#requestCursorUpdatesWithFilter(InputConnectionCommandHeader, - * int, int, int, AndroidFuture)}. + * Invokes {@link IRemoteInputConnection#requestCursorUpdatesWithFilter( + * InputConnectionCommandHeader, int, int, int, AndroidFuture)}. * * @param cursorUpdateMode {@code cursorUpdateMode} parameter to be passed. * @param cursorUpdateFilter {@code cursorUpdateFilter} parameter to be passed. @@ -618,7 +627,7 @@ public final class IInputContextInvoker { int imeDisplayId) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.requestCursorUpdatesWithFilter(createHeader(), cursorUpdateMode, + mConnection.requestCursorUpdatesWithFilter(createHeader(), cursorUpdateMode, cursorUpdateFilter, imeDisplayId, future); } catch (RemoteException e) { future.completeExceptionally(e); @@ -627,8 +636,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#commitContent(InputConnectionCommandHeader, InputContentInfo, - * int, Bundle, AndroidFuture)}. + * Invokes {@link IRemoteInputConnection#commitContent(InputConnectionCommandHeader, + * InputContentInfo, int, Bundle, AndroidFuture)}. * * @param inputContentInfo {@code inputContentInfo} parameter to be passed. * @param flags {@code flags} parameter to be passed. @@ -642,7 +651,7 @@ public final class IInputContextInvoker { Bundle opts) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.commitContent(createHeader(), inputContentInfo, flags, opts, future); + mConnection.commitContent(createHeader(), inputContentInfo, flags, opts, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -650,7 +659,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#setImeConsumesInput(InputConnectionCommandHeader, boolean)}. + * Invokes + * {@link IRemoteInputConnection#setImeConsumesInput(InputConnectionCommandHeader, boolean)}. * * @param imeConsumesInput {@code imeConsumesInput} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -659,7 +669,7 @@ public final class IInputContextInvoker { @AnyThread public boolean setImeConsumesInput(boolean imeConsumesInput) { try { - mIInputContext.setImeConsumesInput(createHeader(), imeConsumesInput); + mConnection.setImeConsumesInput(createHeader(), imeConsumesInput); return true; } catch (RemoteException e) { return false; diff --git a/core/java/com/android/internal/inputmethod/InputConnectionCommandHeader.java b/core/java/com/android/internal/inputmethod/InputConnectionCommandHeader.java index d9141bd7a8fa7..59121771a697e 100644 --- a/core/java/com/android/internal/inputmethod/InputConnectionCommandHeader.java +++ b/core/java/com/android/internal/inputmethod/InputConnectionCommandHeader.java @@ -27,12 +27,13 @@ import android.os.Parcelable; public final class InputConnectionCommandHeader implements Parcelable { /** * An identifier that is to be used when multiplexing multiple sessions into a single - * {@link com.android.internal.view.IInputContext}. + * {@link com.android.internal.inputmethod.IRemoteInputConnection}. * *

This ID is considered to belong to an implicit namespace defined for each - * {@link com.android.internal.view.IInputContext} instance. Uniqueness of the session ID - * across multiple instances of {@link com.android.internal.view.IInputContext} is not - * guaranteed unless explicitly noted in a higher layer.

+ * {@link com.android.internal.inputmethod.IRemoteInputConnection} instance. Uniqueness of the + * session ID across multiple instances of + * {@link com.android.internal.inputmethod.IRemoteInputConnection} is not guaranteed unless + * explicitly noted in a higher layer.

*/ public final int mSessionId; diff --git a/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java b/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java index f21cee9971638..cb18ccc9788a1 100644 --- a/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java +++ b/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java @@ -49,7 +49,6 @@ import android.view.inputmethod.TextSnapshot; import com.android.internal.annotations.GuardedBy; import com.android.internal.infra.AndroidFuture; -import com.android.internal.view.IInputContext; import java.lang.annotation.Retention; import java.lang.ref.WeakReference; @@ -62,10 +61,10 @@ import java.util.function.Supplier; * Takes care of remote method invocations of {@link InputConnection} in the IME client side. * *

{@link android.inputmethodservice.RemoteInputConnection} code is executed in the IME process. - * It makes IInputContext binder calls under the hood. {@link RemoteInputConnectionImpl} receives - * {@link IInputContext} binder calls in the IME client (editor app) process, and forwards them to - * {@link InputConnection} that the IME client provided, on the {@link Looper} associated to the - * {@link InputConnection}.

+ * It makes {@link IRemoteInputConnection} binder calls under the hood. + * {@link RemoteInputConnectionImpl} receives {@link IRemoteInputConnection} binder calls in the IME + * client (editor app) process, and forwards them to {@link InputConnection} that the IME client + * provided, on the {@link Looper} associated to the {@link InputConnection}.

* *

{@link com.android.internal.inputmethod.RemoteAccessibilityInputConnection} code is executed * in the {@link android.accessibilityservice.AccessibilityService} process. It makes @@ -74,7 +73,7 @@ import java.util.function.Supplier; * (editor app) process, and forwards them to {@link InputConnection} that the IME client provided, * on the {@link Looper} associated to the {@link InputConnection}.

*/ -public final class RemoteInputConnectionImpl extends IInputContext.Stub { +public final class RemoteInputConnectionImpl extends IRemoteInputConnection.Stub { private static final String TAG = "RemoteInputConnectionImpl"; private static final boolean DEBUG = false; diff --git a/core/java/com/android/internal/view/IInputMethod.aidl b/core/java/com/android/internal/view/IInputMethod.aidl index 4e2526a281b37..d3b575af87429 100644 --- a/core/java/com/android/internal/view/IInputMethod.aidl +++ b/core/java/com/android/internal/view/IInputMethod.aidl @@ -25,8 +25,8 @@ import android.view.inputmethod.InputBinding; import android.view.inputmethod.InputMethodSubtype; import android.window.ImeOnBackInvokedDispatcher; import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; +import com.android.internal.inputmethod.IRemoteInputConnection; import com.android.internal.view.IInlineSuggestionsRequestCallback; -import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.IInputSessionCallback; import com.android.internal.view.InlineSuggestionsRequestInfo; @@ -47,7 +47,7 @@ oneway interface IInputMethod { void unbindInput(); - void startInput(in IBinder startInputToken, in IInputContext inputContext, + void startInput(in IBinder startInputToken, in IRemoteInputConnection inputConnection, in EditorInfo attribute, boolean restarting, int navigationBarFlags, in ImeOnBackInvokedDispatcher imeDispatcher); diff --git a/core/java/com/android/internal/view/IInputMethodManager.aidl b/core/java/com/android/internal/view/IInputMethodManager.aidl index 3f93fb1a4bac1..9b19e021cc4fa 100644 --- a/core/java/com/android/internal/view/IInputMethodManager.aidl +++ b/core/java/com/android/internal/view/IInputMethodManager.aidl @@ -24,15 +24,15 @@ import android.window.ImeOnBackInvokedDispatcher; import com.android.internal.inputmethod.IInputMethodClient; import com.android.internal.inputmethod.IRemoteAccessibilityInputConnection; +import com.android.internal.inputmethod.IRemoteInputConnection; import com.android.internal.inputmethod.InputBindResult; -import com.android.internal.view.IInputContext; /** * Public interface to the global input method manager, used by all client * applications. */ interface IInputMethodManager { - void addClient(in IInputMethodClient client, in IInputContext inputContext, + void addClient(in IInputMethodClient client, in IRemoteInputConnection inputmethod, int untrustedDisplayId); // TODO: Use ParceledListSlice instead @@ -56,7 +56,7 @@ interface IInputMethodManager { in IInputMethodClient client, in IBinder windowToken, /* @StartInputFlags */ int startInputFlags, /* @android.view.WindowManager.LayoutParams.SoftInputModeFlags */ int softInputMode, - int windowFlags, in EditorInfo attribute, in IInputContext inputContext, + int windowFlags, in EditorInfo attribute, in IRemoteInputConnection inputConnection, in IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection, int unverifiedTargetSdkVersion, in ImeOnBackInvokedDispatcher imeDispatcher); diff --git a/core/java/com/android/internal/view/IInputMethodSession.aidl b/core/java/com/android/internal/view/IInputMethodSession.aidl index d505c1995deff..2f8b3f5108bb6 100644 --- a/core/java/com/android/internal/view/IInputMethodSession.aidl +++ b/core/java/com/android/internal/view/IInputMethodSession.aidl @@ -25,7 +25,7 @@ import android.view.inputmethod.CursorAnchorInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.ExtractedText; -import com.android.internal.view.IInputContext; +import com.android.internal.inputmethod.IRemoteInputConnection; /** * Sub-interface of IInputMethod which is safe to give to client applications. @@ -54,5 +54,6 @@ oneway interface IInputMethodSession { void finishInput(); - void invalidateInput(in EditorInfo editorInfo, in IInputContext inputContext, int sessionId); + void invalidateInput(in EditorInfo editorInfo, in IRemoteInputConnection inputConnection, + int sessionId); } diff --git a/services/core/java/com/android/server/inputmethod/IInputMethodInvoker.java b/services/core/java/com/android/server/inputmethod/IInputMethodInvoker.java index 1703310320869..c719fb5009a81 100644 --- a/services/core/java/com/android/server/inputmethod/IInputMethodInvoker.java +++ b/services/core/java/com/android/server/inputmethod/IInputMethodInvoker.java @@ -33,9 +33,9 @@ import android.view.inputmethod.InputMethodSubtype; import android.window.ImeOnBackInvokedDispatcher; import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; +import com.android.internal.inputmethod.IRemoteInputConnection; import com.android.internal.inputmethod.InputMethodNavButtonFlags; import com.android.internal.view.IInlineSuggestionsRequestCallback; -import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethod; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.IInputSessionCallback; @@ -148,11 +148,11 @@ final class IInputMethodInvoker { } @AnyThread - void startInput(IBinder startInputToken, IInputContext inputContext, EditorInfo attribute, - boolean restarting, @InputMethodNavButtonFlags int navButtonFlags, + void startInput(IBinder startInputToken, IRemoteInputConnection inputConnection, + EditorInfo attribute, boolean restarting, @InputMethodNavButtonFlags int navButtonFlags, @NonNull ImeOnBackInvokedDispatcher imeDispatcher) { try { - mTarget.startInput(startInputToken, inputContext, attribute, restarting, + mTarget.startInput(startInputToken, inputConnection, attribute, restarting, navButtonFlags, imeDispatcher); } catch (RemoteException e) { logRemoteException(e); diff --git a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java index 5d72414fb1711..8b025479b080c 100644 --- a/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java +++ b/services/core/java/com/android/server/inputmethod/InputMethodManagerService.java @@ -161,6 +161,7 @@ import com.android.internal.inputmethod.IInputContentUriToken; import com.android.internal.inputmethod.IInputMethodClient; import com.android.internal.inputmethod.IInputMethodPrivilegedOperations; import com.android.internal.inputmethod.IRemoteAccessibilityInputConnection; +import com.android.internal.inputmethod.IRemoteInputConnection; import com.android.internal.inputmethod.ImeTracing; import com.android.internal.inputmethod.InputBindResult; import com.android.internal.inputmethod.InputMethodDebug; @@ -177,7 +178,6 @@ import com.android.internal.util.ConcurrentUtils; import com.android.internal.util.DumpUtils; import com.android.internal.view.IInlineSuggestionsRequestCallback; import com.android.internal.view.IInlineSuggestionsResponseCallback; -import com.android.internal.view.IInputContext; import com.android.internal.view.IInputMethodManager; import com.android.internal.view.IInputMethodSession; import com.android.internal.view.IInputSessionCallback; @@ -470,7 +470,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub static final class ClientState { final IInputMethodClient client; - final IInputContext inputContext; + final IRemoteInputConnection fallbackInputConnection; final int uid; final int pid; final int selfReportedDisplayId; @@ -489,15 +489,15 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub + " pid=" + pid + " displayId=" + selfReportedDisplayId + "}"; } - ClientState(IInputMethodClient _client, IInputContext _inputContext, + ClientState(IInputMethodClient _client, IRemoteInputConnection _fallbackInputConnection, int _uid, int _pid, int _selfReportedDisplayId, ClientDeathRecipient _clientDeathRecipient) { client = _client; - inputContext = _inputContext; + fallbackInputConnection = _fallbackInputConnection; uid = _uid; pid = _pid; selfReportedDisplayId = _selfReportedDisplayId; - binding = new InputBinding(null, inputContext.asBinder(), uid, pid); + binding = new InputBinding(null, fallbackInputConnection.asBinder(), uid, pid); clientDeathRecipient = _clientDeathRecipient; } } @@ -621,9 +621,9 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub ClientState mCurFocusedWindowClient; /** - * The input context last provided by the current client. + * The {@link IRemoteInputConnection} last provided by the current client. */ - IInputContext mCurInputContext; + IRemoteInputConnection mCurInputConnection; /** * The {@link ImeOnBackInvokedDispatcher} last provided by the current client to @@ -847,7 +847,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub /** * Internal state snapshot when - * {@link com.android.internal.view.IInputMethod#startInput(IBinder, IInputContext, EditorInfo, + * {@link com.android.internal.view.IInputMethod#startInput(IBinder, IRemoteInputConnection, EditorInfo, * boolean)} is about to be called. * *

Calling that IPC endpoint basically means that @@ -2412,14 +2412,14 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub * @param client {@link android.os.Binder} proxy that is associated with the singleton instance * of {@link android.view.inputmethod.InputMethodManager} that runs on the client * process - * @param inputContext communication channel for the fallback {@link InputConnection} + * @param inputConnection communication channel for the fallback {@link InputConnection} * @param selfReportedDisplayId self-reported display ID to which the client is associated. * Whether the client is still allowed to access to this display * or not needs to be evaluated every time the client interacts * with the display */ @Override - public void addClient(IInputMethodClient client, IInputContext inputContext, + public void addClient(IInputMethodClient client, IRemoteInputConnection inputConnection, int selfReportedDisplayId) { // Here there are two scenarios where this method is called: // A. IMM is being instantiated in a different process and this is an IPC from that process @@ -2456,7 +2456,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub // have the client crash. Thus we do not verify the display ID at all here. Instead we // later check the display ID every time the client needs to interact with the specified // display. - mClients.put(client.asBinder(), new ClientState(client, inputContext, callerUid, + mClients.put(client.asBinder(), new ClientState(client, inputConnection, callerUid, callerPid, selfReportedDisplayId, deathRecipient)); } } @@ -2646,7 +2646,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub final int navButtonFlags = getInputMethodNavButtonFlagsLocked(); final SessionState session = mCurClient.curSession; setEnabledSessionLocked(session); - session.method.startInput(startInputToken, mCurInputContext, mCurAttribute, restarting, + session.method.startInput(startInputToken, mCurInputConnection, mCurAttribute, restarting, navButtonFlags, mCurImeDispatcher); if (mShowRequested) { if (DEBUG) Slog.v(TAG, "Attach new input asks to show input"); @@ -2753,7 +2753,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @GuardedBy("ImfLock.class") @NonNull private InputBindResult startInputUncheckedLocked(@NonNull ClientState cs, - IInputContext inputContext, + IRemoteInputConnection inputConnection, @Nullable IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection, @NonNull EditorInfo attribute, @StartInputFlags int startInputFlags, @StartInputReason int startInputReason, @@ -2800,7 +2800,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub // Bump up the sequence for this client and attach it. advanceSequenceNumberLocked(); mCurClient = cs; - mCurInputContext = inputContext; + mCurInputConnection = inputConnection; mCurRemoteAccessibilityInputConnection = remoteAccessibilityInputConnection; mCurImeDispatcher = imeDispatcher; mCurVirtualDisplayToScreenMatrix = @@ -3817,12 +3817,12 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub public InputBindResult startInputOrWindowGainedFocus( @StartInputReason int startInputReason, IInputMethodClient client, IBinder windowToken, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, - int windowFlags, @Nullable EditorInfo attribute, IInputContext inputContext, + int windowFlags, @Nullable EditorInfo attribute, IRemoteInputConnection inputConnection, IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection, int unverifiedTargetSdkVersion, @NonNull ImeOnBackInvokedDispatcher imeDispatcher) { return startInputOrWindowGainedFocusInternal(startInputReason, client, windowToken, - startInputFlags, softInputMode, windowFlags, attribute, inputContext, + startInputFlags, softInputMode, windowFlags, attribute, inputConnection, remoteAccessibilityInputConnection, unverifiedTargetSdkVersion, imeDispatcher); } @@ -3831,7 +3831,8 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub private InputBindResult startInputOrWindowGainedFocusInternal( @StartInputReason int startInputReason, IInputMethodClient client, IBinder windowToken, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, - int windowFlags, @Nullable EditorInfo attribute, @Nullable IInputContext inputContext, + int windowFlags, @Nullable EditorInfo attribute, + @Nullable IRemoteInputConnection inputConnection, @Nullable IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection, int unverifiedTargetSdkVersion, @NonNull ImeOnBackInvokedDispatcher imeDispatcher) { @@ -3870,7 +3871,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub try { result = startInputOrWindowGainedFocusInternalLocked(startInputReason, client, windowToken, startInputFlags, softInputMode, windowFlags, - attribute, inputContext, remoteAccessibilityInputConnection, + attribute, inputConnection, remoteAccessibilityInputConnection, unverifiedTargetSdkVersion, userId, imeDispatcher); } finally { Binder.restoreCallingIdentity(ident); @@ -3897,7 +3898,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub @StartInputReason int startInputReason, IInputMethodClient client, @NonNull IBinder windowToken, @StartInputFlags int startInputFlags, @SoftInputModeFlags int softInputMode, int windowFlags, EditorInfo attribute, - IInputContext inputContext, + IRemoteInputConnection inputContext, @Nullable IRemoteAccessibilityInputConnection remoteAccessibilityInputConnection, int unverifiedTargetSdkVersion, @UserIdInt int userId, @NonNull ImeOnBackInvokedDispatcher imeDispatcher) { @@ -5998,7 +5999,7 @@ public final class InputMethodManagerService extends IInputMethodManager.Stub final ClientState ci = mClients.valueAt(i); p.println(" Client " + ci + ":"); p.println(" client=" + ci.client); - p.println(" inputContext=" + ci.inputContext); + p.println(" fallbackInputConnection=" + ci.fallbackInputConnection); p.println(" sessionRequested=" + ci.sessionRequested); p.println(" sessionRequestedForAccessibility=" + ci.mSessionRequestedForAccessibility);