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

Commit ea289d63 authored by Vinit Nayak's avatar Vinit Nayak Committed by Android (Google) Code Review
Browse files

Merge changes Id49d4178,If55855ee into main

* changes:
  Add double tap divider swap functionality to flex split infra
  Add flex support for shortcut and intent entry points
parents f0683aa8 4f896353
Loading
Loading
Loading
Loading
+36 −4
Original line number Diff line number Diff line
@@ -833,7 +833,14 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,

        setSideStagePosition(splitPosition, wct);
        options1 = options1 != null ? options1 : new Bundle();
        addActivityOptions(options1, mSideStage);
        StageTaskListener stageForTask1;
        if (enableFlexibleSplit()) {
            stageForTask1 = mStageOrderOperator.getStageForLegacyPosition(splitPosition,
                    true /*checkAllStagesIfNotActive*/);
        } else {
            stageForTask1 = mSideStage;
        }
        addActivityOptions(options1, stageForTask1);
        wct.sendPendingIntent(pendingIntent, fillInIntent, options1);
        prepareTasksForSplitScreen(new int[] {taskId}, wct);

@@ -878,7 +885,14 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,

        setSideStagePosition(splitPosition, wct);
        options1 = options1 != null ? options1 : new Bundle();
        addActivityOptions(options1, mSideStage);
        StageTaskListener stageForTask1;
        if (enableFlexibleSplit()) {
            stageForTask1 = mStageOrderOperator.getStageForLegacyPosition(splitPosition,
                    true /*checkAllStagesIfNotActive*/);
        } else {
            stageForTask1 = mSideStage;
        }
        addActivityOptions(options1, stageForTask1);
        wct.startShortcut(mContext.getPackageName(), shortcutInfo, options1);
        prepareTasksForSplitScreen(new int[] {taskId}, wct);

@@ -1010,14 +1024,29 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
        setRootForceTranslucent(false, wct);

        options1 = options1 != null ? options1 : new Bundle();
        addActivityOptions(options1, mSideStage);
        StageTaskListener stageForTask1;
        if (enableFlexibleSplit()) {
            stageForTask1 = mStageOrderOperator.getStageForLegacyPosition(splitPosition,
                    true /*checkAllStagesIfNotActive*/);
        } else {
            stageForTask1 = mSideStage;
        }
        addActivityOptions(options1, stageForTask1);
        if (shortcutInfo1 != null) {
            wct.startShortcut(mContext.getPackageName(), shortcutInfo1, options1);
        } else {
            wct.sendPendingIntent(pendingIntent1, fillInIntent1, options1);
        }

        StageTaskListener stageForTask2;
        if (enableFlexibleSplit()) {
            stageForTask2 = mStageOrderOperator.getStageForLegacyPosition(
                    reverseSplitPosition(splitPosition), true /*checkAllStagesIfNotActive*/);
        } else {
            stageForTask2 = mMainStage;
        }
        options2 = options2 != null ? options2 : new Bundle();
        addActivityOptions(options2, mMainStage);
        addActivityOptions(options2, stageForTask2);
        if (shortcutInfo2 != null) {
            wct.startShortcut(mContext.getPackageName(), shortcutInfo2, options2);
        } else {
@@ -1246,6 +1275,9 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
                    // Restore focus-ability to the windows and divider
                    wct.setFocusable(mRootTaskInfo.token, true);

                    if (enableFlexibleSplit()) {
                        mStageOrderOperator.onDoubleTappedDivider();
                    }
                    setSideStagePosition(reverseSplitPosition(mSideStagePosition), wct);
                    mSyncQueue.queue(wct);
                    mSyncQueue.runInSync(st -> {
+19 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_B
import com.android.wm.shell.splitscreen.SplitScreen.STAGE_TYPE_C
import com.android.wm.shell.splitscreen.SplitScreen.stageTypeToString
import com.android.wm.shell.windowdecor.WindowDecorViewModel
import java.util.Collections
import java.util.Optional

/**
@@ -147,6 +148,24 @@ class StageOrderOperator (
        }
    }

    /**
     * This will swap the stages for the two stages on either side of the given divider.
     * Note: This will keep [activeStages] and [allStages] in sync by swapping both of them
     * If there are no [activeStages] then this will be a no-op.
     *
     * TODO(b/379984874): Take in a divider identifier to determine which array indices to swap
     */
    fun onDoubleTappedDivider() {
        if (activeStages.isEmpty()) {
            ProtoLog.d(ShellProtoLogGroup.WM_SHELL_SPLIT_SCREEN,
                "Stages not active, ignoring swap request")
            return
        }

        Collections.swap(activeStages, 0, 1)
        Collections.swap(allStages, 0, 1)
    }

    /**
     * Returns a legacy split position for the given stage. If no stages are active then this will
     * return [SPLIT_POSITION_UNDEFINED]