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

Commit 9cfa3b06 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Consolidate size compat bounds calculation" into rvc-dev am: 502b81a8

Change-Id: Ie0177174891b5cd3c81dcf76a5fd957d8fa50607
parents 618e105b 502b81a8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -229,6 +229,9 @@ public class SizeCompatModeActivityController extends SystemUI implements Comman
        }

        void remove() {
            if (mShowingHint != null) {
                mShowingHint.dismiss();
            }
            getContext().getSystemService(WindowManager.class).removeViewImmediate(this);
        }

+203 −148

File changed.

Preview size limit exceeded, changes collapsed.

+5 −0
Original line number Diff line number Diff line
@@ -1657,6 +1657,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        mIgnoreRotationForApps = isNonDecorDisplayCloseToSquare(Surface.ROTATION_0, width, height);
    }

    /** @return {@code true} if the orientation requested from application will be ignored. */
    boolean ignoreRotationForApps() {
        return mIgnoreRotationForApps;
    }

    private boolean isNonDecorDisplayCloseToSquare(int rotation, int width, int height) {
        final DisplayCutout displayCutout =
                calculateDisplayCutoutForRotation(rotation).getDisplayCutout();
+1 −1
Original line number Diff line number Diff line
@@ -2195,7 +2195,7 @@ class Task extends WindowContainer<WindowContainer> {
                if (rotation != ROTATION_UNDEFINED && compatInsets != null) {
                    mTmpNonDecorBounds.set(mTmpFullBounds);
                    mTmpStableBounds.set(mTmpFullBounds);
                    compatInsets.getDisplayBoundsByRotation(mTmpBounds, rotation);
                    compatInsets.getBoundsByRotation(mTmpBounds, rotation);
                    intersectWithInsetsIfFits(mTmpNonDecorBounds, mTmpBounds,
                            compatInsets.mNonDecorInsets[rotation]);
                    intersectWithInsetsIfFits(mTmpStableBounds, mTmpBounds,
+0 −45
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION;

import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_AFTER_ANIM;
import static com.android.server.wm.WindowStateAnimator.STACK_CLIP_BEFORE_ANIM;
@@ -208,50 +207,6 @@ public class AppWindowTokenTests extends WindowTestsBase {
        mWm.updateRotation(false, false);
    }

    @Test
    @FlakyTest(bugId = 149760957)
    public void testSizeCompatBounds() {
        // Disable the real configuration resolving because we only simulate partial flow.
        // TODO: Have test use full flow.
        doNothing().when(mTask).computeConfigResourceOverrides(any(), any());
        final Rect fixedBounds = mActivity.getRequestedOverrideConfiguration().windowConfiguration
                .getBounds();
        fixedBounds.set(0, 0, 1200, 1600);
        mActivity.getRequestedOverrideConfiguration().windowConfiguration.setAppBounds(fixedBounds);
        final Configuration newParentConfig = mTask.getConfiguration();

        // Change the size of the container to two times smaller with insets.
        newParentConfig.windowConfiguration.setAppBounds(200, 0, 800, 800);
        final Rect containerAppBounds = newParentConfig.windowConfiguration.getAppBounds();
        final Rect containerBounds = newParentConfig.windowConfiguration.getBounds();
        containerBounds.set(0, 0, 600, 800);
        mActivity.onConfigurationChanged(newParentConfig);

        assertTrue(mActivity.hasSizeCompatBounds());
        assertEquals(containerAppBounds, mActivity.getBounds());
        assertEquals((float) containerAppBounds.width() / fixedBounds.width(),
                mActivity.getSizeCompatScale(), 0.0001f /* delta */);

        // Change the width of the container to two times bigger.
        containerAppBounds.set(0, 0, 2400, 1600);
        containerBounds.set(containerAppBounds);
        mActivity.onConfigurationChanged(newParentConfig);

        assertTrue(mActivity.hasSizeCompatBounds());
        // Don't scale up, so the bounds keep the same as the fixed width.
        assertEquals(fixedBounds.width(), mActivity.getBounds().width());
        // Assert the position is horizontal center.
        assertEquals((containerAppBounds.width() - fixedBounds.width()) / 2,
                mActivity.getBounds().left);
        assertEquals(1f, mActivity.getSizeCompatScale(), 0.0001f  /* delta */);

        // Change the width of the container to fit the fixed bounds.
        containerBounds.set(0, 0, 1200, 2000);
        mActivity.onConfigurationChanged(newParentConfig);
        // Assert don't use fixed bounds because the region is enough.
        assertFalse(mActivity.hasSizeCompatBounds());
    }

    @Test
    @Presubmit
    public void testGetOrientation() {
Loading