Pass isLikelyToStartNewTask to onGestureStarted()
This ensures we immediately setRecentsAttachedToAppWindow(). As
mentioned in the bug, there was an edge case where we would animate
the attached state if the first move event passed the touch slop,
causing the adjacent task view to lag behind during the gesture.
Fixes: 159742520
Change-Id: Ie47bb84fdd3dbd69e3b74ca504d487fb9aedb551
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
index 02bae64..a63f3a8 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java
@@ -327,7 +327,7 @@
public abstract void onMotionPauseChanged(boolean isPaused);
@UiThread
- public void onGestureStarted() { }
+ public void onGestureStarted(boolean isLikelyToStartNewTask) { }
@UiThread
public abstract void onGestureCancelled();
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java
index 413a813..37aa0da 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java
@@ -492,9 +492,13 @@
@Override
public void setIsLikelyToStartNewTask(boolean isLikelyToStartNewTask) {
+ setIsLikelyToStartNewTask(isLikelyToStartNewTask, true /* animate */);
+ }
+
+ private void setIsLikelyToStartNewTask(boolean isLikelyToStartNewTask, boolean animate) {
if (mIsLikelyToStartNewTask != isLikelyToStartNewTask) {
mIsLikelyToStartNewTask = isLikelyToStartNewTask;
- maybeUpdateRecentsAttachedState();
+ maybeUpdateRecentsAttachedState(animate);
}
}
@@ -628,8 +632,9 @@
}
@Override
- public void onGestureStarted() {
+ public void onGestureStarted(boolean isLikelyToStartNewTask) {
notifyGestureStartedAsync();
+ setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */);
mStateCallback.setStateOnUiThread(STATE_GESTURE_STARTED);
mGestureStarted = true;
}
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
index 4e967cf..26df9c7 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java
@@ -277,6 +277,13 @@
if (!mPassedSlopOnThisGesture && passedSlop) {
mPassedSlopOnThisGesture = true;
}
+ // Until passing slop, we don't know what direction we're going, so assume
+ // we're quick switching to avoid translating recents away when continuing
+ // the gesture (in which case mPassedPilferInputSlop starts as true).
+ boolean haveNotPassedSlopOnContinuedGesture =
+ !mPassedSlopOnThisGesture && mPassedPilferInputSlop;
+ boolean isLikelyToStartNewTask = haveNotPassedSlopOnContinuedGesture
+ || horizontalDist > upDist;
if (!mPassedPilferInputSlop) {
if (passedSlop) {
@@ -299,7 +306,7 @@
mStartDisplacement = Math.min(displacement, -mTouchSlop);
}
- notifyGestureStarted();
+ notifyGestureStarted(isLikelyToStartNewTask);
}
}
@@ -310,13 +317,6 @@
}
if (mDeviceState.isFullyGesturalNavMode()) {
- // Until passing slop, we don't know what direction we're going, so assume
- // we're quick switching to avoid translating recents away when continuing
- // the gesture.
- boolean haveNotPassedSlopOnContinuedGesture =
- !mPassedSlopOnThisGesture && mPassedPilferInputSlop;
- boolean isLikelyToStartNewTask = haveNotPassedSlopOnContinuedGesture
- || horizontalDist > upDist;
mMotionPauseDetector.setDisallowPause(upDist < mMotionPauseMinDisplacement
|| isLikelyToStartNewTask);
mMotionPauseDetector.addPosition(ev);
@@ -340,7 +340,7 @@
}
}
- private void notifyGestureStarted() {
+ private void notifyGestureStarted(boolean isLikelyToStartNewTask) {
ActiveGestureLog.INSTANCE.addLog("startQuickstep");
if (mInteractionHandler == null) {
return;
@@ -353,7 +353,7 @@
CLOSE_SYSTEM_WINDOWS_REASON_RECENTS);
// Notify the handler that the gesture has actually started
- mInteractionHandler.onGestureStarted();
+ mInteractionHandler.onGestureStarted(isLikelyToStartNewTask);
}
private void startTouchTrackingForWindowAnimation(long touchTimeMs) {
@@ -370,8 +370,7 @@
mActiveCallbacks = mTaskAnimationManager.continueRecentsAnimation(mGestureState);
mActiveCallbacks.addListener(mInteractionHandler);
mTaskAnimationManager.notifyRecentsAnimationState(mInteractionHandler);
- mInteractionHandler.setIsLikelyToStartNewTask(true);
- notifyGestureStarted();
+ notifyGestureStarted(true /*isLikelyToStartNewTask*/);
} else {
intent.putExtra(INTENT_EXTRA_LOG_TRACE_ID, mGestureState.getGestureId());
mActiveCallbacks = mTaskAnimationManager.startRecentsAnimation(mGestureState, intent,