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

Commit 354ce25c authored by Hongwei Wang's avatar Hongwei Wang Committed by Automerger Merge Worker
Browse files

Merge "Save reentry bounds from SysUI" into rvc-dev am: 6173317a

Change-Id: Id0625a2d8255fe001b971857bf4f287ea0e842a4
parents 0cc5fdb9 6173317a
Loading
Loading
Loading
Loading
+4 −12
Original line number Original line Diff line number Diff line
@@ -60,20 +60,12 @@ oneway interface IPinnedStackListener {
    void onActionsChanged(in ParceledListSlice actions);
    void onActionsChanged(in ParceledListSlice actions);


    /**
    /**
     * Called by the window manager to notify the listener to save the reentry fraction and size,
     * Called by the window manager to notify the listener that Activity (was or is in pinned mode)
     * typically when an Activity leaves PiP (picture-in-picture) mode to fullscreen.
     * is hidden (either stopped or removed). This is generally used as a signal to reset saved
     * {@param componentName} represents the application component of PiP window
     * reentry fraction and size.
     * while {@param bounds} is the current PiP bounds used to calculate the
     * reentry snap fraction and size.
     */
    void onSaveReentryBounds(in ComponentName componentName, in Rect bounds);

    /**
     * Called by the window manager to notify the listener to reset saved reentry fraction and size,
     * typically when an Activity enters PiP (picture-in-picture) mode from fullscreen.
     * {@param componentName} represents the application component of PiP window.
     * {@param componentName} represents the application component of PiP window.
     */
     */
    void onResetReentryBounds(in ComponentName componentName);
    void onActivityHidden(in ComponentName componentName);


    /**
    /**
     * Called when the window manager has detected change on DisplayInfo,  or
     * Called when the window manager has detected change on DisplayInfo,  or
+3 −12
Original line number Original line Diff line number Diff line
@@ -74,16 +74,9 @@ public class PinnedStackListenerForwarder extends IPinnedStackListener.Stub {
    }
    }


    @Override
    @Override
    public void onSaveReentryBounds(ComponentName componentName, Rect bounds) {
    public void onActivityHidden(ComponentName componentName) {
        for (PinnedStackListener listener : mListeners) {
        for (PinnedStackListener listener : mListeners) {
            listener.onSaveReentryBounds(componentName, bounds);
            listener.onActivityHidden(componentName);
        }
    }

    @Override
    public void onResetReentryBounds(ComponentName componentName) {
        for (PinnedStackListener listener : mListeners) {
            listener.onResetReentryBounds(componentName);
        }
        }
    }
    }


@@ -121,9 +114,7 @@ public class PinnedStackListenerForwarder extends IPinnedStackListener.Stub {


        public void onActionsChanged(ParceledListSlice actions) {}
        public void onActionsChanged(ParceledListSlice actions) {}


        public void onSaveReentryBounds(ComponentName componentName, Rect bounds) {}
        public void onActivityHidden(ComponentName componentName) {}

        public void onResetReentryBounds(ComponentName componentName) {}


        public void onDisplayInfoChanged(DisplayInfo displayInfo) {}
        public void onDisplayInfoChanged(DisplayInfo displayInfo) {}


+5 −5
Original line number Original line Diff line number Diff line
@@ -49,10 +49,10 @@ public class PipAnimationController {
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    public @interface AnimationType {}
    public @interface AnimationType {}


    static final int TRANSITION_DIRECTION_NONE = 0;
    public static final int TRANSITION_DIRECTION_NONE = 0;
    static final int TRANSITION_DIRECTION_SAME = 1;
    public static final int TRANSITION_DIRECTION_SAME = 1;
    static final int TRANSITION_DIRECTION_TO_PIP = 2;
    public static final int TRANSITION_DIRECTION_TO_PIP = 2;
    static final int TRANSITION_DIRECTION_TO_FULLSCREEN = 3;
    public static final int TRANSITION_DIRECTION_TO_FULLSCREEN = 3;


    @IntDef(prefix = { "TRANSITION_DIRECTION_" }, value = {
    @IntDef(prefix = { "TRANSITION_DIRECTION_" }, value = {
            TRANSITION_DIRECTION_NONE,
            TRANSITION_DIRECTION_NONE,
@@ -61,7 +61,7 @@ public class PipAnimationController {
            TRANSITION_DIRECTION_TO_FULLSCREEN
            TRANSITION_DIRECTION_TO_FULLSCREEN
    })
    })
    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    @interface TransitionDirection {}
    public @interface TransitionDirection {}


    private final Interpolator mFastOutSlowInInterpolator;
    private final Interpolator mFastOutSlowInInterpolator;
    private final PipSurfaceTransactionHelper mSurfaceTransactionHelper;
    private final PipSurfaceTransactionHelper mSurfaceTransactionHelper;
+14 −6
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.PictureInPictureParams;
import android.app.PictureInPictureParams;
import android.content.ComponentName;
import android.content.Context;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ActivityInfo;
import android.graphics.Rect;
import android.graphics.Rect;
@@ -94,7 +95,8 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
            mMainHandler.post(() -> {
            mMainHandler.post(() -> {
                for (int i = mPipTransitionCallbacks.size() - 1; i >= 0; i--) {
                for (int i = mPipTransitionCallbacks.size() - 1; i >= 0; i--) {
                    final PipTransitionCallback callback = mPipTransitionCallbacks.get(i);
                    final PipTransitionCallback callback = mPipTransitionCallbacks.get(i);
                    callback.onPipTransitionStarted();
                    callback.onPipTransitionStarted(mTaskInfo.baseActivity,
                            animator.getTransitionDirection());
                }
                }
            });
            });
        }
        }
@@ -105,7 +107,8 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
            mMainHandler.post(() -> {
            mMainHandler.post(() -> {
                for (int i = mPipTransitionCallbacks.size() - 1; i >= 0; i--) {
                for (int i = mPipTransitionCallbacks.size() - 1; i >= 0; i--) {
                    final PipTransitionCallback callback = mPipTransitionCallbacks.get(i);
                    final PipTransitionCallback callback = mPipTransitionCallbacks.get(i);
                    callback.onPipTransitionFinished();
                    callback.onPipTransitionFinished(mTaskInfo.baseActivity,
                            animator.getTransitionDirection());
                }
                }
            });
            });
            finishResize(tx, animator.getDestinationBounds(), animator.getTransitionDirection());
            finishResize(tx, animator.getDestinationBounds(), animator.getTransitionDirection());
@@ -116,7 +119,8 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
            mMainHandler.post(() -> {
            mMainHandler.post(() -> {
                for (int i = mPipTransitionCallbacks.size() - 1; i >= 0; i--) {
                for (int i = mPipTransitionCallbacks.size() - 1; i >= 0; i--) {
                    final PipTransitionCallback callback = mPipTransitionCallbacks.get(i);
                    final PipTransitionCallback callback = mPipTransitionCallbacks.get(i);
                    callback.onPipTransitionCanceled();
                    callback.onPipTransitionCanceled(mTaskInfo.baseActivity,
                            animator.getTransitionDirection());
                }
                }
            });
            });
        }
        }
@@ -201,6 +205,10 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
        return mUpdateHandler;
        return mUpdateHandler;
    }
    }


    public Rect getLastReportedBounds() {
        return new Rect(mLastReportedBounds);
    }

    /**
    /**
     * Registers {@link PipTransitionCallback} to receive transition callbacks.
     * Registers {@link PipTransitionCallback} to receive transition callbacks.
     */
     */
@@ -532,16 +540,16 @@ public class PipTaskOrganizer extends ITaskOrganizer.Stub {
        /**
        /**
         * Callback when the pip transition is started.
         * Callback when the pip transition is started.
         */
         */
        void onPipTransitionStarted();
        void onPipTransitionStarted(ComponentName activity, int direction);


        /**
        /**
         * Callback when the pip transition is finished.
         * Callback when the pip transition is finished.
         */
         */
        void onPipTransitionFinished();
        void onPipTransitionFinished(ComponentName activity, int direction);


        /**
        /**
         * Callback when the pip transition is cancelled.
         * Callback when the pip transition is cancelled.
         */
         */
        void onPipTransitionCanceled();
        void onPipTransitionCanceled(ComponentName activity, int direction);
    }
    }
}
}
+20 −21
Original line number Original line Diff line number Diff line
@@ -20,6 +20,8 @@ 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 android.window.WindowOrganizer.TaskOrganizer;
import static android.window.WindowOrganizer.TaskOrganizer;


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

