diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2021-08-15 02:07:29 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-08-15 02:07:29 +0000 |
| commit | a09d2a85814b2fcf92494431dbda6f10b8997464 (patch) | |
| tree | 39491014f556dccacfbcabe4b7f24b7b9016bf90 /core/java/android/widget/TextView.java | |
| parent | e62624a5f42bc6143056d0c4edda4ea11541f7a6 (diff) | |
| parent | 2f64986be1445e3912bdfa8f60d602bbec78b29c (diff) | |
Merge "Fix OOB crash in ContentCapture for translated views" into sc-dev am: f7fb6c535e am: 8737b67e6e am: 2f64986be1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15546784
Change-Id: If70cc89fdddda599e2c69ea7072d8f8a6b994248
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); } |
