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

Commit 23ee71c8 authored by chaviw's avatar chaviw Committed by Jorim Jaggi
Browse files

Set initial position for WindowAnimation and reparent animation leash.

1. Set the initial position for the WindowAnimationSpec to be the stack
position.
2. Reparent the animation leash to mAnimationLayer
3. Updated Surface names for clarity.

Test: Opening apps animate from the correct start location. When apps
are animating, their layers are reparented to the correct animation
layer.

Change-Id: I3e3a1e45f0a0cf9d471dee105abd9bce05d1e91d
parent e07246ad
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ import static com.android.server.wm.proto.AppWindowTokenProto.NAME;
import static com.android.server.wm.proto.AppWindowTokenProto.WINDOW_TOKEN;

import android.annotation.CallSuper;
import android.annotation.NonNull;
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.GraphicBuffer;
@@ -216,6 +215,8 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
    /** Whether this token should be boosted at the top of all app window tokens. */
    private boolean mNeedsZBoost;

    private final Point mTmpPoint = new Point();

    AppWindowToken(WindowManagerService service, IApplicationToken token, boolean voiceInteraction,
            DisplayContent dc, long inputDispatchingTimeoutNanos, boolean fullscreen,
            boolean showForAllUsers, int targetSdk, int orientation, int rotationAnimationHint,
@@ -1503,6 +1504,12 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
                true /* topToBottom */);
    }

    @Override
    public SurfaceControl.Builder makeAnimationLeash() {
        return super.makeAnimationLeash()
                .setParent(getAppAnimationLayer());
    }

    boolean applyAnimationLocked(WindowManager.LayoutParams lp, int transit, boolean enter,
            boolean isVoiceInteraction) {

@@ -1521,8 +1528,13 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        if (okToAnimate()) {
            final Animation a = loadAnimation(lp, transit, enter, isVoiceInteraction);
            if (a != null) {
                final TaskStack stack = getStack();
                mTmpPoint.set(0, 0);
                if (stack != null) {
                    stack.getRelativePosition(mTmpPoint);
                }
                final AnimationAdapter adapter = new LocalAnimationAdapter(
                        new WindowAnimationSpec(a, new Point(),
                        new WindowAnimationSpec(a, mTmpPoint,
                                mService.mAppTransition.canSkipFirstFrame()),
                        mService.mSurfaceAnimationRunner);
                startAnimation(getPendingTransaction(), adapter, !isVisible());
+15 −7
Original line number Diff line number Diff line
@@ -136,7 +136,6 @@ import android.util.DisplayMetrics;
import android.util.MutableBoolean;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import android.view.animation.Transformation;
import android.view.Display;
import android.view.DisplayInfo;
import android.view.InputDevice;
@@ -3176,7 +3175,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        /**
         * A control placed at the appropriate level for transitions to occur.
         */
        SurfaceControl mAnimationLayer = null;
        SurfaceControl mAppAnimationLayer = null;

        // Cached reference to some special stacks we tend to get a lot so we don't need to loop
        // through the list to find them.
@@ -3522,19 +3521,28 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            // The appropriate place for App-Transitions to occur is right
            // above all other animations but still below things in the Picture-and-Picture
            // windowing mode.
            if (mAnimationLayer != null) {
                t.setLayer(mAnimationLayer, layer++);
            if (mAppAnimationLayer != null) {
                t.setLayer(mAppAnimationLayer, layer++);
            }
        }

        @Override
        SurfaceControl getAppAnimationLayer() {
            return mAppAnimationLayer;
        }

        @Override
        void onParentSet() {
            super.onParentSet();
            if (getParent() != null) {
                mAnimationLayer = makeSurface().build();
                mAppAnimationLayer = makeChildSurface(null)
                        .setName("animationLayer")
                        .build();
                getPendingTransaction().show(mAppAnimationLayer);
                scheduleAnimation();
            } else {
                mAnimationLayer.destroy();
                mAnimationLayer = null;
                mAppAnimationLayer.destroy();
                mAppAnimationLayer = null;
            }
        }
    }
+5 −3
Original line number Diff line number Diff line
@@ -93,6 +93,8 @@ class TaskSnapshotController {
    private final ArraySet<Task> mTmpTasks = new ArraySet<>();
    private final Handler mHandler = new Handler();

    private final Rect mTmpRect = new Rect();

    /**
     * Flag indicating whether we are running on an Android TV device.
     */
@@ -223,11 +225,11 @@ class TaskSnapshotController {

        final boolean isLowRamDevice = ActivityManager.isLowRamDeviceStatic();
        final float scaleFraction = isLowRamDevice ? REDUCED_SCALE : 1f;
        final Rect taskFrame = new Rect();
        task.getBounds(taskFrame);
        task.getBounds(mTmpRect);
        mTmpRect.offsetTo(0, 0);

        final GraphicBuffer buffer = SurfaceControl.captureLayers(
                task.getSurfaceControl().getHandle(), taskFrame, scaleFraction);
                task.getSurfaceControl().getHandle(), mTmpRect, scaleFraction);

        if (buffer == null || buffer.getWidth() <= 1 || buffer.getHeight() <= 1) {
            if (DEBUG_SCREENSHOT) {
+11 −0
Original line number Diff line number Diff line
@@ -1020,6 +1020,17 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        return makeSurface();
    }

    /**
     * @return The layer on which all app animations are happening.
     */
    SurfaceControl getAppAnimationLayer() {
        final WindowContainer parent = getParent();
        if (parent != null) {
            return parent.getAppAnimationLayer();
        }
        return null;
    }

    @Override
    public void commitPendingTransaction() {
        scheduleAnimation();