From 083d8aace78207c8aa826f4c440759660f725f9b Mon Sep 17 00:00:00 2001 From: "Philip P. Moltmann" Date: Tue, 15 Aug 2017 15:22:37 -0700 Subject: Don't get struct of children of !laidout viewGroup Some view groups (e.g. the support.v4.viewPager) need to be laid out to determine the order of it's children. As we need the order before being able to collect the structure of the children we need to skip their collection until they are laid out. Fixes: 38198484 Test: cts-tradefed run cts-dev -m CtsAutoFillServiceTestCases cts-tradefed run cts-dev -m CtsAccessibilityTestCases cts-tradefed run cts-dev -m CtsAccessibilityServiceTestCases Change-Id: I1f7bee1505edaf70c9d9a686be6f9a76d8aedd0b --- core/java/android/view/View.java | 4 ---- core/java/android/view/ViewGroup.java | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 2b4015f9063e..8a9b14e37909 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -8078,10 +8078,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, boolean forAutofill, @AutofillFlags int flags) { if (forAutofill) { structure.setAutofillId(getAutofillId()); - if (!isLaidOut()) { - Log.w(VIEW_LOG_TAG, "dispatchProvideAutofillStructure(): not laid out, ignoring"); - return; - } onProvideAutofillStructure(structure, flags); onProvideAutofillVirtualStructure(structure, flags); } else if (!isAssistBlocked()) { diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index ecdfa3fc3336..18b7334c7adf 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -3400,6 +3400,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (childrenCount <= 0) { return; } + + if (!isLaidOut()) { + Log.v(VIEW_LOG_TAG, "dispatchProvideStructure(): not laid out, ignoring " + + childrenCount + " children of " + getAccessibilityViewId()); + return; + } + structure.setChildCount(childrenCount); ArrayList preorderedList = buildOrderedChildList(); boolean customOrder = preorderedList == null @@ -3476,6 +3483,13 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager if (structure.getChildCount() != 0) { return; } + + if (!isLaidOut()) { + Log.v(VIEW_LOG_TAG, "dispatchProvideAutofillStructure(): not laid out, ignoring " + + mChildrenCount + " children of " + getAutofillId()); + return; + } + final ChildListForAutoFill children = getChildrenForAutofill(flags); final int childrenCount = children.size(); structure.setChildCount(childrenCount); -- cgit v1.2.3-59-g8ed1b