import android.app.ActivityManager;
import android.app.ActivityManager;
import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager;
import android.app.IActivityManager;
import android.app.IActivityManager;
@@ -170,24 +172,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
        }
        }


        @Override
        @Override
        public void onSaveReentryBounds(ComponentName componentName, Rect bounds) {
        public void onActivityHidden(ComponentName componentName) {
            mHandler.post(() -> {
                // On phones, the expansion animation that happens on pip tap before restoring
                // to fullscreen makes it so that the bounds received here are the expanded
                // bounds. We want to restore to the unexpanded bounds when re-entering pip,
                // so we save the bounds before expansion (normal) instead of the current
                // bounds.
                mReentryBounds.set(mTouchHandler.getNormalBounds());
                // Apply the snap fraction of the current bounds to the normal bounds.
                float snapFraction = mPipBoundsHandler.getSnapFraction(bounds);
                mPipBoundsHandler.applySnapFraction(mReentryBounds, snapFraction);
                // Save reentry bounds (normal non-expand bounds with current position applied).
                mPipBoundsHandler.onSaveReentryBounds(componentName, mReentryBounds);
            });
        }

        @Override
        public void onResetReentryBounds(ComponentName componentName) {
            mHandler.post(() -> mPipBoundsHandler.onResetReentryBounds(componentName));
            mHandler.post(() -> mPipBoundsHandler.onResetReentryBounds(componentName));
        }
        }


