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

Commit c51dc9bc authored by Wei Sheng Shih's avatar Wei Sheng Shih Committed by Automerger Merge Worker
Browse files

Merge "Cancel pending animation when state changed." into udc-dev am: 0f6ed614

parents 9dcc1363 0f6ed614
Loading
Loading
Loading
Loading
+28 −24
Original line number Diff line number Diff line
@@ -532,14 +532,7 @@ class BackNavigationController {
            if (newFocus != null && newFocus != mNavigatingWindow
                    && (newFocus.mActivityRecord == null
                    || (newFocus.mActivityRecord == mNavigatingWindow.mActivityRecord))) {
                EventLogTags.writeWmBackNaviCanceled("focusWindowChanged");
                if (isMonitorForRemote()) {
                    mObserver.sendResult(null /* result */);
                }
                if (isMonitorAnimationOrTransition()) {
                    // transition won't happen, cancel internal status
                    clearBackAnimations();
                }
                cancelBackNavigating("focusWindowChanged");
            }
        }

@@ -553,19 +546,12 @@ class BackNavigationController {
            }
            final ArrayList<WindowContainer> all = new ArrayList<>(opening);
            all.addAll(closing);
            for (WindowContainer app : all) {
                if (app.hasChild(mNavigatingWindow)) {
                    EventLogTags.writeWmBackNaviCanceled("transitionHappens");
                    if (isMonitorForRemote()) {
                        mObserver.sendResult(null /* result */);
                    }
                    if (isMonitorAnimationOrTransition()) {
                        clearBackAnimations();
                    }
            for (int i = all.size() - 1; i >= 0; --i) {
                if (all.get(i).hasChild(mNavigatingWindow)) {
                    cancelBackNavigating("transitionHappens");
                    break;
                }
            }

        }

        private boolean atSameDisplay(WindowState newFocus) {
@@ -575,6 +561,17 @@ class BackNavigationController {
            final int navigatingDisplayId = mNavigatingWindow.getDisplayId();
            return newFocus == null || newFocus.getDisplayId() == navigatingDisplayId;
        }

        private void cancelBackNavigating(String reason) {
            EventLogTags.writeWmBackNaviCanceled(reason);
            if (isMonitorForRemote()) {
                mObserver.sendResult(null /* result */);
            }
            if (isMonitorAnimationOrTransition()) {
                clearBackAnimations();
            }
            cancelPendingAnimation();
        }
    }

    // For shell transition
@@ -677,12 +674,7 @@ class BackNavigationController {
            Slog.w(TAG, "Finished transition didn't include the targets"
                    + " open: " + mPendingAnimationBuilder.mOpenTarget
                    + " close: " + mPendingAnimationBuilder.mCloseTarget);
            try {
                mPendingAnimationBuilder.mBackAnimationAdapter.getRunner().onAnimationCancelled();
            } catch (RemoteException e) {
                throw new RuntimeException(e);
            }
            mPendingAnimationBuilder = null;
            cancelPendingAnimation();
            return false;
        }

@@ -697,6 +689,18 @@ class BackNavigationController {
        return true;
    }

    private void cancelPendingAnimation() {
        if (mPendingAnimationBuilder == null) {
            return;
        }
        try {
            mPendingAnimationBuilder.mBackAnimationAdapter.getRunner().onAnimationCancelled();
        } catch (RemoteException e) {
            Slog.e(TAG, "Remote animation gone", e);
        }
        mPendingAnimationBuilder = null;
    }

    /**
     * Create and handling animations status for an open/close animation targets.
     */