Don't run finish callback until we actually finish
This fixes the issue where the app re-appears on top if you touch
the nav bar during the animation to home.
The sequence of events leading to this behavior is pretty long,
but actually always should have happened, it was just masked
until the ag/11172732 fix went in.
Here's an abbreviated version of what was happening
on the touch down during the animation to home:
1 Set mRecentsAnimationController#mTouchInProgress = true
2 Cancel the running animation to home
3 onSettledOnEndTarget(HOME) (this is what was missing before)
4 finishCurrentTransitionToHome(), which, due to #1, doesn't
actually finish the controller, but does run the callback
5 Invalidate the handler due to #4, leading to TIS#reset()
6 Create a new handler (still from the original touch down),
which is mResetGestureInputConsumer
7 mResetGestureInputConsumer handles touch down to finish
the controller the app
This change addresses #4. Instead of calling the callback
immediately, we defer it to when we actually finish the
controller, which ensures there's no longer premature
cleanup that leads to the rest of the sequence.
Bug: 157407284
Change-Id: I0b2ff57bfa77a25c2bf1aece4b0ae7f943637ce6
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationController.java b/quickstep/src/com/android/quickstep/RecentsAnimationController.java
index 76a81eb..b0a3cd2 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationController.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationController.java
@@ -29,6 +29,7 @@
import android.view.MotionEvent;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import com.android.launcher3.util.Preconditions;
@@ -58,6 +59,7 @@
private boolean mSplitScreenMinimized = false;
private boolean mTouchInProgress;
private boolean mFinishPending;
+ private @Nullable Runnable mFinishPendingCallback;
public RecentsAnimationController(RecentsAnimationControllerCompat controller,
boolean allowMinimizeSplitScreen,
@@ -165,10 +167,7 @@
} else {
if (mTouchInProgress) {
mFinishPending = true;
- // Execute the callback
- if (onFinishComplete != null) {
- onFinishComplete.run();
- }
+ mFinishPendingCallback = onFinishComplete;
} else {
finishAndClear(true, onFinishComplete, sendUserLeaveHint);
}
@@ -265,7 +264,9 @@
mTouchInProgress = false;
if (mFinishPending) {
mFinishPending = false;
- finishAndClear(true /* toRecents */, null, false /* sendUserLeaveHint */);
+ finishAndClear(true /* toRecents */, mFinishPendingCallback,
+ false /* sendUserLeaveHint */);
+ mFinishPendingCallback = null;
}
}
if (mInputConsumer != null) {