class ShellServer : AutoCloseable


A ShellServer starts a new long running process on device that is capable of establishing and executing multiple concurrent ShellProcess with "/system/bin/sh". Each ShellProcess represents an executing sh process. To interact with it, the 3 standard streams are exposed (stdin, stdout, stderr) via java.io.OutputStreams and java.io.InputStream. At a high-level, you can think of a ShellServer as a "factory" for ShellProcess, which is useful to re-use for performance, or to configure which ports ShellServer opens on-device.

See also
setShellServer

Summary

Public companion functions

ShellServer
start(
    stdInSocketPort: Int,
    stdOutSocketPort: Int,
    stdErrSocketPort: Int,
    nativeLogs: Boolean,
    connectTimeoutMs: Long
)

Starts a new ShellServer with the given configuration.

Public functions

open Unit

Turns off the ShellServer.

ShellProcess

Creates a new ShellProcess.

Public companion functions

start

Added in 1.0.0-alpha02
fun start(
    stdInSocketPort: Int = Random.nextInt(from = PORT_START, until = PORT_END),
    stdOutSocketPort: Int = Random.nextInt(from = PORT_START, until = PORT_END),
    stdErrSocketPort: Int = Random.nextInt(from = PORT_START, until = PORT_END),
    nativeLogs: Boolean = false,
    connectTimeoutMs: Long = 1000
): ShellServer

Starts a new ShellServer with the given configuration.

Parameters
stdInSocketPort: Int = Random.nextInt(from = PORT_START, until = PORT_END)

the port utilized for stdin. If not specified, this is chosen randomly in the interval between PORT_START and PORT_END.

stdOutSocketPort: Int = Random.nextInt(from = PORT_START, until = PORT_END)

the port utilized for stdout. If not specified, this is chosen randomly in the interval between PORT_START and PORT_END.

stdErrSocketPort: Int = Random.nextInt(from = PORT_START, until = PORT_END)

the port utilized for stderr. If not specified, this is chosen randomly in the interval between PORT_START and PORT_END.

nativeLogs: Boolean = false

controls whether the native shell server should print logs.

connectTimeoutMs: Long = 1000

a timeout in millis to connect to the local shell server.

Returns
ShellServer

a started ShellServer

Public functions

close

Added in 1.0.0-alpha02
open fun close(): Unit

Turns off the ShellServer. After the closing, no more ShellProcess can be created.

Throws
kotlin.IllegalStateException

if the shell server did not start correctly.

newProcess

Added in 1.0.0-alpha02
fun newProcess(): ShellProcess

Creates a new ShellProcess.