Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60ebe763 authored by Andrii Kulian's avatar Andrii Kulian
Browse files

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 RootWindowContainer 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
Bug: 131179060
Bug: 132986140
Test: WindowProcessControllerTests#testConfigurationForSecondaryScreen
Change-Id: I5b6d15473c3122a74f5dc2f6fb916b76afa08f8b
parent ee209e11
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -483,7 +483,10 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio

    @Override
    protected ConfigurationContainer getParent() {
        return null;
        // Returning RootWindowContainer 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.mRootWindowContainer;
    }

    @HotPath(caller = HotPath.PROCESS_CHANGE)
+1 −1
Original line number Diff line number Diff line
@@ -3399,7 +3399,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                    "Reporting new frame to %s: %s", this,
                            mWindowFrames.mCompatFrame);
            final MergedConfiguration mergedConfiguration =
                    new MergedConfiguration(mWmService.mRoot.getConfiguration(),
                    new MergedConfiguration(getProcessGlobalConfiguration(),
                    getMergedOverrideConfiguration());

            setLastReportedMergedConfiguration(mergedConfiguration);
+19 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;

import android.content.pm.ApplicationInfo;
import android.content.res.Configuration;
import android.platform.test.annotations.Presubmit;

import org.junit.Before;
@@ -129,6 +130,24 @@ public class WindowProcessControllerTests extends ActivityTestsBase {
        orderVerifier.verifyNoMoreInteractions();
    }

    @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 DisplayContent display = new TestDisplayContent.Builder(mService, 2000, 1000)
                .setDensityDpi(300).setPosition(DisplayContent.POSITION_TOP).build();
        wpc.registerDisplayConfigurationListenerLocked(display);

        assertEquals(display.mDisplayId, wpc.getDisplayId());
        final Configuration expectedConfig = mService.mRootWindowContainer.getConfiguration();
        expectedConfig.updateFrom(display.getConfiguration());
        assertEquals(expectedConfig, wpc.getConfiguration());
    }

    private TestDisplayContent createTestDisplayContentInContainer() {
        return new TestDisplayContent.Builder(mService, 1000, 1500).build();
    }