From 240b064cdb9df3914fe90a55ba94a5101bbd2b22 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 13 Sep 2022 06:58:55 +0000 Subject: [PATCH] Fix case of gesture being stuck when the Launcher is stopped mid-gesture - In rare cases, Launcher may be stopped mid-swipe up gesture which results in two issues: - it continues to register a page transition end callback, but because launcher is not drawing, the page will never scroll and the callback never happens - in the case where the calculated end target is RECENTS, we don't finish the recents animation (because of live tile), and since it's still running, subsequent gestures are interpreted as continuing the current gesture and it gets stuck Instead in these cases we can force the gesture to resolve to LAST_TASK (similar to the canceled gesture case), and not wait for the page to settle. Note, that we would prefer to fix the root issue of Launcher being stopped, but at least this change prevents Launcher from getting into the wrong state if so. Bug: 246476942 Test: Repro steps from the bug Change-Id: I59098229e5e37722e8017a2dfcb42eab6659643d --- .../src/com/android/quickstep/AbsSwipeUpHandler.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 81a5c1cb9d..41c220b39b 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -1150,6 +1150,13 @@ public abstract class AbsSwipeUpHandler, boolean isCancel) { long duration = MAX_SWIPE_DURATION; float currentShift = mCurrentShift.value; + boolean recentsVisible = mRecentsView != null + && (mRecentsView.getWindowVisibility() == View.VISIBLE); + if (!recentsVisible) { + // We've hit a case where Launcher is been stopped mid-gesture, in this case, force + // a LAST_TASK end target + isCancel = true; + } final GestureEndTarget endTarget = calculateEndTarget(velocity, endVelocity, isFling, isCancel); // Set the state, but don't notify until the animation completes @@ -1229,7 +1236,7 @@ public abstract class AbsSwipeUpHandler, // Let RecentsView handle the scrolling to the task, which we launch in startNewTask() // or resumeLastTask(). - if (mRecentsView != null) { + if (recentsVisible) { ActiveGestureLog.INSTANCE.trackEvent(ActiveGestureErrorDetector.GestureEvent .SET_ON_PAGE_TRANSITION_END_CALLBACK); mRecentsView.setOnPageTransitionEndCallback(