From 3fc57cb50a6fd2853d86417eece41ae60416622e Mon Sep 17 00:00:00 2001 From: Tony Huang Date: Mon, 12 Sep 2022 14:59:29 +0800 Subject: [PATCH] Fix split divider flash if swipe again quickly This bug caused by divider will be set to show when animation cancelled, because split screen will show divider itself when both split visible, this call might be unnecessary. Fix it by removing these lines. Add surface valid checking when running divider animation to avoid crash caused if surface was released during animation. Fix: 242823773 Bug: 246371786 Test: manual Test: pass existing tests Change-Id: I10aaf86e4164327b1c6c2f323c62b246c600228a --- .../src/com/android/quickstep/AbsSwipeUpHandler.java | 9 --------- quickstep/src/com/android/quickstep/TaskViewUtils.java | 10 +++++++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 81a5c1cb9d..7a70340628 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -881,11 +881,6 @@ public abstract class AbsSwipeUpHandler, // properly cleaned up the screenshot without accidentally using it. mDeferredCleanupRecentsAnimationController = mRecentsAnimationController; mStateCallback.setStateOnUiThread(STATE_GESTURE_CANCELLED | STATE_HANDLER_INVALIDATED); - - if (mRecentsAnimationTargets != null) { - setDividerShown(true /* shown */, false /* immediate */); - } - // Defer clearing the controller and the targets until after we've updated the state mRecentsAnimationController = null; mRecentsAnimationTargets = null; @@ -1783,10 +1778,6 @@ public abstract class AbsSwipeUpHandler, boolean wasVisible = mWasLauncherAlreadyVisible || mGestureStarted; mActivityInterface.onTransitionCancelled(wasVisible, mGestureState.getEndTarget()); - if (mRecentsAnimationTargets != null && wasVisible) { - setDividerShown(true /* shown */, true /* immediate */); - } - // Leave the pending invisible flag, as it may be used by wallpaper open animation. if (mActivity != null) { mActivity.clearForceInvisibleFlag(INVISIBLE_BY_STATE_HANDLER); diff --git a/quickstep/src/com/android/quickstep/TaskViewUtils.java b/quickstep/src/com/android/quickstep/TaskViewUtils.java index 7e1d1810d1..41972c6b5b 100644 --- a/quickstep/src/com/android/quickstep/TaskViewUtils.java +++ b/quickstep/src/com/android/quickstep/TaskViewUtils.java @@ -672,7 +672,7 @@ public final class TaskViewUtils { for (int i = 0; i < nonApps.length; ++i) { final RemoteAnimationTargetCompat targ = nonApps[i]; final SurfaceControl leash = targ.leash; - if (targ.windowType == TYPE_DOCK_DIVIDER && leash != null) { + if (targ.windowType == TYPE_DOCK_DIVIDER && leash != null && leash.isValid()) { auxiliarySurfaces.add(leash); hasSurfaceToAnimate = true; } @@ -685,7 +685,9 @@ public final class TaskViewUtils { dockFadeAnimator.addUpdateListener(valueAnimator -> { float progress = valueAnimator.getAnimatedFraction(); for (SurfaceControl leash : auxiliarySurfaces) { - t.setAlpha(leash, shown ? progress : 1 - progress); + if (leash != null && leash.isValid()) { + t.setAlpha(leash, shown ? progress : 1 - progress); + } } t.apply(); }); @@ -706,7 +708,9 @@ public final class TaskViewUtils { public void onAnimationEnd(Animator animation) { if (!shown) { for (SurfaceControl leash : auxiliarySurfaces) { - t.hide(leash); + if (leash != null && leash.isValid()) { + t.hide(leash); + } } t.apply(); }