summaryrefslogtreecommitdiff
path: root/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
diff options
context:
space:
mode:
authorYohei Yukawa <yukawa@google.com>2021-11-17 15:21:32 -0800
committerYohei Yukawa <yukawa@google.com>2021-11-17 15:21:32 -0800
commitdaa6695c2ee8f7a8a9d724e4169ced4d28edc54d (patch)
treebcc962f4bb9ee9895596b31da922385e62ee1a97 /core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
parent2e9ec744b607e23a7f93f8aa0a1008fc541a2841 (diff)
Add IMM#invalidateInput()
Historically TextView#setText() has internally called InputMethodManager#restartInput(View) simply because the text seen from the IME is going to be out-of-sync. Although this behavior is semantically helpful for IMEs, especially after the initial surrounding text information became available in EditorInfo, issuing a sync IPC from the calling thread (UI thread actually) is not plausible from the performance perspective. This CL fills this gap by adding a new API InputMethodManager#invalidateInput(View) for the scenario where apps independently modify the text with keeping other text metadata such as input-type to be the same. All the observable behaviors from the IME remain to be the same as InputMethodManager#restartInput(View). For instance, any pending tasks that are already issued with InputMethodService#getCurrentInputConnection() will be effectively cancelled by using a recently added mechanism [1]. [1]: I383c3958d2ac1a8d217706509fa12a92b381bbb3 Fix: 203086369 Test: atest -c CtsInputMethodTestCases:InputMethodStartInputLifecycleTest Change-Id: I3161755779080f98bcef0e47dd0c5247d8a3a256
Diffstat (limited to 'core/java/android/inputmethodservice/IInputMethodSessionWrapper.java')
-rw-r--r--core/java/android/inputmethodservice/IInputMethodSessionWrapper.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
index 5a517ee0b0eb..eccbb403b306 100644
--- a/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
+++ b/core/java/android/inputmethodservice/IInputMethodSessionWrapper.java
@@ -32,11 +32,13 @@ import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CursorAnchorInfo;
+import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.InputMethodSession;
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
@@ -54,6 +56,7 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
private static final int DO_NOTIFY_IME_HIDDEN = 120;
private static final int DO_REMOVE_IME_SURFACE = 130;
private static final int DO_FINISH_INPUT = 140;
+ private static final int DO_INVALIDATE_INPUT = 150;
@UnsupportedAppUsage
@@ -142,6 +145,16 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
mInputMethodSession.finishInput();
return;
}
+ case DO_INVALIDATE_INPUT: {
+ final SomeArgs args = (SomeArgs) msg.obj;
+ try {
+ mInputMethodSession.invalidateInputInternal((EditorInfo) args.arg1,
+ (IInputContext) args.arg2, msg.arg1);
+ } finally {
+ args.recycle();
+ }
+ return;
+ }
}
Log.w(TAG, "Unhandled message code: " + msg.what);
}
@@ -218,6 +231,12 @@ class IInputMethodSessionWrapper extends IInputMethodSession.Stub
}
@Override
+ public void invalidateInput(EditorInfo editorInfo, IInputContext inputContext, int sessionId) {
+ mCaller.executeOrSendMessage(mCaller.obtainMessageIOO(
+ DO_INVALIDATE_INPUT, sessionId, editorInfo, inputContext));
+ }
+
+ @Override
public void finishInput() {
mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_FINISH_INPUT));
}