Merge "Fix NPE from using DeviceLockedInputConsumer after the surface has been released" into tm-qpr-dev am: 8700307b23

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/20501358

Change-Id: Ie3cf43c96594bb0201678e189fd874a74535f4b1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2022-11-21 18:49:07 +00:00
committed by Automerger Merge Worker

View File

@@ -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);
}
});
}
}
}