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 Original line Diff line number Diff line
@@ -158,5 +158,10 @@ interface ISplitScreen {
     * does not expect split to currently be running.
     * does not expect split to currently be running.
     */
     */
    RemoteAnimationTarget[] onStartingSplitLegacy(in RemoteAnimationTarget[] appTargets) = 14;
    RemoteAnimationTarget[] onStartingSplitLegacy(in RemoteAnimationTarget[] appTargets) = 14;

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


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

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

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


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

    @Override
    @Override
    public void printShellCommandHelp(PrintWriter pw, String prefix) {
    public void printShellCommandHelp(PrintWriter pw, String prefix) {
        pw.println(prefix + "moveToSideStage <taskId> <SideStagePosition>");
        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 + "  Remove a task with given id in split-screen mode.");
        pw.println(prefix + "setSideStagePosition <SideStagePosition>");
        pw.println(prefix + "setSideStagePosition <SideStagePosition>");
        pw.println(prefix + "  Sets the position of the side-stage.");
        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 Original line Diff line number Diff line
@@ -421,6 +421,15 @@ public class SplitScreenControllerTests extends ShellTestCase {
        assertEquals(false, controller.supportsMultiInstanceSplit(component));
        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) {
    private Intent createStartIntent(String activityName) {
        Intent intent = new Intent();
        Intent intent = new Intent();
        intent.setComponent(new ComponentName(mContext, activityName));
        intent.setComponent(new ComponentName(mContext, activityName));