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

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

Remove unused methods of SurfaceAnimator

The methods haven't been used in many years.

History: Ib31c1e765639e5490208bccba77b25318ec8dc71

Bug: 163976519
Flag: EXEMPT remove dead code
Test: CtsWindowManagerDeviceActivity
Change-Id: I4451e738854b6f9565cea9ed5d94cb6114915c97
parent 247a20f2
Loading
Loading
Loading
Loading
+3 −59
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.server.wm;


import static com.android.internal.protolog.WmProtoLogGroups.WM_DEBUG_ANIM;
import static com.android.internal.protolog.WmProtoLogGroups.WM_DEBUG_ANIM;
import static com.android.server.wm.SurfaceAnimatorProto.ANIMATION_ADAPTER;
import static com.android.server.wm.SurfaceAnimatorProto.ANIMATION_ADAPTER;
import static com.android.server.wm.SurfaceAnimatorProto.ANIMATION_START_DELAYED;
import static com.android.server.wm.SurfaceAnimatorProto.LEASH;
import static com.android.server.wm.SurfaceAnimatorProto.LEASH;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
@@ -90,8 +89,6 @@ public class SurfaceAnimator {
    @Nullable
    @Nullable
    private Runnable mAnimationCancelledCallback;
    private Runnable mAnimationCancelledCallback;


    private boolean mAnimationStartDelayed;

    private boolean mAnimationFinished;
    private boolean mAnimationFinished;


    /**
    /**
@@ -188,10 +185,6 @@ public class SurfaceAnimator {
            mAnimatable.onAnimationLeashCreated(t, mLeash);
            mAnimatable.onAnimationLeashCreated(t, mLeash);
        }
        }
        mAnimatable.onLeashAnimationStarting(t, mLeash);
        mAnimatable.onLeashAnimationStarting(t, mLeash);
        if (mAnimationStartDelayed) {
            ProtoLog.i(WM_DEBUG_ANIM, "Animation start delayed for %s", mAnimatable);
            return;
        }
        mAnimation.startAnimation(mLeash, t, type, mInnerAnimationFinishedCallback);
        mAnimation.startAnimation(mLeash, t, type, mInnerAnimationFinishedCallback);
        if (ProtoLog.isEnabled(WM_DEBUG_ANIM, LogLevel.DEBUG)) {
        if (ProtoLog.isEnabled(WM_DEBUG_ANIM, LogLevel.DEBUG)) {
            StringWriter sw = new StringWriter();
            StringWriter sw = new StringWriter();
@@ -215,36 +208,7 @@ public class SurfaceAnimator {
                null /* animationCancelledCallback */, null /* snapshotAnim */, null /* freezer */);
                null /* animationCancelledCallback */, null /* snapshotAnim */, null /* freezer */);
    }
    }


    /**
    /** Returns whether it is currently running an animation. */
     * Begins with delaying all animations to start. Any subsequent call to {@link #startAnimation}
     * will not start the animation until {@link #endDelayingAnimationStart} is called. When an
     * animation start is being delayed, the animator is considered animating already.
     */
    void startDelayingAnimationStart() {

        // We only allow delaying animation start we are not currently animating
        if (!isAnimating()) {
            mAnimationStartDelayed = true;
        }
    }

    /**
     * See {@link #startDelayingAnimationStart}.
     */
    void endDelayingAnimationStart() {
        final boolean delayed = mAnimationStartDelayed;
        mAnimationStartDelayed = false;
        if (delayed && mAnimation != null) {
            mAnimation.startAnimation(mLeash, mAnimatable.getSyncTransaction(),
                    mAnimationType, mInnerAnimationFinishedCallback);
            mAnimatable.commitPendingTransaction();
        }
    }

    /**
     * @return Whether we are currently running an animation, or we have a pending animation that
     *         is waiting to be started with {@link #endDelayingAnimationStart}
     */
    boolean isAnimating() {
    boolean isAnimating() {
        return mAnimation != null;
        return mAnimation != null;
    }
    }
@@ -289,15 +253,6 @@ public class SurfaceAnimator {
        t.setRelativeLayer(mLeash != null ? mLeash : mAnimatable.getSurfaceControl(), relativeTo, layer);
        t.setRelativeLayer(mLeash != null ? mLeash : mAnimatable.getSurfaceControl(), relativeTo, layer);
    }
    }


    /**
     * Reparents the surface.
     *
     * @see #setLayer
     */
    void reparent(Transaction t, SurfaceControl newParent) {
        t.reparent(mLeash != null ? mLeash : mAnimatable.getSurfaceControl(), newParent);
    }

    /**
    /**
     * @return True if the surface is attached to the leash; false otherwise.
     * @return True if the surface is attached to the leash; false otherwise.
     */
     */
@@ -319,7 +274,6 @@ public class SurfaceAnimator {
            Slog.w(TAG, "Unable to transfer animation, because " + from + " animation is finished");
            Slog.w(TAG, "Unable to transfer animation, because " + from + " animation is finished");
            return;
            return;
        }
        }
        endDelayingAnimationStart();
        final Transaction t = mAnimatable.getSyncTransaction();
        final Transaction t = mAnimatable.getSyncTransaction();
        cancelAnimation(t, true /* restarting */, true /* forwardCancel */);
        cancelAnimation(t, true /* restarting */, true /* forwardCancel */);
        mLeash = from.mLeash;
        mLeash = from.mLeash;
