public final class ShellServer implements 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 methods

void

Turns off the ShellServer.

final @NonNull ShellProcess

Creates a new ShellProcess.

static final @NonNull ShellServer
start(
    int stdInSocketPort,
    int stdOutSocketPort,
    int stdErrSocketPort,
    boolean nativeLogs,
    long connectTimeoutMs
)

Starts a new ShellServer with the given configuration.

Public methods

close

Added in 1.0.0-alpha02
public void close()

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
public final @NonNull ShellProcess newProcess()

Creates a new ShellProcess.

start

Added in 1.0.0-alpha02
public static final @NonNull ShellServer start(
    int stdInSocketPort,
    int stdOutSocketPort,
    int stdErrSocketPort,
    boolean nativeLogs,
    long connectTimeoutMs
)

Starts a new ShellServer with the given configuration.

Parameters
int stdInSocketPort

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

int stdOutSocketPort

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

int stdErrSocketPort

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

boolean nativeLogs

controls whether the native shell server should print logs.

long connectTimeoutMs

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

Returns
@NonNull ShellServer

a started ShellServer