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

Commit c49cbea0 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Do not recompute display config if its config frame is not changed

Since insetsDecoupledConfiguration is enabled, the display
configuration is no longer affected by insets. So if the insets are
changed, it only needs to update the override frame for legacy apps
and reports no change to the display.

Bug: 159103089
Flag: EXEMPT skip extra invocation
Test: DisplayPolicyTests#testUpdateDisplayConfigurationByDecor
Change-Id: I33b026ecee464d7d0b9417a32f871daf47f6fea5
parent 5268d622
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)