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

Commit 3d8e6080 authored by Orhan Uysal's avatar Orhan Uysal Committed by Android (Google) Code Review
Browse files

Merge "Create shellCommand for moveToNextDisplay." into main

parents 1570cce7 4f1de39c
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