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

Commit 998ccda0 authored by Massimo Carli's avatar Massimo Carli Committed by Android (Google) Code Review
Browse files

Merge "Don't override bounds to include insets for floating activities" into main

parents 26c0ef25 1fefa04d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.app.WindowConfiguration.isFloating;
import static android.content.pm.ActivityInfo.FLAG_ALLOW_UNTRUSTED_ACTIVITY_EMBEDDING;
import static android.content.pm.ActivityInfo.FLAG_RESUME_WHILE_PAUSING;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
@@ -2248,8 +2249,10 @@ class TaskFragment extends WindowContainer<WindowContainer> {
        void resolveTmpOverrides(DisplayContent dc, Configuration parentConfig,
                boolean isFixedRotationTransforming) {
            mParentAppBoundsOverride = new Rect(parentConfig.windowConfiguration.getAppBounds());
            mTmpOverrideConfigOrientation = parentConfig.orientation;
            final Insets insets;
            if (mUseOverrideInsetsForConfig && dc != null) {
            if (mUseOverrideInsetsForConfig && dc != null
                    && !isFloating(parentConfig.windowConfiguration.getWindowingMode())) {
                // Insets are decoupled from configuration by default from V+, use legacy
                // compatibility behaviour for apps targeting SDK earlier than 35
                // (see applySizeOverrideIfNeeded).
+21 −0
Original line number Diff line number Diff line
@@ -4271,6 +4271,27 @@ public class SizeCompatTests extends WindowTestsBase {

    }

    @Test
    public void testInsetOverrideNotAppliedInFreeform() {
        final int notchHeight = 100;
        final DisplayContent display = new TestDisplayContent.Builder(mAtm, 1000, 2800)
                .setNotch(notchHeight)
                .build();
        setUpApp(display);

        // Simulate inset override for legacy app bound behaviour
        mActivity.mResolveConfigHint.mUseOverrideInsetsForConfig = true;
        // Set task as freeform
        mTask.setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM);
        prepareUnresizable(mActivity,  SCREEN_ORIENTATION_PORTRAIT);

        Rect bounds = new Rect(mActivity.getWindowConfiguration().getBounds());
        Rect appBounds = new Rect(mActivity.getWindowConfiguration().getAppBounds());
        // App bounds should not include insets and should match bounds when in freeform.
        assertEquals(new Rect(0, 0, 1000, 2800), appBounds);
        assertEquals(new Rect(0, 0, 1000, 2800), bounds);
    }

    private void assertVerticalPositionForDifferentDisplayConfigsForLandscapeActivity(
            float letterboxVerticalPositionMultiplier, Rect fixedOrientationLetterbox,
            Rect sizeCompatUnscaled, Rect sizeCompatScaled) {