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

Commit 99b439fe authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Use full config to check size compat"

parents 8a61718a 359c84dc
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -6138,10 +6138,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        if (mCompatDisplayInsets == null || !shouldUseSizeCompatMode()) {
            return false;
        }
        final Configuration resolvedConfig = getResolvedOverrideConfiguration();
        final Rect resolvedAppBounds = resolvedConfig.windowConfiguration.getAppBounds();
        if (resolvedAppBounds == null) {
            // The override configuration has not been resolved yet.
        final Rect appBounds = getConfiguration().windowConfiguration.getAppBounds();
        if (appBounds == null) {
            // The app bounds hasn't been computed yet.
            return false;
        }

@@ -6149,13 +6148,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // Although colorMode, screenLayout, smallestScreenWidthDp are also fixed, generally these
        // fields should be changed with density and bounds, so here only compares the most
        // significant field.
        if (parentConfig.densityDpi != resolvedConfig.densityDpi) {
        if (parentConfig.densityDpi != getConfiguration().densityDpi) {
            return true;
        }

        final Rect parentAppBounds = parentConfig.windowConfiguration.getAppBounds();
        final int appWidth = resolvedAppBounds.width();
        final int appHeight = resolvedAppBounds.height();
        final int appWidth = appBounds.width();
        final int appHeight = appBounds.height();
        final int parentAppWidth = parentAppBounds.width();
        final int parentAppHeight = parentAppBounds.height();
        if (parentAppWidth == appWidth && parentAppHeight == appHeight) {
@@ -6174,7 +6173,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // The rest of the condition is that only one side is smaller than the parent, but it still
        // needs to exclude the cases where the size is limited by the fixed aspect ratio.
        if (info.maxAspectRatio > 0) {
            final float aspectRatio = Math.max(appWidth, appHeight) / Math.min(appWidth, appHeight);
            final float aspectRatio =
                    (float) Math.max(appWidth, appHeight) / Math.min(appWidth, appHeight);
            if (aspectRatio >= info.maxAspectRatio) {
                // The current size has reached the max aspect ratio.
                return false;
+2 −1
Original line number Diff line number Diff line
@@ -265,7 +265,8 @@ public class SizeCompatTests extends ActivityTestsBase {
        setUpApp(new TestActivityDisplay.Builder(mService, 1000, 2500).build());

        prepareUnresizable(1.4f /* maxAspect */, SCREEN_ORIENTATION_LANDSCAPE);
        assertTrue(mActivity.inSizeCompatMode());
        // The display aspect ratio 2.5 > 1.4 (max of activity), so the size is fitted.
        assertFalse(mActivity.inSizeCompatMode());

        final Rect originalBounds = new Rect(mActivity.getBounds());
        final Rect originalAppBounds = new Rect(mActivity.getWindowConfiguration().getAppBounds());