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

Commit 351b9212 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Do not recompute display config if its config frame is not changed" into main

parents 8658e88a c49cbea0
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -2131,7 +2131,8 @@ public class DisplayPolicy {
        final DecorInsets.Info newInfo = mDecorInsets.mTmpInfo;
        final InsetsState newInsetsState = newInfo.update(mDisplayContent, rotation, dw, dh);
        final DecorInsets.Info currentInfo = getDecorInsetsInfo(rotation, dw, dh);
        if (newInfo.mConfigFrame.equals(currentInfo.mConfigFrame)
        final boolean sameConfigFrame = newInfo.mConfigFrame.equals(currentInfo.mConfigFrame);
        if (sameConfigFrame
                && newInfo.mOverrideConfigFrame.equals(currentInfo.mOverrideConfigFrame)) {
            // Even if the config frame is not changed in current rotation, it may change the
            // insets in other rotations if the frame of insets source is changed.
@@ -2155,7 +2156,7 @@ public class DisplayPolicy {
        }
        mDecorInsets.invalidate();
        mDecorInsets.mInfoForRotation[rotation].set(newInfo);
        return true;
        return !sameConfigFrame;
    }

    DecorInsets.Info getDecorInsetsInfo(int rotation, int w, int h) {
+14 −4
Original line number Diff line number Diff line
@@ -413,15 +413,25 @@ public class DisplayPolicyTests extends WindowTestsBase {

    @Test
    public void testUpdateDisplayConfigurationByDecor() {
        if (Flags.insetsDecoupledConfiguration()) {
            // No configuration update when flag enables.
            return;
        }
        doReturn(NO_CUTOUT).when(mDisplayContent).calculateDisplayCutoutForRotation(anyInt());
        final WindowState navbar = createNavBarWithProvidedInsets(mDisplayContent);
        final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
        final DisplayInfo di = mDisplayContent.getDisplayInfo();
        final int prevScreenHeightDp = mDisplayContent.getConfiguration().screenHeightDp;
        if (Flags.insetsDecoupledConfiguration()) {
            // No configuration update when flag enables.
            assertFalse(displayPolicy.updateDecorInsetsInfo());
            assertEquals(NAV_BAR_HEIGHT, displayPolicy.getDecorInsetsInfo(di.rotation,
                    di.logicalHeight, di.logicalWidth).mOverrideConfigInsets.bottom);

            final int barHeight = 2 * NAV_BAR_HEIGHT;
            navbar.mAttrs.providedInsets[0].setInsetsSize(Insets.of(0, 0, 0, barHeight));
            assertFalse(displayPolicy.updateDecorInsetsInfo());
            assertEquals(barHeight, displayPolicy.getDecorInsetsInfo(di.rotation,
                    di.logicalHeight, di.logicalWidth).mOverrideConfigInsets.bottom);
            return;
        }

        assertTrue(navbar.providesDisplayDecorInsets() && displayPolicy.updateDecorInsetsInfo());
        assertEquals(NAV_BAR_HEIGHT, displayPolicy.getDecorInsetsInfo(di.rotation,
                di.logicalWidth, di.logicalHeight).mConfigInsets.bottom);
+9 −6
Original line number Diff line number Diff line
@@ -4063,8 +4063,9 @@ public class SizeCompatTests extends WindowTestsBase {
                        .setInsetsSize(Insets.of(0, 0, 0, 150))
        };
        display.getDisplayPolicy().addWindowLw(navbar, navbar.mAttrs);
        assertTrue(display.getDisplayPolicy().updateDecorInsetsInfo());
        if (display.getDisplayPolicy().updateDecorInsetsInfo()) {
            display.sendNewConfiguration();
        }

        final ActivityRecord activity = getActivityBuilderOnSameTask()
                .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT)
@@ -4097,8 +4098,9 @@ public class SizeCompatTests extends WindowTestsBase {
                        .setInsetsSize(Insets.of(0, 0, 0, 150))
        };
        display.getDisplayPolicy().addWindowLw(navbar, navbar.mAttrs);
        assertTrue(display.getDisplayPolicy().updateDecorInsetsInfo());
        if (display.getDisplayPolicy().updateDecorInsetsInfo()) {
            display.sendNewConfiguration();
        }

        final ActivityRecord activity = getActivityBuilderOnSameTask()
                .setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT)
@@ -4126,8 +4128,9 @@ public class SizeCompatTests extends WindowTestsBase {
                        .setInsetsSize(Insets.of(0, 0, 0, 150))
        };
        dc.getDisplayPolicy().addWindowLw(navbar, navbar.mAttrs);
        assertTrue(dc.getDisplayPolicy().updateDecorInsetsInfo());
        if (dc.getDisplayPolicy().updateDecorInsetsInfo()) {
            dc.sendNewConfiguration();
        }

        final ActivityRecord activity = getActivityBuilderOnSameTask()
                .setResizeMode(RESIZE_MODE_UNRESIZEABLE)