From 7f6f7aad7b26b62b9fdc765bd8be5d622386a666 Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Wed, 5 Feb 2025 16:28:17 -0500 Subject: [PATCH] Re-use existing method to get split root Test: Launching app pair from desktop, in-app, overview from taskbar launches as expected Bug: 372837890 Flag: EXEMPT bugfix Change-Id: I50ab3cb1dc95a2cf20b77ae5d00cad3be7cd8e5c --- .../util/SplitAnimationController.kt | 33 +++---------------- .../quickstep/util/SplitScreenUtils.kt | 4 +-- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt index 9b4c772daa..48f257bce7 100644 --- a/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt +++ b/quickstep/src/com/android/quickstep/util/SplitAnimationController.kt @@ -65,6 +65,7 @@ import com.android.launcher3.util.MultiPropertyFactory.MULTI_PROPERTY_VALUE import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource import com.android.launcher3.views.BaseDragLayer import com.android.quickstep.TaskViewUtils +import com.android.quickstep.util.SplitScreenUtils.Companion.extractTopParentAndChildren import com.android.quickstep.views.FloatingAppPairView import com.android.quickstep.views.FloatingTaskView import com.android.quickstep.views.GroupedTaskView @@ -986,35 +987,9 @@ class SplitAnimationController(val splitSelectStateController: SplitSelectStateC progressUpdater.setDuration(QuickstepTransitionManager.APP_LAUNCH_DURATION) progressUpdater.interpolator = Interpolators.EMPHASIZED - var rootCandidate: Change? = null - - for (change in transitionInfo.changes) { - val taskInfo: RunningTaskInfo = change.taskInfo ?: continue - - // TODO (b/316490565): Replace this logic when SplitBounds is available to - // startAnimation() and we can know the precise taskIds of launching tasks. - if ( - taskInfo.windowingMode == windowingMode && - (change.mode == TRANSIT_OPEN || change.mode == TRANSIT_TO_FRONT) - ) { - // Found one! - rootCandidate = change - break - } - } - - // If we could not find a proper root candidate, something went wrong. - check(rootCandidate != null) { "Could not find a split root candidate" } - - // Recurse up the tree until parent is null, then we've found our root. - var parentToken: WindowContainerToken? = rootCandidate.parent - while (parentToken != null) { - rootCandidate = transitionInfo.getChange(parentToken) ?: break - parentToken = rootCandidate.parent - } - - // Make sure nothing weird happened, like getChange() returning null. - check(rootCandidate != null) { "Failed to find a root leash" } + val splitTree: Pair>? = extractTopParentAndChildren(transitionInfo) + check(splitTree != null) { "Could not find a split root candidate" } + val rootCandidate = splitTree.first // Starting position is a 34% size tile centered in the middle of the screen. // Ending position is the full device screen. diff --git a/quickstep/src/com/android/quickstep/util/SplitScreenUtils.kt b/quickstep/src/com/android/quickstep/util/SplitScreenUtils.kt index 4005c5a813..7787e30b42 100644 --- a/quickstep/src/com/android/quickstep/util/SplitScreenUtils.kt +++ b/quickstep/src/com/android/quickstep/util/SplitScreenUtils.kt @@ -46,8 +46,8 @@ class SplitScreenUtils { * 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. * - * @return a [Pair] where first -> top most split root, second -> [List] of 2, - * leftTop/bottomRight stage roots + * @return null if no root is found, otherwise a [Pair] where first -> top most split root, + * second -> [List] of 2, leftTop/bottomRight stage roots */ fun extractTopParentAndChildren( transitionInfo: TransitionInfo