Inherit source task windowing mode if available

Transfers the launch windowing mode from the source task if available
to the launching task. This closes a gap in proto2's windowing mode
launch calculation in Shell (DesktopTasksController#handleRequest)
where task trampolines are one single transition, so an old task that's
relaunched by a new task is never a "trigger task" in #handleRequest
and its windowing mode can't be adjusted by Shell based on the current
desktop mode shell state.

This change still relies on the windowing mode being set by
handleRequest on the trigger task, which is then transfered to the task
that is launched by the trigger task.

Bug: 286929122
Test: manual:
 (1) Launch Calendar in fullscreen, launch Chrome in fullscreen, drag
Chrome into desktop mode, launch Calendar from taskbar - verify it
launches in freeform mode.
 (2) Launch Calendar in fullscreen, launch Chrome in fullscreen, drag
Chrome in to desktop mode, swipe up to go Home, launch Calendar from
Home - verify it launches in freeform mode.
 (3) Launch Calendar and enter desktop mode, launch Chrome in freeform,
drag Chrome to top to exit desktop mode, launch Calendar from taskbar -
verify it launches in fullscreen.
 (4) Launch Calendar and enter desktop mode, launch Chrome in freeform,
drag Chrome to top to exit desktop mode, swipe up to go Home, launch
Calendar from Home - verify it launches in fullscreen mode.

Change-Id: I27f50e661c155b6e504b49fc044b889135af7b09
This commit is contained in:
Jorge Gil
2023-06-28 16:16:01 +00:00
parent 80bd64a237
commit 3a1620f627
2 changed files with 32 additions and 11 deletions

View File

@@ -39,10 +39,11 @@ public class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
TAG_WITH_CLASS_NAME ? "DesktopModeLaunchParamsModifier" : TAG_ATM;
private static final boolean DEBUG = false;
// Desktop mode feature flag.
static final boolean DESKTOP_MODE_SUPPORTED = SystemProperties.getBoolean(
"persist.wm.debug.desktop_mode", false) || SystemProperties.getBoolean(
"persist.wm.debug.desktop_mode_2", false);
// Desktop mode feature flags.
private static final boolean DESKTOP_MODE_PROTO1_SUPPORTED =
SystemProperties.getBoolean("persist.wm.debug.desktop_mode", false);
private static final boolean DESKTOP_MODE_PROTO2_SUPPORTED =
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);
@@ -76,22 +77,37 @@ public class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
appendLog("task null, skipping");
return RESULT_SKIP;
}
if (phase != PHASE_BOUNDS) {
appendLog("not in bounds phase, skipping");
return RESULT_SKIP;
}
if (!task.isActivityTypeStandardOrUndefined()) {
appendLog("not standard or undefined activity type, skipping");
return RESULT_SKIP;
}
if (!currentParams.mBounds.isEmpty()) {
appendLog("currentParams has bounds set, not overriding");
if (phase < PHASE_WINDOWING_MODE) {
appendLog("not in windowing mode or bounds phase, skipping");
return RESULT_SKIP;
}
// Copy over any values
outParams.set(currentParams);
// In Proto2, trampoline task launches of an existing background task can result in the
// previous windowing mode to be restored even if the desktop mode state has changed.
// Let task launches inherit the windowing mode from the source task if available, which
// should have the desired windowing mode set by WM Shell. See b/286929122.
if (DESKTOP_MODE_PROTO2_SUPPORTED && source != null && source.getTask() != null) {
final Task sourceTask = source.getTask();
outParams.mWindowingMode = sourceTask.getWindowingMode();
appendLog("inherit-from-source=" + outParams.mWindowingMode);
}
if (phase == PHASE_WINDOWING_MODE) {
return RESULT_DONE;
}
if (!currentParams.mBounds.isEmpty()) {
appendLog("currentParams has bounds set, not overriding");
return RESULT_SKIP;
}
// Update width and height with default desktop mode values
float density = (float) task.getConfiguration().densityDpi / DENSITY_DEFAULT;
final int width = (int) (DESKTOP_MODE_DEFAULT_WIDTH_DP * density + 0.5f);
@@ -123,4 +139,9 @@ public class DesktopModeLaunchParamsModifier implements LaunchParamsModifier {
private void outputLog() {
if (DEBUG) Slog.d(TAG, mLogBuilder.toString());
}
/** Whether desktop mode is supported. */
static boolean isDesktopModeSupported() {
return DESKTOP_MODE_PROTO1_SUPPORTED || DESKTOP_MODE_PROTO2_SUPPORTED;
}
}

View File

@@ -64,7 +64,7 @@ class LaunchParamsController {
void registerDefaultModifiers(ActivityTaskSupervisor supervisor) {
// {@link TaskLaunchParamsModifier} handles window layout preferences.
registerModifier(new TaskLaunchParamsModifier(supervisor));
if (DesktopModeLaunchParamsModifier.DESKTOP_MODE_SUPPORTED) {
if (DesktopModeLaunchParamsModifier.isDesktopModeSupported()) {
// {@link DesktopModeLaunchParamsModifier} handles default task size changes
registerModifier(new DesktopModeLaunchParamsModifier());
}