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

Commit d6836043 authored by Garfield Tan's avatar Garfield Tan
Browse files

Clear bounds of fullscreen leaf tasks

...not created by organizers

From the discussion of a previous uncommited CL we plan to restore the
bounds clearing when a leaf task is in fullscreen.

This restores a piece of logic that was removed in the commit
939b27cb and
3b911d9d.

Bug: 262317904
Test: ImeInsetsControllerTest#testChangeSizeWhileControlling on CF PC.
Test: atest TaskTests#testBoundsOnModeChangeFreeformToFullscreen
Test: atest ContentRecorderTests#testOnTaskBoundsConfigurationChanged_notifiesCallback
Test: atest TransitionTests#testVisibleChange_snapshot
Test: atest TransitionTests#testTransitionVisibleChange
Change-Id: I9b5a4d5dd0e2c519342f5ea8dc09ce2ef1e39bce
parent 458a0764
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2035,6 +2035,10 @@ class Task extends TaskFragment {
        Rect outOverrideBounds = getResolvedOverrideConfiguration().windowConfiguration.getBounds();

        if (windowingMode == WINDOWING_MODE_FULLSCREEN) {
            if (!mCreatedByOrganizer) {
                // Use empty bounds to indicate "fill parent".
                outOverrideBounds.setEmpty();
            }
            // The bounds for fullscreen mode shouldn't be adjusted by minimal size. Otherwise if
            // the parent or display is smaller than the size, the content may be cropped.
            return;
+12 −1
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.never;

import android.app.WindowConfiguration;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Point;
import android.graphics.Rect;
@@ -45,6 +47,7 @@ import android.platform.test.annotations.Presubmit;
import android.provider.DeviceConfig;
import android.util.DisplayMetrics;
import android.view.ContentRecordingSession;
import android.view.Gravity;
import android.view.Surface;
import android.view.SurfaceControl;

@@ -258,8 +261,17 @@ public class ContentRecorderTests extends WindowTestsBase {

    @Test
    public void testOnTaskBoundsConfigurationChanged_notifiesCallback() {
        mTask.getRootTask().setWindowingMode(WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW);

        final int recordedWidth = 333;
        final int recordedHeight = 999;

        final ActivityInfo info = new ActivityInfo();
        info.windowLayout = new ActivityInfo.WindowLayout(-1 /* width */,
                        -1 /* widthFraction */, -1 /* height */, -1 /* heightFraction */,
                        Gravity.NO_GRAVITY, recordedWidth, recordedHeight);
        mTask.setMinDimensions(info);

        // WHEN a recording is ongoing.
        mContentRecorder.setContentRecordingSession(mTaskSession);
        mContentRecorder.updateRecording();
@@ -267,7 +279,6 @@ public class ContentRecorderTests extends WindowTestsBase {

        // WHEN a configuration change arrives, and the recorded content is a different size.
        mTask.setBounds(new Rect(0, 0, recordedWidth, recordedHeight));
        mContentRecorder.onConfigurationChanged(mDefaultDisplay.getLastOrientation());
        assertThat(mContentRecorder.isCurrentlyRecording()).isTrue();

        // THEN content in the captured DisplayArea is scaled to fit the surface size.
+28 −0
Original line number Diff line number Diff line
@@ -535,6 +535,34 @@ public class TaskTests extends WindowTestsBase {
        assertEquals(reqBounds.height(), task.getBounds().height());
    }

    /** Tests that the task bounds adjust properly to changes between FULLSCREEN and FREEFORM */
    @Test
    public void testBoundsOnModeChangeFreeformToFullscreen() {
        DisplayContent display = mAtm.mRootWindowContainer.getDefaultDisplay();
        Task rootTask = new TaskBuilder(mSupervisor).setDisplay(display).setCreateActivity(true)
                .setWindowingMode(WINDOWING_MODE_FREEFORM).build();
        Task task = rootTask.getBottomMostTask();
        task.getRootActivity().setOrientation(SCREEN_ORIENTATION_UNSPECIFIED);
        DisplayInfo info = new DisplayInfo();
        display.mDisplay.getDisplayInfo(info);
        final Rect fullScreenBounds = new Rect(0, 0, info.logicalWidth, info.logicalHeight);
        final Rect freeformBounds = new Rect(fullScreenBounds);
        freeformBounds.inset((int) (freeformBounds.width() * 0.2),
                (int) (freeformBounds.height() * 0.2));
        task.setBounds(freeformBounds);

        assertEquals(freeformBounds, task.getBounds());

        // FULLSCREEN inherits bounds
        rootTask.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        assertEquals(fullScreenBounds, task.getBounds());
        assertEquals(freeformBounds, task.mLastNonFullscreenBounds);

        // FREEFORM restores bounds
        rootTask.setWindowingMode(WINDOWING_MODE_FREEFORM);
        assertEquals(freeformBounds, task.getBounds());
    }

    /**
     * Tests that a task with forced orientation has orientation-consistent bounds within the
     * parent.
+5 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.wm;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS;
@@ -1696,7 +1697,8 @@ public class TransitionTests extends WindowTestsBase {
    @Test
    public void testTransitionVisibleChange() {
        registerTestTransitionPlayer();
        final ActivityRecord app = createActivityRecord(mDisplayContent);
        final ActivityRecord app = createActivityRecord(
                mDisplayContent, WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD);
        final Transition transition = new Transition(TRANSIT_OPEN, 0 /* flags */,
                app.mTransitionController, mWm.mSyncEngine);
        app.mTransitionController.moveToCollecting(transition, BLASTSyncEngine.METHOD_NONE);
@@ -1746,7 +1748,8 @@ public class TransitionTests extends WindowTestsBase {
    @Test
    public void testVisibleChange_snapshot() {
        registerTestTransitionPlayer();
        final ActivityRecord app = createActivityRecord(mDisplayContent);
        final ActivityRecord app = createActivityRecord(
                mDisplayContent, WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD);
        final Transition transition = new Transition(TRANSIT_CHANGE, 0 /* flags */,
                app.mTransitionController, mWm.mSyncEngine);
        app.mTransitionController.moveToCollecting(transition, BLASTSyncEngine.METHOD_NONE);