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
This commit is contained in:
Andrii Kulian
2019-05-08 14:24:43 -07:00
parent a7423ca97c
commit 33ab86910e
3 changed files with 27 additions and 2 deletions

View File

@@ -439,7 +439,10 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
@Override
protected ConfigurationContainer getParent() {
return null;
// Returning RootActivityContainer as the parent, so that this process controller always
// has full configuration and overrides (e.g. from display) are always added on top of
// global config.
return mAtm.mRootActivityContainer;
}
@HotPath(caller = HotPath.PROCESS_CHANGE)

View File

@@ -3103,7 +3103,7 @@ class WindowState extends WindowContainer<WindowState> 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);

View File

@@ -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);