@@ -325,7 +310,21 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
    }
    }


    @Override
    @Override
    public void onPipTransitionStarted() {
    public void onPipTransitionStarted(ComponentName activity, int direction) {
        if (direction == TRANSITION_DIRECTION_TO_FULLSCREEN) {
            // On phones, the expansion animation that happens on pip tap before restoring
            // to fullscreen makes it so that the bounds received here are the expanded
            // bounds. We want to restore to the unexpanded bounds when re-entering pip,
            // so we save the bounds before expansion (normal) instead of the current
            // bounds.
            mReentryBounds.set(mTouchHandler.getNormalBounds());
            // Apply the snap fraction of the current bounds to the normal bounds.
            final Rect bounds = mPipTaskOrganizer.getLastReportedBounds();
            float snapFraction = mPipBoundsHandler.getSnapFraction(bounds);
            mPipBoundsHandler.applySnapFraction(mReentryBounds, snapFraction);
            // Save reentry bounds (normal non-expand bounds with current position applied).
            mPipBoundsHandler.onSaveReentryBounds(activity, mReentryBounds);
        }
        // Disable touches while the animation is running
        // Disable touches while the animation is running
        mTouchHandler.setTouchEnabled(false);
        mTouchHandler.setTouchEnabled(false);
        if (mPinnedStackAnimationRecentsListener != null) {
        if (mPinnedStackAnimationRecentsListener != null) {
@@ -338,12 +337,12 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
    }
    }


    @Override
    @Override
    public void onPipTransitionFinished() {
    public void onPipTransitionFinished(ComponentName activity, int direction) {
        onPipTransitionFinishedOrCanceled();
        onPipTransitionFinishedOrCanceled();
    }
    }


    @Override
    @Override
    public void onPipTransitionCanceled() {
    public void onPipTransitionCanceled(ComponentName activity, int direction) {
        onPipTransitionFinishedOrCanceled();
        onPipTransitionFinishedOrCanceled();
    }
    }


Loading