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

Commit 08f79506 authored by Graciela Wissen Putri's avatar Graciela Wissen Putri
Browse files

Don't return half folded state when display in transition

When unfolding device, device returns true for tabletop for a split
second. Tabletop has different default letterbox position multiplier
(top). When device is fully unfolded, tabletop position is false and
if position multiplier returns bottom/middle, app will flicker from top
to final position.

Flag: EXEMPT bugfix
Fix: 345735235
Test: Unfold with landscape app
      Open YT in tabletop
      atest SizeCompatTests
Change-Id: Iefaf6e2422e9c38fff7c3a931d94e94061bb5dd2
parent 465043a7
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -871,12 +871,14 @@ final class LetterboxUiController {
    // Check if we are in the given pose and in fullscreen mode.
    // Check if we are in the given pose and in fullscreen mode.
    // Note that we check the task rather than the parent as with ActivityEmbedding the parent might
    // Note that we check the task rather than the parent as with ActivityEmbedding the parent might
    // be a TaskFragment, and its windowing mode is always MULTI_WINDOW, even if the task is
    // be a TaskFragment, and its windowing mode is always MULTI_WINDOW, even if the task is
    // actually fullscreen.
    // actually fullscreen. If display is still in transition e.g. unfolding, don't return true
    // for HALF_FOLDED state or app will flicker.
    private boolean isDisplayFullScreenAndInPosture(boolean isTabletop) {
    private boolean isDisplayFullScreenAndInPosture(boolean isTabletop) {
        Task task = mActivityRecord.getTask();
        Task task = mActivityRecord.getTask();
        return mActivityRecord.mDisplayContent != null && task != null
        return mActivityRecord.mDisplayContent != null && task != null
                && mActivityRecord.mDisplayContent.getDisplayRotation().isDeviceInPosture(
                && mActivityRecord.mDisplayContent.getDisplayRotation().isDeviceInPosture(
                        DeviceStateController.DeviceState.HALF_FOLDED, isTabletop)
                        DeviceStateController.DeviceState.HALF_FOLDED, isTabletop)
                && !mActivityRecord.mDisplayContent.inTransition()
                && task.getWindowingMode() == WINDOWING_MODE_FULLSCREEN;
                && task.getWindowingMode() == WINDOWING_MODE_FULLSCREEN;
    }
    }


+29 −0
Original line number Original line Diff line number Diff line
@@ -4120,6 +4120,35 @@ public class SizeCompatTests extends WindowTestsBase {
        assertEquals(letterboxNoFold, mActivity.getBounds());
        assertEquals(letterboxNoFold, mActivity.getBounds());
    }
    }


    @Test
    public void testUpdateResolvedBoundsVerticalPosition_unfoldDisplay_notTabletop() {
        // Set up a display in portrait with a fixed-orientation LANDSCAPE app.
        setUpDisplaySizeWithApp(1000, 2000);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mActivity.mWmService.mLetterboxConfiguration.setLetterboxVerticalPositionMultiplier(
                1.0f /*letterboxVerticalPositionMultiplier*/);
        prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);

        // Make the activity full-screen.
        mTask.setWindowingMode(WINDOWING_MODE_FULLSCREEN);

        // Simulate display unfolding.
        setFoldablePosture(true /* isHalfFolded */, true /* isTabletop */);
        doReturn(true).when(mActivity.mDisplayContent).inTransition();
        resizeDisplay(mTask.mDisplayContent, 1400, 2800);

        // Make sure app doesn't jump to top (default tabletop position) when unfolding.
        assertEquals(1.0f, mActivity.mLetterboxUiController.getVerticalPositionMultiplier(
                mActivity.getParent().getConfiguration()), 0);

        // Simulate display fully open after unfolding.
        setFoldablePosture(false /* isHalfFolded */, false /* isTabletop */);
        doReturn(false).when(mActivity.mDisplayContent).inTransition();

        assertEquals(1.0f, mActivity.mLetterboxUiController.getVerticalPositionMultiplier(
                mActivity.getParent().getConfiguration()), 0);
    }

    @Test
    @Test
    public void testGetFixedOrientationLetterboxAspectRatio_tabletop_centered() {
    public void testGetFixedOrientationLetterboxAspectRatio_tabletop_centered() {
        // Set up a display in portrait with a fixed-orientation LANDSCAPE app
        // Set up a display in portrait with a fixed-orientation LANDSCAPE app