Text in accessibility events not consistent
bug:2513822
Text added to accessibility events is truncated to max
length. However, the fromIndex and toIndex properties
are relative to the text before being truncated, thus
potentially our of bound. Removed the max length
limitation because test very rarely is longer that
500 characters and in the cases in which text is longer
than 500 character it will not be a real problem to
pass a bit more data through an IPC (very rarely).
Change-Id: Ie70ac630dfeb56d4f59079abb2f46d07582796b6
diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java
index fc61700..9af19b8 100644
--- a/core/java/android/view/accessibility/AccessibilityEvent.java
+++ b/core/java/android/view/accessibility/AccessibilityEvent.java
@@ -159,7 +159,12 @@
*
* @see #getBeforeText()
* @see #getText()
+ * </br>
+ * Note: This constant is no longer needed since there
+ * is no limit on the length of text that is contained
+ * in an accessibility event anymore.
*/
+ @Deprecated
public static final int MAX_TEXT_LENGTH = 500;
/**
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 82022fb..222bc84 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -7898,9 +7898,6 @@
text = getHint();
}
if (!TextUtils.isEmpty(text)) {
- if (text.length() > AccessibilityEvent.MAX_TEXT_LENGTH) {
- text = text.subSequence(0, AccessibilityEvent.MAX_TEXT_LENGTH + 1);
- }
event.getText().add(text);
}
} else {