diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 972ce4deda..45b2081952 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -122,6 +122,7 @@ import com.android.systemui.shared.system.TaskStackChangeListeners; import java.util.ArrayList; import java.util.HashMap; +import java.util.Arrays; import java.util.function.Consumer; /** @@ -976,12 +977,13 @@ public abstract class AbsSwipeUpHandler, } /** @return Whether this was the task we were waiting to appear, and thus handled it. */ - protected boolean handleTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) { + protected boolean handleTaskAppeared(RemoteAnimationTargetCompat[] appearedTaskTarget) { if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) { return false; } - if (mStateCallback.hasStates(STATE_START_NEW_TASK) - && appearedTaskTarget.taskId == mGestureState.getLastStartedTaskId()) { + boolean hasStartedTaskBefore = Arrays.stream(appearedTaskTarget).anyMatch( + targetCompat -> targetCompat.taskId == mGestureState.getLastStartedTaskId()); + if (mStateCallback.hasStates(STATE_START_NEW_TASK) && hasStartedTaskBefore) { reset(); return true; } @@ -1866,9 +1868,9 @@ public abstract class AbsSwipeUpHandler, } @Override - public void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) { + public void onTasksAppeared(RemoteAnimationTargetCompat[] appearedTaskTargets) { if (mRecentsAnimationController != null) { - if (handleTaskAppeared(appearedTaskTarget)) { + if (handleTaskAppeared(appearedTaskTargets)) { mRecentsAnimationController.finish(false /* toRecents */, null /* onFinishComplete */); mActivityInterface.onLaunchTaskSuccess(); diff --git a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java index fed5ae56ea..a82137e07c 100644 --- a/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java +++ b/quickstep/src/com/android/quickstep/FallbackSwipeHandler.java @@ -147,7 +147,7 @@ public class FallbackSwipeHandler extends } @Override - protected boolean handleTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) { + protected boolean handleTaskAppeared(RemoteAnimationTargetCompat[] appearedTaskTarget) { if (mActiveAnimationFactory != null && mActiveAnimationFactory.handleHomeTaskAppeared(appearedTaskTarget)) { mActiveAnimationFactory = null; @@ -260,7 +260,8 @@ public class FallbackSwipeHandler extends } } - public boolean handleHomeTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) { + public boolean handleHomeTaskAppeared(RemoteAnimationTargetCompat[] appearedTaskTargets) { + RemoteAnimationTargetCompat appearedTaskTarget = appearedTaskTargets[0]; if (appearedTaskTarget.activityType == ACTIVITY_TYPE_HOME) { RemoteAnimationTargets targets = new RemoteAnimationTargets( new RemoteAnimationTargetCompat[] {appearedTaskTarget}, diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java index 750985a3f8..dd6392cb9a 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationCallbacks.java @@ -136,10 +136,10 @@ public class RecentsAnimationCallbacks implements @BinderThread @Override - public void onTaskAppeared(RemoteAnimationTargetCompat app) { + public void onTasksAppeared(RemoteAnimationTargetCompat[] apps) { Utilities.postAsyncCallback(MAIN_EXECUTOR.getHandler(), () -> { for (RecentsAnimationListener listener : getListeners()) { - listener.onTaskAppeared(app); + listener.onTasksAppeared(apps); } }); } @@ -177,6 +177,6 @@ public class RecentsAnimationCallbacks implements /** * Callback made when a task started from the recents is ready for an app transition. */ - default void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {} + default void onTasksAppeared(RemoteAnimationTargetCompat[] appearedTaskTarget) {} } } diff --git a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java index 0871a6d150..b031c4744b 100644 --- a/quickstep/src/com/android/quickstep/RemoteTargetGluer.java +++ b/quickstep/src/com/android/quickstep/RemoteTargetGluer.java @@ -85,13 +85,21 @@ public class RemoteTargetGluer { /** * Similar to {@link #assignTargets(RemoteAnimationTargets)}, except this matches the - * apps in targets.apps to that of the split screened tasks. If split screen is active, then - * {@link #mRemoteTargetHandles} index 0 will be the left/top task, index one right/bottom + * apps in targets.apps to that of the _active_ split screened tasks. + * See {@link #assignTargetsForSplitScreen(RemoteAnimationTargets, int[])} */ public RemoteTargetHandle[] assignTargetsForSplitScreen(RemoteAnimationTargets targets) { int[] splitIds = LauncherSplitScreenListener.INSTANCE.getNoCreate() .getRunningSplitTaskIds(); + return assignTargetsForSplitScreen(targets, splitIds); + } + /** + * Assigns the provided splitIDs to the {@link #mRemoteTargetHandles}, with index 0 will beint + * the left/top task, index 1 right/bottom + */ + public RemoteTargetHandle[] assignTargetsForSplitScreen(RemoteAnimationTargets targets, + int[] splitIds) { RemoteAnimationTargetCompat primaryTaskTarget; RemoteAnimationTargetCompat secondaryTaskTarget; if (mRemoteTargetHandles.length == 1) { diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index ed7f0b3999..e69330ab22 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -147,16 +147,16 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn } @Override - public void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) { + public void onTasksAppeared(RemoteAnimationTargetCompat[] appearedTaskTargets) { + RemoteAnimationTargetCompat appearedTaskTarget = appearedTaskTargets[0]; BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface(); if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode() && activityInterface.getCreatedActivity() != null) { RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel(); if (recentsView != null) { - RemoteAnimationTargetCompat[] apps = new RemoteAnimationTargetCompat[1]; - apps[0] = appearedTaskTarget; - recentsView.launchSideTaskInLiveTileMode(appearedTaskTarget.taskId, apps, + recentsView.launchSideTaskInLiveTileMode(appearedTaskTarget.taskId, + appearedTaskTargets, new RemoteAnimationTargetCompat[0] /* wallpaper */, new RemoteAnimationTargetCompat[0] /* nonApps */); return; diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 15729e11fb..67a94cc9d0 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -177,8 +177,8 @@ public final class TaskViewUtils { } else { RemoteTargetGluer gluer = new RemoteTargetGluer(v.getContext(), recentsView.getSizeStrategy(), targets); - if (recentsViewHandles != null && recentsViewHandles.length > 1) { - remoteTargetHandles = gluer.assignTargetsForSplitScreen(targets); + if (v.containsMultipleTasks()) { + remoteTargetHandles = gluer.assignTargetsForSplitScreen(targets, v.getTaskIds()); } else { remoteTargetHandles = gluer.assignTargets(targets); } diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index 4c300ec17a..e1afa97f6f 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -56,6 +56,7 @@ public class SplitSelectStateController { private Task mInitialTask; private Task mSecondTask; private Rect mInitialBounds; + private boolean mRecentsAnimationRunning; public SplitSelectStateController(Handler handler, SystemUiProxy systemUiProxy) { mHandler = handler; @@ -113,6 +114,10 @@ public class SplitSelectStateController { return mStagePosition; } + public void setRecentsAnimationRunning(boolean running) { + this.mRecentsAnimationRunning = running; + } + /** * Requires Shell Transitions */ @@ -172,7 +177,9 @@ public class SplitSelectStateController { public void onAnimationCancelled() { postAsyncCallback(mHandler, () -> { if (mSuccessCallback != null) { - mSuccessCallback.accept(false); + // Launching legacy tasks while recents animation is running will always cause + // onAnimationCancelled to be called (should be fixed w/ shell transitions?) + mSuccessCallback.accept(mRecentsAnimationRunning); } resetState(); }); @@ -187,6 +194,7 @@ public class SplitSelectStateController { mSecondTask = null; mStagePosition = SplitConfigurationOptions.STAGE_POSITION_UNDEFINED; mInitialBounds = null; + mRecentsAnimationRunning = false; } /** diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 8566720702..1d01b7a564 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -1874,6 +1874,7 @@ public abstract class RecentsView