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

Commit 3e39f468 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Do not restrict app bounds by parent if overridden bounds exist" into main

parents fe53b5ea f871b31e
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() {