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

Commit ede9a606 authored by Ben Lin's avatar Ben Lin
Browse files

Add flag to allow OEMs to disable PIP enter/exit animation.

Bug: 132747337
Test: Manual
Change-Id: I59591cca79ece1131575f37f3f33a1b19e03c0b1
parent a106225b
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -468,6 +468,9 @@
    <!-- On debuggable builds, alert the user if SystemUI PSS goes over this number (in kb) -->
    <!-- On debuggable builds, alert the user if SystemUI PSS goes over this number (in kb) -->
    <integer name="watch_heap_limit">256000</integer>
    <integer name="watch_heap_limit">256000</integer>


    <!-- Animation duration for resizing of PIP when entering/exiting. -->
    <integer name="config_pipResizeAnimationDuration">425</integer>

    <!-- Allow dragging the PIP to a location to close it -->
    <!-- Allow dragging the PIP to a location to close it -->
    <bool name="config_pipEnableDismissDragToEdge">true</bool>
    <bool name="config_pipEnableDismissDragToEdge">true</bool>


+0 −1
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@ public class PipAnimationController {
    private static final float FRACTION_START = 0f;
    private static final float FRACTION_START = 0f;
    private static final float FRACTION_END = 1f;
    private static final float FRACTION_END = 1f;


    public static final int DURATION_DEFAULT_MS = 425;
    public static final int ANIM_TYPE_BOUNDS = 0;
    public static final int ANIM_TYPE_BOUNDS = 0;
    public static final int ANIM_TYPE_ALPHA = 1;
    public static final int ANIM_TYPE_ALPHA = 1;


+7 −5
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.systemui.pip;


import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_ALPHA;
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_ALPHA;
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
import static com.android.systemui.pip.PipAnimationController.ANIM_TYPE_BOUNDS;
import static com.android.systemui.pip.PipAnimationController.DURATION_DEFAULT_MS;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_NONE;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_NONE;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_SAME;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_SAME;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_FULLSCREEN;
import static com.android.systemui.pip.PipAnimationController.TRANSITION_DIRECTION_TO_FULLSCREEN;
@@ -81,6 +80,7 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
    private final Rect mLastReportedBounds = new Rect();
    private final Rect mLastReportedBounds = new Rect();
    private final int mCornerRadius;
    private final int mCornerRadius;
    private final Map<IBinder, Rect> mBoundsToRestore = new HashMap<>();
    private final Map<IBinder, Rect> mBoundsToRestore = new HashMap<>();
    private final int mEnterExitAnimationDuration;


    // These callbacks are called on the update thread
    // These callbacks are called on the update thread
    private final PipAnimationController.PipAnimationCallback mPipAnimationCallback =
    private final PipAnimationController.PipAnimationCallback mPipAnimationCallback =
@@ -180,6 +180,8 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
        mPipBoundsHandler = boundsHandler;
        mPipBoundsHandler = boundsHandler;
        mPipAnimationController = new PipAnimationController(context);
        mPipAnimationController = new PipAnimationController(context);
        mCornerRadius = context.getResources().getDimensionPixelSize(R.dimen.pip_corner_radius);
        mCornerRadius = context.getResources().getDimensionPixelSize(R.dimen.pip_corner_radius);
        mEnterExitAnimationDuration = context.getResources()
                .getInteger(R.integer.config_pipResizeAnimationDuration);
    }
    }


    public Handler getUpdateHandler() {
    public Handler getUpdateHandler() {
@@ -235,14 +237,14 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
        mBoundsToRestore.put(mToken.asBinder(), currentBounds);
        mBoundsToRestore.put(mToken.asBinder(), currentBounds);
        if (mOneShotAnimationType == ANIM_TYPE_BOUNDS) {
        if (mOneShotAnimationType == ANIM_TYPE_BOUNDS) {
            scheduleAnimateResizePip(currentBounds, destinationBounds,
            scheduleAnimateResizePip(currentBounds, destinationBounds,
                    TRANSITION_DIRECTION_TO_PIP, DURATION_DEFAULT_MS, null);
                    TRANSITION_DIRECTION_TO_PIP, mEnterExitAnimationDuration, null);
        } else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) {
        } else if (mOneShotAnimationType == ANIM_TYPE_ALPHA) {
            mUpdateHandler.post(() -> mPipAnimationController
            mUpdateHandler.post(() -> mPipAnimationController
                    .getAnimator(mLeash, destinationBounds, 0f, 1f)
                    .getAnimator(mLeash, destinationBounds, 0f, 1f)
                    .setTransitionDirection(TRANSITION_DIRECTION_TO_PIP)
                    .setTransitionDirection(TRANSITION_DIRECTION_TO_PIP)
                    .setCornerRadius(mCornerRadius)
                    .setCornerRadius(mCornerRadius)
                    .setPipAnimationCallback(mPipAnimationCallback)
                    .setPipAnimationCallback(mPipAnimationCallback)
                    .setDuration(DURATION_DEFAULT_MS)
                    .setDuration(mEnterExitAnimationDuration)
                    .start());
                    .start());
            mOneShotAnimationType = ANIM_TYPE_BOUNDS;
            mOneShotAnimationType = ANIM_TYPE_BOUNDS;
        } else {
        } else {
@@ -260,7 +262,7 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
        }
        }
        final Rect boundsToRestore = mBoundsToRestore.remove(mToken.asBinder());
        final Rect boundsToRestore = mBoundsToRestore.remove(mToken.asBinder());
        scheduleAnimateResizePip(mLastReportedBounds, boundsToRestore,
        scheduleAnimateResizePip(mLastReportedBounds, boundsToRestore,
                TRANSITION_DIRECTION_TO_FULLSCREEN, DURATION_DEFAULT_MS, null);
                TRANSITION_DIRECTION_TO_FULLSCREEN, mEnterExitAnimationDuration, null);
        mInPip = false;
        mInPip = false;
    }
    }


