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

Commit 1fefa04d authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas
Browse files

Don't override bounds to include insets for floating activities

Insets have been decoupled from app bounds from V+. To keep the legacy
behaviour, we override the app bounds to include insets for apps
targeting older sdks. However, floating windows do not include insets
and thus the app bounds in this case should not be adjusted to include
them.

Flag: EXEMPT bugfix
Test: Manual && atest WmTests:SizeCompatTests
Fixes: 348202594
Change-Id: I2d472e4d92f5be95b448e9fed4a2cd7d2f45517e
parent ba45d797
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) {