diff options
| author | 2022-06-21 04:58:14 +0000 | |
|---|---|---|
| committer | 2022-06-21 04:58:14 +0000 | |
| commit | 2cc4677f2cd24adf010d3f3fb44975d4b3bba43c (patch) | |
| tree | 9c203f467a71d732551f62a86393c9fbb75f463a | |
| parent | 5f1bc821ac29809d3e429d2583703d24567e441e (diff) | |
Revert "Don't send the same values to onUpdateSelection repeatedly"
This reverts commit c743cb94770701ec20a01b57b09232f1aae5bcbb.
Reason for revert:
This workaround is no longer necessary [1][2].
[1]: I56f3198e54f689adc9541f2c2644ee19bcc6deed
e345e90a0197c01b638cfc538ccea3757e7a92ed
[2]: Ic84fb070e0ff21dffb7e6c9bbdc6320eb5946fd9
1046a22aae6d6c0ee21aca7446540a9d27902559
Fix: 183474466
Test: atest CtsInputMethodTestCases:InProcessImeTest
Test: atest CtsAccessibilityServiceTestCases:AccessibilityImeTest#testOnUpdateSelectionForInProcessA11yIme
Change-Id: Ie5d00bbc51b66f1d6b50969f03d1b3e3bca5e9da
| -rw-r--r-- | core/java/android/inputmethodservice/InputMethodService.java | 5 | ||||
| -rw-r--r-- | core/java/android/view/inputmethod/InputMethodManager.java | 13 |
2 files changed, 4 insertions, 14 deletions
diff --git a/core/java/android/inputmethodservice/InputMethodService.java b/core/java/android/inputmethodservice/InputMethodService.java index 9c146b58de49..655e3193e2d0 100644 --- a/core/java/android/inputmethodservice/InputMethodService.java +++ b/core/java/android/inputmethodservice/InputMethodService.java @@ -2987,11 +2987,6 @@ public class InputMethodService extends AbstractInputMethodService { * the text. This is called whether or not the input method has requested * extracted text updates, although if so it will not receive this call * if the extracted text has changed as well. - * - * <p>Be careful about changing the text in reaction to this call with - * methods such as setComposingText, commitText or - * deleteSurroundingText. If the cursor moves as a result, this method - * will be called again, which may result in an infinite loop. * * <p>The default implementation takes care of updating the cursor in * the extract text, if it is being shown. diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 73d6241c21d1..dfcc6f6568b8 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -2675,19 +2675,14 @@ public final class InputMethodManager { if (DEBUG) { Log.v(TAG, "SELECTION CHANGE: " + mCurrentInputMethodSession); } - final int oldSelStart = mCursorSelStart; - final int oldSelEnd = mCursorSelEnd; - // Update internal values before sending updateSelection to the IME, because - // if it changes the text within its onUpdateSelection handler in a way that - // does not move the cursor we don't want to call it again with the same values. + mCurrentInputMethodSession.updateSelection(mCursorSelStart, mCursorSelEnd, selStart, + selEnd, candidatesStart, candidatesEnd); + forAccessibilitySessionsLocked(wrapper -> wrapper.updateSelection(mCursorSelStart, + mCursorSelEnd, selStart, selEnd, candidatesStart, candidatesEnd)); mCursorSelStart = selStart; mCursorSelEnd = selEnd; mCursorCandStart = candidatesStart; mCursorCandEnd = candidatesEnd; - mCurrentInputMethodSession.updateSelection( - oldSelStart, oldSelEnd, selStart, selEnd, candidatesStart, candidatesEnd); - forAccessibilitySessionsLocked(wrapper -> wrapper.updateSelection(oldSelStart, - oldSelEnd, selStart, selEnd, candidatesStart, candidatesEnd)); } } } |