From 51ceb9971587057cb244102d433c75a6d79c5d40 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Fri, 22 Dec 2023 20:07:43 +0800 Subject: [PATCH] Perform TaskView animation when reopening the current task When using gesture navigation to switch task, if the next started task moves the previous task in live tile to top, the appeared task will be the previous animating task rather than the task started by recents. Previously, none of condition handles the case, which causes a splash screen task view to stay on screen and the transition keeps in running state. By running the side task launch animation, it can indicate that there is an additional task switch visually, and the recents transition can be finished when the animation is finished. Bug: 317160303 Test: Activity A's onResume always starts activity B (declares different taskAffinity) with FLAG_ACTIVITY_NEW_TASK. Use gesture to swipe from B to A. B should be visible instead of staying at recents with a splash screen view. Change-Id: Id1a441561ac9958f71efe2440e4fb467bedc6947 --- .../android/quickstep/TaskAnimationManager.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/TaskAnimationManager.java b/quickstep/src/com/android/quickstep/TaskAnimationManager.java index 8e03a91738..6c861d572f 100644 --- a/quickstep/src/com/android/quickstep/TaskAnimationManager.java +++ b/quickstep/src/com/android/quickstep/TaskAnimationManager.java @@ -38,6 +38,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.UiThread; +import com.android.internal.util.ArrayUtils; import com.android.launcher3.Utilities; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.util.DisplayController; @@ -185,6 +186,16 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn cleanUpRecentsAnimation(newCallbacks); } + private boolean isNonRecentsStartedTasksAppeared( + RemoteAnimationTarget[] appearedTaskTargets) { + // For example, right after swiping from task X to task Y (e.g. from + // AbsSwipeUpHandler#startNewTask), and then task Y starts X immediately + // (e.g. in Y's onResume). The case will be: lastStartedTask=Y and appearedTask=X. + return mLastGestureState.getEndTarget() == GestureState.GestureEndTarget.NEW_TASK + && ArrayUtils.find(appearedTaskTargets, + mLastGestureState.mLastStartedTaskIdPredicate) == null; + } + @Override public void onTasksAppeared(RemoteAnimationTarget[] appearedTaskTargets) { RemoteAnimationTarget appearedTaskTarget = appearedTaskTargets[0]; @@ -212,7 +223,8 @@ public class TaskAnimationManager implements RecentsAnimationCallbacks.RecentsAn nonAppTargets = new RemoteAnimationTarget[0]; } if ((activityInterface.isInLiveTileMode() - || mLastGestureState.getEndTarget() == RECENTS) + || mLastGestureState.getEndTarget() == RECENTS + || isNonRecentsStartedTasksAppeared(appearedTaskTargets)) && activityInterface.getCreatedActivity() != null) { RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel();