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

Commit b97a2f68 authored by Graciela Putri's avatar Graciela Putri Committed by Automerger Merge Worker
Browse files

Merge "Don't check height if activity bounds empty" into tm-qpr-dev am:...

Merge "Don't check height if activity bounds empty" into tm-qpr-dev am: f2d3b4a5 am: 700202fe am: dcd1f47a

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22162527



Change-Id: I0f79e6ab4294661fb66bb937a9741ffd400d0236
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c6da2bd2 dcd1f47a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -8442,6 +8442,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
    }

    @NonNull Rect getScreenResolvedBounds() {
        final Configuration resolvedConfig = getResolvedOverrideConfiguration();
        final Rect resolvedBounds = resolvedConfig.windowConfiguration.getBounds();
        return mSizeCompatBounds != null ? mSizeCompatBounds : resolvedBounds;
    }

    void recomputeConfiguration() {
        // We check if the current activity is transparent. In that case we need to
        // recomputeConfiguration of the first opaque activity beneath, to allow a
+6 −2
Original line number Diff line number Diff line
@@ -969,6 +969,8 @@ final class LetterboxUiController {
     * </ul>
     */
    private boolean isHorizontalReachabilityEnabled(Configuration parentConfiguration) {
        // Use screen resolved bounds which uses resolved bounds or size compat bounds
        // as activity bounds can sometimes be empty
        return mLetterboxConfiguration.getIsHorizontalReachabilityEnabled()
                && parentConfiguration.windowConfiguration.getWindowingMode()
                        == WINDOWING_MODE_FULLSCREEN
@@ -976,7 +978,7 @@ final class LetterboxUiController {
                        && mActivityRecord.getOrientationForReachability() == ORIENTATION_PORTRAIT)
                // Check whether the activity fills the parent vertically.
                && parentConfiguration.windowConfiguration.getAppBounds().height()
                        <= mActivityRecord.getBounds().height();
                        <= mActivityRecord.getScreenResolvedBounds().height();
    }

    @VisibleForTesting
@@ -996,6 +998,8 @@ final class LetterboxUiController {
     * </ul>
     */
    private boolean isVerticalReachabilityEnabled(Configuration parentConfiguration) {
        // Use screen resolved bounds which uses resolved bounds or size compat bounds
        // as activity bounds can sometimes be empty
        return mLetterboxConfiguration.getIsVerticalReachabilityEnabled()
                && parentConfiguration.windowConfiguration.getWindowingMode()
                        == WINDOWING_MODE_FULLSCREEN
@@ -1003,7 +1007,7 @@ final class LetterboxUiController {
                        && mActivityRecord.getOrientationForReachability() == ORIENTATION_LANDSCAPE)
                // Check whether the activity fills the parent horizontally.
                && parentConfiguration.windowConfiguration.getBounds().width()
                        == mActivityRecord.getBounds().width();
                        == mActivityRecord.getScreenResolvedBounds().width();
    }

    @VisibleForTesting
+40 −7
Original line number Diff line number Diff line
@@ -3113,11 +3113,43 @@ public class SizeCompatTests extends WindowTestsBase {
        assertTrue(mActivity.inSizeCompatMode());

        // Vertical reachability is disabled because the app does not match parent width
        assertNotEquals(mActivity.getBounds().width(), mActivity.mDisplayContent.getBounds()
                .width());
        assertNotEquals(mActivity.getScreenResolvedBounds().width(),
                mActivity.mDisplayContent.getBounds().width());
        assertFalse(mActivity.mLetterboxUiController.isVerticalReachabilityEnabled());
    }

    @Test
    public void testIsVerticalReachabilityEnabled_emptyBounds_true() {
        setUpDisplaySizeWithApp(/* dw */ 1000, /* dh */ 2800);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mWm.mLetterboxConfiguration.setIsVerticalReachabilityEnabled(true);

        prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);

        // Set up activity with empty bounds to mock loading of app
        mActivity.getWindowConfiguration().setBounds(null);
        assertEquals(new Rect(0, 0, 0, 0), mActivity.getBounds());

        // Vertical reachability is still enabled as resolved bounds is not empty
        assertTrue(mActivity.mLetterboxUiController.isVerticalReachabilityEnabled());
    }

    @Test
    public void testIsHorizontalReachabilityEnabled_emptyBounds_true() {
        setUpDisplaySizeWithApp(/* dw */ 2800, /* dh */ 1000);
        mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
        mWm.mLetterboxConfiguration.setIsHorizontalReachabilityEnabled(true);

        prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);

        // Set up activity with empty bounds to mock loading of app
        mActivity.getWindowConfiguration().setBounds(null);
        assertEquals(new Rect(0, 0, 0, 0), mActivity.getBounds());

        // Horizontal reachability is still enabled as resolved bounds is not empty
        assertTrue(mActivity.mLetterboxUiController.isHorizontalReachabilityEnabled());
    }

    @Test
    public void testIsHorizontalReachabilityEnabled_doesNotMatchParentHeight_false() {
        setUpDisplaySizeWithApp(2800, 1000);
@@ -3134,8 +3166,8 @@ public class SizeCompatTests extends WindowTestsBase {
        assertTrue(mActivity.inSizeCompatMode());

        // Horizontal reachability is disabled because the app does not match parent height
        assertNotEquals(mActivity.getBounds().height(), mActivity.mDisplayContent.getBounds()
                .height());
        assertNotEquals(mActivity.getScreenResolvedBounds().height(),
                mActivity.mDisplayContent.getBounds().height());
        assertFalse(mActivity.mLetterboxUiController.isHorizontalReachabilityEnabled());
    }

@@ -3155,8 +3187,8 @@ public class SizeCompatTests extends WindowTestsBase {
        assertTrue(mActivity.inSizeCompatMode());

        // Horizontal reachability is enabled because the app matches parent height
        assertEquals(mActivity.getBounds().height(), mActivity.mDisplayContent.getBounds()
                .height());
        assertEquals(mActivity.getScreenResolvedBounds().height(),
                mActivity.mDisplayContent.getBounds().height());
        assertTrue(mActivity.mLetterboxUiController.isHorizontalReachabilityEnabled());
    }

@@ -3176,7 +3208,8 @@ public class SizeCompatTests extends WindowTestsBase {
        assertTrue(mActivity.inSizeCompatMode());

        // Vertical reachability is enabled because the app matches parent width
        assertEquals(mActivity.getBounds().width(), mActivity.mDisplayContent.getBounds().width());
        assertEquals(mActivity.getScreenResolvedBounds().width(),
                mActivity.mDisplayContent.getBounds().width());
        assertTrue(mActivity.mLetterboxUiController.isVerticalReachabilityEnabled());
    }