From 084bac819aa6af39bd471b27bfbd97edf2c071f1 Mon Sep 17 00:00:00 2001 From: Wale Ogunwale Date: Wed, 29 Jun 2022 15:22:12 +0000 Subject: [PATCH] Revert "Get rid of double measure" This reverts commit 4234e6cea8c9aa34a778d21a35576e7a8d40f9a5. Reason for revert: b/231383951 Change-Id: I41cbc5b4c036109cf45463bddb5b5cc12d11f88e --- core/java/android/view/ViewRootImpl.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index e46e44b4115b3..a13872eef6b80 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -2802,10 +2802,6 @@ public final class ViewRootImpl implements ViewParent, // Execute enqueued actions on every traversal in case a detached view enqueued an action getRunQueue().executeActions(mAttachInfo.mHandler); - if (mApplyInsetsRequested) { - dispatchApplyInsets(host); - } - if (mFirst) { // make sure touch mode code executes by setting cached value // to opposite of the added touch mode. @@ -2869,6 +2865,18 @@ public final class ViewRootImpl implements ViewParent, } } + if (mApplyInsetsRequested) { + dispatchApplyInsets(host); + if (mLayoutRequested) { + // Short-circuit catching a new layout request here, so + // we don't need to go through two layout passes when things + // change due to fitting system windows, which can happen a lot. + windowSizeMayChange |= measureHierarchy(host, lp, + mView.getContext().getResources(), + desiredWindowWidth, desiredWindowHeight); + } + } + if (layoutRequested) { // Clear this now, so that if anything requests a layout in the // rest of this function we will catch it and re-run a full