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

Commit 352d3280 authored by Qijing Yao's avatar Qijing Yao Committed by Android (Google) Code Review
Browse files

Merge "Update DisplayLayout#mGlobalBoundsDp when display config changes" into main

parents 34f9f07e 80e83f72
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -287,7 +287,13 @@ public class DisplayController {
                    ? mContext
                    : mContext.createDisplayContext(display);
            final Context context = perDisplayContext.createConfigurationContext(newConfig);
            dr.setDisplayLayout(context, new DisplayLayout(context, display));
            final DisplayLayout displayLayout = new DisplayLayout(context, display);
            if (mDisplayTopology != null) {
                displayLayout.setGlobalBoundsDp(
                        mDisplayTopology.getAbsoluteBounds().get(
                                displayId, displayLayout.globalBoundsDp()));
            }
            dr.setDisplayLayout(context, displayLayout);
            for (int i = 0; i < mDisplayChangedListeners.size(); ++i) {
                mDisplayChangedListeners.get(i).onDisplayConfigurationChanged(
                        displayId, newConfig);
+21 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.common;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -231,4 +232,24 @@ public class DisplayControllerTests extends ShellTestCase {
        assertEquals(DISPLAY_ABS_BOUNDS_1,
                mController.getDisplayLayout(DISPLAY_ID_1).globalBoundsDp());
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_CONNECTED_DISPLAYS_WINDOW_DRAG)
    public void onDisplayConfigurationChanged_reInitDisplayLayout()
            throws RemoteException {
        ExtendedMockito.doReturn(true)
                .when(() -> DesktopModeStatus.canEnterDesktopMode(any()));
        mController.onInit();
        mController.addDisplayWindowListener(mListener);

        mCapturedTopologyListener.accept(mMockTopology);

        DisplayLayout displayLayoutBefore = mController.getDisplayLayout(DISPLAY_ID_0);
        mDisplayContainerListener.onDisplayConfigurationChanged(DISPLAY_ID_0, new Configuration());
        DisplayLayout displayLayoutAfter = mController.getDisplayLayout(DISPLAY_ID_0);

        assertNotSame(displayLayoutBefore, displayLayoutAfter);
        assertEquals(DISPLAY_ABS_BOUNDS_0,
                mController.getDisplayLayout(DISPLAY_ID_0).globalBoundsDp());
    }
}