diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2021-08-15 02:19:15 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-08-15 02:19:15 +0000 |
| commit | 7e10f513f32d37def87b5faac41599488fc6f9a6 (patch) | |
| tree | b77d35d7c01857fee1ef58f49361d474a58fb7ff /core/java/android/widget/TextView.java | |
| parent | 42ae6c99f98fb43e2005a0be1697ea5e9dc18ed8 (diff) | |
| parent | a09d2a85814b2fcf92494431dbda6f10b8997464 (diff) | |
Merge "Fix OOB crash in ContentCapture for translated views" into sc-dev am: f7fb6c535e am: 8737b67e6e am: 2f64986be1 am: a09d2a8581
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15546784
Change-Id: I707049893d1ba46617426d38b3e397d1055cfe68
Diffstat (limited to 'core/java/android/widget/TextView.java')
| -rw-r--r-- | core/java/android/widget/TextView.java | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index 5500ff035ccb..69a5e3904715 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -11872,6 +11872,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener if (text != null) { if (expandedTopChar > 0 || expandedBottomChar < text.length()) { + // Cap the offsets to avoid an OOB exception. That can happen if the + // displayed/layout text, on which these offsets are calculated, is longer + // than the original text (such as when the view is translated by the + // platform intelligence). + // TODO(b/196433694): Figure out how to better handle the offset + // calculations for this case (so we don't unnecessarily cutoff the original + // text, for example). + expandedTopChar = Math.min(expandedTopChar, text.length()); + expandedBottomChar = Math.min(expandedBottomChar, text.length()); text = text.subSequence(expandedTopChar, expandedBottomChar); } |
