Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3e54415 authored by wilsonshih's avatar wilsonshih
Browse files

Fix NPE crash from scheduleAnimation after cancelPendingAnimation.

Re-check mPendingAnimationBuilder before schedule, it might be canceled
from focus change.

Bug: 330295782
Test: presubmit
Change-Id: Ieba580d239763e8c14cd04445ed4adc567576e4a
parent ef54218e
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -843,14 +843,14 @@ class BackNavigationController {
     * @param targets The final animation targets derived in transition.
     * @param finishedTransition The finished transition target.
    */
    boolean onTransitionFinish(ArrayList<Transition.ChangeInfo> targets,
    void onTransitionFinish(ArrayList<Transition.ChangeInfo> targets,
            @NonNull Transition finishedTransition) {
        if (finishedTransition == mWaitTransitionFinish) {
            clearBackAnimations();
        }

        if (!mBackAnimationInProgress || mPendingAnimationBuilder == null) {
            return false;
            return;
        }
        ProtoLog.d(WM_DEBUG_BACK_PREVIEW,
                "Handling the deferred animation after transition finished");
@@ -878,7 +878,7 @@ class BackNavigationController {
                    + " open: " + Arrays.toString(mPendingAnimationBuilder.mOpenTargets)
                    + " close: " + mPendingAnimationBuilder.mCloseTarget);
            cancelPendingAnimation();
            return false;
            return;
        }

        // Ensure the final animation targets which hidden by transition could be visible.
@@ -887,9 +887,14 @@ class BackNavigationController {
            wc.prepareSurfaces();
        }

        // The pending builder could be cleared due to prepareSurfaces
        // => updateNonSystemOverlayWindowsVisibilityIfNeeded
        // => setForceHideNonSystemOverlayWindowIfNeeded
        // => updateFocusedWindowLocked => onFocusWindowChanged.
        if (mPendingAnimationBuilder != null) {
            scheduleAnimation(mPendingAnimationBuilder);
            mPendingAnimationBuilder = null;
        return true;
        }
    }

    private void cancelPendingAnimation() {