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

Commit ccd1c01b authored by wilsonshih's avatar wilsonshih
Browse files

Fixes two BackAnimationController crash from window focus change.

1. Shell side is waiting for animation but got window focus changed,
so mBackNavigationInfo will be reset. Keep previous navigation type
incase shell receive onAnimationCancelled later.

2. Core should preventing from cause window focus change during
startBackNavigation, it's allowed to happen after BackNavigationInfo
return to shell.

Bug: 319293969
Test: presubmit
Change-Id: I9061db055003f661e585fdc647f0bf17be6f9081
parent 6b300d7a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -176,6 +176,10 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
    private StatusBarCustomizer mCustomizer;
    private boolean mTrackingLatency;

    // Keep previous navigation type before remove mBackNavigationInfo.
    @BackNavigationInfo.BackTargetType
    private int mPreviousNavigationType;

    public BackAnimationController(
            @NonNull ShellInit shellInit,
            @NonNull ShellController shellController,
@@ -861,6 +865,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
        mShellBackAnimationRegistry.resetDefaultCrossActivity();
        cancelLatencyTracking();
        if (mBackNavigationInfo != null) {
            mPreviousNavigationType = mBackNavigationInfo.getType();
            mBackNavigationInfo.onBackNavigationFinished(triggerBack);
            mBackNavigationInfo = null;
        }
@@ -965,7 +970,9 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                        mShellExecutor.execute(
                                () -> {
                                    if (!mShellBackAnimationRegistry.cancel(
                                            mBackNavigationInfo.getType())) {
                                            mBackNavigationInfo != null
                                                    ? mBackNavigationInfo.getType()
                                                    : mPreviousNavigationType)) {
                                        return;
                                    }
                                    if (!mBackGestureStarted) {
+3 −1
Original line number Diff line number Diff line
@@ -1594,7 +1594,9 @@ class BackNavigationController {
            // skip commitVisibility call in setVisibility cause the activity won't visible here.
            // Call it again to make sure the activity could be visible while handling the pending
            // animation.
            activity.commitVisibility(true, true);
            // Do not performLayout during prepare animation, because it could cause focus window
            // change. Let that happen after the BackNavigationInfo has returned to shell.
            activity.commitVisibility(true, false /* performLayout */);
            activity.mTransitionController.mSnapshotController
                    .mActivitySnapshotController.addOnBackPressedActivity(activity);
        }