ShellStreamHandle class

A long-running adb command whose stdout is consumed line by line.

This is the streaming counterpart of Executor.execute, which buffers the whole output and only returns once the process has exited — useless for a command that is meant not to exit, such as a sampling loop:

final handle = await client.shell().execStream([
  'while true; do cat /proc/stat; sleep 1; done',
]);
final subscription = handle.lines.listen(parse);
// later:
await handle.stop();

One process, one consumer: lines is a single-subscription stream, and nothing is read from the process until something listens to it. Subscribing late therefore loses no output (the pipe buffers it), but a caller that never listens will eventually block the command once the OS pipe is full — stop still tears it down.

Properties

done Future<ShellStreamResult>
Completes when the session ends, for any reason: stop was called, adb exited, or the stream broke. Never completes with an error.
no setter
hashCode int
The hash code for this object.
no setterinherited
isRunning bool
Whether the command is still running.
no setter
lines Stream<String>
The stdout of the command, one event per line, without line terminators.
no setter
pid int
The pid of the host adb process. The device-side command is a child of the adbd shell service and goes away with it, so killing this one is enough to stop the sampling on the device too.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
stop() Future<void>
Kills the adb process and completes done. Safe to call more than once, and safe to call after the session already ended on its own.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

start(Executor executor, List<String> arguments, {bool runInShell = false, bool debug = false}) Future<ShellStreamHandle>
Starts arguments with adbPath and returns a handle to the running process.