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

Commit ad16d682 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Rename FadeAnimationController to AsyncRotationController

The controller may support effects other than fade animation.
The 'async' means that the windows handled by the controller can
rotate individually without having the display wait for them.

Bug: 214324186
Test: CtsWindowManagerDeviceTestCases

Change-Id: Ie5f9f6ae36b5e36727517882aff05ae898f688d3
parent 112c5401
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ import java.util.ArrayList;
 * both fixed rotation and normal rotation to hide some non-activity windows. The caller should show
 * the windows until they are drawn with the new rotation.
 */
public class FadeRotationAnimationController extends FadeAnimationController {
public class AsyncRotationController extends FadeAnimationController {

    /** The map of window token to its animation leash. */
    private final ArrayMap<WindowToken, SurfaceControl> mTargetWindowTokens = new ArrayMap<>();
@@ -70,7 +70,7 @@ public class FadeRotationAnimationController extends FadeAnimationController {
    private final int mOriginalRotation;
    private final boolean mHasScreenRotationAnimation;

    public FadeRotationAnimationController(DisplayContent displayContent) {
    public AsyncRotationController(DisplayContent displayContent) {
        super(displayContent);
        mService = displayContent.mWmService;
        mOriginalRotation = displayContent.getWindowConfiguration().getRotation();
@@ -81,7 +81,7 @@ public class FadeRotationAnimationController extends FadeAnimationController {
        mIsStartTransactionCommitted = !mIsChangeTransition;
        mTimeoutRunnable = displayContent.inTransition() ? () -> {
            synchronized (mService.mGlobalLock) {
                displayContent.finishFadeRotationAnimationIfPossible();
                displayContent.finishAsyncRotationIfPossible();
                mService.mWindowPlacerLocked.performSurfacePlacement();
            }
        } : null;
@@ -277,7 +277,7 @@ public class FadeRotationAnimationController extends FadeAnimationController {
                mIsStartTransactionCommitted = true;
                if (mPendingShowTokens == null) return;
                for (int i = mPendingShowTokens.size() - 1; i >= 0; i--) {
                    mDisplayContent.finishFadeRotationAnimation(mPendingShowTokens.get(i));
                    mDisplayContent.finishAsyncRotation(mPendingShowTokens.get(i));
                }
                mPendingShowTokens = null;
            }
@@ -298,7 +298,7 @@ public class FadeRotationAnimationController extends FadeAnimationController {
                // Only fade in the drawn windows. If the remaining windows are drawn later,
                // show(WindowToken) will be called to fade in them.
                if (token.getChildAt(j).isDrawFinishedLw()) {
                    mDisplayContent.finishFadeRotationAnimation(token);
                    mDisplayContent.finishAsyncRotation(token);
                    break;
                }
            }
@@ -320,7 +320,7 @@ public class FadeRotationAnimationController extends FadeAnimationController {
            }
            return true;
        }
        mDisplayContent.finishFadeRotationAnimation(w.mToken);
        mDisplayContent.finishAsyncRotation(w.mToken);
        return false;
    }

+24 −24
Original line number Diff line number Diff line
@@ -545,7 +545,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    /** The delay to avoid toggling the animation quickly. */
    private static final long FIXED_ROTATION_HIDE_ANIMATION_DEBOUNCE_DELAY_MS = 250;
    private FadeRotationAnimationController mFadeRotationAnimationController;
    private AsyncRotationController mAsyncRotationController;

    final FixedRotationTransitionListener mFixedRotationTransitionListener =
            new FixedRotationTransitionListener();
@@ -1714,8 +1714,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    }

    @VisibleForTesting
    @Nullable FadeRotationAnimationController getFadeRotationAnimationController() {
        return mFadeRotationAnimationController;
    @Nullable AsyncRotationController getAsyncRotationController() {
        return mAsyncRotationController;
    }

    void setFixedRotationLaunchingAppUnchecked(@Nullable ActivityRecord r) {
@@ -1725,13 +1725,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    void setFixedRotationLaunchingAppUnchecked(@Nullable ActivityRecord r, int rotation) {
        if (mFixedRotationLaunchingApp == null && r != null) {
            mWmService.mDisplayNotificationController.dispatchFixedRotationStarted(this, rotation);
            startFadeRotationAnimation(
            startAsyncRotation(
                    // Delay the hide animation to avoid blinking by clicking navigation bar that
                    // may toggle fixed rotation in a short time.
                    r == mFixedRotationTransitionListener.mAnimatingRecents /* shouldDebounce */);
        } else if (mFixedRotationLaunchingApp != null && r == null) {
            mWmService.mDisplayNotificationController.dispatchFixedRotationFinished(this);
            finishFadeRotationAnimationIfPossible();
            finishAsyncRotationIfPossible();
        }
        mFixedRotationLaunchingApp = r;
    }
@@ -1844,9 +1844,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        return mDisplayRotation.getRotation() != getWindowConfiguration().getRotation();
    }

    private void startFadeRotationAnimationIfNeeded() {
    private void startAsyncRotationIfNeeded() {
        if (isRotationChanging()) {
            startFadeRotationAnimation(false /* shouldDebounce */);
            startAsyncRotation(false /* shouldDebounce */);
        }
    }

@@ -1855,12 +1855,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     *
     * @return {@code true} if the animation is executed right now.
     */
    private boolean startFadeRotationAnimation(boolean shouldDebounce) {
    private boolean startAsyncRotation(boolean shouldDebounce) {
        if (shouldDebounce) {
            mWmService.mH.postDelayed(() -> {
                synchronized (mWmService.mGlobalLock) {
                    if (mFixedRotationLaunchingApp != null
                            && startFadeRotationAnimation(false /* shouldDebounce */)) {
                            && startAsyncRotation(false /* shouldDebounce */)) {
                        // Apply the transaction so the animation leash can take effect immediately.
                        getPendingTransaction().apply();
                    }
@@ -1868,28 +1868,28 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }, FIXED_ROTATION_HIDE_ANIMATION_DEBOUNCE_DELAY_MS);
            return false;
        }
        if (mFadeRotationAnimationController == null) {
            mFadeRotationAnimationController = new FadeRotationAnimationController(this);
            mFadeRotationAnimationController.hide();
        if (mAsyncRotationController == null) {
            mAsyncRotationController = new AsyncRotationController(this);
            mAsyncRotationController.hide();
            return true;
        }
        return false;
    }

    /** Re-show the previously hidden windows if all seamless rotated windows are done. */
    void finishFadeRotationAnimationIfPossible() {
        final FadeRotationAnimationController controller = mFadeRotationAnimationController;
    void finishAsyncRotationIfPossible() {
        final AsyncRotationController controller = mAsyncRotationController;
        if (controller != null && !mDisplayRotation.hasSeamlessRotatingWindow()) {
            controller.show();
            mFadeRotationAnimationController = null;
            mAsyncRotationController = null;
        }
    }

    /** Shows the given window which may be hidden for screen rotation. */
    void finishFadeRotationAnimation(WindowToken windowToken) {
        final FadeRotationAnimationController controller = mFadeRotationAnimationController;
    void finishAsyncRotation(WindowToken windowToken) {
        final AsyncRotationController controller = mAsyncRotationController;
        if (controller != null && controller.show(windowToken)) {
            mFadeRotationAnimationController = null;
            mAsyncRotationController = null;
        }
    }

@@ -1899,7 +1899,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            // The window should look no different before and after rotation.
            return false;
        }
        final FadeRotationAnimationController controller = mFadeRotationAnimationController;
        final AsyncRotationController controller = mAsyncRotationController;
        return controller == null || !controller.isHandledToken(w.mToken);
    }

@@ -3206,7 +3206,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        // Hide the windows which are not significant in rotation animation. So that the windows
        // don't need to block the unfreeze time.
        if (screenRotationAnimation != null && screenRotationAnimation.hasScreenshot()) {
            startFadeRotationAnimationIfNeeded();
            startAsyncRotationIfNeeded();
        }
    }

@@ -3228,7 +3228,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }
            if (!controller.isCollecting(this)) {
                controller.collect(this);
                startFadeRotationAnimationIfNeeded();
                startAsyncRotationIfNeeded();
            }
            return;
        }
@@ -3240,7 +3240,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                mWmService.mLatencyTracker.onActionStart(ACTION_ROTATE_SCREEN);
                controller.mTransitionMetricsReporter.associate(t,
                        startTime -> mWmService.mLatencyTracker.onActionEnd(ACTION_ROTATE_SCREEN));
                startFadeRotationAnimation(false /* shouldDebounce */);
                startAsyncRotation(false /* shouldDebounce */);
            }
            t.setKnownConfigChanges(this, changes);
        }
@@ -3969,8 +3969,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            mInputMethodWindow.mToken.linkFixedRotationTransform(mImeLayeringTarget.mToken);
            // Hide the window until the rotation is done to avoid intermediate artifacts if the
            // parent surface of IME container is changed.
            if (mFadeRotationAnimationController != null) {
                mFadeRotationAnimationController.hideImmediately(mInputMethodWindow.mToken);
            if (mAsyncRotationController != null) {
                mAsyncRotationController.hideImmediately(mInputMethodWindow.mToken);
            }
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -638,7 +638,7 @@ public class DisplayRotation {
        }, true /* traverseTopToBottom */);
        mSeamlessRotationCount = 0;
        mRotatingSeamlessly = false;
        mDisplayContent.finishFadeRotationAnimationIfPossible();
        mDisplayContent.finishAsyncRotationIfPossible();
    }

    private void prepareSeamlessRotation() {
@@ -729,7 +729,7 @@ public class DisplayRotation {
                    "Performing post-rotate rotation after seamless rotation");
            // Finish seamless rotation.
            mRotatingSeamlessly = false;
            mDisplayContent.finishFadeRotationAnimationIfPossible();
            mDisplayContent.finishAsyncRotationIfPossible();

            updateRotationAndSendNewConfigIfChanged();
        }
+3 −3
Original line number Diff line number Diff line
@@ -298,9 +298,9 @@ class InsetsSourceProvider {

    private Point getWindowFrameSurfacePosition() {
        if (mControl != null) {
            final FadeRotationAnimationController fadeController =
                    mWin.mDisplayContent.getFadeRotationAnimationController();
            if (fadeController != null && fadeController.shouldFreezeInsetsPosition(mWin)) {
            final AsyncRotationController controller =
                    mWin.mDisplayContent.getAsyncRotationController();
            if (controller != null && controller.shouldFreezeInsetsPosition(mWin)) {
                // Use previous position because the fade-out animation runs in old rotation.
                return mControl.getSurfacePosition();
            }
+2 −2
Original line number Diff line number Diff line
@@ -80,8 +80,8 @@ public class NavBarFadeAnimationController extends FadeAnimationController{
     * @param show true for fade-in, otherwise for fade-out.
     */
    public void fadeWindowToken(boolean show) {
        final FadeRotationAnimationController controller =
                mDisplayContent.getFadeRotationAnimationController();
        final AsyncRotationController controller =
                mDisplayContent.getAsyncRotationController();
        final Runnable fadeAnim = () -> fadeWindowToken(show, mNavigationBar.mToken,
                ANIMATION_TYPE_APP_TRANSITION);
        if (controller == null) {
Loading