From 437c0e4c15799da751a91b013361941b5e31093e Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 18 Jun 2019 16:12:29 -0700 Subject: [PATCH] ViewRootImpl: Ensure layout when configuration changes. When the configuration changes between landscape and reverse landscape, the app will not receive onConfigurationChanged as orientation is not part of the public portion of the configuration. However, when the ViewRootImpl receives such a configuration back from relayout, it will force a layout of the client views (see updatedConfiguration in performTraversals), this is because Configuration#equals compares the non public part of the configuration as well. This CL changes MSG_REPORT_RESIZED to handle the configuration changing the same way performTraversals does, so that the app consistently receives a configuration change. Bug: 134643273 Test: Manual Change-Id: If016bcd9a5b8d2a7efc5e1ab3c82a88a608caf8b --- core/java/android/view/ViewRootImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 3adddc790c675..5636f48fd0721 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -4453,6 +4453,7 @@ public final class ViewRootImpl implements ViewParent, final int displayId = args.argi3; MergedConfiguration mergedConfiguration = (MergedConfiguration) args.arg4; final boolean displayChanged = mDisplay.getDisplayId() != displayId; + boolean configChanged = false; if (!mLastReportedMergedConfiguration.equals(mergedConfiguration)) { // If configuration changed - notify about that and, maybe, @@ -4460,6 +4461,7 @@ public final class ViewRootImpl implements ViewParent, performConfigurationChange(mergedConfiguration, false /* force */, displayChanged ? displayId : INVALID_DISPLAY /* same display */); + configChanged = true; } else if (displayChanged) { // Moved to display without config change - report last applied one. onMovedToDisplay(displayId, mLastConfigurationFromResources); @@ -4490,7 +4492,7 @@ public final class ViewRootImpl implements ViewParent, reportNextDraw(); } - if (mView != null && framesChanged) { + if (mView != null && (framesChanged || configChanged)) { forceLayout(mView); } requestLayout();