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

Commit 3fbb8193 authored by Priyanka Advani's avatar Priyanka Advani Committed by Automerger Merge Worker
Browse files

Merge "Revert "Use resolved bounds in CompatDisplayInsets if letterboxed for...

Merge "Revert "Use resolved bounds in CompatDisplayInsets if letterboxed for aspect ratio"" into 24D1-dev am: 0c3e06ec

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



Change-Id: Ifb2c6db8f86d67add65bab4e4a4c1541e1b25757
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 57636844 0c3e06ec
Loading
Loading
Loading
Loading
+17 −31
Original line number Original line Diff line number Diff line
@@ -819,12 +819,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    @Nullable
    @Nullable
    private Rect mLetterboxBoundsForFixedOrientationAndAspectRatio;
    private Rect mLetterboxBoundsForFixedOrientationAndAspectRatio;


    // Bounds populated in resolveAspectRatioRestriction when this activity is letterboxed for
    // aspect ratio. If not null, they are used as parent container in
    // resolveSizeCompatModeConfiguration and in a constructor of CompatDisplayInsets.
    @Nullable
    private Rect mLetterboxBoundsForAspectRatio;

    // Whether the activity is eligible to be letterboxed for fixed orientation with respect to its
    // Whether the activity is eligible to be letterboxed for fixed orientation with respect to its
    // requested orientation, even when it's letterbox for another reason (e.g., size compat mode)
    // requested orientation, even when it's letterbox for another reason (e.g., size compat mode)
    // and therefore #isLetterboxedForFixedOrientationAndAspectRatio returns false.
    // and therefore #isLetterboxedForFixedOrientationAndAspectRatio returns false.
@@ -8427,14 +8421,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    fullConfig.windowConfiguration.getRotation());
                    fullConfig.windowConfiguration.getRotation());
        }
        }


        final Rect letterboxedContainerBounds =
                mLetterboxBoundsForFixedOrientationAndAspectRatio != null
                ? mLetterboxBoundsForFixedOrientationAndAspectRatio
                : mLetterboxBoundsForAspectRatio;

        // The role of CompatDisplayInsets is like the override bounds.
        // The role of CompatDisplayInsets is like the override bounds.
        mCompatDisplayInsets =
        mCompatDisplayInsets =
                new CompatDisplayInsets(mDisplayContent, this, letterboxedContainerBounds);
                new CompatDisplayInsets(
                        mDisplayContent, this, mLetterboxBoundsForFixedOrientationAndAspectRatio);
    }
    }


    private void clearSizeCompatModeAttributes() {
    private void clearSizeCompatModeAttributes() {
@@ -8506,7 +8496,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        mIsAspectRatioApplied = false;
        mIsAspectRatioApplied = false;
        mIsEligibleForFixedOrientationLetterbox = false;
        mIsEligibleForFixedOrientationLetterbox = false;
        mLetterboxBoundsForFixedOrientationAndAspectRatio = null;
        mLetterboxBoundsForFixedOrientationAndAspectRatio = null;
        mLetterboxBoundsForAspectRatio = null;


        // Can't use resolvedConfig.windowConfiguration.getWindowingMode() because it can be
        // Can't use resolvedConfig.windowConfiguration.getWindowingMode() because it can be
        // different from windowing mode of the task (PiP) during transition from fullscreen to PiP
        // different from windowing mode of the task (PiP) during transition from fullscreen to PiP
@@ -8545,11 +8534,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                getTaskFragment().computeConfigResourceOverrides(resolvedConfig,
                getTaskFragment().computeConfigResourceOverrides(resolvedConfig,
                        newParentConfiguration);
                        newParentConfiguration);
            }
            }
        }
        // If activity in fullscreen mode is letterboxed because of fixed orientation then bounds
        // If activity in fullscreen mode is letterboxed because of fixed orientation then bounds
        // are already calculated in resolveFixedOrientationConfiguration, or if in size compat
        // are already calculated in resolveFixedOrientationConfiguration.
        // mode, it should already be calculated in resolveSizeCompatModeConfiguration
        } else if (!isLetterboxedForFixedOrientationAndAspectRatio()) {
        if (!isLetterboxedForFixedOrientationAndAspectRatio() && !mInSizeCompatModeForBounds) {
            resolveAspectRatioRestriction(newParentConfiguration);
            resolveAspectRatioRestriction(newParentConfiguration);
        }
        }


