Loading services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java +3 −2 Original line number Diff line number Diff line Loading @@ -141,14 +141,15 @@ public final class DesktopModeBoundsCalculator { */ @NonNull private static Rect calculateInitialBounds(@NonNull Task task, @NonNull ActivityRecord activity, @NonNull Rect stableBounds, @Nullable ActivityRecord activity, @NonNull Rect stableBounds, @Nullable ActivityOptions options, @NonNull DisplayContent displayContent, boolean shouldRespectOptionPosition, int captionHeight ) { // Display bounds not taking into account insets. final Rect screenBounds = displayContent.getBounds(); final Size idealSize = calculateIdealSize(screenBounds, DESKTOP_MODE_INITIAL_BOUNDS_SCALE); if (!DesktopModeFlags.ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS.isTrue()) { if (!DesktopModeFlags.ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS.isTrue() || activity == null) { return centerInScreen(idealSize, screenBounds); } if (activity.mAppCompatController.getAspectRatioOverrides() Loading services/core/java/com/android/server/wm/DesktopModeLaunchParamsModifier.java +12 −7 Original line number Diff line number Diff line Loading @@ -152,17 +152,22 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { return RESULT_SKIP; } // If activity is null attempt to use task top activity if available. final ActivityRecord targetActivity = activity != null ? activity : task.getTopMostActivity(); if (DesktopExperienceFlags.HANDLE_INCOMPATIBLE_TASKS_IN_DESKTOP_LAUNCH_PARAMS.isTrue() && activity != null) { && targetActivity != null) { final boolean isActivityStackTransparent = !task.forAllActivities(r -> (r.occludesParent())) && !activity.occludesParent(); (r.occludesParent())) && !targetActivity.occludesParent(); final AtomicInteger numActivities = new AtomicInteger(1); task.forAllActivities((r) -> { numActivities.incrementAndGet(); }); if (mDesktopModeCompatPolicy.isTopActivityExemptFromDesktopWindowing( activity.mActivityComponent, activity.isNoDisplay(), isActivityStackTransparent, numActivities.get(), task.getUserId(), activity.info)) { targetActivity.mActivityComponent, targetActivity.isNoDisplay(), isActivityStackTransparent, numActivities.get(), task.getUserId(), targetActivity.info)) { appendLog("activity exempt from desktop, launching in fullscreen"); outParams.mWindowingMode = WINDOWING_MODE_FULLSCREEN; return RESULT_DONE; Loading Loading @@ -255,7 +260,7 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { if (DesktopModeFlags.INHERIT_TASK_BOUNDS_FOR_TRAMPOLINE_TASK_LAUNCHES.isTrue()) { ActivityRecord topVisibleFreeformActivity = task.getDisplayContent().getTopMostVisibleFreeformActivity(); if (shouldInheritExistingTaskBounds(topVisibleFreeformActivity, activity, task)) { if (shouldInheritExistingTaskBounds(topVisibleFreeformActivity, targetActivity, task)) { appendLog("inheriting bounds from existing closing instance"); outParams.mBounds.set(topVisibleFreeformActivity.getBounds()); appendLog("final desktop mode task bounds set to %s", outParams.mBounds); Loading @@ -264,8 +269,8 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { } } DesktopModeBoundsCalculator.updateInitialBounds(task, layout, activity, options, display, outParams, this::appendLog); DesktopModeBoundsCalculator.updateInitialBounds(task, layout, targetActivity, options, display, outParams, this::appendLog); appendLog("final desktop mode task bounds set to %s", outParams.mBounds); if (options != null && options.getFlexibleLaunchSize()) { // Return result done to prevent other modifiers from respecting option bounds and Loading services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java +20 −0 Original line number Diff line number Diff line Loading @@ -1412,6 +1412,26 @@ public class DesktopModeLaunchParamsModifierTests extends assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE) public void testNullActivity_defaultBoundsApplied() { setupDesktopModeLaunchParamsModifier(); final TestDisplayContent display = createDisplayContent(ORIENTATION_LANDSCAPE, LANDSCAPE_DISPLAY_BOUNDS); final Task task = createTask(display, /* isResizeable */ true); final int desiredWidth = (int) (LANDSCAPE_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); final int desiredHeight = (int) (LANDSCAPE_DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task) .setActivity(null).calculate()); assertEquals(desiredWidth, mResult.mBounds.width()); assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE) public void testNonEmptyActivityOptionsBounds() { Loading Loading
services/core/java/com/android/server/wm/DesktopModeBoundsCalculator.java +3 −2 Original line number Diff line number Diff line Loading @@ -141,14 +141,15 @@ public final class DesktopModeBoundsCalculator { */ @NonNull private static Rect calculateInitialBounds(@NonNull Task task, @NonNull ActivityRecord activity, @NonNull Rect stableBounds, @Nullable ActivityRecord activity, @NonNull Rect stableBounds, @Nullable ActivityOptions options, @NonNull DisplayContent displayContent, boolean shouldRespectOptionPosition, int captionHeight ) { // Display bounds not taking into account insets. final Rect screenBounds = displayContent.getBounds(); final Size idealSize = calculateIdealSize(screenBounds, DESKTOP_MODE_INITIAL_BOUNDS_SCALE); if (!DesktopModeFlags.ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS.isTrue()) { if (!DesktopModeFlags.ENABLE_WINDOWING_DYNAMIC_INITIAL_BOUNDS.isTrue() || activity == null) { return centerInScreen(idealSize, screenBounds); } if (activity.mAppCompatController.getAspectRatioOverrides() Loading
services/core/java/com/android/server/wm/DesktopModeLaunchParamsModifier.java +12 −7 Original line number Diff line number Diff line Loading @@ -152,17 +152,22 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { return RESULT_SKIP; } // If activity is null attempt to use task top activity if available. final ActivityRecord targetActivity = activity != null ? activity : task.getTopMostActivity(); if (DesktopExperienceFlags.HANDLE_INCOMPATIBLE_TASKS_IN_DESKTOP_LAUNCH_PARAMS.isTrue() && activity != null) { && targetActivity != null) { final boolean isActivityStackTransparent = !task.forAllActivities(r -> (r.occludesParent())) && !activity.occludesParent(); (r.occludesParent())) && !targetActivity.occludesParent(); final AtomicInteger numActivities = new AtomicInteger(1); task.forAllActivities((r) -> { numActivities.incrementAndGet(); }); if (mDesktopModeCompatPolicy.isTopActivityExemptFromDesktopWindowing( activity.mActivityComponent, activity.isNoDisplay(), isActivityStackTransparent, numActivities.get(), task.getUserId(), activity.info)) { targetActivity.mActivityComponent, targetActivity.isNoDisplay(), isActivityStackTransparent, numActivities.get(), task.getUserId(), targetActivity.info)) { appendLog("activity exempt from desktop, launching in fullscreen"); outParams.mWindowingMode = WINDOWING_MODE_FULLSCREEN; return RESULT_DONE; Loading Loading @@ -255,7 +260,7 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { if (DesktopModeFlags.INHERIT_TASK_BOUNDS_FOR_TRAMPOLINE_TASK_LAUNCHES.isTrue()) { ActivityRecord topVisibleFreeformActivity = task.getDisplayContent().getTopMostVisibleFreeformActivity(); if (shouldInheritExistingTaskBounds(topVisibleFreeformActivity, activity, task)) { if (shouldInheritExistingTaskBounds(topVisibleFreeformActivity, targetActivity, task)) { appendLog("inheriting bounds from existing closing instance"); outParams.mBounds.set(topVisibleFreeformActivity.getBounds()); appendLog("final desktop mode task bounds set to %s", outParams.mBounds); Loading @@ -264,8 +269,8 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { } } DesktopModeBoundsCalculator.updateInitialBounds(task, layout, activity, options, display, outParams, this::appendLog); DesktopModeBoundsCalculator.updateInitialBounds(task, layout, targetActivity, options, display, outParams, this::appendLog); appendLog("final desktop mode task bounds set to %s", outParams.mBounds); if (options != null && options.getFlexibleLaunchSize()) { // Return result done to prevent other modifiers from respecting option bounds and Loading
services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java +20 −0 Original line number Diff line number Diff line Loading @@ -1412,6 +1412,26 @@ public class DesktopModeLaunchParamsModifierTests extends assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE) public void testNullActivity_defaultBoundsApplied() { setupDesktopModeLaunchParamsModifier(); final TestDisplayContent display = createDisplayContent(ORIENTATION_LANDSCAPE, LANDSCAPE_DISPLAY_BOUNDS); final Task task = createTask(display, /* isResizeable */ true); final int desiredWidth = (int) (LANDSCAPE_DISPLAY_BOUNDS.width() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); final int desiredHeight = (int) (LANDSCAPE_DISPLAY_BOUNDS.height() * DESKTOP_MODE_INITIAL_BOUNDS_SCALE); assertEquals(RESULT_CONTINUE, new CalculateRequestBuilder().setTask(task) .setActivity(null).calculate()); assertEquals(desiredWidth, mResult.mBounds.width()); assertEquals(desiredHeight, mResult.mBounds.height()); } @Test @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE) public void testNonEmptyActivityOptionsBounds() { Loading