From d8a07fa030aea4732dbbef28727f24bc7dd32637 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Tue, 13 Dec 2022 02:05:35 -0800 Subject: [PATCH] Fix NPE from getting swipe pip to home animator finish transation after the surface has been released Fixes: 243154747 Test: programmatically added delay to finish transation later Change-Id: Ia667372678f2224406147f5659c5fc6f61f270ad --- .../android/quickstep/AbsSwipeUpHandler.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 3d8ffc418a..09ddba3a2a 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -323,6 +323,9 @@ public abstract class AbsSwipeUpHandler, // May be set to false when mIsTransientTaskbar is true. private boolean mCanSlowSwipeGoHome = true; + @Nullable + private RemoteAnimationTargets.ReleaseCheck mSwipePipToHomeReleaseCheck = null; + public AbsSwipeUpHandler(Context context, RecentsAnimationDeviceState deviceState, TaskAnimationManager taskAnimationManager, GestureState gestureState, long touchTimeMs, boolean continuingLastGesture, @@ -867,6 +870,9 @@ public abstract class AbsSwipeUpHandler, mRemoteTargetHandles = mTargetGluer.assignTargetsForSplitScreen(mContext, targets); mRecentsAnimationController = controller; mRecentsAnimationTargets = targets; + mSwipePipToHomeReleaseCheck = new RemoteAnimationTargets.ReleaseCheck(); + mSwipePipToHomeReleaseCheck.setCanRelease(true); + mRecentsAnimationTargets.addReleaseCheck(mSwipePipToHomeReleaseCheck); // Only initialize the device profile, if it has not been initialized before, as in some // configurations targets.homeContentInsets may not be correct. @@ -1416,9 +1422,16 @@ public abstract class AbsSwipeUpHandler, mSwipePipToHomeAnimator = createWindowAnimationToPip( homeAnimFactory, runningTaskTarget, start); mSwipePipToHomeAnimators[0] = mSwipePipToHomeAnimator; + if (mSwipePipToHomeReleaseCheck != null) { + mSwipePipToHomeReleaseCheck.setCanRelease(false); + } windowAnim = mSwipePipToHomeAnimators; } else { mSwipePipToHomeAnimator = null; + if (mSwipePipToHomeReleaseCheck != null) { + mSwipePipToHomeReleaseCheck.setCanRelease(true); + mSwipePipToHomeReleaseCheck = null; + } windowAnim = createWindowAnimationToHome(start, homeAnimFactory); windowAnim[0].addAnimatorListener(new AnimationSuccessListener() { @@ -1940,6 +1953,10 @@ public abstract class AbsSwipeUpHandler, finishRecentsControllerToHome( () -> mStateCallback.setStateOnUiThread(STATE_CURRENT_TASK_FINISHED)); } + if (mSwipePipToHomeReleaseCheck != null) { + mSwipePipToHomeReleaseCheck.setCanRelease(true); + mSwipePipToHomeReleaseCheck = null; + } doLogGesture(HOME, mRecentsView == null ? null : mRecentsView.getCurrentPageTaskView()); }