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

Commit 8127ce57 authored by Chris Li's avatar Chris Li
Browse files

Fix NPE in Snapshot#startAnimation

Pass in an empty finish callback instead of null for possible calls from
the animation adapter.

Fix: 202872508
Test: pass exisiting
Change-Id: Ic98a03ff8f05d9b6590d5e5ed4572f09c4af8936
parent bb723071
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.server.wm;
package com.android.server.wm;


import android.annotation.NonNull;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.SurfaceControl.Transaction;
@@ -52,7 +53,7 @@ interface AnimationAdapter {
     * @param finishCallback The callback to be invoked when the animation has finished.
     * @param finishCallback The callback to be invoked when the animation has finished.
     */
     */
    void startAnimation(SurfaceControl animationLeash, Transaction t, @AnimationType int type,
    void startAnimation(SurfaceControl animationLeash, Transaction t, @AnimationType int type,
            OnAnimationFinishedCallback finishCallback);
            @NonNull OnAnimationFinishedCallback finishCallback);


    /**
    /**
     * Called when the animation that was started with {@link #startAnimation} was cancelled by the
     * Called when the animation that was started with {@link #startAnimation} was cancelled by the
+1 −1
Original line number Original line Diff line number Diff line
@@ -535,7 +535,7 @@ class InsetsSourceProvider {


        @Override
        @Override
        public void startAnimation(SurfaceControl animationLeash, Transaction t,
        public void startAnimation(SurfaceControl animationLeash, Transaction t,
                @AnimationType int type, OnAnimationFinishedCallback finishCallback) {
                @AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback) {
            // TODO(b/166736352): Check if we still need to control the IME visibility here.
            // TODO(b/166736352): Check if we still need to control the IME visibility here.
            if (mSource.getType() == ITYPE_IME) {
            if (mSource.getType() == ITYPE_IME) {
                // TODO: use 0 alpha and remove t.hide() once b/138459974 is fixed.
                // TODO: use 0 alpha and remove t.hide() once b/138459974 is fixed.
+2 −1
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.wm;
import static com.android.server.wm.AnimationAdapterProto.LOCAL;
import static com.android.server.wm.AnimationAdapterProto.LOCAL;
import static com.android.server.wm.LocalAnimationAdapterProto.ANIMATION_SPEC;
import static com.android.server.wm.LocalAnimationAdapterProto.ANIMATION_SPEC;


import android.annotation.NonNull;
import android.os.SystemClock;
import android.os.SystemClock;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;
import android.view.SurfaceControl;
import android.view.SurfaceControl;
@@ -51,7 +52,7 @@ class LocalAnimationAdapter implements AnimationAdapter {


    @Override
    @Override
    public void startAnimation(SurfaceControl animationLeash, Transaction t,
    public void startAnimation(SurfaceControl animationLeash, Transaction t,
            @AnimationType int type, OnAnimationFinishedCallback finishCallback) {
            @AnimationType int type, @NonNull OnAnimationFinishedCallback finishCallback) {
        mAnimator.startAnimation(mSpec, animationLeash, t,
        mAnimator.startAnimation(mSpec, animationLeash, t,
                () -> finishCallback.onAnimationFinished(type, this));
                () -> finishCallback.onAnimationFinished(type, this));
    }
    }
+2 −1
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.wm;


import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_APP_TRANSITION;


import android.annotation.NonNull;
import android.view.SurfaceControl;
import android.view.SurfaceControl;
import android.view.animation.AlphaAnimation;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation;
@@ -144,7 +145,7 @@ public class NavBarFadeAnimationController extends FadeAnimationController{


        @Override
        @Override
        public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t,
        public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t,
                int type, SurfaceAnimator.OnAnimationFinishedCallback finishCallback) {
                int type, @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) {
            super.startAnimation(animationLeash, t, type, finishCallback);
            super.startAnimation(animationLeash, t, type, finishCallback);
            if (mParent != null && mParent.isValid()) {
            if (mParent != null && mParent.isValid()) {
                t.reparent(animationLeash, mParent);
                t.reparent(animationLeash, mParent);
+2 −1
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import static com.android.server.wm.AnimationAdapterProto.REMOTE;
import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET;
import static com.android.server.wm.RemoteAnimationAdapterWrapperProto.TARGET;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION;


import android.annotation.NonNull;
import android.graphics.Rect;
import android.graphics.Rect;
import android.os.SystemClock;
import android.os.SystemClock;
import android.util.proto.ProtoOutputStream;
import android.util.proto.ProtoOutputStream;
@@ -145,7 +146,7 @@ class NonAppWindowAnimationAdapter implements AnimationAdapter {


    @Override
    @Override
    public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t,
    public void startAnimation(SurfaceControl animationLeash, SurfaceControl.Transaction t,
            int type, SurfaceAnimator.OnAnimationFinishedCallback finishCallback) {
            int type, @NonNull SurfaceAnimator.OnAnimationFinishedCallback finishCallback) {
        ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "startAnimation");
        ProtoLog.d(WM_DEBUG_REMOTE_ANIMATIONS, "startAnimation");
        mCapturedLeash = animationLeash;
        mCapturedLeash = animationLeash;
        mCapturedLeashFinishCallback = finishCallback;
        mCapturedLeashFinishCallback = finishCallback;
Loading