diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2021-08-13 22:11:34 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-08-13 22:11:34 +0000 |
| commit | 2f64986be1445e3912bdfa8f60d602bbec78b29c (patch) | |
| tree | c31fa45c3f7c87ee0705a457df819910f3338159 /core/java/android/widget/TextView.java | |
| parent | 6d9c64d62e42be07eebada1b4e127305100590ab (diff) | |
| parent | 8737b67e6eac0d24ef82c0a9c3185b0c1d4bd0e6 (diff) | |
Merge "Fix OOB crash in ContentCapture for translated views" into sc-dev am: f7fb6c535e am: 8737b67e6e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15546784
Change-Id: I2bc87030c90c9353908e3cfdde3a453585a13cd9
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 ca6e735f86b4..f5c1bcf2de42 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -11857,6 +11857,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); } |
