From 6ff55fcb8553857c9e2b0c0ddaee8a40cdbc6c47 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Wed, 5 Aug 2015 18:07:31 -0700 Subject: [PATCH] Fix issue #22846750: Starting Screenie Now On Tap crashes USA Today Try to deal well with badly behaving old apps. Change-Id: Ibc41e5867869463fbf91f3e411c69677909fedad --- core/java/android/view/ViewGroup.java | 54 +++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index fab81a424f761..52d6cbec4abb3 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -43,6 +43,7 @@ import android.util.AttributeSet; import android.util.Log; import android.util.Pools.SynchronizedPool; import android.util.SparseArray; +import android.util.SparseBooleanArray; import android.view.accessibility.AccessibilityEvent; import android.view.accessibility.AccessibilityNodeInfo; import android.view.animation.Animation; @@ -2902,13 +2903,58 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager final int childrenCount = getChildCount(); if (childrenCount > 0) { structure.setChildCount(childrenCount); - final ArrayList preorderedList = buildOrderedChildList(); - final boolean customOrder = preorderedList == null + ArrayList preorderedList = buildOrderedChildList(); + boolean customOrder = preorderedList == null && isChildrenDrawingOrderEnabled(); final View[] children = mChildren; for (int i=0; i 0) { + // If we failed at the first index, there really isn't + // anything to do -- we will just proceed with the simple + // sequence order. + // Otherwise, we failed in the middle, so need to come up + // with an order for the remaining indices and use that. + // Failed at the first one, easy peasy. + int[] permutation = new int[childrenCount]; + SparseBooleanArray usedIndices = new SparseBooleanArray(); + // Go back and collected the indices we have done so far. + for (int j=0; j(childrenCount); + for (int j=0; j