Merge "Align PiP animation and touch on vsync-sf" into rvc-dev am: 79f93b02f2
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11653259 Change-Id: I80ab1b281a7d4439357fcf72b2c1e41844b14ba1
This commit is contained in:
@@ -63,8 +63,9 @@ public class InputConsumerController {
|
||||
*/
|
||||
private final class InputEventReceiver extends BatchedInputEventReceiver {
|
||||
|
||||
public InputEventReceiver(InputChannel inputChannel, Looper looper) {
|
||||
super(inputChannel, looper, Choreographer.getInstance());
|
||||
InputEventReceiver(InputChannel inputChannel, Looper looper,
|
||||
Choreographer choreographer) {
|
||||
super(inputChannel, looper, choreographer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -143,6 +144,14 @@ public class InputConsumerController {
|
||||
* Registers the input consumer.
|
||||
*/
|
||||
public void registerInputConsumer() {
|
||||
registerInputConsumer(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the input consumer.
|
||||
* @param withSfVsync the flag set using sf vsync signal or no
|
||||
*/
|
||||
public void registerInputConsumer(boolean withSfVsync) {
|
||||
if (mInputEventReceiver == null) {
|
||||
final InputChannel inputChannel = new InputChannel();
|
||||
try {
|
||||
@@ -152,7 +161,8 @@ public class InputConsumerController {
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to create input consumer", e);
|
||||
}
|
||||
mInputEventReceiver = new InputEventReceiver(inputChannel, Looper.myLooper());
|
||||
mInputEventReceiver = new InputEventReceiver(inputChannel, Looper.myLooper(),
|
||||
withSfVsync ? Choreographer.getSfInstance() : Choreographer.getInstance());
|
||||
if (mRegistrationListener != null) {
|
||||
mRegistrationListener.onRegistrationChanged(true /* isRegistered */);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.systemui.pip;
|
||||
|
||||
import android.animation.AnimationHandler;
|
||||
import android.animation.Animator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.IntDef;
|
||||
@@ -26,6 +27,7 @@ import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -79,6 +81,13 @@ public class PipAnimationController {
|
||||
|
||||
private PipTransitionAnimator mCurrentAnimator;
|
||||
|
||||
private ThreadLocal<AnimationHandler> mSfAnimationHandlerThreadLocal =
|
||||
ThreadLocal.withInitial(() -> {
|
||||
AnimationHandler handler = new AnimationHandler();
|
||||
handler.setProvider(new SfVsyncFrameCallbackProvider());
|
||||
return handler;
|
||||
});
|
||||
|
||||
@Inject
|
||||
PipAnimationController(Context context, PipSurfaceTransactionHelper helper) {
|
||||
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context,
|
||||
@@ -135,6 +144,7 @@ public class PipAnimationController {
|
||||
animator.setSurfaceTransactionHelper(mSurfaceTransactionHelper);
|
||||
animator.setInterpolator(mFastOutSlowInInterpolator);
|
||||
animator.setFloatValues(FRACTION_START, FRACTION_END);
|
||||
animator.setAnimationHandler(mSfAnimationHandlerThreadLocal.get());
|
||||
return animator;
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
||||
if (stackInfo != null) {
|
||||
// If SystemUI restart, and it already existed a pinned stack,
|
||||
// register the pip input consumer to ensure touch can send to it.
|
||||
mInputConsumerController.registerInputConsumer();
|
||||
mInputConsumerController.registerInputConsumer(true /* withSfVsync */);
|
||||
}
|
||||
} catch (RemoteException | UnsupportedOperationException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -197,7 +197,7 @@ public class PipMenuActivityController {
|
||||
}
|
||||
|
||||
public void onActivityPinned() {
|
||||
mInputConsumerController.registerInputConsumer();
|
||||
mInputConsumerController.registerInputConsumer(true /* withSfVsync */);
|
||||
}
|
||||
|
||||
public void onActivityUnpinned() {
|
||||
|
||||
@@ -23,9 +23,11 @@ import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Debug;
|
||||
import android.util.Log;
|
||||
import android.view.Choreographer;
|
||||
|
||||
import androidx.dynamicanimation.animation.SpringForce;
|
||||
|
||||
import com.android.internal.graphics.SfVsyncFrameCallbackProvider;
|
||||
import com.android.systemui.pip.PipSnapAlgorithm;
|
||||
import com.android.systemui.pip.PipTaskOrganizer;
|
||||
import com.android.systemui.util.FloatingContentCoordinator;
|
||||
@@ -68,6 +70,9 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
||||
/** The region that all of PIP must stay within. */
|
||||
private final Rect mFloatingAllowedArea = new Rect();
|
||||
|
||||
private final SfVsyncFrameCallbackProvider mSfVsyncFrameProvider =
|
||||
new SfVsyncFrameCallbackProvider();
|
||||
|
||||
/**
|
||||
* Bounds that are animated using the physics animator.
|
||||
*/
|
||||
@@ -79,6 +84,10 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
||||
/** Coordinator instance for resolving conflicts with other floating content. */
|
||||
private FloatingContentCoordinator mFloatingContentCoordinator;
|
||||
|
||||
/** Callback that re-sizes PIP to the animated bounds. */
|
||||
private final Choreographer.FrameCallback mResizePipVsyncCallback =
|
||||
l -> resizePipUnchecked(mAnimatedBounds);
|
||||
|
||||
/**
|
||||
* PhysicsAnimator instance for animating {@link #mAnimatedBounds} using physics animations.
|
||||
*/
|
||||
@@ -89,7 +98,7 @@ public class PipMotionHelper implements PipAppOpsListener.Callback,
|
||||
* Update listener that resizes the PIP to {@link #mAnimatedBounds}.
|
||||
*/
|
||||
final PhysicsAnimator.UpdateListener<Rect> mResizePipUpdateListener =
|
||||
(target, values) -> resizePipUnchecked(mAnimatedBounds);
|
||||
(target, values) -> mSfVsyncFrameProvider.postFrameCallback(mResizePipVsyncCallback);
|
||||
|
||||
/** FlingConfig instances provided to PhysicsAnimator for fling gestures. */
|
||||
private PhysicsAnimator.FlingConfig mFlingConfigX;
|
||||
|
||||
@@ -32,6 +32,8 @@ import android.hardware.input.InputManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.view.BatchedInputEventReceiver;
|
||||
import android.view.Choreographer;
|
||||
import android.view.InputChannel;
|
||||
import android.view.InputEvent;
|
||||
import android.view.InputEventReceiver;
|
||||
@@ -323,9 +325,9 @@ public class PipResizeGestureHandler {
|
||||
mMinSize.set(minX, minY);
|
||||
}
|
||||
|
||||
class SysUiInputEventReceiver extends InputEventReceiver {
|
||||
class SysUiInputEventReceiver extends BatchedInputEventReceiver {
|
||||
SysUiInputEventReceiver(InputChannel channel, Looper looper) {
|
||||
super(channel, looper);
|
||||
super(channel, looper, Choreographer.getSfInstance());
|
||||
}
|
||||
|
||||
public void onInputEvent(InputEvent event) {
|
||||
|
||||
Reference in New Issue
Block a user