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

Commit 4183867d authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas Committed by Android (Google) Code Review
Browse files

Merge changes I612a4cf6,Ib6f3a69e into main

* changes:
  [2/n] Ignore current params in desktop launch params
  [1/n] Create flag for ignoring current params in desktop modifier
parents bb15d247 2eb4c1e8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -280,6 +280,9 @@ public enum DesktopExperienceFlags {
    HANDLE_INCOMPATIBLE_TASKS_IN_DESKTOP_LAUNCH_PARAMS(
            Flags::handleIncompatibleTasksInDesktopLaunchParams, false,
            Flags.FLAG_HANDLE_INCOMPATIBLE_TASKS_IN_DESKTOP_LAUNCH_PARAMS),
    IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS(
            Flags::ignoreCurrentParamsInDesktopLaunchParams, false,
            Flags.FLAG_IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS),
    IGNORE_OVERRIDE_TASK_BOUNDS_IF_INCOMPATIBLE_WITH_DISPLAY(
            Flags::ignoreOverrideTaskBoundsIfIncompatibleWithDisplay, false,
            Flags.FLAG_IGNORE_OVERRIDE_TASK_BOUNDS_IF_INCOMPATIBLE_WITH_DISPLAY),
+11 −0
Original line number Diff line number Diff line
@@ -1534,6 +1534,17 @@ flag {
    }
}

