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

Commit 30ea0b03 authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Restore to split for request fullscreen API

This change does the following:
1. Saves the parent of a split-screen task when it is requesting
   fullscreen using the request fullscreen API.
2. When task is requesting to restore to its original windowing mode,
   the parent will also be restored so that the StageCoordinator can
   intercept the transition and animate the task to fullscreen.

Test: Restoring to split using request fullscreen API
Bug: 315352482

Change-Id: I6dfd34b237cadbb9599e6441c77bceee9f340554
parent 93fa1b04
Loading
Loading
Loading
Loading
+27 −2
Original line number Diff line number Diff line
@@ -2757,6 +2757,14 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            // cases above and it is not already visible
            return null;
        } else {
            if (triggerTask.parentTaskId == mMainStage.mRootTaskInfo.taskId
                    || triggerTask.parentTaskId == mSideStage.mRootTaskInfo.taskId) {
                ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "handleRequest: transition=%d "
                                + "restoring to split", request.getDebugId());
                out = new WindowContainerTransaction();
                mSplitTransitions.setEnterTransition(transition, request.getRemoteTransition(),
                        TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE, false /* resizeAnim */);
            }
            if (isOpening && getStageOfTask(triggerTask) != null) {
                ProtoLog.d(WM_SHELL_SPLIT_SCREEN, "handleRequest: transition=%d enter split",
                        request.getDebugId());
@@ -3103,7 +3111,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                // Includes TRANSIT_CHANGE to cover reparenting top-most task to split.
                mainChild = change;
            } else if (sideChild == null && stageType == STAGE_TYPE_SIDE
                    && isOpeningType(change.getMode())) {
                    && (isOpeningType(change.getMode()) || change.getMode() == TRANSIT_CHANGE)) {
                sideChild = change;
            } else if (stageType != STAGE_TYPE_UNDEFINED && change.getMode() == TRANSIT_TO_BACK) {
                // Collect all to back task's and evict them when transition finished.
@@ -3114,7 +3122,8 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        SplitScreenTransitions.EnterSession pendingEnter = mSplitTransitions.mPendingEnter;
        if (pendingEnter.mExtraTransitType
                == TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE) {
            // Open to side should only be used when split already active and foregorund.
            // Open to side should only be used when split already active and foregorund or when
            // app is restoring to split from fullscreen.
            if (mainChild == null && sideChild == null) {
                Log.w(TAG, splitFailureMessage("startPendingEnterAnimation",
                        "Launched a task in split, but didn't receive any task in transition."));
@@ -3201,6 +3210,22 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
            mPausingTasks.clear();
        });

        if (info.getType() == TRANSIT_CHANGE && !isSplitActive()
                && pendingEnter.mExtraTransitType == TRANSIT_SPLIT_SCREEN_OPEN_TO_SIDE) {
            if (finalMainChild != null && finalSideChild == null) {
                requestEnterSplitSelect(finalMainChild.getTaskInfo(),
                        new WindowContainerTransaction(),
                        getMainStagePosition(), finalMainChild.getStartAbsBounds());
            } else if (finalSideChild != null && finalMainChild == null) {
                requestEnterSplitSelect(finalSideChild.getTaskInfo(),
                        new WindowContainerTransaction(),
                        getSideStagePosition(), finalSideChild.getStartAbsBounds());
            } else {
                throw new IllegalStateException(
                        "Attempting to restore to split but reparenting change not found");
            }
        }

        finishEnterSplitScreen(finishT);
        addDividerBarToTransition(info, true /* show */);
        return true;
+3 −1
Original line number Diff line number Diff line
@@ -1299,9 +1299,11 @@ class ActivityClientController extends IActivityClientController.Stub {
            // The restore windowing mode must be set after the windowing mode is set since
            // Task#setWindowingMode resets the restore windowing mode to WINDOWING_MODE_INVALID.
            requester.mMultiWindowRestoreWindowingMode = restoreWindowingMode;
            requester.mMultiWindowRestoreParent =
                    requester.getParent().mRemoteToken.toWindowContainerToken();
        } else {
            targetWindowingMode = requester.mMultiWindowRestoreWindowingMode;
            requester.setWindowingMode(targetWindowingMode);
            requester.restoreWindowingMode();
        }
        if (targetWindowingMode == WINDOWING_MODE_FULLSCREEN) {
            requester.setBounds(null);
+20 −0
Original line number Diff line number Diff line
@@ -445,6 +445,7 @@ class Task extends TaskFragment {
    int mPrevDisplayId = INVALID_DISPLAY;

    int mMultiWindowRestoreWindowingMode = INVALID_WINDOWING_MODE;
    WindowContainerToken mMultiWindowRestoreParent;

    /**
     * Last requested orientation reported to DisplayContent. This is different from {@link
@@ -4620,6 +4621,25 @@ class Task extends TaskFragment {
        return TASK;
    }

    /**
     * Restores to the windowing mode saved when task requested to enter fullscreen using
     * {@link Activity#requestFullscreenMode} API if it is valid. The task is also reparented to
     * the previous parent if parent has changed.
     */
    void restoreWindowingMode() {
        if (mMultiWindowRestoreWindowingMode == INVALID_WINDOWING_MODE) {
            return;
        }
        if (!getParent().mRemoteToken.toWindowContainerToken()
                .equals(mMultiWindowRestoreParent)) {
            // Restore previous parent if parent has changed.
            final Task parent = fromWindowContainerToken(mMultiWindowRestoreParent);
            reparent(parent, MAX_VALUE);
        }

        setWindowingMode(mMultiWindowRestoreWindowingMode);
    }

    @Override
    public void setWindowingMode(int windowingMode) {
        // Calling Task#setWindowingMode() for leaf task since this is a specialization of