From 445ee3c0f1ee9ad7ffa15bc58ef52875b3a44f0e Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Thu, 21 Apr 2022 11:38:51 -0700 Subject: [PATCH] Fix testGetSurroundingTextFailWithNegative{Before,After}LengthForA11y This is a follow up CL to my previous CLs[1][2], which are submitted almost at the same time but not compatible with each other. The first CL [1] introduced a new behavior that negative indices passed to AccessibilityInputConnection#getSurroundingText(int, int, int) result in IllegalArgumentException, which is a different behavior than what's observed from IMEs. The second CL [2] assumed that negative indices passed to that API result in just receiving null result like what's observed from IMEs. This CL effectively reverts the new behavior introduced in the first CL [1] to keep two observable behaviors consistent. Note that negative indices passed to getSurroundingText() are already handled in RemoteInputConnectionImpl#getSurroundingText() in a graceful manner [3], which guarantees that the IME client process will not see such an irregular parameter (Bug 169114026) with keeping the InputConnection commands order (Bug 194110780). [1]: I5ff2e804cbcf90828370a0612ff54111130bdff4 c60176c1f315e10c95f3eec0019149d7b7932aa9 [2]: I62b80916369bdac981dc93c14dcaedc1f2b6e95f 495ac0f55cbcc976995e8c73fdc89babfbdce902 [3]: Ie0c18d0c9b8bf8f02f2fcdca5aac7e580c6bf2cd 8821afef81ad0e09d77805dadea5b03725785bca Bug: 215633021 Fix: 229981360 Test: atest CtsInputMethodTestCases:InputConnectionEndToEndTest Change-Id: I16a0185343c7c7c3e0947aab2c398714a1077b97 --- .../inputmethod/RemoteAccessibilityInputConnection.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/core/java/com/android/internal/inputmethod/RemoteAccessibilityInputConnection.java b/core/java/com/android/internal/inputmethod/RemoteAccessibilityInputConnection.java index b2ab819eb8a59..0ee8ee7fb4c72 100644 --- a/core/java/com/android/internal/inputmethod/RemoteAccessibilityInputConnection.java +++ b/core/java/com/android/internal/inputmethod/RemoteAccessibilityInputConnection.java @@ -115,14 +115,6 @@ public final class RemoteAccessibilityInputConnection { @AnyThread public SurroundingText getSurroundingText( @IntRange(from = 0) int beforeLength, @IntRange(from = 0) int afterLength, int flags) { - if (beforeLength < 0) { - throw new IllegalArgumentException("beforeLength cannot be negative but was " - + beforeLength); - } - if (afterLength < 0) { - throw new IllegalArgumentException("afterLength cannot be negative but was " - + afterLength); - } if (mCancellationGroup.isCanceled()) { return null; }