From 33ab86910e9090d10dd91d760d2dc53e1f3e99e6 Mon Sep 17 00:00:00 2001 From: Andrii Kulian Date: Wed, 8 May 2019 14:24:43 -0700 Subject: [PATCH] Set parent for WindowProcessController If WindowProcessController was registered to display configuration changes, then an override from display level can erase some of the configuration fields. This can result in incomplete configuration. Since process configuration is used as a "global" config in some places, it should always be complete and contain all fields. This CL uses ActivityRootContainer as parent for a WindowProcessController, so any overrides should be applied on top of global configuration and the resulting full config will always be complete. Bug: 131915789 Test: WindowProcessControllerTests#testConfigurationForSecondaryScreen Change-Id: Id4d30ec9fc64dbdf3f31347240f6bb3cbd655fb2 --- .../server/wm/WindowProcessController.java | 5 ++++- .../com/android/server/wm/WindowState.java | 2 +- .../wm/WindowProcessControllerTests.java | 22 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java index 12b62b99b3e21..5fc399719aed7 100644 --- a/services/core/java/com/android/server/wm/WindowProcessController.java +++ b/services/core/java/com/android/server/wm/WindowProcessController.java @@ -439,7 +439,10 @@ public class WindowProcessController extends ConfigurationContainer implements WindowManagerP if (DEBUG_RESIZE || DEBUG_ORIENTATION) Slog.v(TAG, "Reporting new frame to " + this + ": " + mWindowFrames.mCompatFrame); final MergedConfiguration mergedConfiguration = - new MergedConfiguration(mWmService.mRoot.getConfiguration(), + new MergedConfiguration(getProcessGlobalConfiguration(), getMergedOverrideConfiguration()); setLastReportedMergedConfiguration(mergedConfiguration); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java index a7c84a1c28b40..7b8fba03b6d7c 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowProcessControllerTests.java @@ -26,7 +26,9 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import android.content.pm.ApplicationInfo; +import android.content.res.Configuration; import android.platform.test.annotations.Presubmit; +import android.view.DisplayInfo; import org.junit.Test; @@ -78,6 +80,26 @@ public class WindowProcessControllerTests extends ActivityTestsBase { assertEquals(INVALID_DISPLAY, wpc.getDisplayId()); } + @Test + public void testConfigurationForSecondaryScreen() { + final WindowProcessController wpc = new WindowProcessController( + mService, mock(ApplicationInfo.class), null, 0, -1, null, null); + //By default, the process should not listen to any display. + assertEquals(INVALID_DISPLAY, wpc.getDisplayId()); + + // Register to a new display as a listener. + final DisplayInfo info = new DisplayInfo(); + info.logicalWidth = 100; + info.logicalHeight = 100; + TestActivityDisplay display = addNewActivityDisplayAt(info, WindowContainer.POSITION_TOP); + wpc.registerDisplayConfigurationListenerLocked(display); + + assertEquals(display.mDisplayId, wpc.getDisplayId()); + final Configuration expectedConfig = mService.mRootActivityContainer.getConfiguration(); + expectedConfig.updateFrom(display.getConfiguration()); + assertEquals(expectedConfig, wpc.getConfiguration()); + } + private TestActivityDisplay createTestActivityDisplayInContainer() { final TestActivityDisplay testActivityDisplay = createNewActivityDisplay(); mRootActivityContainer.addChild(testActivityDisplay, POSITION_TOP);