flag {
    name: "ignore_current_params_in_desktop_launch_params"
    namespace: "lse_desktop_experience"
    description: "Ignore the current params when resolving desktop specific launch params in the /n"
                 "desktop mode launch params modifier."
    bug: "419222219"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "ignore_override_task_bounds_if_incompatible_with_display"
    namespace: "lse_desktop_experience"
+27 −10
Original line number Diff line number Diff line
@@ -195,10 +195,11 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
            return RESULT_SKIP;
        }

        // TODO(b/419222219): Remove inheritance on currentParams.
        if (!DesktopExperienceFlags.IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS.isTrue()) {
            // Copy over any values.
            outParams.set(currentParams);
            outParams.mPreferredTaskDisplayArea = suggestedDisplayArea;
        }

        boolean isFullscreenInDeskTask = inDesktopFirstContainer && requestFullscreen;
        if (source != null && source.getTask() != null) {
@@ -240,7 +241,9 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
            return RESULT_CONTINUE;
        }

        if (!currentParams.mBounds.isEmpty() && !inDesktopMode) {
        if (!currentParams.mBounds.isEmpty() && !inDesktopMode
                && !DesktopExperienceFlags.IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS.isTrue()
        ) {
            appendLog("currentParams has bounds set, not overriding");
            return RESULT_SKIP;
        }
@@ -321,7 +324,8 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
            @NonNull LaunchParamsController.LaunchParams currentParams) {
        return (task != null && task.inFreeformWindowingMode())
                || (options != null && options.getLaunchWindowingMode() == WINDOWING_MODE_FREEFORM)
                || currentParams.mWindowingMode == WINDOWING_MODE_FREEFORM;
                || (currentParams.mWindowingMode == WINDOWING_MODE_FREEFORM
                && !DesktopExperienceFlags.IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS.isTrue());
    }

    /**
@@ -331,10 +335,23 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
            @NonNull Task task,
            @Nullable ActivityOptions options,
            @NonNull LaunchParamsController.LaunchParams currentParams) {
        return isCompatibleDesktopWindowingMode(task.getWindowingMode())
                && (options == null
                    || isCompatibleDesktopWindowingMode(options.getLaunchWindowingMode()))
                && isCompatibleDesktopWindowingMode(currentParams.mWindowingMode);
        // 1. Check the task's own windowing mode.
        final boolean isTaskWindowModeCompatible =
                isCompatibleDesktopWindowingMode(task.getWindowingMode());
        // 2. Check the windowing mode from ActivityOptions, if they exist.
        // If options are null, we consider it compatible.
        final boolean isOptionsWindowModeCompatible = options == null
                || isCompatibleDesktopWindowingMode(options.getLaunchWindowingMode());
        // 3. Check the windowing mode from the current launch parameters.
        // This check can be skipped if the IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS flag is
        // true.
        final boolean isCurrentParamsWindowModeCompatible =
                isCompatibleDesktopWindowingMode(currentParams.mWindowingMode)
                        || DesktopExperienceFlags.IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS
                        .isTrue();
        // All checks must pass for the source window modes to be considered compatible.
        return isTaskWindowModeCompatible && isOptionsWindowModeCompatible
                && isCurrentParamsWindowModeCompatible;
    }

    /**
+36 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE;
import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_LARGE_VALUE;
import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_MEDIUM_VALUE;
@@ -40,6 +41,7 @@ import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.util.DisplayMetrics.DENSITY_DEFAULT;
import static android.view.Surface.ROTATION_90;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.doCallRealMethod;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.internal.policy.SystemBarUtils.getDesktopViewAppHeaderHeightPx;
@@ -452,6 +454,7 @@ public class DesktopModeLaunchParamsModifierTests extends

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE)
    @DisableFlags(Flags.FLAG_IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS)
    public void testReturnsSkipIfCurrentParamsHasBounds() {
        setupDesktopModeLaunchParamsModifier();

@@ -461,6 +464,19 @@ public class DesktopModeLaunchParamsModifierTests extends
        assertEquals(RESULT_SKIP, new CalculateRequestBuilder().setTask(task).calculate());
    }

    @Test
    @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE,
            Flags.FLAG_IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS})
    public void testIgnoreCurrentParamsBounds() {
        setupDesktopModeLaunchParamsModifier();

        final Task task = new TaskBuilder(mSupervisor).setActivityType(
                ACTIVITY_TYPE_STANDARD).build();
        mCurrent.mBounds.set(/* left */ 0, /* top */ 0, /* right */ 100, /* bottom */ 100);
        new CalculateRequestBuilder().setTask(task).calculate();
        assertNotEquals(mCurrent.mBounds, mResult.mBounds);
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS)
    public void testReturnsDoneIfTaskNullLaunchInFreeform() {
@@ -1880,6 +1896,7 @@ public class DesktopModeLaunchParamsModifierTests extends

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE)
    @DisableFlags(Flags.FLAG_IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS)
    public void testInheritWindowingModeFromCurrentParams() {
        setupDesktopModeLaunchParamsModifier();

@@ -1895,6 +1912,25 @@ public class DesktopModeLaunchParamsModifierTests extends
        assertEquals(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode);
    }

    @Test
    @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE,
            Flags.FLAG_IGNORE_CURRENT_PARAMS_IN_DESKTOP_LAUNCH_PARAMS})
    public void testDoesntInheritWindowingModeFromCurrentParams() {
        setupDesktopModeLaunchParamsModifier();
        doCallRealMethod().when(mTarget).isEnteringDesktopMode(any(), any(), any());

        final Task task = new TaskBuilder(mSupervisor).setActivityType(
                ACTIVITY_TYPE_STANDARD).build();
        final TaskDisplayArea currTaskDisplayArea = mock(TaskDisplayArea.class);
        mCurrent.mPreferredTaskDisplayArea = currTaskDisplayArea;
        mCurrent.mWindowingMode = WINDOWING_MODE_FREEFORM;

        assertEquals(RESULT_SKIP, new CalculateRequestBuilder().setTask(task).calculate());
        assertEquals(task.getRootTask().getDisplayArea(), mResult.mPreferredTaskDisplayArea);
        assertNotEquals(currTaskDisplayArea, mResult.mPreferredTaskDisplayArea);
        assertEquals(WINDOWING_MODE_UNDEFINED, mResult.mWindowingMode);
    }

    @Test
    @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE,
            Flags.FLAG_DISABLE_DESKTOP_LAUNCH_PARAMS_OUTSIDE_DESKTOP_BUG_FIX,