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

Commit 987a2b41 authored by Mihir Patel's avatar Mihir Patel
Browse files

Guarding against null pointer exception when setting view structure info for content capture

Test: Manual, CTS
Bug: 189329389
Change-Id: Iaaacd59dc377079847951ab635df9bb602467390
parent 3d44d6ed
Loading
Loading
Loading
Loading
+20 −15
Original line number Diff line number Diff line
@@ -11848,6 +11848,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                // Get the text and trim it to the range we are reporting.
                CharSequence text = getText();
                if (text != null) {
                    if (expandedTopChar > 0 || expandedBottomChar < text.length()) {
                        text = text.subSequence(expandedTopChar, expandedBottomChar);
                    }
@@ -11855,7 +11857,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) {
                        structure.setText(text);
                    } else {
                    structure.setText(text, selStart - expandedTopChar, selEnd - expandedTopChar);
                        structure.setText(text,
                                selStart - expandedTopChar,
                                selEnd - expandedTopChar);
                        final int[] lineOffsets = new int[bottomLine - topLine + 1];
                        final int[] lineBaselines = new int[bottomLine - topLine + 1];
@@ -11867,6 +11871,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                        structure.setTextLines(lineOffsets, lineBaselines);
                    }
                }
            }
            if (viewFor == VIEW_STRUCTURE_FOR_ASSIST
                    || viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) {