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

Commit 88e3c873 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Fix screen size configuration computing of task

Correct the typo for screen height.

Bug: 124532338
Test: atest TaskRecordTests#testComputeConfigResourceOverrides
Change-Id: I02ff82620f538291f2ae5518e1b4ee2c2ac288d1
parent cb889759
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2134,7 +2134,7 @@ class TaskRecord extends ConfigurationContainer {
            if (inOutConfig.screenHeightDp == Configuration.SCREEN_HEIGHT_DP_UNDEFINED) {
                final int overrideScreenHeightDp = (int) (mTmpStableBounds.height() / density);
                inOutConfig.screenHeightDp = insideParentBounds
                        ? Math.min(overrideScreenHeightDp, parentConfig.screenWidthDp)
                        ? Math.min(overrideScreenHeightDp, parentConfig.screenHeightDp)
                        : overrideScreenHeightDp;
            }

+36 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static android.content.Intent.FLAG_ACTIVITY_TASK_ON_HOME;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.util.DisplayMetrics.DENSITY_DEFAULT;

import static com.android.server.wm.WindowContainer.POSITION_TOP;

@@ -307,6 +308,41 @@ public class TaskRecordTests extends ActivityTestsBase {
        assertEquals(fullScreenBounds, task.getBounds());
    }

    @Test
    public void testComputeConfigResourceOverrides() {
        final TaskRecord task = new TaskBuilder(mSupervisor).build();
        final Configuration inOutConfig = new Configuration();
        final Configuration parentConfig = new Configuration();
        final int longSide = 1200;
        final int shortSide = 600;
        parentConfig.densityDpi = 400;
        parentConfig.screenHeightDp = 200; // 200 * 400 / 160 = 500px
        parentConfig.screenWidthDp = 100; // 100 * 400 / 160 = 250px

        // Portrait bounds.
        inOutConfig.windowConfiguration.getBounds().set(0, 0, shortSide, longSide);
        // By default, the parent bounds should limit the existing input bounds.
        task.computeConfigResourceOverrides(inOutConfig, parentConfig);

        assertEquals(parentConfig.screenHeightDp, inOutConfig.screenHeightDp);
        assertEquals(parentConfig.screenWidthDp, inOutConfig.screenWidthDp);
        assertEquals(Configuration.ORIENTATION_PORTRAIT, inOutConfig.orientation);

        inOutConfig.setToDefaults();
        // Landscape bounds.
        inOutConfig.windowConfiguration.getBounds().set(0, 0, longSide, shortSide);
        // Without limiting to be inside the parent bounds, the out screen size should keep relative
        // to the input bounds.
        task.computeConfigResourceOverrides(inOutConfig, parentConfig,
                false /* insideParentBounds */);

        assertEquals(shortSide * DENSITY_DEFAULT / parentConfig.densityDpi,
                inOutConfig.screenHeightDp);
        assertEquals(longSide * DENSITY_DEFAULT / parentConfig.densityDpi,
                inOutConfig.screenWidthDp);
        assertEquals(Configuration.ORIENTATION_LANDSCAPE, inOutConfig.orientation);
    }

    /** Ensures that the alias intent won't have target component resolved. */
    @Test
    public void testTaskIntentActivityAlias() {