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

Commit a20643bb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "DisplayPolicy: Check that window provided insets" into tm-qpr-dev am:...

Merge "DisplayPolicy: Check that window provided insets" into tm-qpr-dev am: efeebb8c am: 1e27923b

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20063509



Change-Id: I66c1f760686cd2823cdfe336af9b9066effceb66
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 91d28dbd 1e27923b
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -2167,10 +2167,7 @@ public class DisplayPolicy {
     * If the decor insets changes, the display configuration may be affected. The caller should
     * If the decor insets changes, the display configuration may be affected. The caller should
     * call {@link DisplayContent#sendNewConfiguration()} if this method returns {@code true}.
     * call {@link DisplayContent#sendNewConfiguration()} if this method returns {@code true}.
     */
     */
    boolean updateDecorInsetsInfoIfNeeded(WindowState win) {
    boolean updateDecorInsetsInfo() {
        if (!win.providesNonDecorInsets()) {
            return false;
        }
        final DisplayFrames displayFrames = mDisplayContent.mDisplayFrames;
        final DisplayFrames displayFrames = mDisplayContent.mDisplayFrames;
        final int rotation = displayFrames.mRotation;
        final int rotation = displayFrames.mRotation;
        final int dw = displayFrames.mWidth;
        final int dw = displayFrames.mWidth;
+8 −4
Original line number Original line Diff line number Diff line
@@ -1834,8 +1834,12 @@ public class WindowManagerService extends IWindowManager.Stub
            ProtoLog.v(WM_DEBUG_ADD_REMOVE, "addWindow: New client %s"
            ProtoLog.v(WM_DEBUG_ADD_REMOVE, "addWindow: New client %s"
                    + ": window=%s Callers=%s", client.asBinder(), win, Debug.getCallers(5));
                    + ": window=%s Callers=%s", client.asBinder(), win, Debug.getCallers(5));


            if ((win.isVisibleRequestedOrAdding() && displayContent.updateOrientation())
            boolean needToSendNewConfiguration =
                    || displayPolicy.updateDecorInsetsInfoIfNeeded(win)) {
                    win.isVisibleRequestedOrAdding() && displayContent.updateOrientation();
            if (win.providesNonDecorInsets()) {
                needToSendNewConfiguration |= displayPolicy.updateDecorInsetsInfo();
            }
            if (needToSendNewConfiguration) {
                displayContent.sendNewConfiguration();
                displayContent.sendNewConfiguration();
            }
            }


@@ -2304,8 +2308,8 @@ public class WindowManagerService extends IWindowManager.Stub
                        & WindowManager.LayoutParams.SYSTEM_UI_VISIBILITY_CHANGED) != 0) {
                        & WindowManager.LayoutParams.SYSTEM_UI_VISIBILITY_CHANGED) != 0) {
                    win.mLayoutNeeded = true;
                    win.mLayoutNeeded = true;
                }
                }
                if (layoutChanged) {
                if (layoutChanged && win.providesNonDecorInsets()) {
                    configChanged = displayPolicy.updateDecorInsetsInfoIfNeeded(win);
                    configChanged = displayPolicy.updateDecorInsetsInfo();
                }
                }
                if (win.mActivityRecord != null && ((flagChanges & FLAG_SHOW_WHEN_LOCKED) != 0
                if (win.mActivityRecord != null && ((flagChanges & FLAG_SHOW_WHEN_LOCKED) != 0
                        || (flagChanges & FLAG_DISMISS_KEYGUARD) != 0)) {
                        || (flagChanges & FLAG_DISMISS_KEYGUARD) != 0)) {
+10 −2
Original line number Original line Diff line number Diff line
@@ -2626,11 +2626,19 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                }
                }
            }
            }


            // Check if window provides non decor insets before clearing its provided insets.
            final boolean windowProvidesNonDecorInsets = providesNonDecorInsets();

            removeImmediately();
            removeImmediately();
            // Removing a visible window may affect the display orientation so just update it if
            // Removing a visible window may affect the display orientation so just update it if
            // needed. Also recompute configuration if it provides screen decor insets.
            // needed. Also recompute configuration if it provides screen decor insets.
            if ((wasVisible && displayContent.updateOrientation())
            boolean needToSendNewConfiguration = wasVisible && displayContent.updateOrientation();
                    || displayContent.getDisplayPolicy().updateDecorInsetsInfoIfNeeded(this)) {
            if (windowProvidesNonDecorInsets) {
                needToSendNewConfiguration |=
                        displayContent.getDisplayPolicy().updateDecorInsetsInfo();
            }

            if (needToSendNewConfiguration) {
                displayContent.sendNewConfiguration();
                displayContent.sendNewConfiguration();
            }
            }
            mWmService.updateFocusedWindowLocked(isFocused()
            mWmService.updateFocusedWindowLocked(isFocused()
+2 −1
Original line number Original line Diff line number Diff line
@@ -2990,7 +2990,8 @@ public class ActivityRecordTests extends WindowTestsBase {
                .setSystemDecorations(true).build();
                .setSystemDecorations(true).build();
        // Add a decor insets provider window.
        // Add a decor insets provider window.
        final WindowState navbar = createNavBarWithProvidedInsets(squareDisplay);
        final WindowState navbar = createNavBarWithProvidedInsets(squareDisplay);
        squareDisplay.getDisplayPolicy().updateDecorInsetsInfoIfNeeded(navbar);
        assertTrue(navbar.providesNonDecorInsets()
                && squareDisplay.getDisplayPolicy().updateDecorInsetsInfo());
        squareDisplay.sendNewConfiguration();
        squareDisplay.sendNewConfiguration();
        final Task task = new TaskBuilder(mSupervisor).setDisplay(squareDisplay).build();
        final Task task = new TaskBuilder(mSupervisor).setDisplay(squareDisplay).build();


+6 −2
Original line number Original line Diff line number Diff line
@@ -292,12 +292,16 @@ public class DisplayPolicyTests extends WindowTestsBase {
        final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
        final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
        final DisplayInfo di = mDisplayContent.getDisplayInfo();
        final DisplayInfo di = mDisplayContent.getDisplayInfo();
        final int prevScreenHeightDp = mDisplayContent.getConfiguration().screenHeightDp;
        final int prevScreenHeightDp = mDisplayContent.getConfiguration().screenHeightDp;
        assertTrue(displayPolicy.updateDecorInsetsInfoIfNeeded(navbar));
        assertTrue(navbar.providesNonDecorInsets() && displayPolicy.updateDecorInsetsInfo());
        assertEquals(NAV_BAR_HEIGHT, displayPolicy.getDecorInsetsInfo(di.rotation,
        assertEquals(NAV_BAR_HEIGHT, displayPolicy.getDecorInsetsInfo(di.rotation,
                di.logicalWidth, di.logicalHeight).mConfigInsets.bottom);
                di.logicalWidth, di.logicalHeight).mConfigInsets.bottom);
        mDisplayContent.sendNewConfiguration();
        mDisplayContent.sendNewConfiguration();
        assertNotEquals(prevScreenHeightDp, mDisplayContent.getConfiguration().screenHeightDp);
        assertNotEquals(prevScreenHeightDp, mDisplayContent.getConfiguration().screenHeightDp);
        assertFalse(displayPolicy.updateDecorInsetsInfoIfNeeded(navbar));
        assertFalse(navbar.providesNonDecorInsets() && displayPolicy.updateDecorInsetsInfo());

        navbar.removeIfPossible();
        assertEquals(0, displayPolicy.getDecorInsetsInfo(di.rotation, di.logicalWidth,
                di.logicalHeight).mNonDecorInsets.bottom);
    }
    }


    @SetupWindows(addWindows = { W_NAVIGATION_BAR, W_INPUT_METHOD })
    @SetupWindows(addWindows = { W_NAVIGATION_BAR, W_INPUT_METHOD })