@@ -278,7 +280,7 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
        final Rect destinationBounds = mPipBoundsHandler.getDestinationBounds(
        final Rect destinationBounds = mPipBoundsHandler.getDestinationBounds(
                getAspectRatioOrDefault(newParams), null /* bounds */);
                getAspectRatioOrDefault(newParams), null /* bounds */);
        Objects.requireNonNull(destinationBounds, "Missing destination bounds");
        Objects.requireNonNull(destinationBounds, "Missing destination bounds");
        scheduleAnimateResizePip(destinationBounds, DURATION_DEFAULT_MS, null);
        scheduleAnimateResizePip(destinationBounds, mEnterExitAnimationDuration, null);
    }
    }


    /**
    /**
+5 −3
Original line number Original line Diff line number Diff line
@@ -20,8 +20,6 @@ import static android.app.ActivityTaskManager.INVALID_STACK_ID;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;


import static com.android.systemui.pip.PipAnimationController.DURATION_DEFAULT_MS;

import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityManager.StackInfo;
import android.app.ActivityManager.StackInfo;
import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager;
@@ -136,6 +134,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
    private String[] mLastPackagesResourceGranted;
    private String[] mLastPackagesResourceGranted;
    private PipNotification mPipNotification;
    private PipNotification mPipNotification;
    private ParceledListSlice mCustomActions;
    private ParceledListSlice mCustomActions;
    private int mResizeAnimationDuration;


    // Used to calculate the movement bounds
    // Used to calculate the movement bounds
    private final DisplayInfo mTmpDisplayInfo = new DisplayInfo();
    private final DisplayInfo mTmpDisplayInfo = new DisplayInfo();
@@ -238,6 +237,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
        mInitialized = true;
        mInitialized = true;
        mContext = context;
        mContext = context;
        mPipBoundsHandler = pipBoundsHandler;
        mPipBoundsHandler = pipBoundsHandler;
        mResizeAnimationDuration = context.getResources()
                .getInteger(R.integer.config_pipResizeAnimationDuration);
        mPipTaskOrganizer = new PipTaskOrganizer(mContext, mPipBoundsHandler);
        mPipTaskOrganizer = new PipTaskOrganizer(mContext, mPipBoundsHandler);
        mPipTaskOrganizer.registerPipTransitionCallback(this);
        mPipTaskOrganizer.registerPipTransitionCallback(this);
        mActivityTaskManager = ActivityTaskManager.getService();
        mActivityTaskManager = ActivityTaskManager.getService();
@@ -436,7 +437,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
                mCurrentPipBounds = mPipBounds;
                mCurrentPipBounds = mPipBounds;
                break;
                break;
        }
        }
        mPipTaskOrganizer.scheduleAnimateResizePip(mCurrentPipBounds, DURATION_DEFAULT_MS, null);
        mPipTaskOrganizer.scheduleAnimateResizePip(mCurrentPipBounds, mResizeAnimationDuration,
                null);
    }
    }


    /**
    /**