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

Commit 00c5aafb authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Add debounce for hide animation of fixed rotation recents"

parents 3b732c01 791332f4
Loading
Loading
Loading
Loading
+32 −4
Original line number Original line Diff line number Diff line
@@ -490,6 +490,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     */
     */
    private ActivityRecord mFixedRotationLaunchingApp;
    private ActivityRecord mFixedRotationLaunchingApp;


    /** The delay to avoid toggling the animation quickly. */
    private static final long FIXED_ROTATION_HIDE_ANIMATION_DEBOUNCE_DELAY_MS = 250;
    private FixedRotationAnimationController mFixedRotationAnimationController;
    private FixedRotationAnimationController mFixedRotationAnimationController;


    final FixedRotationTransitionListener mFixedRotationTransitionListener =
    final FixedRotationTransitionListener mFixedRotationTransitionListener =
@@ -1524,10 +1526,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    void setFixedRotationLaunchingAppUnchecked(@Nullable ActivityRecord r, int rotation) {
    void setFixedRotationLaunchingAppUnchecked(@Nullable ActivityRecord r, int rotation) {
        if (mFixedRotationLaunchingApp == null && r != null) {
        if (mFixedRotationLaunchingApp == null && r != null) {
            mWmService.mDisplayNotificationController.dispatchFixedRotationStarted(this, rotation);
            mWmService.mDisplayNotificationController.dispatchFixedRotationStarted(this, rotation);
            if (mFixedRotationAnimationController == null) {
            startFixedRotationAnimation(
                mFixedRotationAnimationController = new FixedRotationAnimationController(this);
                    // Delay the hide animation to avoid blinking by clicking navigation bar that
                mFixedRotationAnimationController.hide();
                    // may toggle fixed rotation in a short time.
            }
                    r == mFixedRotationTransitionListener.mAnimatingRecents /* shouldDebounce */);
        } else if (mFixedRotationLaunchingApp != null && r == null) {
        } else if (mFixedRotationLaunchingApp != null && r == null) {
            mWmService.mDisplayNotificationController.dispatchFixedRotationFinished(this);
            mWmService.mDisplayNotificationController.dispatchFixedRotationFinished(this);
            finishFixedRotationAnimationIfPossible();
            finishFixedRotationAnimationIfPossible();
@@ -1625,6 +1627,32 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }
        }
    }
    }


    /**
     * Starts the hide animation for the windows which will be rotated seamlessly.
     *
     * @return {@code true} if the animation is executed right now.
     */
    private boolean startFixedRotationAnimation(boolean shouldDebounce) {
        if (shouldDebounce) {
            mWmService.mH.postDelayed(() -> {
                synchronized (mWmService.mGlobalLock) {
                    if (mFixedRotationLaunchingApp != null
                            && startFixedRotationAnimation(false /* shouldDebounce */)) {
                        // Apply the transaction so the animation leash can take effect immediately.
                        getPendingTransaction().apply();
                    }
                }
            }, FIXED_ROTATION_HIDE_ANIMATION_DEBOUNCE_DELAY_MS);
            return false;
        }
        if (mFixedRotationAnimationController == null) {
            mFixedRotationAnimationController = new FixedRotationAnimationController(this);
            mFixedRotationAnimationController.hide();
            return true;
        }
        return false;
    }

    /** Re-show the previously hidden windows if all seamless rotated windows are done. */
    /** Re-show the previously hidden windows if all seamless rotated windows are done. */
    void finishFixedRotationAnimationIfPossible() {
    void finishFixedRotationAnimationIfPossible() {
        final FixedRotationAnimationController controller = mFixedRotationAnimationController;
        final FixedRotationAnimationController controller = mFixedRotationAnimationController;