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

Commit f871b31e authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Do not restrict app bounds by parent if overridden bounds exist

This removed the app bounds intersection added in 7566d76c.

It is outdated since insetsDecoupledConfiguration is enabled.
The appBounds from display no longer considers decor insets.
The test testAppBounds_RootConfigurationBounds will always fail
if the display info has cutout.

It may also compute inconsistent info in configuration, e.g.
override bounds=300x600, parent app bounds=600x300,
then the intersected app bounds is 300x300
 > If app calls Display#getSize, it will get the square bounds.
But mTmpStableBounds is still calculated from full bounds 300x600.
 > If app gets Configuration#screenWidthDp/screenHeightDp,
   it will get a portrait size.

The real case may happen on flexible split screen that one side
is shifted outside the screen. It's app bounds should be able to
put at a negative position.

For legacy apps that needs the app bounds excluding decor insets,
now it is done by ConfigurationContainer#applySizeOverrideIfNeeded.

Bug: 426114417
Flag: EXEMPT bugfix
Test: TaskTests#testComputeConfigResourceOverrides
Change-Id: I06c540226c676bdc600976ac004fd5121b654b65
parent 1b9f146b
Loading
Loading
Loading
Loading
+10 −18
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ 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;
@@ -2437,23 +2436,16 @@ class TaskFragment extends WindowContainer<WindowContainer> {
            inOutConfig.windowConfiguration.setAppBounds(mTmpFullBounds);
            outAppBounds = inOutConfig.windowConfiguration.getAppBounds();

            // Floating tasks shouldn't be restricted by containing app bounds.
            if (!customContainerPolicy && !isFloating(windowingMode)) {
                final Rect containingAppBounds;
                if (insideParentBounds) {
                    containingAppBounds = useOverrideInsetsForConfig
                            ? overrideHint.mParentAppBoundsOverride
                            : parentConfig.windowConfiguration.getAppBounds();
                } else {
                    // Restrict appBounds to display non-decor rather than parent because the
                    // override bounds are beyond the parent. Otherwise, it won't match the
                    // overridden bounds.
                    final TaskDisplayArea displayArea = getDisplayArea();
                    containingAppBounds = displayArea != null
                            ? displayArea.getWindowConfiguration().getAppBounds() : null;
                }
                if (containingAppBounds != null && !containingAppBounds.isEmpty()) {
                    outAppBounds.intersect(containingAppBounds);
            if (insideParentBounds && useOverrideInsetsForConfig && !customContainerPolicy
                    && overrideHint.mParentAppBoundsOverride != null
                    && !WindowConfiguration.isFloating(windowingMode)) {
                // Clip decor insets for legacy apps (no INSETS_DECOUPLED_CONFIGURATION_ENFORCED).
                outAppBounds.intersectUnchecked(overrideHint.mParentAppBoundsOverride);
            } else if (resolvedBounds.isEmpty()) {
                // Inherit from parent if there is no override bounds.
                final Rect parentAppBounds = parentConfig.windowConfiguration.getAppBounds();
                if (parentAppBounds != null) {
                    outAppBounds.set(parentAppBounds);
                }
            }
        }
+8 −0
Original line number Diff line number Diff line
@@ -913,6 +913,14 @@ public class TaskTests extends WindowTestsBase {
        assertEquals(800, inOutConfig.screenHeightDp); // 960/(192/160) = 800
        assertEquals(450, inOutConfig.screenWidthDp); // 540/(192/160) = 450

        // Shift the bounds to be half outside the display (e.g. flexible/offscreen split).
        inOutConfig.windowConfiguration.getBounds().offset(0, -longSide / 2);
        inOutConfig.windowConfiguration.setAppBounds(null);
        task.computeConfigResourceOverrides(inOutConfig, parentConfig);
        assertEquals("Shifted override bounds should not be clipped by parent",
                inOutConfig.windowConfiguration.getBounds().height(),
                inOutConfig.windowConfiguration.getAppBounds().height());

        inOutConfig.setToDefaults();
        // Landscape bounds.
        final Rect largerLandscapeBounds = new Rect(0, 0, longSide, shortSide);
+0 −23
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import android.app.WindowConfiguration;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.platform.test.annotations.Presubmit;
import android.view.DisplayInfo;
import android.view.Surface;

import androidx.test.filters.SmallTest;
@@ -182,28 +181,6 @@ public class WindowConfigurationTests extends WindowTestsBase {
        assertEquals(ACTIVITY_TYPE_STANDARD, config.getActivityType());
    }

    /** Ensures the configuration app bounds at the root level match the app dimensions. */
    @Test
    public void testAppBounds_RootConfigurationBounds() {
        final DisplayInfo info = mDisplayContent.getDisplayInfo();
        info.appWidth = 1024;
        info.appHeight = 768;

        final Rect appBounds = mWm.computeNewConfiguration(
                mDisplayContent.getDisplayId()).windowConfiguration.getAppBounds();
        // The bounds should always be positioned in the top left besides cutout.
        final int expectedLeft = info.displayCutout != null
                ? info.displayCutout.getSafeInsetLeft() : 0;
        final int expectedTop = info.displayCutout != null
                ? info.displayCutout.getSafeInsetTop() : 0;
        assertEquals(expectedLeft, appBounds.left);
        assertEquals(expectedTop, appBounds.top);

        // The bounds should equal the defined app width and height
        assertEquals(info.appWidth, appBounds.width());
        assertEquals(info.appHeight, appBounds.height());
    }

    /** Ensure the window always has a caption in Freeform window mode or display mode. */
    @Test
    public void testMaskedSetTo() {