From fdcfb61f1be03a1b9c902cf2b0fa2387b0d8a8e8 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Mon, 3 Mar 2025 18:18:28 -0500 Subject: [PATCH] Use shell's SplitBounds class instead of our own * Previously we had duplicated classes because of some launcher3 and quickstep package separation. That got refactored so now we can conslidate to only use one class. Yay! Bug: 254378592 Test: Compiles, manual Flag: EXEMPT refactor Change-Id: Ifea3358ac38c1d2881cb19bb88cf14ef9c0aaa29 --- .../taskbar/KeyboardQuickSwitchTaskView.java | 2 +- .../android/quickstep/RecentTasksList.java | 12 +- .../android/quickstep/RemoteTargetGluer.java | 14 +-- .../orientation/LandscapePagedViewHandler.kt | 2 +- .../orientation/PortraitPagedViewHandler.kt | 11 +- .../RecentsPagedOrientationHandler.kt | 12 +- .../orientation/SeascapePagedViewHandler.kt | 2 +- .../com/android/quickstep/util/GroupTask.kt | 3 +- .../quickstep/util/SplitScreenUtils.kt | 12 -- .../quickstep/util/TaskViewSimulator.java | 2 +- .../quickstep/views/DigitalWellBeingToast.kt | 4 +- .../quickstep/views/GroupedTaskView.kt | 5 +- .../android/quickstep/views/RecentsView.java | 2 +- .../TaskbarRecentAppsControllerTest.kt | 3 +- .../android/quickstep/RecentsModelTest.java | 3 +- .../recents/data/TasksRepositoryTest.kt | 3 +- .../android/quickstep/util/GroupTaskTest.kt | 9 +- .../util/SplitSelectStateControllerTest.kt | 5 +- .../util/SplitConfigurationOptions.java | 119 ------------------ 19 files changed, 45 insertions(+), 180 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java index c49029daf9..bcaca16278 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java @@ -36,12 +36,12 @@ import androidx.constraintlayout.widget.ConstraintLayout; import com.android.launcher3.R; import com.android.launcher3.util.Preconditions; -import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds; import com.android.quickstep.util.BorderAnimator; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.wm.shell.shared.TypefaceUtils; import com.android.wm.shell.shared.TypefaceUtils.FontFamily; +import com.android.wm.shell.shared.split.SplitBounds; import kotlin.Unit; diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java index ea9bdb01f3..a03f267932 100644 --- a/quickstep/src/com/android/quickstep/RecentTasksList.java +++ b/quickstep/src/com/android/quickstep/RecentTasksList.java @@ -20,7 +20,6 @@ import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; import static com.android.launcher3.Flags.enableSeparateExternalDisplayTasks; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; -import static com.android.quickstep.util.SplitScreenUtils.convertShellSplitBoundsToLauncher; import static com.android.wm.shell.shared.GroupedTaskInfo.TYPE_DESK; import static com.android.wm.shell.shared.GroupedTaskInfo.TYPE_SPLIT; @@ -430,11 +429,8 @@ public class RecentTasksList implements WindowManagerProxy.DesktopVisibilityList final Task.TaskKey task2Key = new Task.TaskKey(taskInfo2); final Task task2 = Task.from(task2Key, taskInfo2, tmpLockedUsers.get(task2Key.userId) /* isLocked */); - final SplitBounds splitBounds = rawTask.getBaseGroupedTask().getSplitBounds(); - final SplitConfigurationOptions.SplitBounds launcherSplitBounds = - splitBounds == null ? null : convertShellSplitBoundsToLauncher( - splitBounds); - allTasks.add(new SplitTask(task1, task2, launcherSplitBounds)); + allTasks.add(new SplitTask(task1, task2, + rawTask.getBaseGroupedTask().getSplitBounds())); } else { allTasks.add(new SingleTask(task1)); } @@ -471,9 +467,7 @@ public class RecentTasksList implements WindowManagerProxy.DesktopVisibilityList } if (task2 != null) { Objects.requireNonNull(rawTask.getSplitBounds()); - final SplitConfigurationOptions.SplitBounds launcherSplitBounds = - convertShellSplitBoundsToLauncher(rawTask.getSplitBounds()); - allTasks.add(new SplitTask(task1, task2, launcherSplitBounds)); + allTasks.add(new SplitTask(task1, task2, rawTask.getSplitBounds())); } else { allTasks.add(new SingleTask(task1)); } diff --git a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java index d85326e674..4588b778eb 100644 --- a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java +++ b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java @@ -16,7 +16,6 @@ package com.android.quickstep; -import static com.android.quickstep.util.SplitScreenUtils.convertShellSplitBoundsToLauncher; import static com.android.wm.shell.shared.split.SplitBounds.KEY_EXTRA_SPLIT_BOUNDS; import static com.android.wm.shell.shared.desktopmode.DesktopModeStatus.enableMultipleDesktops; @@ -31,7 +30,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.launcher3.statehandlers.DesktopVisibilityController; -import com.android.launcher3.util.SplitConfigurationOptions; import com.android.quickstep.util.AnimatorControllerWithResistance; import com.android.quickstep.util.TaskViewSimulator; import com.android.quickstep.util.TransformParams; @@ -55,7 +53,7 @@ public class RemoteTargetGluer { private static final int DEFAULT_NUM_HANDLES = 4; private RemoteTargetHandle[] mRemoteTargetHandles; - private SplitConfigurationOptions.SplitBounds mSplitBounds; + private SplitBounds mSplitBounds; /** * Use this constructor if remote targets are split-screen independent @@ -136,7 +134,7 @@ public class RemoteTargetGluer { * information specified. */ public RemoteTargetHandle[] assignTargetsForSplitScreen(RemoteAnimationTargets targets, - SplitConfigurationOptions.SplitBounds splitBounds) { + SplitBounds splitBounds) { mSplitBounds = splitBounds; return assignTargetsForSplitScreen(targets); } @@ -154,11 +152,7 @@ public class RemoteTargetGluer { // b) A SplitBounds was passed up from shell (via AbsSwipeUpHandler) // If both of these are null, we are in a 1-app or 1-app-plus-assistant case. if (mSplitBounds == null) { - SplitBounds shellSplitBounds = targets.extras.getParcelable(KEY_EXTRA_SPLIT_BOUNDS, - SplitBounds.class); - if (shellSplitBounds != null) { - mSplitBounds = convertShellSplitBoundsToLauncher(shellSplitBounds); - } + mSplitBounds = targets.extras.getParcelable(KEY_EXTRA_SPLIT_BOUNDS, SplitBounds.class); } boolean containsSplitTargets = mSplitBounds != null; @@ -318,7 +312,7 @@ public class RemoteTargetGluer { return mRemoteTargetHandles; } - public SplitConfigurationOptions.SplitBounds getSplitBounds() { + public SplitBounds getSplitBounds() { return mSplitBounds; } diff --git a/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt index 1e626cd78d..7ab783baee 100644 --- a/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt @@ -52,11 +52,11 @@ import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTO import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED import com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MAIN -import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption import com.android.launcher3.util.SplitConfigurationOptions.StagePosition import com.android.launcher3.views.BaseDragLayer import com.android.quickstep.views.IconAppChipView +import com.android.wm.shell.shared.split.SplitBounds import kotlin.math.max open class LandscapePagedViewHandler : RecentsPagedOrientationHandler { diff --git a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt index 9132783b60..8e69e44a77 100644 --- a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.kt @@ -44,6 +44,7 @@ import com.android.launcher3.util.SplitConfigurationOptions import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption import com.android.launcher3.util.SplitConfigurationOptions.StagePosition import com.android.quickstep.views.IconAppChipView +import com.android.wm.shell.shared.split.SplitBounds import kotlin.math.max import kotlin.math.min @@ -238,7 +239,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat override fun getDwbBannerTranslations( taskViewWidth: Int, taskViewHeight: Int, - splitBounds: SplitConfigurationOptions.SplitBounds?, + splitBounds: SplitBounds?, deviceProfile: DeviceProfile, thumbnailViews: Array, desiredTaskId: Int, @@ -515,7 +516,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat override fun setSplitTaskSwipeRect( dp: DeviceProfile, outRect: Rect, - splitInfo: SplitConfigurationOptions.SplitBounds, + splitInfo: SplitBounds, desiredStagePosition: Int, ) { val topLeftTaskPercent = splitInfo.leftTopTaskPercent @@ -554,7 +555,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat secondarySnapshot: View, parentWidth: Int, parentHeight: Int, - splitBoundsConfig: SplitConfigurationOptions.SplitBounds, + splitBoundsConfig: SplitBounds, dp: DeviceProfile, isRtl: Boolean, inSplitSelection: Boolean, @@ -613,7 +614,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat override fun getGroupedTaskViewSizes( dp: DeviceProfile, - splitBoundsConfig: SplitConfigurationOptions.SplitBounds, + splitBoundsConfig: SplitBounds, parentWidth: Int, parentHeight: Int, ): Pair { @@ -706,7 +707,7 @@ class PortraitPagedViewHandler : DefaultPagedViewHandler(), RecentsPagedOrientat groupedTaskViewWidth: Int, isRtl: Boolean, deviceProfile: DeviceProfile, - splitConfig: SplitConfigurationOptions.SplitBounds, + splitConfig: SplitBounds, inSplitSelection: Boolean, oneIconHiddenDueToSmallWidth: Boolean, ) { diff --git a/quickstep/src/com/android/quickstep/orientation/RecentsPagedOrientationHandler.kt b/quickstep/src/com/android/quickstep/orientation/RecentsPagedOrientationHandler.kt index 13287c9370..0cd79d32df 100644 --- a/quickstep/src/com/android/quickstep/orientation/RecentsPagedOrientationHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/RecentsPagedOrientationHandler.kt @@ -31,10 +31,10 @@ import com.android.launcher3.touch.PagedOrientationHandler import com.android.launcher3.touch.PagedOrientationHandler.Float2DAction import com.android.launcher3.touch.PagedOrientationHandler.Int2DAction import com.android.launcher3.touch.SingleAxisSwipeDetector -import com.android.launcher3.util.SplitConfigurationOptions import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption import com.android.launcher3.util.SplitConfigurationOptions.StagePosition import com.android.quickstep.views.IconAppChipView +import com.android.wm.shell.shared.split.SplitBounds /** * Abstraction layer to separate horizontal and vertical specific implementations for @@ -175,7 +175,7 @@ interface RecentsPagedOrientationHandler : PagedOrientationHandler { fun setSplitTaskSwipeRect( dp: DeviceProfile, outRect: Rect, - splitInfo: SplitConfigurationOptions.SplitBounds, + splitInfo: SplitBounds, @StagePosition desiredStagePosition: Int, ) @@ -184,7 +184,7 @@ interface RecentsPagedOrientationHandler : PagedOrientationHandler { secondarySnapshot: View, parentWidth: Int, parentHeight: Int, - splitBoundsConfig: SplitConfigurationOptions.SplitBounds, + splitBoundsConfig: SplitBounds, dp: DeviceProfile, isRtl: Boolean, inSplitSelection: Boolean, @@ -198,7 +198,7 @@ interface RecentsPagedOrientationHandler : PagedOrientationHandler { */ fun getGroupedTaskViewSizes( dp: DeviceProfile, - splitBoundsConfig: SplitConfigurationOptions.SplitBounds, + splitBoundsConfig: SplitBounds, parentWidth: Int, parentHeight: Int, ): Pair @@ -238,7 +238,7 @@ interface RecentsPagedOrientationHandler : PagedOrientationHandler { groupedTaskViewWidth: Int, isRtl: Boolean, deviceProfile: DeviceProfile, - splitConfig: SplitConfigurationOptions.SplitBounds, + splitConfig: SplitBounds, inSplitSelection: Boolean, oneIconHiddenDueToSmallWidth: Boolean, ) @@ -320,7 +320,7 @@ interface RecentsPagedOrientationHandler : PagedOrientationHandler { fun getDwbBannerTranslations( taskViewWidth: Int, taskViewHeight: Int, - splitBounds: SplitConfigurationOptions.SplitBounds?, + splitBounds: SplitBounds?, deviceProfile: DeviceProfile, thumbnailViews: Array, desiredTaskId: Int, diff --git a/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt index dcd7d876e3..96e8651146 100644 --- a/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt +++ b/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt @@ -39,10 +39,10 @@ import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_BOTTO import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED import com.android.launcher3.util.SplitConfigurationOptions.STAGE_TYPE_MAIN -import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption import com.android.launcher3.views.BaseDragLayer import com.android.quickstep.views.IconAppChipView +import com.android.wm.shell.shared.split.SplitBounds class SeascapePagedViewHandler : LandscapePagedViewHandler() { override fun rotateInsets(insets: Rect, outInsets: Rect) { diff --git a/quickstep/src/com/android/quickstep/util/GroupTask.kt b/quickstep/src/com/android/quickstep/util/GroupTask.kt index 2772cfc16d..9ba20673a1 100644 --- a/quickstep/src/com/android/quickstep/util/GroupTask.kt +++ b/quickstep/src/com/android/quickstep/util/GroupTask.kt @@ -20,6 +20,7 @@ import com.android.launcher3.model.data.WorkspaceItemInfo import com.android.launcher3.util.SplitConfigurationOptions import com.android.quickstep.views.TaskViewType import com.android.systemui.shared.recents.model.Task +import com.android.wm.shell.shared.split.SplitBounds import java.util.Objects /** @@ -94,7 +95,7 @@ class SingleTask(task: Task) : GroupTask(listOf(task), task.key.displayId, TaskV * A [Task] container that must contain exactly two tasks and split bounds to represent an app-pair * in the recent tasks list. */ -class SplitTask(task1: Task, task2: Task, val splitBounds: SplitConfigurationOptions.SplitBounds?) : +class SplitTask(task1: Task, task2: Task, val splitBounds: SplitBounds?) : GroupTask(listOf(task1, task2), task1.key.displayId, TaskViewType.GROUPED) { val topLeftTask: Task diff --git a/quickstep/src/com/android/quickstep/util/SplitScreenUtils.kt b/quickstep/src/com/android/quickstep/util/SplitScreenUtils.kt index 1919f68d4a..2eb848216d 100644 --- a/quickstep/src/com/android/quickstep/util/SplitScreenUtils.kt +++ b/quickstep/src/com/android/quickstep/util/SplitScreenUtils.kt @@ -29,18 +29,6 @@ class SplitScreenUtils { companion object { private const val TAG = "SplitScreenUtils" - // TODO(b/254378592): Remove these methods when the two classes are reunited - /** Converts the shell version of SplitBounds to the launcher version */ - @JvmStatic - fun convertShellSplitBoundsToLauncher(shellSplitBounds: SplitBounds) = - SplitConfigurationOptions.SplitBounds( - shellSplitBounds.leftTopBounds, - shellSplitBounds.rightBottomBounds, - shellSplitBounds.leftTopTaskId, - shellSplitBounds.rightBottomTaskId, - shellSplitBounds.snapPosition, - ) - /** * Given a TransitionInfo, generates the tree structure for those changes and extracts out * the top most root and it's two immediate children. Changes can be provided in any order. diff --git a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java index f6c38c9e12..bb68c4c348 100644 --- a/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java +++ b/quickstep/src/com/android/quickstep/util/TaskViewSimulator.java @@ -45,7 +45,6 @@ import com.android.launcher3.DeviceProfile; import com.android.launcher3.Utilities; import com.android.launcher3.anim.AnimatedFloat; import com.android.launcher3.anim.PendingAnimation; -import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds; import com.android.launcher3.util.TraceHelper; import com.android.quickstep.BaseActivityInterface; import com.android.quickstep.BaseContainerInterface; @@ -55,6 +54,7 @@ import com.android.quickstep.TaskAnimationManager; import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties; import com.android.systemui.shared.recents.model.ThumbnailData; import com.android.systemui.shared.recents.utilities.PreviewPositionHelper; +import com.android.wm.shell.shared.split.SplitBounds; /** * A utility class which emulates the layout behavior of TaskView and RecentsView diff --git a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt index 39739a1755..9cc4558d8d 100644 --- a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt +++ b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt @@ -43,12 +43,12 @@ import androidx.core.view.isVisible import com.android.launcher3.R import com.android.launcher3.Utilities import com.android.launcher3.util.Executors -import com.android.launcher3.util.SplitConfigurationOptions import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_TOP_OR_LEFT import com.android.launcher3.util.SplitConfigurationOptions.STAGE_POSITION_UNDEFINED import com.android.launcher3.util.SplitConfigurationOptions.StagePosition import com.android.quickstep.TaskUtils import com.android.systemui.shared.recents.model.Task +import com.android.wm.shell.shared.split.SplitBounds import java.time.Duration import java.util.Locale @@ -87,7 +87,7 @@ constructor( private set var hasLimit = false - var splitBounds: SplitConfigurationOptions.SplitBounds? = null + var splitBounds: SplitBounds? = null var bannerOffsetPercentage = 0f set(value) { if (field != value) { diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt index e3e987ccf7..ca8f5414f4 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt @@ -38,6 +38,7 @@ import com.android.quickstep.util.SplitSelectStateController import com.android.quickstep.util.SplitTask import com.android.systemui.shared.system.InteractionJankMonitorWrapper import com.android.wm.shell.Flags.enableFlexibleTwoAppSplit +import com.android.wm.shell.shared.split.SplitBounds import com.android.wm.shell.shared.split.SplitScreenConstants.PersistentSnapPosition /** @@ -62,7 +63,7 @@ class GroupedTaskView @JvmOverloads constructor(context: Context, attrs: Attribu get() = taskContainers[1] // TODO(b/336612373): Support new TTV for GroupedTaskView - var splitBoundsConfig: SplitConfigurationOptions.SplitBounds? = null + var splitBoundsConfig: SplitBounds? = null private set @get:PersistentSnapPosition @@ -255,7 +256,7 @@ class GroupedTaskView @JvmOverloads constructor(context: Context, attrs: Attribu } } - fun updateSplitBoundsConfig(splitBounds: SplitConfigurationOptions.SplitBounds?) { + fun updateSplitBoundsConfig(splitBounds: SplitBounds?) { splitBoundsConfig = splitBounds taskContainers.forEach { it.digitalWellBeingToast?.splitBounds = splitBoundsConfig diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 2abb8a7284..1368e6d658 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -175,7 +175,6 @@ import com.android.launcher3.util.IntArray; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.ResourceBasedOverride.Overrides; import com.android.launcher3.util.RunnableList; -import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds; import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource; import com.android.launcher3.util.SplitConfigurationOptions.StagePosition; import com.android.launcher3.util.Themes; @@ -245,6 +244,7 @@ import com.android.wm.shell.common.pip.IPipAnimationListener; import com.android.wm.shell.shared.GroupedTaskInfo; import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; import com.android.wm.shell.shared.desktopmode.DesktopModeTransitionSource; +import com.android.wm.shell.shared.split.SplitBounds; import kotlin.Unit; import kotlin.collections.CollectionsKt; diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt index f452af3bf2..4abada9274 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt @@ -47,6 +47,7 @@ import com.android.quickstep.util.GroupTask import com.android.quickstep.util.SingleTask import com.android.quickstep.util.SplitTask import com.android.systemui.shared.recents.model.Task +import com.android.wm.shell.shared.split.SplitBounds import com.android.wm.shell.shared.split.SplitScreenConstants import com.google.common.truth.Truth.assertThat import java.util.function.Consumer @@ -922,7 +923,7 @@ class TaskbarRecentAppsControllerTest : TaskbarBaseTestCase() { SplitTask( createTask(100, splitPackages[0]), createTask(101, splitPackages[1]), - SplitConfigurationOptions.SplitBounds( + SplitBounds( /* leftTopBounds = */ Rect(), /* rightBottomBounds = */ Rect(), /* leftTopTaskId = */ -1, diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsModelTest.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsModelTest.java index 2eb2e4c2ca..f247f2ff9d 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsModelTest.java +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/RecentsModelTest.java @@ -50,6 +50,7 @@ import com.android.quickstep.util.GroupTask; import com.android.quickstep.util.SplitTask; import com.android.systemui.shared.recents.model.Task; import com.android.systemui.shared.system.TaskStackChangeListeners; +import com.android.wm.shell.shared.split.SplitBounds; import com.android.wm.shell.shared.split.SplitScreenConstants; import org.junit.Before; @@ -197,7 +198,7 @@ public class RecentsModelTest { Task task2 = Task.from(taskKey2, taskInfo2, false); allTasks.add( - new SplitTask(task1, task2, new SplitConfigurationOptions.SplitBounds( + new SplitTask(task1, task2, new SplitBounds( /* leftTopBounds = */ new Rect(), /* rightBottomBounds = */ new Rect(), /* leftTopTaskId = */ -1, diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/data/TasksRepositoryTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/data/TasksRepositoryTest.kt index e22892c9cc..a3468a7958 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/data/TasksRepositoryTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/data/TasksRepositoryTest.kt @@ -30,6 +30,7 @@ import com.android.quickstep.util.SingleTask import com.android.quickstep.util.SplitTask import com.android.systemui.shared.recents.model.Task import com.android.systemui.shared.recents.model.ThumbnailData +import com.android.wm.shell.shared.split.SplitBounds import com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50 import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -57,7 +58,7 @@ class TasksRepositoryTest { SplitTask( tasks[1], tasks[2], - SplitConfigurationOptions.SplitBounds( + SplitBounds( /* leftTopBounds = */ Rect(), /* rightBottomBounds = */ Rect(), /* leftTopTaskId = */ -1, diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt index 3d8a64f115..f745134109 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt @@ -24,6 +24,7 @@ import android.view.Display.INVALID_DISPLAY import com.android.launcher3.util.LauncherMultivalentJUnit import com.android.launcher3.util.SplitConfigurationOptions import com.android.systemui.shared.recents.model.Task +import com.android.wm.shell.shared.split.SplitBounds import com.android.wm.shell.shared.split.SplitScreenConstants import com.google.common.truth.Truth.assertThat import org.junit.Test @@ -62,7 +63,7 @@ class GroupTaskTest { @Test fun testGroupTask_equalSplitTasks_isEqual() { val splitBounds = - SplitConfigurationOptions.SplitBounds( + SplitBounds( Rect(), Rect(), 1, @@ -77,7 +78,7 @@ class GroupTaskTest { @Test fun testGroupTask_differentSplitTasks_isNotEqual() { val splitBounds1 = - SplitConfigurationOptions.SplitBounds( + SplitBounds( Rect(), Rect(), 1, @@ -85,7 +86,7 @@ class GroupTaskTest { SplitScreenConstants.SNAP_TO_2_50_50, ) val splitBounds2 = - SplitConfigurationOptions.SplitBounds( + SplitBounds( Rect(), Rect(), 1, @@ -133,7 +134,7 @@ class GroupTaskTest { @Test fun testSplitTask_matchesDisplayId() { val splitBounds = - SplitConfigurationOptions.SplitBounds( + SplitBounds( Rect(), Rect(), 1, diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt index e4bdba510f..d6f150c8e2 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt @@ -39,6 +39,7 @@ import com.android.quickstep.util.SplitSelectStateController.SplitFromDesktopCon import com.android.quickstep.views.RecentsView import com.android.quickstep.views.RecentsViewContainer import com.android.systemui.shared.recents.model.Task +import com.android.wm.shell.shared.split.SplitBounds import com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50 import java.util.function.Consumer import org.junit.Assert.assertEquals @@ -663,7 +664,7 @@ class SplitSelectStateControllerTest { return SplitTask( task1, task2, - SplitConfigurationOptions.SplitBounds( + SplitBounds( /* leftTopBounds = */ Rect(), /* rightBottomBounds = */ Rect(), /* leftTopTaskId = */ task1.key.id, @@ -701,7 +702,7 @@ class SplitSelectStateControllerTest { return SplitTask( task1, task2, - SplitConfigurationOptions.SplitBounds( + SplitBounds( /* leftTopBounds = */ Rect(), /* rightBottomBounds = */ Rect(), /* leftTopTaskId = */ task1.key.id, diff --git a/src/com/android/launcher3/util/SplitConfigurationOptions.java b/src/com/android/launcher3/util/SplitConfigurationOptions.java index e1ef77a00a..fcd420e297 100644 --- a/src/com/android/launcher3/util/SplitConfigurationOptions.java +++ b/src/com/android/launcher3/util/SplitConfigurationOptions.java @@ -114,125 +114,6 @@ public final class SplitConfigurationOptions { } } - /** - * NOTE: Engineers complained about too little ambiguity in the last survey, so there is a class - * with the same name/functionality in wm.shell.util (which launcher3 cannot be built against) - * - * If you make changes here, consider making the same changes there - * TODO(b/254378592): We really need to consolidate this - */ - public static class SplitBounds { - public final Rect leftTopBounds; - public final Rect rightBottomBounds; - /** This rect represents the actual gap between the two apps */ - public final Rect visualDividerBounds; - // This class is orientation-agnostic, so we compute both for later use - private final float topTaskPercent; - private final float leftTaskPercent; - private final float dividerWidthPercent; - private final float dividerHeightPercent; - public final int snapPosition; - - /** - * If {@code true}, that means at the time of creation of this object, the - * split-screened apps were vertically stacked. This is useful in scenarios like - * rotation where the bounds won't change, but this variable can indicate what orientation - * the bounds were originally in - */ - public final boolean appsStackedVertically; - /** - * If {@code true}, that means at the time of creation of this object, the phone was in - * seascape orientation. This is important on devices with insets, because they do not split - * evenly -- one of the insets must be slightly larger to account for the inset. - * From landscape, it is the leftTop task that expands slightly. - * From seascape, it is the rightBottom task that expands slightly. - */ - public final boolean initiatedFromSeascape; - public final int leftTopTaskId; - public final int rightBottomTaskId; - - public SplitBounds(Rect leftTopBounds, Rect rightBottomBounds, int leftTopTaskId, - int rightBottomTaskId, int snapPosition) { - this.leftTopBounds = leftTopBounds; - this.rightBottomBounds = rightBottomBounds; - this.leftTopTaskId = leftTopTaskId; - this.rightBottomTaskId = rightBottomTaskId; - this.snapPosition = snapPosition; - - if (rightBottomBounds.top > leftTopBounds.top) { - // vertical apps, horizontal divider - this.visualDividerBounds = new Rect(leftTopBounds.left, leftTopBounds.bottom, - leftTopBounds.right, rightBottomBounds.top); - appsStackedVertically = true; - initiatedFromSeascape = false; - } else { - // horizontal apps, vertical divider - this.visualDividerBounds = new Rect(leftTopBounds.right, leftTopBounds.top, - rightBottomBounds.left, leftTopBounds.bottom); - appsStackedVertically = false; - // The following check is unreliable on devices without insets - // (initiatedFromSeascape will always be set to false.) This happens to be OK for - // all our current uses, but should be refactored. - // TODO: Create a more reliable check, or refactor how splitting works on devices - // with insets. - if (rightBottomBounds.width() > leftTopBounds.width()) { - initiatedFromSeascape = true; - } else { - initiatedFromSeascape = false; - } - } - - float totalWidth = rightBottomBounds.right - leftTopBounds.left; - float totalHeight = rightBottomBounds.bottom - leftTopBounds.top; - leftTaskPercent = leftTopBounds.width() / totalWidth; - topTaskPercent = leftTopBounds.height() / totalHeight; - dividerWidthPercent = visualDividerBounds.width() / totalWidth; - dividerHeightPercent = visualDividerBounds.height() / totalHeight; - } - - /** - * Returns the percentage size of the left/top task (compared to the full width/height of - * the split pair). E.g. if the left task is 4 units wide, the divider is 2 units, and the - * right task is 4 units, this method will return 0.4f. - */ - public float getLeftTopTaskPercent() { - // topTaskPercent and leftTaskPercent are defined at creation time, and are not updated - // on device rotate, so we have to check appsStackedVertically to return the right - // creation-time measurements. - return appsStackedVertically ? topTaskPercent : leftTaskPercent; - } - - /** - * Returns the percentage size of the divider's thickness (compared to the full width/height - * of the split pair). E.g. if the left task is 4 units wide, the divider is 2 units, and - * the right task is 4 units, this method will return 0.2f. - */ - public float getDividerPercent() { - // dividerHeightPercent and dividerWidthPercent are defined at creation time, and are - // not updated on device rotate, so we have to check appsStackedVertically to return - // the right creation-time measurements. - return appsStackedVertically ? dividerHeightPercent : dividerWidthPercent; - } - - /** - * Returns the percentage size of the right/bottom task (compared to the full width/height - * of the split pair). E.g. if the left task is 4 units wide, the divider is 2 units, and - * the right task is 4 units, this method will return 0.4f. - */ - public float getRightBottomTaskPercent() { - return 1 - (getLeftTopTaskPercent() + getDividerPercent()); - } - - @Override - public String toString() { - return "LeftTop: " + leftTopBounds + ", taskId: " + leftTopTaskId + "\n" - + "RightBottom: " + rightBottomBounds + ", taskId: " + rightBottomTaskId + "\n" - + "Divider: " + visualDividerBounds + "\n" - + "AppsVertical? " + appsStackedVertically + "\n" - + "snapPosition: " + snapPosition; - } - } - public static class SplitStageInfo { public int taskId = -1; @StagePosition