RootShellBackend

ShellBackend backed by libsu — runs commands as the root UID. Strictly more powerful than Shizuku's ShizukuShellBackend: writes to /system, freezes apps via pm hide, reads /data/data/<pkg>, etc.

Output model. libsu's Shell.Result.out is List<String> (UTF-8 line-decoded). exec joins those lines back into a byte stream via UTF-8 re-encoding which is lossy for binary stdout (the PNG signature 89 50 4E 47 ... is invalid UTF-8, so the round-trip mangles it). Tools whose stdout is raw bytes — screencap -p, anything streaming non-UTF-8 — must call execBinary, which uses a temp-file roundtrip via SuFileInputStream to read raw bytes.

Host responsibility — do not override libsu's default builder to a non-root config. requestAccess calls Shell.getShell which uses whatever default builder is configured. If your host has called Shell.setDefaultBuilder(...) with non-root flags before any droid-mcp code runs, the prompt will never fire and root tools will silently fail with shell_unavailable. libsu's untouched default prefers root, which is the configuration droid-mcp expects.

Command parsing. libsu writes each Shell.cmd(String) invocation to the stdin of a long-running interactive shell process — it is NOT a sh -c <string> wrap. The shell still parses each line per sh syntax, so argv quoting via ShellUtils.escapedString is required for any value that could contain shell metacharacters.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override val name: String

Functions

Link copied to clipboard
open suspend override fun exec(command: String, args: List<String>): ShellResult
Link copied to clipboard
open suspend override fun execBinary(command: String, args: List<String>): ShellResult

Binary-safe path: writes stdout to a tempfile under /data/local/tmp (root-only), then reads it raw via SuFileInputStream. Used by capture_screen_quiet for PNG bytes.

Link copied to clipboard
open override fun isAvailable(): Boolean