From a602a0a8954556e8d75101688880e42620e15415 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Tue, 6 Sep 2022 13:34:00 -0700 Subject: [PATCH] Add error detection for aborting the recents scrolling during transition to home Bug: 227514916 Test: swiped to overview, to home and quick switch and checked the logs Change-Id: Ie02d3933e2fb05eedd9c264a381329bc04feac2d --- .../com/android/quickstep/GestureState.java | 11 +++++++++++ .../util/ActiveGestureErrorDetector.java | 18 +++++++++++++++--- .../android/quickstep/views/RecentsView.java | 10 ++++++++++ src/com/android/launcher3/PagedView.java | 11 ++++++++--- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/GestureState.java b/quickstep/src/com/android/quickstep/GestureState.java index 38bf1fd6d8..703db078c1 100644 --- a/quickstep/src/com/android/quickstep/GestureState.java +++ b/quickstep/src/com/android/quickstep/GestureState.java @@ -20,6 +20,7 @@ import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_OVERVIEW; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.SET_END_TARGET; +import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.SET_END_TARGET_HOME; import android.annotation.Nullable; import android.annotation.TargetApi; @@ -330,6 +331,16 @@ public class GestureState implements RecentsAnimationCallbacks.RecentsAnimationL ActiveGestureLog.INSTANCE.addLog( /* event= */ "setEndTarget " + mEndTarget, /* gestureEvent= */ SET_END_TARGET); + switch (mEndTarget) { + case HOME: + ActiveGestureLog.INSTANCE.trackEvent(SET_END_TARGET_HOME); + break; + case RECENTS: + case NEW_TASK: + case LAST_TASK: + default: + // No-Op + } if (isAtomic) { mStateCallback.setState(STATE_END_TARGET_ANIMATION_FINISHED); } diff --git a/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java b/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java index 54f632afdb..5e41259e71 100644 --- a/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java +++ b/quickstep/src/com/android/quickstep/util/ActiveGestureErrorDetector.java @@ -33,9 +33,10 @@ public class ActiveGestureErrorDetector { * Enums associated to gesture navigation events. */ public enum GestureEvent { - MOTION_DOWN, MOTION_UP, SET_END_TARGET, ON_SETTLED_ON_END_TARGET, START_RECENTS_ANIMATION, - FINISH_RECENTS_ANIMATION, CANCEL_RECENTS_ANIMATION, SET_ON_PAGE_TRANSITION_END_CALLBACK, - CANCEL_CURRENT_ANIMATION, CLEANUP_SCREENSHOT, + MOTION_DOWN, MOTION_UP, SET_END_TARGET, SET_END_TARGET_HOME, ON_SETTLED_ON_END_TARGET, + START_RECENTS_ANIMATION, FINISH_RECENTS_ANIMATION, CANCEL_RECENTS_ANIMATION, + SET_ON_PAGE_TRANSITION_END_CALLBACK, CANCEL_CURRENT_ANIMATION, CLEANUP_SCREENSHOT, + SCROLLER_ANIMATION_ABORTED, /** * These GestureEvents are specifically associated to state flags that get set in @@ -111,6 +112,16 @@ public class ActiveGestureErrorDetector { + "being set.", writer); break; + case SCROLLER_ANIMATION_ABORTED: + errorDetected |= printErrorIfTrue( + encounteredEvents.contains(GestureEvent.SET_END_TARGET_HOME) + && !encounteredEvents.contains( + GestureEvent.ON_SETTLED_ON_END_TARGET), + /* errorMessage= */ prefix + "\t\trecents view scroller animation " + + "aborted after setting end target HOME, but before" + + " settling on end target.", + writer); + break; case STATE_GESTURE_COMPLETED: errorDetected |= printErrorIfTrue( !encounteredEvents.contains(GestureEvent.MOTION_UP), @@ -161,6 +172,7 @@ public class ActiveGestureErrorDetector { break; case MOTION_DOWN: case SET_END_TARGET: + case SET_END_TARGET_HOME: case START_RECENTS_ANIMATION: case SET_ON_PAGE_TRANSITION_END_CALLBACK: case CANCEL_CURRENT_ANIMATION: diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 69557a8103..70b2958999 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -162,6 +162,8 @@ import com.android.quickstep.TaskThumbnailCache; import com.android.quickstep.TaskViewUtils; import com.android.quickstep.TopTaskTracker; import com.android.quickstep.ViewUtils; +import com.android.quickstep.util.ActiveGestureErrorDetector; +import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.GroupTask; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.util.RecentsOrientedState; @@ -1266,6 +1268,8 @@ public abstract class RecentsView taskGroups) { if (mPendingAnimation != null) { mPendingAnimation.addEndListener(success -> applyLoadPlan(taskGroups)); diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 73be5beb2c..68c54c7667 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -259,8 +259,13 @@ public abstract class PagedView extends ViewGrou abortScrollerAnimation(true); } + protected void onScrollerAnimationAborted() { + // No-Op + } + private void abortScrollerAnimation(boolean resetNextPage) { mScroller.abortAnimation(); + onScrollerAnimationAborted(); // We need to clean up the next page here to avoid computeScrollHelper from // updating current page on the pass. if (resetNextPage) { @@ -555,11 +560,11 @@ public abstract class PagedView extends ViewGrou if (mAllowOverScroll) { if (newPos < mMinScroll && oldPos >= mMinScroll) { mEdgeGlowLeft.onAbsorb((int) mScroller.getCurrVelocity()); - mScroller.abortAnimation(); + abortScrollerAnimation(false); onEdgeAbsorbingScroll(); } else if (newPos > mMaxScroll && oldPos <= mMaxScroll) { mEdgeGlowRight.onAbsorb((int) mScroller.getCurrVelocity()); - mScroller.abortAnimation(); + abortScrollerAnimation(false); onEdgeAbsorbingScroll(); } } @@ -569,7 +574,7 @@ public abstract class PagedView extends ViewGrou int finalPos = mOrientationHandler.getPrimaryValue(mScroller.getFinalX(), mScroller.getFinalY()); if (newPos == finalPos && mEdgeGlowLeft.isFinished() && mEdgeGlowRight.isFinished()) { - mScroller.abortAnimation(); + abortScrollerAnimation(false); } invalidate();