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
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 81a5c1c..41c220b 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -1150,6 +1150,13 @@
             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 @@
 
         // 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(