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

Commit 4f1de39c authored by Orhan Uysal's avatar Orhan Uysal
Browse files

Create shellCommand for moveToNextDisplay.

Create a shell command that allows us to move a task into next display.

Bug: 324236069
Test: adb shell dumpsys activity service SystemUIService WMShell
desktopmode moveToNextDisplay <taskId> moves task to next display.

Change-Id: I1b7bafe0ca687e8fefdb4794ca5327129e7a4f4b
parent bdf3e457
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -36,7 +36,14 @@ class DesktopModeShellCommandHandler(private val controller: DesktopTasksControl
                    true
                }
            }

            "moveToNextDisplay" -> {
                if (!runMoveToNextDisplay(args, pw)) {
                    pw.println("Task not found. Please enter a valid taskId.")
                    false
                } else {
                    true
                }
            }
            else -> {
                pw.println("Invalid command: ${args[0]}")
                false
@@ -61,8 +68,28 @@ class DesktopModeShellCommandHandler(private val controller: DesktopTasksControl
        return controller.moveToDesktop(taskId, WindowContainerTransaction())
    }

    private fun runMoveToNextDisplay(args: Array<String>, pw: PrintWriter): Boolean {
        if (args.size < 2) {
            // First argument is the action name.
            pw.println("Error: task id should be provided as arguments")
            return false
        }

        val taskId = try {
            args[1].toInt()
        } catch (e: NumberFormatException) {
            pw.println("Error: task id should be an integer")
            return false
        }

        controller.moveToNextDisplay(taskId)
        return true
    }

    override fun printShellCommandHelp(pw: PrintWriter, prefix: String) {
        pw.println("$prefix moveToDesktop <taskId> ")
        pw.println("$prefix  Move a task with given id to desktop mode.")
        pw.println("$prefix moveToNextDisplay <taskId> ")
        pw.println("$prefix  Move a task with given id to next display.")
    }
}
 No newline at end of file