@@ -336,10 +290,6 @@ public class SurfaceAnimator {
        mService.mAnimationTransferMap.put(mAnimation, this);
        mService.mAnimationTransferMap.put(mAnimation, this);
    }
    }


    boolean isAnimationStartDelayed() {
        return mAnimationStartDelayed;
    }

    /**
    /**
     * Cancels the animation, and resets the leash.
     * Cancels the animation, and resets the leash.
     *
     *
@@ -361,7 +311,7 @@ public class SurfaceAnimator {
        final SurfaceFreezer.Snapshot snapshot = mSnapshot;
        final SurfaceFreezer.Snapshot snapshot = mSnapshot;
        reset(t, false);
        reset(t, false);
        if (animation != null) {
        if (animation != null) {
            if (!mAnimationStartDelayed && forwardCancel) {
            if (forwardCancel) {
                animation.onAnimationCancelled(leash);
                animation.onAnimationCancelled(leash);
                if (animationCancelledCallback != null) {
                if (animationCancelledCallback != null) {
                    animationCancelledCallback.run();
                    animationCancelledCallback.run();
@@ -386,10 +336,6 @@ public class SurfaceAnimator {
                mService.scheduleAnimationLocked();
                mService.scheduleAnimationLocked();
            }
            }
        }
        }

        if (!restarting) {
            mAnimationStartDelayed = false;
        }
    }
    }


    private void reset(Transaction t, boolean destroyLeash) {
    private void reset(Transaction t, boolean destroyLeash) {
@@ -495,14 +441,12 @@ public class SurfaceAnimator {
        if (mLeash != null) {
        if (mLeash != null) {
            mLeash.dumpDebug(proto, LEASH);
            mLeash.dumpDebug(proto, LEASH);
        }
        }
        proto.write(ANIMATION_START_DELAYED, mAnimationStartDelayed);
        proto.end(token);
        proto.end(token);
    }
    }


    void dump(PrintWriter pw, String prefix) {
    void dump(PrintWriter pw, String prefix) {
        pw.print(prefix); pw.print("mLeash="); pw.print(mLeash);
        pw.print(prefix); pw.print("mLeash="); pw.print(mLeash);
        pw.print(" mAnimationType=" + animationTypeToString(mAnimationType));
        pw.print(" mAnimationType="); pw.println(animationTypeToString(mAnimationType));
        pw.println(mAnimationStartDelayed ? " mAnimationStartDelayed=true" : "");
        pw.print(prefix); pw.print("Animation: "); pw.println(mAnimation);
        pw.print(prefix); pw.print("Animation: "); pw.println(mAnimation);
        if (mAnimation != null) {
        if (mAnimation != null) {
            mAnimation.dump(pw, prefix + "  ");
            mAnimation.dump(pw, prefix + "  ");
+1 −16
Original line number Original line Diff line number Diff line
@@ -3215,8 +3215,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        final boolean isChanging = AppTransition.isChangeTransitOld(transit) && enter
        final boolean isChanging = AppTransition.isChangeTransitOld(transit) && enter
                && isChangingAppTransition();
                && isChangingAppTransition();


        // Delaying animation start isn't compatible with remote animations at all.
        if (controller != null) {
        if (controller != null && !mSurfaceAnimator.isAnimationStartDelayed()) {
            // Here we load App XML in order to read com.android.R.styleable#Animation_showBackdrop.
            // Here we load App XML in order to read com.android.R.styleable#Animation_showBackdrop.
            boolean showBackdrop = false;
            boolean showBackdrop = false;
            // Optionally set backdrop color if App explicitly provides it through
            // Optionally set backdrop color if App explicitly provides it through
@@ -3639,20 +3638,6 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
        return getAnimatingContainer(PARENTS, ANIMATION_TYPE_ALL);
        return getAnimatingContainer(PARENTS, ANIMATION_TYPE_ALL);
    }
    }


    /**
     * @see SurfaceAnimator#startDelayingAnimationStart
     */
    void startDelayingAnimationStart() {
        mSurfaceAnimator.startDelayingAnimationStart();
    }

    /**
     * @see SurfaceAnimator#endDelayingAnimationStart
     */
    void endDelayingAnimationStart() {
        mSurfaceAnimator.endDelayingAnimationStart();
    }

    @Override
    @Override
    public int getSurfaceWidth() {
    public int getSurfaceWidth() {
        return mSurfaceControl.getWidth();
        return mSurfaceControl.getWidth();
+0 −26
Original line number Original line Diff line number Diff line
@@ -21,7 +21,6 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.never;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.verifyZeroInteractions;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertEquals;
@@ -164,31 +163,6 @@ public class SurfaceAnimatorTest extends WindowTestsBase {
        verify(mTransaction).remove(eq(mAnimatable.mLeash));
        verify(mTransaction).remove(eq(mAnimatable.mLeash));
    }
    }


    @Test
    public void testDelayingAnimationStart() {
        mAnimatable.mSurfaceAnimator.startDelayingAnimationStart();
        mAnimatable.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */,
                ANIMATION_TYPE_APP_TRANSITION);
        verifyZeroInteractions(mSpec);
        assertAnimating(mAnimatable);
        assertTrue(mAnimatable.mSurfaceAnimator.isAnimationStartDelayed());
        mAnimatable.mSurfaceAnimator.endDelayingAnimationStart();
        verify(mSpec).startAnimation(any(), any(), eq(ANIMATION_TYPE_APP_TRANSITION), any());
    }

    @Test
    public void testDelayingAnimationStartAndCancelled() {
        mAnimatable.mSurfaceAnimator.startDelayingAnimationStart();
        mAnimatable.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */,
                ANIMATION_TYPE_APP_TRANSITION);
        mAnimatable.mSurfaceAnimator.cancelAnimation();
        verifyZeroInteractions(mSpec);
        assertNotAnimating(mAnimatable);
        assertTrue(mAnimatable.mFinishedCallbackCalled);
        assertEquals(ANIMATION_TYPE_APP_TRANSITION, mAnimatable.mFinishedAnimationType);
        verify(mTransaction).remove(eq(mAnimatable.mLeash));
    }

    @Test
    @Test
    public void testTransferAnimation() {
    public void testTransferAnimation() {
        mAnimatable.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */,
        mAnimatable.mSurfaceAnimator.startAnimation(mTransaction, mSpec, true /* hidden */,