From 59f67752ad0215c37d090f93d08f6f6301bf312f Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 5 May 2021 12:10:04 -0700 Subject: [PATCH] Some cleanup for handler invalidation - Cancel reapplyWindowTransformAnim when STATE_HANDLER_INVALIDATED - Set mActivity and mRecentsView = null in invalidateHandlerWithLauncher() instead of posting from invalidateHandler() - Just in case, ignore onActivityInit() if we're already invalidated Test: Tap repeatedly in nav region in an app, no crash Fixes: 186983662 Change-Id: I3c005099b46ebb7c9203bcfcceedf48679dd1965 (cherry picked from commit 95e62812b2f17ccee77fb0e956b0bffde65409fc) --- .../android/quickstep/AbsSwipeUpHandler.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 10384a8a6e..fe1090878a 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -338,6 +338,10 @@ public abstract class AbsSwipeUpHandler, } protected boolean onActivityInit(Boolean alreadyOnHome) { + if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) { + return false; + } + T createdActivity = mActivityInterface.getCreatedActivity(); if (createdActivity != null) { initTransitionEndpoints(createdActivity.getDeviceProfile()); @@ -567,6 +571,8 @@ public abstract class AbsSwipeUpHandler, } }); reapplyWindowTransformAnim.setDuration(RECENTS_ATTACH_DURATION).start(); + mStateCallback.runOnceAtState(STATE_HANDLER_INVALIDATED, + reapplyWindowTransformAnim::cancel); } else { applyWindowTransform(); } @@ -1376,12 +1382,6 @@ public abstract class AbsSwipeUpHandler, mActivityInitListener.unregister(); ActivityManagerWrapper.getInstance().unregisterTaskStackListener(mActivityRestartListener); mTaskSnapshot = null; - mHandler.post(() -> { - // Defer clearing the activity since invalidation can happen over multiple callbacks - // ie. invalidateHandlerWithLauncher() - mActivity = null; - mRecentsView = null; - }); } private void invalidateHandlerWithLauncher() { @@ -1392,6 +1392,12 @@ public abstract class AbsSwipeUpHandler, mRecentsView.removeOnScrollChangedListener(mOnRecentsScrollListener); resetLauncherListeners(); + + mHandler.post(() -> { + // Defer clearing the activity since invalidation can happen over multiple callbacks. + mActivity = null; + mRecentsView = null; + }); } private void endLauncherTransitionController() {