@@ -9043,8 +9030,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        }
        final CompatDisplayInsets compatDisplayInsets = getCompatDisplayInsets();
        final CompatDisplayInsets compatDisplayInsets = getCompatDisplayInsets();


        if (compatDisplayInsets != null
        if (compatDisplayInsets != null && !compatDisplayInsets.mIsInFixedOrientationLetterbox) {
                && !compatDisplayInsets.mIsInFixedOrientationOrAspectRatioLetterbox) {
            // App prefers to keep its original size.
            // App prefers to keep its original size.
            // If the size compat is from previous fixed orientation letterboxing, we may want to
            // If the size compat is from previous fixed orientation letterboxing, we may want to
            // have fixed orientation letterbox again, otherwise it will show the size compat
            // have fixed orientation letterbox again, otherwise it will show the size compat
@@ -9176,7 +9162,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            // restrict, the bounds should be the requested override bounds.
            // restrict, the bounds should be the requested override bounds.
            getTaskFragment().computeConfigResourceOverrides(resolvedConfig, newParentConfiguration,
            getTaskFragment().computeConfigResourceOverrides(resolvedConfig, newParentConfiguration,
                    getFixedRotationTransformDisplayInfo());
                    getFixedRotationTransformDisplayInfo());
            mLetterboxBoundsForAspectRatio = new Rect(resolvedBounds);
        }
        }
    }
    }


@@ -10741,10 +10726,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        /** Whether the {@link Task} windowingMode represents a floating window*/
        /** Whether the {@link Task} windowingMode represents a floating window*/
        final boolean mIsFloating;
        final boolean mIsFloating;
        /**
        /**
         * Whether is letterboxed because of fixed orientation or aspect ratio when the
         * Whether is letterboxed because of fixed orientation when the unresizable activity is
         * unresizable activity is first shown.
         * first shown.
         */
         */
        final boolean mIsInFixedOrientationOrAspectRatioLetterbox;
        final boolean mIsInFixedOrientationLetterbox;
        /**
        /**
         * The nonDecorInsets for each rotation. Includes the navigation bar and cutout insets. It
         * The nonDecorInsets for each rotation. Includes the navigation bar and cutout insets. It
         * is used to compute the appBounds.
         * is used to compute the appBounds.
@@ -10759,7 +10744,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A


        /** Constructs the environment to simulate the bounds behavior of the given container. */
        /** Constructs the environment to simulate the bounds behavior of the given container. */
        CompatDisplayInsets(DisplayContent display, ActivityRecord container,
        CompatDisplayInsets(DisplayContent display, ActivityRecord container,
                @Nullable Rect letterboxedContainerBounds) {
                @Nullable Rect fixedOrientationBounds) {
            mOriginalRotation = display.getRotation();
            mOriginalRotation = display.getRotation();
            mIsFloating = container.getWindowConfiguration().tasksAreFloating();
            mIsFloating = container.getWindowConfiguration().tasksAreFloating();
            mOriginalRequestedOrientation = container.getRequestedConfigurationOrientation();
            mOriginalRequestedOrientation = container.getRequestedConfigurationOrientation();
@@ -10774,21 +10759,22 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    mNonDecorInsets[rotation] = emptyRect;
                    mNonDecorInsets[rotation] = emptyRect;
                    mStableInsets[rotation] = emptyRect;
                    mStableInsets[rotation] = emptyRect;
                }
                }
                mIsInFixedOrientationOrAspectRatioLetterbox = false;
                mIsInFixedOrientationLetterbox = false;
                return;
                return;
            }
            }


            final Task task = container.getTask();
            final Task task = container.getTask();


            mIsInFixedOrientationOrAspectRatioLetterbox = letterboxedContainerBounds != null;
            mIsInFixedOrientationLetterbox = fixedOrientationBounds != null;

            // Store the bounds of the Task for the non-resizable activity to use in size compat
            // Store the bounds of the Task for the non-resizable activity to use in size compat
            // mode so that the activity will not be resized regardless the windowing mode it is
            // mode so that the activity will not be resized regardless the windowing mode it is
            // currently in.
            // currently in.
            // When an activity needs to be letterboxed because of fixed orientation or aspect
            // When an activity needs to be letterboxed because of fixed orientation, use fixed
            // ratio, use resolved bounds instead of task bounds since the activity will be
            // orientation bounds instead of task bounds since the activity will be displayed
            // displayed within these even if it is in size compat mode.
            // within these even if it is in size compat mode.
            final Rect filledContainerBounds = mIsInFixedOrientationOrAspectRatioLetterbox
            final Rect filledContainerBounds = mIsInFixedOrientationLetterbox
                    ? letterboxedContainerBounds
                    ? fixedOrientationBounds
                    : task != null ? task.getBounds() : display.getBounds();
                    : task != null ? task.getBounds() : display.getBounds();
            final int filledContainerRotation = task != null
            final int filledContainerRotation = task != null
                    ? task.getConfiguration().windowConfiguration.getRotation()
                    ? task.getConfiguration().windowConfiguration.getRotation()
