From 2b4a008f3fb3bbeab4ab16f573d1c807d52fa74e Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Fri, 17 Dec 2021 20:03:01 +0000 Subject: [PATCH] Use IMM#invalidateInput() in EditText#setText() (2nd try) With this CL, EditText#setText() actually starts using InputMethodManger#invalidateInput(), which does not block the UI thread. See the previous CL [1] about how that API actually works. There should be no observable changes from the viewpoint of IMEs. Note that this CL was once reverted due to Bug 208941904, which was caused by a misbehaving InputConnection#endBatchEdit() implementation as a combination of the following bugs: * Chromium (crbug.com/1277732) * EditableInputConnection (Bug 209958658) Now those two bugs were addressed. We have also implemented a safeguard [2] against the same type of app issues so that the system can gracefully fall back to the previous behavior as needed. [1]: I3161755779080f98bcef0e47dd0c5247d8a3a256 daa6695c2ee8f7a8a9d724e4169ced4d28edc54d [2]: I109e0c26d8249fc2e01323e3e1cb36395fa7cc97 60c7c55c36cf6115468affa11e24bd1544552f7f Bug: 203086369 Fix: 209008342 Test: atest CtsInputMethodTestCases Change-Id: I2ce4be729e23ef686e128f832f8cf7debdcd551e --- core/java/android/widget/Editor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 62585c1a40d18..a8bf50e76a653 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -1848,7 +1848,7 @@ public class Editor { if (mHasPendingRestartInputForSetText) { final InputMethodManager imm = getInputMethodManager(); if (imm != null) { - imm.restartInput(mTextView); + imm.invalidateInput(mTextView); } mHasPendingRestartInputForSetText = false; }