From 1ba39205bc5b4eafa72ba0d710cec691682d0e67 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Thu, 17 Nov 2022 14:57:07 -0800 Subject: [PATCH] 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 --- .../DeviceLockedInputConsumer.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java index 8410149df6..db7e0878b6 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java @@ -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); + } + }); + } + } }