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

Commit aebc0b18 authored by Ats Jenk's avatar Ats Jenk
Browse files

Fix default app size for desktop proto 2

Make sure tasks launch in the default size for the prototype. And that
it does not use the default phone size.
In proto 2, we don't set the tasks to freeform at this stage yet. But
the task bounds do not take effect in fullscreen tasks. Use the desktop
mode bounds for all standard activity type tasks.

Bug: 269661358
Test: atest DesktopModeLaunchParamsModifierTests

Change-Id: I424dec21fb295300aefa6f74ee4ca70401529f69
parent dccbda11
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ public class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {

    // Desktop mode feature flag.
    static final boolean DESKTOP_MODE_SUPPORTED = SystemProperties.getBoolean(
            "persist.wm.debug.desktop_mode", false);
            "persist.wm.debug.desktop_mode", false) || SystemProperties.getBoolean(
            "persist.wm.debug.desktop_mode_2", false);
    // Override default freeform task width when desktop mode is enabled. In dips.
    private static final int DESKTOP_MODE_DEFAULT_WIDTH_DP = SystemProperties.getInt(
            "persist.wm.debug.desktop_mode.default_width", 840);
@@ -79,8 +80,8 @@ public class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
            appendLog("not in bounds phase, skipping");
            return RESULT_SKIP;
        }
        if (!task.inFreeformWindowingMode()) {
            appendLog("not a freeform task, skipping");
        if (!task.isActivityTypeStandard()) {
            appendLog("not standard activity type, skipping");
            return RESULT_SKIP;
        }
        if (!currentParams.mBounds.isEmpty()) {
+11 −10
Original line number Diff line number Diff line
@@ -16,8 +16,9 @@

package com.android.server.wm;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.util.DisplayMetrics.DENSITY_DEFAULT;

import static com.android.server.wm.LaunchParamsController.LaunchParamsModifier.PHASE_BOUNDS;
@@ -79,24 +80,24 @@ public class DesktopModeLaunchParamsModifierTests extends WindowTestsBase {
    }

    @Test
    public void testReturnsSkipIfTaskNotInFreeform() {
        final Task task = new TaskBuilder(mSupervisor).setWindowingMode(
                WINDOWING_MODE_FULLSCREEN).build();
    public void testReturnsSkipIfTaskNotUsingActivityTypeStandard() {
        final Task task = new TaskBuilder(mSupervisor).setActivityType(
                ACTIVITY_TYPE_ASSISTANT).build();
        assertEquals(RESULT_SKIP, new CalculateRequestBuilder().setTask(task).calculate());
    }

    @Test
    public void testReturnsSkipIfCurrentParamsHasBounds() {
        final Task task = new TaskBuilder(mSupervisor).setWindowingMode(
                WINDOWING_MODE_FREEFORM).build();
        final Task task = new TaskBuilder(mSupervisor).setActivityType(
                ACTIVITY_TYPE_STANDARD).build();
        mCurrent.mBounds.set(/* left */ 0, /* top */ 0, /* right */ 100, /* bottom */ 100);
        assertEquals(RESULT_SKIP, new CalculateRequestBuilder().setTask(task).calculate());
    }

    @Test
    public void testUsesDefaultBounds() {
        final Task task = new TaskBuilder(mSupervisor).setWindowingMode(
                WINDOWING_MODE_FREEFORM).build();
        final Task task = new TaskBuilder(mSupervisor).setActivityType(
                ACTIVITY_TYPE_STANDARD).build();
        assertEquals(RESULT_DONE, new CalculateRequestBuilder().setTask(task).calculate());
        assertEquals(dpiToPx(task, 840), mResult.mBounds.width());
        assertEquals(dpiToPx(task, 630), mResult.mBounds.height());
@@ -104,8 +105,8 @@ public class DesktopModeLaunchParamsModifierTests extends WindowTestsBase {

    @Test
    public void testUsesDisplayAreaAndWindowingModeFromSource() {
        final Task task = new TaskBuilder(mSupervisor).setWindowingMode(
                WINDOWING_MODE_FREEFORM).build();
        final Task task = new TaskBuilder(mSupervisor).setActivityType(
                ACTIVITY_TYPE_STANDARD).build();
        TaskDisplayArea mockTaskDisplayArea = mock(TaskDisplayArea.class);
        mCurrent.mPreferredTaskDisplayArea = mockTaskDisplayArea;
        mCurrent.mWindowingMode = WINDOWING_MODE_FREEFORM;