diff options
| author | Yohei Yukawa <yukawa@google.com> | 2021-07-09 09:46:58 -0700 |
|---|---|---|
| committer | Yohei Yukawa <yukawa@google.com> | 2021-07-13 15:54:10 +0000 |
| commit | a975bfc447b04fe90a5ec9c3d4757810f7d07af1 (patch) | |
| tree | 43527584fe64c505f2fc958e7bbd44876008fa02 /core/java/android/inputmethodservice/RemoteInputConnection.java | |
| parent | 26b594af104352c397200de2f0f40b8e2d1a1f04 (diff) | |
Introduce InputMethodServiceInternal for better abstraction
This is a mechanical refactoring CL that has no behavior change.
This CL removes the direct dependency on AbstractInputMethodService
from whenever possible. As a result, the following classes no longer
directly depend on AbstractInputMethodService.
* android.inputmethodservice.IInputMethodWrapper
* android.inputmethodservice.RemoteInputConnection
* com.android.internal.inputmethod.ImeTracing
* com.android.internal.inputmethod.ImeTracingClientImpl
* com.android.internal.inputmethod.ImeTracingServerImpl
This is still a purely mechanical refactoring. There should be no
observable behavior change.
Bug: 192412909
Test: atest CtsInputMethodTestCases
Test: Manually verified that IME tracing still works
Change-Id: I2aeeeacd27195ce10059d6590e098a4a969e774d
Diffstat (limited to 'core/java/android/inputmethodservice/RemoteInputConnection.java')
| -rw-r--r-- | core/java/android/inputmethodservice/RemoteInputConnection.java | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/core/java/android/inputmethodservice/RemoteInputConnection.java b/core/java/android/inputmethodservice/RemoteInputConnection.java index 98a49ccb27d8..4fa98be75b46 100644 --- a/core/java/android/inputmethodservice/RemoteInputConnection.java +++ b/core/java/android/inputmethodservice/RemoteInputConnection.java @@ -52,7 +52,7 @@ final class RemoteInputConnection implements InputConnection { private final IInputContextInvoker mInvoker; @NonNull - private final WeakReference<AbstractInputMethodService> mInputMethodService; + private final WeakReference<InputMethodServiceInternal> mInputMethodService; @MissingMethodFlags private final int mMissingMethods; @@ -67,7 +67,7 @@ final class RemoteInputConnection implements InputConnection { private final CancellationGroup mCancellationGroup; RemoteInputConnection( - @NonNull WeakReference<AbstractInputMethodService> inputMethodService, + @NonNull WeakReference<InputMethodServiceInternal> inputMethodService, IInputContext inputContext, @MissingMethodFlags int missingMethods, @NonNull CancellationGroup cancellationGroup) { mInputMethodService = inputMethodService; @@ -90,12 +90,11 @@ final class RemoteInputConnection implements InputConnection { final CharSequence result = Completable.getResultOrNull( value, TAG, "getTextAfterCursor()", mCancellationGroup, MAX_WAIT_TIME_MILLIS); - final AbstractInputMethodService inputMethodService = mInputMethodService.get(); + final InputMethodServiceInternal inputMethodService = mInputMethodService.get(); if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) { final byte[] icProto = InputConnectionProtoDumper.buildGetTextAfterCursorProto(length, flags, result); - ImeTracing.getInstance().triggerServiceDump(TAG + "#getTextAfterCursor", - inputMethodService, icProto); + inputMethodService.triggerServiceDump(TAG + "#getTextAfterCursor", icProto); } return result; @@ -115,12 +114,11 @@ final class RemoteInputConnection implements InputConnection { final CharSequence result = Completable.getResultOrNull( value, TAG, "getTextBeforeCursor()", mCancellationGroup, MAX_WAIT_TIME_MILLIS); - final AbstractInputMethodService inputMethodService = mInputMethodService.get(); + final InputMethodServiceInternal inputMethodService = mInputMethodService.get(); if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) { final byte[] icProto = InputConnectionProtoDumper.buildGetTextBeforeCursorProto(length, flags, result); - ImeTracing.getInstance().triggerServiceDump(TAG + "#getTextBeforeCursor", - inputMethodService, icProto); + inputMethodService.triggerServiceDump(TAG + "#getTextBeforeCursor", icProto); } return result; @@ -140,12 +138,11 @@ final class RemoteInputConnection implements InputConnection { final CharSequence result = Completable.getResultOrNull( value, TAG, "getSelectedText()", mCancellationGroup, MAX_WAIT_TIME_MILLIS); - final AbstractInputMethodService inputMethodService = mInputMethodService.get(); + final InputMethodServiceInternal inputMethodService = mInputMethodService.get(); if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) { final byte[] icProto = InputConnectionProtoDumper.buildGetSelectedTextProto(flags, result); - ImeTracing.getInstance().triggerServiceDump(TAG + "#getSelectedText", - inputMethodService, icProto); + inputMethodService.triggerServiceDump(TAG + "#getSelectedText", icProto); } return result; @@ -179,12 +176,11 @@ final class RemoteInputConnection implements InputConnection { final SurroundingText result = Completable.getResultOrNull( value, TAG, "getSurroundingText()", mCancellationGroup, MAX_WAIT_TIME_MILLIS); - final AbstractInputMethodService inputMethodService = mInputMethodService.get(); + final InputMethodServiceInternal inputMethodService = mInputMethodService.get(); if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) { final byte[] icProto = InputConnectionProtoDumper.buildGetSurroundingTextProto( beforeLength, afterLength, flags, result); - ImeTracing.getInstance().triggerServiceDump(TAG + "#getSurroundingText", - inputMethodService, icProto); + inputMethodService.triggerServiceDump(TAG + "#getSurroundingText", icProto); } return result; @@ -200,12 +196,11 @@ final class RemoteInputConnection implements InputConnection { final int result = Completable.getResultOrZero( value, TAG, "getCursorCapsMode()", mCancellationGroup, MAX_WAIT_TIME_MILLIS); - final AbstractInputMethodService inputMethodService = mInputMethodService.get(); + final InputMethodServiceInternal inputMethodService = mInputMethodService.get(); if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) { final byte[] icProto = InputConnectionProtoDumper.buildGetCursorCapsModeProto( reqModes, result); - ImeTracing.getInstance().triggerServiceDump(TAG + "#getCursorCapsMode", - inputMethodService, icProto); + inputMethodService.triggerServiceDump(TAG + "#getCursorCapsMode", icProto); } return result; @@ -221,12 +216,11 @@ final class RemoteInputConnection implements InputConnection { final ExtractedText result = Completable.getResultOrNull( value, TAG, "getExtractedText()", mCancellationGroup, MAX_WAIT_TIME_MILLIS); - final AbstractInputMethodService inputMethodService = mInputMethodService.get(); + final InputMethodServiceInternal inputMethodService = mInputMethodService.get(); if (inputMethodService != null && ImeTracing.getInstance().isEnabled()) { final byte[] icProto = InputConnectionProtoDumper.buildGetExtractedTextProto( request, flags, result); - ImeTracing.getInstance().triggerServiceDump(TAG + "#getExtractedText", - inputMethodService, icProto); + inputMethodService.triggerServiceDump(TAG + "#getExtractedText", icProto); } return result; @@ -243,7 +237,7 @@ final class RemoteInputConnection implements InputConnection { @AnyThread private void notifyUserActionIfNecessary() { - final AbstractInputMethodService inputMethodService = mInputMethodService.get(); + final InputMethodServiceInternal inputMethodService = mInputMethodService.get(); if (inputMethodService == null) { // This basically should not happen, because it's the the caller of this method. return; @@ -395,7 +389,7 @@ final class RemoteInputConnection implements InputConnection { } if ((flags & InputConnection.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) { - final AbstractInputMethodService inputMethodService = mInputMethodService.get(); + final InputMethodServiceInternal inputMethodService = mInputMethodService.get(); if (inputMethodService == null) { // This basically should not happen, because it's the caller of this method. return false; |
