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

Commit e6385a23 authored by Winson Chung's avatar Winson Chung
Browse files

Workaround launching PiP task with CLEAR_TASK & NEW_TASK flag.

- When launching an activity with CLEAR_TASK and NEW_TASK, the result code
  of the start is START_SUCCESS, but we still need to notify SystemUI to
  expand the PiP.  However, because the PiP transition now waits for the
  first draw, this can cause severe jank and delay if the original activity
  is a trampoline activity. As a workaround, we immediately move the task
  to the fullscreen stack when clearing and restarting the task to ensure
  that the new task shows without delay.

Bug: 37501224
Test: Open YT in PIP, launch sub-shortcut from Home

Change-Id: I16bebf19b082f30695e99da1d93bc4adf5e9df0c
parent bf08eb6d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -39,8 +39,11 @@ oneway interface ITaskStackListener {
     * Called whenever IActivityManager.startActivity is called on an activity that is already
     * running in the pinned stack and the activity is not actually started, but the task is either
     * brought to the front or a new Intent is delivered to it.
     *
     * @param clearedTask whether or not the launch activity also cleared the task as a part of
     * starting
     */
    void onPinnedActivityRestartAttempt();
    void onPinnedActivityRestartAttempt(boolean clearedTask);

    /**
     * Called whenever the pinned stack is starting animating a resize.
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
    }

    @Override
    public void onPinnedActivityRestartAttempt() throws RemoteException {
    public void onPinnedActivityRestartAttempt(boolean clearedTask) throws RemoteException {
    }

    @Override
+2 −2
Original line number Diff line number Diff line
@@ -107,12 +107,12 @@ public class PipManager implements BasePipManager {
        }

        @Override
        public void onPinnedActivityRestartAttempt() {
        public void onPinnedActivityRestartAttempt(boolean clearedTask) {
            if (!checkCurrentUserId(false /* debug */)) {
                return;
            }

            mTouchHandler.getMotionHelper().expandPip();
            mTouchHandler.getMotionHelper().expandPip(clearedTask /* skipAnimation */);
        }
    };

+15 −4
Original line number Diff line number Diff line
@@ -140,14 +140,25 @@ public class PipMotionHelper {
     * Resizes the pinned stack back to fullscreen.
     */
    void expandPip() {
        expandPip(false /* skipAnimation */);
    }

    /**
     * Resizes the pinned stack back to fullscreen.
     */
    void expandPip(boolean skipAnimation) {
        cancelAnimations();
        mHandler.post(() -> {
            try {
                if (skipAnimation) {
                    mActivityManager.moveTasksToFullscreenStack(PINNED_STACK_ID, true /* onTop */);
                } else {
                    mActivityManager.resizeStack(PINNED_STACK_ID, null /* bounds */,
                            true /* allowResizeInDockedMode */, true /* preserveWindows */,
                            true /* animate */, EXPAND_STACK_TO_FULLSCREEN_DURATION);
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Error showing PiP menu activity", e);
                Log.e(TAG, "Error expanding PiP activity", e);
            }
        });
    }
+1 −1
Original line number Diff line number Diff line
@@ -625,7 +625,7 @@ public class PipManager implements BasePipManager {
        }

        @Override
        public void onPinnedActivityRestartAttempt() {
        public void onPinnedActivityRestartAttempt(boolean clearedTask) {
            if (DEBUG) Log.d(TAG, "onPinnedActivityRestartAttempt()");
            if (!checkCurrentUserId(DEBUG)) {
                return;
Loading