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

Commit 1ba39205 authored by Schneider Victor-tulias's avatar Schneider Victor-tulias
Browse files

Fix NPE from using DeviceLockedInputConsumer after the surface has been released

Fixes: 243154747
Test: swipe up from camera app while device is locked
Change-Id: Ia92e3e3cccb37e0d14592b0f3094f5aba1073300
parent bddda819
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ import com.android.quickstep.RecentsAnimationCallbacks;
import com.android.quickstep.RecentsAnimationController;
import com.android.quickstep.RecentsAnimationDeviceState;
import com.android.quickstep.RecentsAnimationTargets;
import com.android.quickstep.RemoteAnimationTargets;
import com.android.quickstep.TaskAnimationManager;
import com.android.quickstep.util.SurfaceTransaction.SurfaceProperties;
import com.android.quickstep.util.TransformParams;
@@ -226,6 +227,10 @@ public class DeviceLockedInputConsumer implements InputConsumer,
                    mStateCallback.setState(STATE_HANDLER_INVALIDATED);
                }
            });
            RemoteAnimationTargets targets = mTransformParams.getTargetSet();
            if (targets != null) {
                targets.addReleaseCheck(new DeviceLockedReleaseCheck(animator));
            }
            animator.start();
        } else {
            mStateCallback.setState(STATE_HANDLER_INVALIDATED);
@@ -304,4 +309,27 @@ public class DeviceLockedInputConsumer implements InputConsumer,
    public boolean allowInterceptByParent() {
        return !mThresholdCrossed;
    }

    private static final class DeviceLockedReleaseCheck extends
            RemoteAnimationTargets.ReleaseCheck {

        private DeviceLockedReleaseCheck(Animator animator) {
            setCanRelease(true);

            animator.addListener(new AnimatorListenerAdapter() {

                @Override
                public void onAnimationStart(Animator animation) {
                    super.onAnimationStart(animation);
                    setCanRelease(false);
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    setCanRelease(true);
                }
            });
        }
    }
}