+2 −33
Original line number Original line Diff line number Diff line
@@ -27,7 +27,6 @@ import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_16_9;
import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_16_9;
import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_3_2;
import static android.content.pm.PackageManager.USER_MIN_ASPECT_RATIO_3_2;
@@ -1943,6 +1942,7 @@ public class SizeCompatTests extends WindowTestsBase {
        assertThat(mActivity.inSizeCompatMode()).isTrue();
        assertThat(mActivity.inSizeCompatMode()).isTrue();
        assertActivityMaxBoundsSandboxed();
        assertActivityMaxBoundsSandboxed();



	final int scale = dh / dw;
	final int scale = dh / dw;


        // App bounds should be dh / scale x dw / scale
        // App bounds should be dh / scale x dw / scale
@@ -4147,37 +4147,6 @@ public class SizeCompatTests extends WindowTestsBase {
        assertFalse(mActivity.isLetterboxedForFixedOrientationAndAspectRatio());
        assertFalse(mActivity.isLetterboxedForFixedOrientationAndAspectRatio());
    }
    }


    @Test
    public void testFixedAspectRatioAppInPortraitCloseToSquareDisplay_notInSizeCompat() {
        setUpDisplaySizeWithApp(2200, 2280);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        final DisplayContent display = mActivity.mDisplayContent;
        // Simulate taskbar, final app bounds are (0, 0, 2200, 2130) - landscape
        final WindowState navbar = createWindow(null, TYPE_NAVIGATION_BAR, mDisplayContent,
                "navbar");
        final Binder owner = new Binder();
        navbar.mAttrs.providedInsets = new InsetsFrameProvider[] {
                new InsetsFrameProvider(owner, 0, WindowInsets.Type.navigationBars())
                        .setInsetsSize(Insets.of(0, 0, 0, 150))
        };
        display.getDisplayPolicy().addWindowLw(navbar, navbar.mAttrs);
        assertTrue(navbar.providesDisplayDecorInsets()
                && display.getDisplayPolicy().updateDecorInsetsInfo());
        display.sendNewConfiguration();

        prepareMinAspectRatio(mActivity, OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE,
                SCREEN_ORIENTATION_LANDSCAPE);
        // To force config to update again but with the same landscape orientation.
        mActivity.setRequestedOrientation(SCREEN_ORIENTATION_SENSOR_LANDSCAPE);

        assertTrue(mActivity.shouldCreateCompatDisplayInsets());
        assertNotNull(mActivity.getCompatDisplayInsets());
        // Activity is not letterboxed for fixed orientation because orientation is respected
        // with insets, and should not be in size compat mode
        assertFalse(mActivity.isLetterboxedForFixedOrientationAndAspectRatio());
        assertFalse(mActivity.inSizeCompatMode());
    }

    @Test
    @Test
    public void testApplyAspectRatio_activityAlignWithParentAppVertical() {
    public void testApplyAspectRatio_activityAlignWithParentAppVertical() {
        if (Flags.insetsDecoupledConfiguration()) {
        if (Flags.insetsDecoupledConfiguration()) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -833,7 +833,7 @@ public class TaskTests extends WindowTestsBase {
        final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(task).build();
        final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(task).build();
        final ActivityRecord.CompatDisplayInsets compatInsets =
        final ActivityRecord.CompatDisplayInsets compatInsets =
                new ActivityRecord.CompatDisplayInsets(
                new ActivityRecord.CompatDisplayInsets(
                        display, activity, /* letterboxedContainerBounds */ null);
                        display, activity, /* fixedOrientationBounds= */ null);
        task.computeConfigResourceOverrides(inOutConfig, parentConfig, compatInsets);
        task.computeConfigResourceOverrides(inOutConfig, parentConfig, compatInsets);


        assertEquals(largerLandscapeBounds, inOutConfig.windowConfiguration.getAppBounds());
        assertEquals(largerLandscapeBounds, inOutConfig.windowConfiguration.getAppBounds());