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

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

Merge "Add split screen API to switch the split positions" into main

parents 4462a1b7 55e0763b
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -158,5 +158,10 @@ interface ISplitScreen {
     * does not expect split to currently be running.
     */
    RemoteAnimationTarget[] onStartingSplitLegacy(in RemoteAnimationTarget[] appTargets) = 14;

    /**
     * Reverse the split.
     */
    oneway void switchSplitPosition() = 22;
}
// Last id = 21
 No newline at end of file
// Last id = 22
 No newline at end of file
+12 −0
Original line number Diff line number Diff line
@@ -1109,6 +1109,12 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
        mStageCoordinator.onDroppedToSplit(position, dragSessionId);
    }

    void switchSplitPosition(String reason) {
        if (isSplitScreenVisible()) {
            mStageCoordinator.switchSplitPosition(reason);
        }
    }

    /**
     * Return the {@param exitReason} as a string.
     */
@@ -1473,5 +1479,11 @@ public class SplitScreenController implements DragAndDropPolicy.Starter,
                    true /* blocking */);
            return out[0];
        }

        @Override
        public void switchSplitPosition() {
            executeRemoteCallWithTaskPermission(mController, "switchSplitPosition",
                    (controller) -> controller.switchSplitPosition("remoteCall"));
        }
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ public class SplitScreenShellCommandHandler implements
                return runRemoveFromSideStage(args, pw);
            case "setSideStagePosition":
                return runSetSideStagePosition(args, pw);
            case "switchSplitPosition":
                return runSwitchSplitPosition();
            default:
                pw.println("Invalid command: " + args[0]);
                return false;
@@ -84,6 +86,11 @@ public class SplitScreenShellCommandHandler implements
        return true;
    }

    private boolean runSwitchSplitPosition() {
        mController.switchSplitPosition("shellCommand");
        return true;
    }

    @Override
    public void printShellCommandHelp(PrintWriter pw, String prefix) {
        pw.println(prefix + "moveToSideStage <taskId> <SideStagePosition>");
@@ -92,5 +99,7 @@ public class SplitScreenShellCommandHandler implements
        pw.println(prefix + "  Remove a task with given id in split-screen mode.");
        pw.println(prefix + "setSideStagePosition <SideStagePosition>");
        pw.println(prefix + "  Sets the position of the side-stage.");
        pw.println(prefix + "switchSplitPosition");
        pw.println(prefix + "  Reverses the split.");
    }
}
+9 −0
Original line number Diff line number Diff line
@@ -421,6 +421,15 @@ public class SplitScreenControllerTests extends ShellTestCase {
        assertEquals(false, controller.supportsMultiInstanceSplit(component));
    }

    @Test
    public void testSwitchSplitPosition_checksIsSplitScreenVisible() {
        final String reason = "test";
        when(mSplitScreenController.isSplitScreenVisible()).thenReturn(true, false);
        mSplitScreenController.switchSplitPosition(reason);
        mSplitScreenController.switchSplitPosition(reason);
        verify(mStageCoordinator, times(1)).switchSplitPosition(reason);
    }

    private Intent createStartIntent(String activityName) {
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(mContext, activityName));