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

Commit 73b61057 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Use surface position for starting reveal animation

The surface position is basically relative frame - surface insets.

This aligns the same behavior as WindowState#startAnimation(anim)
that uses mSurfacePosition to animate.

If the app sets surface insets, its content will draw from the offset,
e.g. (50,50), then the surface position will be (-50,-50) to make
the window show at the requested position.

Bug: 328282706
Test: Cold or warm launch an app with calling
      getWindow().getDecorView().setElevation(100f);
      in onCreate. The activity window should not have a weird
      offset when playing starting window reveal animation.
Change-Id: I8c4f79d513014997f28c915682640c27d761a26c
parent d7c542d1
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -573,7 +573,7 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {

    // Capture the animation surface control for activity's main window
    static class StartingWindowAnimationAdaptor implements AnimationAdapter {
        SurfaceControl mAnimationLeash;

        @Override
        public boolean getShowWallpaper() {
            return false;
@@ -582,14 +582,10 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
        @Override
        public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t,
                int type, @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) {
            mAnimationLeash = animationLeash;
        }

        @Override
        public void onAnimationCancelled(SurfaceControl animationLeash) {
            if (mAnimationLeash == animationLeash) {
                mAnimationLeash = null;
            }
        }

        @Override
@@ -604,9 +600,6 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {

        @Override
        public void dump(PrintWriter pw, String prefix) {
            pw.print(prefix + "StartingWindowAnimationAdaptor mCapturedLeash=");
            pw.print(mAnimationLeash);
            pw.println();
        }

        @Override
@@ -616,16 +609,16 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {

    static SurfaceControl applyStartingWindowAnimation(WindowState window) {
        final SurfaceControl.Transaction t = window.getPendingTransaction();
        final Rect mainFrame = window.getRelativeFrame();
        final StartingWindowAnimationAdaptor adaptor = new StartingWindowAnimationAdaptor();
        window.startAnimation(t, adaptor, false, ANIMATION_TYPE_STARTING_REVEAL);
        if (adaptor.mAnimationLeash == null) {
        final SurfaceControl leash = window.getAnimationLeash();
        if (leash == null) {
            Slog.e(TAG, "Cannot start starting window animation, the window " + window
                    + " was removed");
            return null;
        }
        t.setPosition(adaptor.mAnimationLeash, mainFrame.left, mainFrame.top);
        return adaptor.mAnimationLeash;
        t.setPosition(leash, window.mSurfacePosition.x, window.mSurfacePosition.y);
        return leash;
    }

    boolean addStartingWindow(Task task, ActivityRecord activity, int launchTheme,
@@ -696,7 +689,9 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
                removalInfo.roundedCornerRadius =
                        topActivity.mLetterboxUiController.getRoundedCornersRadius(mainWindow);
                removalInfo.windowAnimationLeash = applyStartingWindowAnimation(mainWindow);
                removalInfo.mainFrame = mainWindow.getRelativeFrame();
                removalInfo.mainFrame = new Rect(mainWindow.getFrame());
                removalInfo.mainFrame.offsetTo(mainWindow.mSurfacePosition.x,
                        mainWindow.mSurfacePosition.y);
            }
        }
        try {
+2 −1
Original line number Diff line number Diff line
@@ -695,7 +695,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
     */
    private boolean mDrawnStateEvaluated;

    private final Point mSurfacePosition = new Point();
    /** The surface position relative to the parent container. */
    final Point mSurfacePosition = new Point();

    /**
     * A region inside of this window to be excluded from touch.