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

Commit ac4ac928 authored by Tony Huang's avatar Tony Huang Committed by Automerger Merge Worker
Browse files

Merge "Align PiP animation and touch on vsync-sf" into rvc-dev am: 79f93b02

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11653259

Change-Id: Id18dfb8edd83a3044963fcd11e679224485a3b67
parents c8c6ada3 79f93b02
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -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 */);
            }
+10 −0
Original line number Diff line number Diff line
@@ -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;
    }

+1 −1
Original line number Diff line number Diff line
@@ -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();
+1 −1
Original line number Diff line number Diff line
@@ -197,7 +197,7 @@ public class PipMenuActivityController {
    }

    public void onActivityPinned() {
        mInputConsumerController.registerInputConsumer();
        mInputConsumerController.registerInputConsumer(true /* withSfVsync */);
    }

    public void onActivityUnpinned() {
+10 −1
Original line number Diff line number Diff line
@@ -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;
Loading