Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a09d2a85 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix OOB crash in ContentCapture for translated views" into sc-dev am:...

Merge "Fix OOB crash in ContentCapture for translated views" into sc-dev am: f7fb6c53 am: 8737b67e am: 2f64986b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15546784

Change-Id: If70cc89fdddda599e2c69ea7072d8f8a6b994248
parents e62624a5 2f64986b
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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);
                    }