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

Commit 2dbc2cf5 authored by Garfield Tan's avatar Garfield Tan
Browse files

Treat fullscreen windowing mode as fillsParent

At this moment not all fullscreen tasks fill its parent. They don't fill
parents because they are in letterbox, but in such cases it should still
let window containers above it know its requested orientation so when
display decides to respect its requested orientation it can rotate right
away before making a configuration resolution.

WindowState#isObscuringDisplay() also calls Task#fillsParent() which
seems to need this change as well.

This patching a hole mentioned in the bug because due to other reasons
the previous fix isn't enough anymore.

Bug: 156423660
Test: When fixed to user rotation is disabled display can rotate right
away.
Test: New test passed.

Change-Id: If09995815a505e885c789d288ca97a8c9e2b0bbd
parent 7fc13e85
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -3820,7 +3820,10 @@ class Task extends WindowContainer<WindowContainer> {

    @Override
    boolean fillsParent() {
        return matchParentBounds();
        // From the perspective of policy, we still want to report that this task fills parent
        // in fullscreen windowing mode even it doesn't match parent bounds because there will be
        // letterbox around its real content.
        return getWindowingMode() == WINDOWING_MODE_FULLSCREEN || matchParentBounds();
    }

    @Override
+33 −5
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@@ -245,17 +246,17 @@ public class TaskRecordTests extends WindowTestsBase {
        final Rect fullScreenBoundsPort = new Rect(0, 0, 1080, 1920);
        final DisplayContent display = new TestDisplayContent.Builder(mAtm,
                fullScreenBounds.width(), fullScreenBounds.height()).setCanRotate(false).build();
        assertTrue(mRootWindowContainer.getDisplayContent(display.mDisplayId) != null);
        assertNotNull(mRootWindowContainer.getDisplayContent(display.mDisplayId));
        // Fix the display orientation to landscape which is the natural rotation (0) for the test
        // display.
        final DisplayRotation dr = display.mDisplayContent.getDisplayRotation();
        dr.setFixedToUserRotation(FIXED_TO_USER_ROTATION_ENABLED);
        dr.setUserRotation(USER_ROTATION_FREE, ROTATION_0);

        Task stack = new StackBuilder(mRootWindowContainer)
        final Task stack = new StackBuilder(mRootWindowContainer)
                .setWindowingMode(WINDOWING_MODE_FULLSCREEN).setDisplay(display).build();
        Task task = stack.getBottomMostTask();
        ActivityRecord root = task.getTopNonFinishingActivity();
        final Task task = stack.getBottomMostTask();
        final ActivityRecord root = task.getTopNonFinishingActivity();

        assertEquals(fullScreenBounds, task.getBounds());

@@ -267,7 +268,7 @@ public class TaskRecordTests extends WindowTestsBase {
        assertEquals(fullScreenBounds.height(), task.getBounds().height());

        // Top activity gets used
        ActivityRecord top = new ActivityBuilder(mAtm).setTask(task).setStack(stack).build();
        final ActivityRecord top = new ActivityBuilder(mAtm).setTask(task).setStack(stack).build();
        assertEquals(top, task.getTopNonFinishingActivity());
        top.setRequestedOrientation(SCREEN_ORIENTATION_LANDSCAPE);
        assertThat(task.getBounds().width()).isGreaterThan(task.getBounds().height());
@@ -303,6 +304,33 @@ public class TaskRecordTests extends WindowTestsBase {
        assertEquals(freeformBounds, task.getBounds());
    }

    @Test
    public void testReportsOrientationRequestInLetterboxForOrientation() {
        final Rect fullScreenBounds = new Rect(0, 0, 1920, 1080);
        final Rect fullScreenBoundsPort = new Rect(0, 0, 1080, 1920);
        final DisplayContent display = new TestDisplayContent.Builder(mAtm,
                fullScreenBounds.width(), fullScreenBounds.height()).setCanRotate(false).build();
        assertNotNull(mRootWindowContainer.getDisplayContent(display.mDisplayId));
        // Fix the display orientation to landscape which is the natural rotation (0) for the test
        // display.
        final DisplayRotation dr = display.mDisplayContent.getDisplayRotation();
        dr.setFixedToUserRotation(FIXED_TO_USER_ROTATION_ENABLED);
        dr.setUserRotation(USER_ROTATION_FREE, ROTATION_0);

        final Task stack = new StackBuilder(mRootWindowContainer)
                .setWindowingMode(WINDOWING_MODE_FULLSCREEN).setDisplay(display).build();
        final Task task = stack.getBottomMostTask();
        ActivityRecord root = task.getTopNonFinishingActivity();

        assertEquals(fullScreenBounds, task.getBounds());

        // Setting app to fixed portrait fits within parent
        root.setRequestedOrientation(SCREEN_ORIENTATION_PORTRAIT);
        assertThat(task.getBounds().width()).isLessThan(task.getBounds().height());

        assertEquals(SCREEN_ORIENTATION_PORTRAIT, task.getOrientation());
    }

    @Test
    public void testIgnoresForcedOrientationWhenParentHandles() {
        final Rect fullScreenBounds = new Rect(0, 0, 1920, 1080);