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

Commit 7bae749b authored by Vadim Caen's avatar Vadim Caen Committed by Android (Google) Code Review
Browse files

Merge changes Iead191ab,If35a0bb0

* changes:
  Wait for SurfaceAnimationThread before teardown
  Call end callback for custom rotation anim.
parents 44223a28 e654aa46
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1093,6 +1093,12 @@
      "group": "WM_DEBUG_REMOTE_ANIMATIONS",
      "at": "com\/android\/server\/wm\/RemoteAnimationController.java"
    },
    "200829729": {
      "message": "ScreenRotationAnimation onAnimationEnd",
      "level": "DEBUG",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ScreenRotationAnimation.java"
    },
    "221540118": {
      "message": "mUserActivityTimeout set to %d",
      "level": "DEBUG",
@@ -1159,6 +1165,12 @@
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/AppTransitionController.java"
    },
    "292555239": {
      "message": "ScreenRotation sill animating: mDisplayAnimator: %s\nmEnterBlackFrameAnimator: %s\nmRotateScreenAnimator: %s\nmScreenshotRotationAnimator: %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/ScreenRotationAnimation.java"
    },
    "292904800": {
      "message": "Deferring rotation, animation in progress.",
      "level": "VERBOSE",
+36 −17
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static com.android.server.wm.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.server.wm.ProtoLogGroup.WM_SHOW_SURFACE_ALLOC;
import static com.android.server.wm.ScreenRotationAnimationProto.ANIMATION_RUNNING;
import static com.android.server.wm.ScreenRotationAnimationProto.STARTED;
@@ -558,8 +559,6 @@ class ScreenRotationAnimation {
        private SurfaceAnimator mEnterBlackFrameAnimator;
        private SurfaceAnimator mScreenshotRotationAnimator;
        private SurfaceAnimator mRotateScreenAnimator;
        private final Runnable mNoopCallback = () -> { // b/141177184
        };

        /**
         * Start the rotation animation of the display and the screenshot on the
@@ -592,7 +591,7 @@ class ScreenRotationAnimation {
                            .setHeight(mDisplayContent.getSurfaceHeight())
                            .build(),
                    createWindowAnimationSpec(mRotateEnterAnimation),
                    this::cancel);
                    this::onAnimationEnd);
        }

        private SurfaceAnimator startScreenshotAlphaAnimation() {
@@ -603,7 +602,7 @@ class ScreenRotationAnimation {
                            .setHeight(mHeight)
                            .build(),
                    createWindowAnimationSpec(mRotateAlphaAnimation),
                    mNoopCallback);
                    this::onAnimationEnd);
        }

        private SurfaceAnimator startEnterBlackFrameAnimation() {
@@ -612,7 +611,7 @@ class ScreenRotationAnimation {
                            .setAnimationLeashParent(mDisplayContent.getOverlayLayer())
                            .build(),
                    createWindowAnimationSpec(mRotateEnterAnimation),
                    mNoopCallback);
                    this::onAnimationEnd);
        }

        private SurfaceAnimator startScreenshotRotationAnimation() {
@@ -654,6 +653,25 @@ class ScreenRotationAnimation {
        }

        private void onAnimationEnd() {
            synchronized (mService.mGlobalLock) {
                if (isAnimating()) {
                    ProtoLog.v(WM_DEBUG_ORIENTATION,
                            "ScreenRotation sill animating: mDisplayAnimator: %s\n"
                                    + "mEnterBlackFrameAnimator: "
                                    + "%s\nmRotateScreenAnimator: %s\n"
                                    + "mScreenshotRotationAnimator: %s",
                            mDisplayAnimator != null
                                    ? mDisplayAnimator.isAnimating() : null,
                            mEnterBlackFrameAnimator != null
                                    ? mEnterBlackFrameAnimator.isAnimating() : null,
                            mRotateScreenAnimator != null
                                    ? mRotateScreenAnimator.isAnimating() : null,
                            mScreenshotRotationAnimator != null
                                    ? mScreenshotRotationAnimator.isAnimating() : null
                    );
                    return;
                }
                ProtoLog.d(WM_DEBUG_ORIENTATION, "ScreenRotationAnimation onAnimationEnd");
                mEnterBlackFrameAnimator = null;
                mScreenshotRotationAnimator = null;
                mRotateScreenAnimator = null;
@@ -668,6 +686,7 @@ class ScreenRotationAnimation {
                    accessibilityController.onRotationChangedLocked(mDisplayContent);
                }
            }
        }

        public void cancel() {
            if (mEnterBlackFrameAnimator != null) {
+17 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.os.Process.THREAD_PRIORITY_DISPLAY;
import android.os.Handler;
import android.os.Trace;

import com.android.internal.annotations.VisibleForTesting;
import com.android.server.ServiceThread;

/**
@@ -56,4 +57,20 @@ public final class SurfaceAnimationThread extends ServiceThread {
            return sHandler;
        }
    }

    /**
     * Disposes current surface animation thread if it's initialized. Should only be used in tests
     * to set up a new environment.
     */
    @VisibleForTesting
    public static void dispose() {
        synchronized (SurfaceAnimationThread.class) {
            if (sInstance == null) {
                return;
            }

            getHandler().runWithScissors(() -> sInstance.quit(), 0 /* timeout */);
            sInstance = null;
        }
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -310,6 +310,7 @@ public class SystemServicesTestRule implements TestRule {
        DisplayThread.dispose();
        AnimationThread.dispose();
        UiThread.dispose();
        SurfaceAnimationThread.dispose();
        mInputChannel.dispose();

        tearDownLocalServices();