public class AdbStream
extends java.lang.Object
implements java.io.Closeable
Constructor and Description |
---|
AdbStream(AdbConnection adbConn,
int localId)
Creates a new AdbStream object on the specified AdbConnection
with the given local ID.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the stream.
|
boolean |
isClosed()
Retreives whether the stream is closed or not
|
byte[] |
read()
Reads a pending write payload from the other side.
|
void |
write(byte[] payload)
Sends a write packet with a given byte array payload.
|
void |
write(byte[] payload,
boolean flush)
Queues a write packet and optionally sends it immediately.
|
void |
write(java.lang.String payload)
Sends a write packet with a given String payload.
|
public AdbStream(AdbConnection adbConn, int localId)
adbConn
- AdbConnection that this stream is running onlocalId
- Local ID of the streampublic byte[] read() throws java.lang.InterruptedException, java.io.IOException
java.lang.InterruptedException
- If we are unable to wait for datajava.io.IOException
- If the stream fails while waitingpublic void write(java.lang.String payload) throws java.io.IOException, java.lang.InterruptedException
payload
- Payload in the form of a Stringjava.io.IOException
- If the stream fails while sending datajava.lang.InterruptedException
- If we are unable to wait to send datapublic void write(byte[] payload) throws java.io.IOException, java.lang.InterruptedException
payload
- Payload in the form of a byte arrayjava.io.IOException
- If the stream fails while sending datajava.lang.InterruptedException
- If we are unable to wait to send datapublic void write(byte[] payload, boolean flush) throws java.io.IOException, java.lang.InterruptedException
payload
- Payload in the form of a byte arrayflush
- Specifies whether to send the packet immediatelyjava.io.IOException
- If the stream fails while sending datajava.lang.InterruptedException
- If we are unable to wait to send datapublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
- If the stream fails while sending the close message.public boolean isClosed()