From 2b06fa518b5e2b290a8df2725557d74446bf724a Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Thu, 12 May 2022 14:36:39 +0800 Subject: [PATCH] Cancel the recents animation for locked gesture[2/2] When device is locked and going to finish the recents animation, instead of start home activity, calling finishRunningRecentsAnimation directly so core and shell does not need to handle another transition. Bug: 230582311 Test: enable shell transition. Start showWhenLocked activity while keyguard showing. Scroll up to dismiss the activity and verify the activity and home shall be stopped and only keyguard remains on the screen. Also verify entering recents works fine when device is unlocked. Change-Id: Ic76f81efcaa8ed00d5af1475259ec16659f6b568 --- .../DeviceLockedInputConsumer.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java index 3c0da01db6..c1750b5803 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java @@ -25,6 +25,7 @@ import static com.android.launcher3.util.VelocityUtils.PX_PER_MS; import static com.android.quickstep.AbsSwipeUpHandler.MIN_PROGRESS_FOR_OVERVIEW; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; import static com.android.quickstep.OverviewComponentObserver.startHomeIntentSafely; +import static com.android.quickstep.TaskAnimationManager.ENABLE_SHELL_TRANSITIONS; import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID; import android.animation.Animator; @@ -101,6 +102,8 @@ public class DeviceLockedInputConsumer implements InputConsumer, private boolean mThresholdCrossed = false; private boolean mHomeLaunched = false; + private boolean mCancelWhenRecentsStart = false; + private boolean mDismissTask = false; private RecentsAnimationController mRecentsAnimationController; @@ -204,7 +207,17 @@ public class DeviceLockedInputConsumer implements InputConsumer, animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - if (dismissTask) { + if (ENABLE_SHELL_TRANSITIONS) { + if (mTaskAnimationManager.getCurrentCallbacks() != null) { + if (mRecentsAnimationController != null) { + finishRecentsAnimationForShell(dismissTask); + } else { + // the transition of recents animation hasn't started, wait for it + mCancelWhenRecentsStart = true; + mDismissTask = dismissTask; + } + } + } else if (dismissTask) { // For now, just start the home intent so user is prompted to // unlock the device. startHomeIntentSafely(mContext, mGestureState.getHomeIntent(), null); @@ -239,12 +252,24 @@ public class DeviceLockedInputConsumer implements InputConsumer, mTransformParams.setTargetSet(targets); applyTransform(); mStateCallback.setState(STATE_TARGET_RECEIVED); + if (mCancelWhenRecentsStart) { + finishRecentsAnimationForShell(mDismissTask); + } } @Override public void onRecentsAnimationCanceled(HashMap thumbnailDatas) { mRecentsAnimationController = null; mTransformParams.setTargetSet(null); + mCancelWhenRecentsStart = false; + } + + private void finishRecentsAnimationForShell(boolean dismissTask) { + mCancelWhenRecentsStart = false; + mTaskAnimationManager.finishRunningRecentsAnimation(dismissTask /* toHome */); + if (dismissTask) { + mHomeLaunched = true; + } } private void endRemoteAnimation() {