From 4ebdbc9db168d38341c131f9c53cf799311b6601 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 5 Oct 2021 12:06:53 -0700 Subject: [PATCH] Cancel the existing recents animation before any initialization - In the rare case that we are canceling the recents animation as a part of starting another recents animation, ensure that we do it before we move the target activity to be visible, otherwise the cancelation will undo the previous work. Bug: 193851085 Test: atest RecentsAnimationControllerTest Change-Id: I22589a034eab3b1fab10f4b677f777b282305bbd --- .../com/android/server/wm/RecentsAnimation.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/RecentsAnimation.java b/services/core/java/com/android/server/wm/RecentsAnimation.java index ba1cf8ae06df3..ee05523b3f2ac 100644 --- a/services/core/java/com/android/server/wm/RecentsAnimation.java +++ b/services/core/java/com/android/server/wm/RecentsAnimation.java @@ -170,6 +170,13 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan ProtoLog.d(WM_DEBUG_RECENTS_ANIMATIONS, "startRecentsActivity(): intent=%s", mTargetIntent); Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "RecentsAnimation#startRecentsActivity"); + // Cancel any existing recents animation running synchronously (do not hold the + // WM lock) before starting the newly requested recents animation as they can not coexist + if (mWindowManager.getRecentsAnimationController() != null) { + mWindowManager.getRecentsAnimationController().forceCancelAnimation( + REORDER_MOVE_TO_ORIGINAL_POSITION, "startRecentsActivity"); + } + // If the activity is associated with the root recents task, then try and get that first Task targetRootTask = mDefaultTaskDisplayArea.getRootTask(WINDOWING_MODE_UNDEFINED, mTargetActivityType); @@ -243,12 +250,7 @@ class RecentsAnimation implements RecentsAnimationCallbacks, OnRootTaskOrderChan targetActivity.intent.replaceExtras(mTargetIntent); // Fetch all the surface controls and pass them to the client to get the animation - // started. Cancel any existing recents animation running synchronously (do not hold the - // WM lock) - if (mWindowManager.getRecentsAnimationController() != null) { - mWindowManager.getRecentsAnimationController().forceCancelAnimation( - REORDER_MOVE_TO_ORIGINAL_POSITION, "startRecentsActivity"); - } + // started mWindowManager.initializeRecentsAnimation(mTargetActivityType, recentsAnimationRunner, this, mDefaultTaskDisplayArea.getDisplayId(), mTaskSupervisor.mRecentTasks.getRecentTaskIds(), targetActivity);