diff --git a/core/java/com/android/internal/inputmethod/IInputContextInvoker.java b/core/java/com/android/internal/inputmethod/IInputContextInvoker.java index 2fde98177fa7c..001e304ca1110 100644 --- a/core/java/com/android/internal/inputmethod/IInputContextInvoker.java +++ b/core/java/com/android/internal/inputmethod/IInputContextInvoker.java @@ -57,9 +57,14 @@ public final class IInputContextInvoker { return new IInputContextInvoker(inputContext); } + @NonNull + InputConnectionCommandHeader createHeader() { + return new InputConnectionCommandHeader(); + } + /** - * Invokes {@link IInputContext#getTextAfterCursor(int, int, - * com.android.internal.inputmethod.ICharSequenceResultCallback)}. + * Invokes {@link IInputContext#getTextAfterCursor(InputConnectionCommandHeader, int, int, + * AndroidFuture)}. * * @param length {@code length} parameter to be passed. * @param flags {@code flags} parameter to be passed. @@ -71,7 +76,7 @@ public final class IInputContextInvoker { public AndroidFuture getTextAfterCursor(int length, int flags) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getTextAfterCursor(length, flags, future); + mIInputContext.getTextAfterCursor(createHeader(), length, flags, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -79,7 +84,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#getTextBeforeCursor(int, int, ICharSequenceResultCallback)}. + * Invokes {@link IInputContext#getTextBeforeCursor(InputConnectionCommandHeader, int, int, + * AndroidFuture)}. * * @param length {@code length} parameter to be passed. * @param flags {@code flags} parameter to be passed. @@ -91,7 +97,7 @@ public final class IInputContextInvoker { public AndroidFuture getTextBeforeCursor(int length, int flags) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getTextBeforeCursor(length, flags, future); + mIInputContext.getTextBeforeCursor(createHeader(), length, flags, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -99,7 +105,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#getSelectedText(int, ICharSequenceResultCallback)}. + * Invokes + * {@link IInputContext#getSelectedText(InputConnectionCommandHeader, int, AndroidFuture)}. * * @param flags {@code flags} parameter to be passed. * @return {@link AndroidFuture} that can be used to retrieve the invocation @@ -110,7 +117,7 @@ public final class IInputContextInvoker { public AndroidFuture getSelectedText(int flags) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getSelectedText(flags, future); + mIInputContext.getSelectedText(createHeader(), flags, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -119,7 +126,8 @@ public final class IInputContextInvoker { /** * Invokes - * {@link IInputContext#getSurroundingText(int, int, int, ISurroundingTextResultCallback)}. + * {@link IInputContext#getSurroundingText(InputConnectionCommandHeader, int, int, int, + * AndroidFuture)}. * * @param beforeLength {@code beforeLength} parameter to be passed. * @param afterLength {@code afterLength} parameter to be passed. @@ -133,7 +141,8 @@ public final class IInputContextInvoker { int flags) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getSurroundingText(beforeLength, afterLength, flags, future); + mIInputContext.getSurroundingText(createHeader(), beforeLength, afterLength, flags, + future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -141,7 +150,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#getCursorCapsMode(int, IIntResultCallback)}. + * Invokes + * {@link IInputContext#getCursorCapsMode(InputConnectionCommandHeader, int, AndroidFuture)}. * * @param reqModes {@code reqModes} parameter to be passed. * @return {@link AndroidFuture} that can be used to retrieve the invocation @@ -152,7 +162,7 @@ public final class IInputContextInvoker { public AndroidFuture getCursorCapsMode(int reqModes) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getCursorCapsMode(reqModes, future); + mIInputContext.getCursorCapsMode(createHeader(), reqModes, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -160,8 +170,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#getExtractedText(ExtractedTextRequest, int, - * IExtractedTextResultCallback)}. + * Invokes {@link IInputContext#getExtractedText(InputConnectionCommandHeader, + * ExtractedTextRequest, int, AndroidFuture)}. * * @param request {@code request} parameter to be passed. * @param flags {@code flags} parameter to be passed. @@ -174,7 +184,7 @@ public final class IInputContextInvoker { int flags) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.getExtractedText(request, flags, future); + mIInputContext.getExtractedText(createHeader(), request, flags, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -182,7 +192,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#commitText(CharSequence, int)}. + * Invokes {@link IInputContext#commitText(InputConnectionCommandHeader, CharSequence, int)}. * * @param text {@code text} parameter to be passed. * @param newCursorPosition {@code newCursorPosition} parameter to be passed. @@ -192,7 +202,7 @@ public final class IInputContextInvoker { @AnyThread public boolean commitText(CharSequence text, int newCursorPosition) { try { - mIInputContext.commitText(text, newCursorPosition); + mIInputContext.commitText(createHeader(), text, newCursorPosition); return true; } catch (RemoteException e) { return false; @@ -200,7 +210,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#commitCompletion(CompletionInfo)}. + * Invokes {@link IInputContext#commitCompletion(InputConnectionCommandHeader, CompletionInfo)}. * * @param text {@code text} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -209,7 +219,7 @@ public final class IInputContextInvoker { @AnyThread public boolean commitCompletion(CompletionInfo text) { try { - mIInputContext.commitCompletion(text); + mIInputContext.commitCompletion(createHeader(), text); return true; } catch (RemoteException e) { return false; @@ -217,7 +227,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#commitCorrection(CorrectionInfo)}. + * Invokes {@link IInputContext#commitCorrection(InputConnectionCommandHeader, CorrectionInfo)}. * * @param correctionInfo {@code correctionInfo} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -226,7 +236,7 @@ public final class IInputContextInvoker { @AnyThread public boolean commitCorrection(CorrectionInfo correctionInfo) { try { - mIInputContext.commitCorrection(correctionInfo); + mIInputContext.commitCorrection(createHeader(), correctionInfo); return true; } catch (RemoteException e) { return false; @@ -234,7 +244,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#setSelection(int, int)}. + * Invokes {@link IInputContext#setSelection(InputConnectionCommandHeader, int, int)}. * * @param start {@code start} parameter to be passed. * @param end {@code start} parameter to be passed. @@ -244,7 +254,7 @@ public final class IInputContextInvoker { @AnyThread public boolean setSelection(int start, int end) { try { - mIInputContext.setSelection(start, end); + mIInputContext.setSelection(createHeader(), start, end); return true; } catch (RemoteException e) { return false; @@ -252,7 +262,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#performEditorAction(int)}. + * Invokes {@link IInputContext#performEditorAction(InputConnectionCommandHeader, int)}. * * @param actionCode {@code start} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -261,7 +271,7 @@ public final class IInputContextInvoker { @AnyThread public boolean performEditorAction(int actionCode) { try { - mIInputContext.performEditorAction(actionCode); + mIInputContext.performEditorAction(createHeader(), actionCode); return true; } catch (RemoteException e) { return false; @@ -269,7 +279,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#performContextMenuAction(id)}. + * Invokes {@link IInputContext#performContextMenuAction(InputConnectionCommandHeader, int)}. * * @param id {@code id} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -278,7 +288,7 @@ public final class IInputContextInvoker { @AnyThread public boolean performContextMenuAction(int id) { try { - mIInputContext.performContextMenuAction(id); + mIInputContext.performContextMenuAction(createHeader(), id); return true; } catch (RemoteException e) { return false; @@ -286,7 +296,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#setComposingRegion(int, int)}. + * Invokes {@link IInputContext#setComposingRegion(InputConnectionCommandHeader, int, int)}. * * @param start {@code id} parameter to be passed. * @param end {@code id} parameter to be passed. @@ -296,7 +306,7 @@ public final class IInputContextInvoker { @AnyThread public boolean setComposingRegion(int start, int end) { try { - mIInputContext.setComposingRegion(start, end); + mIInputContext.setComposingRegion(createHeader(), start, end); return true; } catch (RemoteException e) { return false; @@ -304,7 +314,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#setComposingText(CharSequence, int)}. + * Invokes + * {@link IInputContext#setComposingText(InputConnectionCommandHeader, CharSequence, int)}. * * @param text {@code text} parameter to be passed. * @param newCursorPosition {@code newCursorPosition} parameter to be passed. @@ -314,7 +325,7 @@ public final class IInputContextInvoker { @AnyThread public boolean setComposingText(CharSequence text, int newCursorPosition) { try { - mIInputContext.setComposingText(text, newCursorPosition); + mIInputContext.setComposingText(createHeader(), text, newCursorPosition); return true; } catch (RemoteException e) { return false; @@ -322,7 +333,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#finishComposingText()}. + * Invokes {@link IInputContext#finishComposingText(InputConnectionCommandHeader)}. * * @return {@code true} if the invocation is completed without {@link RemoteException}. * {@code false} otherwise. @@ -330,7 +341,7 @@ public final class IInputContextInvoker { @AnyThread public boolean finishComposingText() { try { - mIInputContext.finishComposingText(); + mIInputContext.finishComposingText(createHeader()); return true; } catch (RemoteException e) { return false; @@ -338,7 +349,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#beginBatchEdit()}. + * Invokes {@link IInputContext#beginBatchEdit(InputConnectionCommandHeader)}. * * @return {@code true} if the invocation is completed without {@link RemoteException}. * {@code false} otherwise. @@ -346,7 +357,7 @@ public final class IInputContextInvoker { @AnyThread public boolean beginBatchEdit() { try { - mIInputContext.beginBatchEdit(); + mIInputContext.beginBatchEdit(createHeader()); return true; } catch (RemoteException e) { return false; @@ -354,7 +365,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#endBatchEdit()}. + * Invokes {@link IInputContext#endBatchEdit(InputConnectionCommandHeader)}. * * @return {@code true} if the invocation is completed without {@link RemoteException}. * {@code false} otherwise. @@ -362,7 +373,7 @@ public final class IInputContextInvoker { @AnyThread public boolean endBatchEdit() { try { - mIInputContext.endBatchEdit(); + mIInputContext.endBatchEdit(createHeader()); return true; } catch (RemoteException e) { return false; @@ -370,7 +381,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#sendKeyEvent(KeyEvent)}. + * Invokes {@link IInputContext#sendKeyEvent(InputConnectionCommandHeader, KeyEvent)}. * * @param event {@code event} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -379,7 +390,7 @@ public final class IInputContextInvoker { @AnyThread public boolean sendKeyEvent(KeyEvent event) { try { - mIInputContext.sendKeyEvent(event); + mIInputContext.sendKeyEvent(createHeader(), event); return true; } catch (RemoteException e) { return false; @@ -387,7 +398,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#clearMetaKeyStates(int)}. + * Invokes {@link IInputContext#clearMetaKeyStates(InputConnectionCommandHeader, int)}. * * @param states {@code states} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -396,7 +407,7 @@ public final class IInputContextInvoker { @AnyThread public boolean clearMetaKeyStates(int states) { try { - mIInputContext.clearMetaKeyStates(states); + mIInputContext.clearMetaKeyStates(createHeader(), states); return true; } catch (RemoteException e) { return false; @@ -404,7 +415,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#deleteSurroundingText(int, int)}. + * Invokes {@link IInputContext#deleteSurroundingText(InputConnectionCommandHeader, int, int)}. * * @param beforeLength {@code beforeLength} parameter to be passed. * @param afterLength {@code afterLength} parameter to be passed. @@ -414,7 +425,7 @@ public final class IInputContextInvoker { @AnyThread public boolean deleteSurroundingText(int beforeLength, int afterLength) { try { - mIInputContext.deleteSurroundingText(beforeLength, afterLength); + mIInputContext.deleteSurroundingText(createHeader(), beforeLength, afterLength); return true; } catch (RemoteException e) { return false; @@ -422,7 +433,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#deleteSurroundingTextInCodePoints(int, int)}. + * Invokes {@link IInputContext#deleteSurroundingTextInCodePoints(InputConnectionCommandHeader, + * int, int)}. * * @param beforeLength {@code beforeLength} parameter to be passed. * @param afterLength {@code afterLength} parameter to be passed. @@ -432,7 +444,8 @@ public final class IInputContextInvoker { @AnyThread public boolean deleteSurroundingTextInCodePoints(int beforeLength, int afterLength) { try { - mIInputContext.deleteSurroundingTextInCodePoints(beforeLength, afterLength); + mIInputContext.deleteSurroundingTextInCodePoints(createHeader(), beforeLength, + afterLength); return true; } catch (RemoteException e) { return false; @@ -440,7 +453,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#performSpellCheck()}. + * Invokes {@link IInputContext#performSpellCheck(InputConnectionCommandHeader)}. * * @return {@code true} if the invocation is completed without {@link RemoteException}. * {@code false} otherwise. @@ -448,7 +461,7 @@ public final class IInputContextInvoker { @AnyThread public boolean performSpellCheck() { try { - mIInputContext.performSpellCheck(); + mIInputContext.performSpellCheck(createHeader()); return true; } catch (RemoteException e) { return false; @@ -456,7 +469,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#performPrivateCommand(String, Bundle)}. + * Invokes + * {@link IInputContext#performPrivateCommand(InputConnectionCommandHeader, String, Bundle)}. * * @param action {@code action} parameter to be passed. * @param data {@code data} parameter to be passed. @@ -466,7 +480,7 @@ public final class IInputContextInvoker { @AnyThread public boolean performPrivateCommand(String action, Bundle data) { try { - mIInputContext.performPrivateCommand(action, data); + mIInputContext.performPrivateCommand(createHeader(), action, data); return true; } catch (RemoteException e) { return false; @@ -474,7 +488,8 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#requestCursorUpdates(int, IIntResultCallback)}. + * Invokes {@link IInputContext#requestCursorUpdates(InputConnectionCommandHeader, int, int, + * AndroidFuture)}. * * @param cursorUpdateMode {@code cursorUpdateMode} parameter to be passed. * @param imeDisplayId the display ID that is associated with the IME. @@ -486,7 +501,8 @@ public final class IInputContextInvoker { public AndroidFuture requestCursorUpdates(int cursorUpdateMode, int imeDisplayId) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.requestCursorUpdates(cursorUpdateMode, imeDisplayId, future); + mIInputContext.requestCursorUpdates(createHeader(), cursorUpdateMode, imeDisplayId, + future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -494,8 +510,8 @@ public final class IInputContextInvoker { } /** - * Invokes - * {@link IInputContext#commitContent(InputContentInfo, int, Bundle, IIntResultCallback)}. + * Invokes {@link IInputContext#commitContent(InputConnectionCommandHeader, InputContentInfo, + * int, Bundle, AndroidFuture)}. * * @param inputContentInfo {@code inputContentInfo} parameter to be passed. * @param flags {@code flags} parameter to be passed. @@ -509,7 +525,7 @@ public final class IInputContextInvoker { Bundle opts) { final AndroidFuture future = new AndroidFuture<>(); try { - mIInputContext.commitContent(inputContentInfo, flags, opts, future); + mIInputContext.commitContent(createHeader(), inputContentInfo, flags, opts, future); } catch (RemoteException e) { future.completeExceptionally(e); } @@ -517,7 +533,7 @@ public final class IInputContextInvoker { } /** - * Invokes {@link IInputContext#setImeConsumesInput(boolean)}. + * Invokes {@link IInputContext#setImeConsumesInput(InputConnectionCommandHeader, boolean)}. * * @param imeConsumesInput {@code imeConsumesInput} parameter to be passed. * @return {@code true} if the invocation is completed without {@link RemoteException}. @@ -526,7 +542,7 @@ public final class IInputContextInvoker { @AnyThread public boolean setImeConsumesInput(boolean imeConsumesInput) { try { - mIInputContext.setImeConsumesInput(imeConsumesInput); + mIInputContext.setImeConsumesInput(createHeader(), imeConsumesInput); return true; } catch (RemoteException e) { return false; diff --git a/core/java/com/android/internal/inputmethod/InputConnectionCommandHeader.aidl b/core/java/com/android/internal/inputmethod/InputConnectionCommandHeader.aidl new file mode 100644 index 0000000000000..9de3ffc163fb9 --- /dev/null +++ b/core/java/com/android/internal/inputmethod/InputConnectionCommandHeader.aidl @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.inputmethod; + +parcelable InputConnectionCommandHeader; \ No newline at end of file diff --git a/core/java/com/android/internal/inputmethod/InputConnectionCommandHeader.java b/core/java/com/android/internal/inputmethod/InputConnectionCommandHeader.java new file mode 100644 index 0000000000000..4bd8d0cc578b5 --- /dev/null +++ b/core/java/com/android/internal/inputmethod/InputConnectionCommandHeader.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2021 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.inputmethod; + +import android.annotation.NonNull; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * A common IPC header used behind {@link RemoteInputConnectionImpl} and + * {@link android.inputmethodservice.RemoteInputConnection}. + */ +public final class InputConnectionCommandHeader implements Parcelable { + public InputConnectionCommandHeader() { + } + + @Override + public int describeContents() { + return 0; + } + + @NonNull + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { + @NonNull + public InputConnectionCommandHeader createFromParcel(Parcel in) { + return new InputConnectionCommandHeader(); + } + + @NonNull + public InputConnectionCommandHeader[] newArray(int size) { + return new InputConnectionCommandHeader[size]; + } + }; + + @Override + public void writeToParcel(@NonNull Parcel dest, int flags) { + } +} diff --git a/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java b/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java index 788e3e4e6682c..3867afdf0faaa 100644 --- a/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java +++ b/core/java/com/android/internal/inputmethod/RemoteInputConnectionImpl.java @@ -225,7 +225,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void getTextAfterCursor(int length, int flags, + public void getTextAfterCursor(InputConnectionCommandHeader header, int length, int flags, AndroidFuture future /* T=CharSequence */) { dispatchWithTracing("getTextAfterCursor", future, () -> { final InputConnection ic = getInputConnection(); @@ -243,7 +243,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void getTextBeforeCursor(int length, int flags, + public void getTextBeforeCursor(InputConnectionCommandHeader header, int length, int flags, AndroidFuture future /* T=CharSequence */) { dispatchWithTracing("getTextBeforeCursor", future, () -> { final InputConnection ic = getInputConnection(); @@ -261,7 +261,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void getSelectedText(int flags, AndroidFuture future /* T=CharSequence */) { + public void getSelectedText(InputConnectionCommandHeader header, int flags, + AndroidFuture future /* T=CharSequence */) { dispatchWithTracing("getSelectedText", future, () -> { final InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -278,8 +279,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void getSurroundingText(int beforeLength, int afterLength, int flags, - AndroidFuture future /* T=SurroundingText */) { + public void getSurroundingText(InputConnectionCommandHeader header, int beforeLength, + int afterLength, int flags, AndroidFuture future /* T=SurroundingText */) { dispatchWithTracing("getSurroundingText", future, () -> { final InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -302,7 +303,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void getCursorCapsMode(int reqModes, AndroidFuture future /* T=Integer */) { + public void getCursorCapsMode(InputConnectionCommandHeader header, int reqModes, + AndroidFuture future /* T=Integer */) { dispatchWithTracing("getCursorCapsMode", future, () -> { final InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -314,8 +316,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void getExtractedText(ExtractedTextRequest request, int flags, - AndroidFuture future /* T=ExtractedText */) { + public void getExtractedText(InputConnectionCommandHeader header, ExtractedTextRequest request, + int flags, AndroidFuture future /* T=ExtractedText */) { dispatchWithTracing("getExtractedText", future, () -> { final InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -327,7 +329,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void commitText(CharSequence text, int newCursorPosition) { + public void commitText(InputConnectionCommandHeader header, CharSequence text, + int newCursorPosition) { dispatchWithTracing("commitText", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -339,7 +342,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void commitCompletion(CompletionInfo text) { + public void commitCompletion(InputConnectionCommandHeader header, CompletionInfo text) { dispatchWithTracing("commitCompletion", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -351,7 +354,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void commitCorrection(CorrectionInfo info) { + public void commitCorrection(InputConnectionCommandHeader header, CorrectionInfo info) { dispatchWithTracing("commitCorrection", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -367,7 +370,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void setSelection(int start, int end) { + public void setSelection(InputConnectionCommandHeader header, int start, int end) { dispatchWithTracing("setSelection", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -379,7 +382,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void performEditorAction(int id) { + public void performEditorAction(InputConnectionCommandHeader header, int id) { dispatchWithTracing("performEditorAction", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -391,7 +394,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void performContextMenuAction(int id) { + public void performContextMenuAction(InputConnectionCommandHeader header, int id) { dispatchWithTracing("performContextMenuAction", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -403,7 +406,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void setComposingRegion(int start, int end) { + public void setComposingRegion(InputConnectionCommandHeader header, int start, int end) { dispatchWithTracing("setComposingRegion", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -419,7 +422,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void setComposingText(CharSequence text, int newCursorPosition) { + public void setComposingText(InputConnectionCommandHeader header, CharSequence text, + int newCursorPosition) { dispatchWithTracing("setComposingText", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -459,7 +463,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void finishComposingText() { + public void finishComposingText(InputConnectionCommandHeader header) { dispatchWithTracing("finishComposingText", () -> { if (isFinished()) { // In this case, #finishComposingText() is guaranteed to be called already. @@ -483,7 +487,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void sendKeyEvent(KeyEvent event) { + public void sendKeyEvent(InputConnectionCommandHeader header, KeyEvent event) { dispatchWithTracing("sendKeyEvent", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -495,7 +499,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void clearMetaKeyStates(int states) { + public void clearMetaKeyStates(InputConnectionCommandHeader header, int states) { dispatchWithTracing("clearMetaKeyStates", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -507,7 +511,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void deleteSurroundingText(int beforeLength, int afterLength) { + public void deleteSurroundingText(InputConnectionCommandHeader header, int beforeLength, + int afterLength) { dispatchWithTracing("deleteSurroundingText", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -519,7 +524,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void deleteSurroundingTextInCodePoints(int beforeLength, int afterLength) { + public void deleteSurroundingTextInCodePoints(InputConnectionCommandHeader header, + int beforeLength, int afterLength) { dispatchWithTracing("deleteSurroundingTextInCodePoints", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -535,7 +541,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void beginBatchEdit() { + public void beginBatchEdit(InputConnectionCommandHeader header) { dispatchWithTracing("beginBatchEdit", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -547,7 +553,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void endBatchEdit() { + public void endBatchEdit(InputConnectionCommandHeader header) { dispatchWithTracing("endBatchEdit", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -559,7 +565,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void performSpellCheck() { + public void performSpellCheck(InputConnectionCommandHeader header) { dispatchWithTracing("performSpellCheck", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -571,7 +577,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void performPrivateCommand(String action, Bundle data) { + public void performPrivateCommand(InputConnectionCommandHeader header, String action, + Bundle data) { dispatchWithTracing("performPrivateCommand", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -583,8 +590,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void requestCursorUpdates(int cursorUpdateMode, int imeDisplayId, - AndroidFuture future /* T=Boolean */) { + public void requestCursorUpdates(InputConnectionCommandHeader header, int cursorUpdateMode, + int imeDisplayId, AndroidFuture future /* T=Boolean */) { dispatchWithTracing("requestCursorUpdates", future, () -> { final InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { @@ -605,7 +612,8 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void commitContent(InputContentInfo inputContentInfo, int flags, Bundle opts, + public void commitContent(InputConnectionCommandHeader header, + InputContentInfo inputContentInfo, int flags, Bundle opts, AndroidFuture future /* T=Boolean */) { dispatchWithTracing("commitContent", future, () -> { final InputConnection ic = getInputConnection(); @@ -627,7 +635,7 @@ public final class RemoteInputConnectionImpl extends IInputContext.Stub { } @Override - public void setImeConsumesInput(boolean imeConsumesInput) { + public void setImeConsumesInput(InputConnectionCommandHeader header, boolean imeConsumesInput) { dispatchWithTracing("setImeConsumesInput", () -> { InputConnection ic = getInputConnection(); if (ic == null || !isActive()) { diff --git a/core/java/com/android/internal/view/IInputContext.aidl b/core/java/com/android/internal/view/IInputContext.aidl index 2e6f9e537b002..df55bebb35efc 100644 --- a/core/java/com/android/internal/view/IInputContext.aidl +++ b/core/java/com/android/internal/view/IInputContext.aidl @@ -24,6 +24,7 @@ import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputContentInfo; import com.android.internal.infra.AndroidFuture; +import com.android.internal.inputmethod.InputConnectionCommandHeader; /** * Interface from an input method to the application, allowing it to perform @@ -31,58 +32,67 @@ import com.android.internal.infra.AndroidFuture; * {@hide} */ oneway interface IInputContext { - void getTextBeforeCursor(int length, int flags, in AndroidFuture future /* T=CharSequence */); + void getTextBeforeCursor(in InputConnectionCommandHeader header, int length, int flags, + in AndroidFuture future /* T=CharSequence */); - void getTextAfterCursor(int length, int flags, in AndroidFuture future /* T=CharSequence */); + void getTextAfterCursor(in InputConnectionCommandHeader header, int length, int flags, + in AndroidFuture future /* T=CharSequence */); - void getCursorCapsMode(int reqModes, in AndroidFuture future /* T=Integer */); + void getCursorCapsMode(in InputConnectionCommandHeader header, int reqModes, + in AndroidFuture future /* T=Integer */); - void getExtractedText(in ExtractedTextRequest request, int flags, - in AndroidFuture future /* T=ExtractedText */); + void getExtractedText(in InputConnectionCommandHeader header, in ExtractedTextRequest request, + int flags, in AndroidFuture future /* T=ExtractedText */); - void deleteSurroundingText(int beforeLength, int afterLength); - void deleteSurroundingTextInCodePoints(int beforeLength, int afterLength); + void deleteSurroundingText(in InputConnectionCommandHeader header, int beforeLength, + int afterLength); + void deleteSurroundingTextInCodePoints(in InputConnectionCommandHeader header, int beforeLength, + int afterLength); - void setComposingText(CharSequence text, int newCursorPosition); + void setComposingText(in InputConnectionCommandHeader header, CharSequence text, + int newCursorPosition); - void finishComposingText(); + void finishComposingText(in InputConnectionCommandHeader header); - void commitText(CharSequence text, int newCursorPosition); + void commitText(in InputConnectionCommandHeader header, CharSequence text, + int newCursorPosition); - void commitCompletion(in CompletionInfo completion); + void commitCompletion(in InputConnectionCommandHeader header, in CompletionInfo completion); - void commitCorrection(in CorrectionInfo correction); + void commitCorrection(in InputConnectionCommandHeader header, in CorrectionInfo correction); - void setSelection(int start, int end); + void setSelection(in InputConnectionCommandHeader header, int start, int end); - void performEditorAction(int actionCode); + void performEditorAction(in InputConnectionCommandHeader header, int actionCode); - void performContextMenuAction(int id); + void performContextMenuAction(in InputConnectionCommandHeader header, int id); - void beginBatchEdit(); + void beginBatchEdit(in InputConnectionCommandHeader header); - void endBatchEdit(); + void endBatchEdit(in InputConnectionCommandHeader header); - void sendKeyEvent(in KeyEvent event); + void sendKeyEvent(in InputConnectionCommandHeader header, in KeyEvent event); - void clearMetaKeyStates(int states); + void clearMetaKeyStates(in InputConnectionCommandHeader header, int states); - void performSpellCheck(); + void performSpellCheck(in InputConnectionCommandHeader header); - void performPrivateCommand(String action, in Bundle data); + void performPrivateCommand(in InputConnectionCommandHeader header, String action, + in Bundle data); - void setComposingRegion(int start, int end); + void setComposingRegion(in InputConnectionCommandHeader header, int start, int end); - void getSelectedText(int flags, in AndroidFuture future /* T=CharSequence */); + void getSelectedText(in InputConnectionCommandHeader header, int flags, + in AndroidFuture future /* T=CharSequence */); - void requestCursorUpdates(int cursorUpdateMode, int imeDisplayId, - in AndroidFuture future /* T=Boolean */); + void requestCursorUpdates(in InputConnectionCommandHeader header, int cursorUpdateMode, + int imeDisplayId, in AndroidFuture future /* T=Boolean */); - void commitContent(in InputContentInfo inputContentInfo, int flags, in Bundle opts, - in AndroidFuture future /* T=Boolean */); + void commitContent(in InputConnectionCommandHeader header, in InputContentInfo inputContentInfo, + int flags, in Bundle opts, in AndroidFuture future /* T=Boolean */); - void getSurroundingText(int beforeLength, int afterLength, int flags, - in AndroidFuture future /* T=SurroundingText */); + void getSurroundingText(in InputConnectionCommandHeader header, int beforeLength, + int afterLength, int flags, in AndroidFuture future /* T=SurroundingText */); - void setImeConsumesInput(boolean imeConsumesInput); + void setImeConsumesInput(in InputConnectionCommandHeader header, boolean imeConsumesInput); }