public class AdbProtocol
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
ADB_HEADER_LENGTH
The length of the ADB message header
|
static int |
AUTH_TYPE_RSA_PUBLIC
This authentication type represents a RSA public key
|
static int |
AUTH_TYPE_SIGNATURE
This authentication type represents the signed SHA1 hash
|
static int |
AUTH_TYPE_TOKEN
This authentication type represents a SHA1 hash to sign
|
static int |
CMD_AUTH
AUTH is the authentication message.
|
static int |
CMD_CLSE
CLSE is the close stream message.
|
static int |
CMD_CNXN
CNXN is the connect message.
|
static int |
CMD_OKAY
OKAY is a success message.
|
static int |
CMD_OPEN
OPEN is the open stream message.
|
static int |
CMD_SYNC |
static int |
CMD_WRTE
WRTE is the write stream message.
|
static int |
CONNECT_MAXDATA
The maximum data payload supported by the ADB implementation
|
static byte[] |
CONNECT_PAYLOAD
The payload sent with the connect message
|
static int |
CONNECT_VERSION
The current version of the ADB protocol
|
Constructor and Description |
---|
AdbProtocol() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
generateAuth(int type,
byte[] data)
Generates an auth message with the specified type and payload.
|
static byte[] |
generateClose(int localId,
int remoteId)
Generates a close stream message with the specified IDs.
|
static byte[] |
generateConnect()
Generates a connect message with default parameters.
|
static byte[] |
generateMessage(int cmd,
int arg0,
int arg1,
byte[] payload)
This function generates an ADB message given the fields.
|
static byte[] |
generateOpen(int localId,
java.lang.String dest)
Generates an open stream message with the specified local ID and destination.
|
static byte[] |
generateReady(int localId,
int remoteId)
Generates an okay message with the specified IDs.
|
static byte[] |
generateWrite(int localId,
int remoteId,
byte[] data)
Generates a write stream message with the specified IDs and payload.
|
static boolean |
validateMessage(com.cgutman.adblib.AdbProtocol.AdbMessage msg)
This function validate the ADB message by checking
its command, magic, and payload checksum.
|
public static final int ADB_HEADER_LENGTH
public static final int CMD_SYNC
public static final int CMD_CNXN
public static final int CONNECT_VERSION
public static final int CONNECT_MAXDATA
public static byte[] CONNECT_PAYLOAD
public static final int CMD_AUTH
public static final int AUTH_TYPE_TOKEN
public static final int AUTH_TYPE_SIGNATURE
public static final int AUTH_TYPE_RSA_PUBLIC
public static final int CMD_OPEN
public static final int CMD_OKAY
public static final int CMD_CLSE
public static final int CMD_WRTE
public static boolean validateMessage(com.cgutman.adblib.AdbProtocol.AdbMessage msg)
msg
- ADB message to validatepublic static byte[] generateMessage(int cmd, int arg0, int arg1, byte[] payload)
cmd
- Command identifierarg0
- First argumentarg1
- Second argumentpayload
- Data payloadpublic static byte[] generateConnect()
public static byte[] generateAuth(int type, byte[] data)
type
- Authentication type (see AUTH_TYPE_* constants)data
- The payload for the messagepublic static byte[] generateOpen(int localId, java.lang.String dest) throws java.io.UnsupportedEncodingException
localId
- A unique local ID identifying the streamdest
- The destination of the stream on the targetjava.io.UnsupportedEncodingException
- If the destination cannot be encoded to UTF-8public static byte[] generateWrite(int localId, int remoteId, byte[] data)
localId
- The unique local ID of the streamremoteId
- The unique remote ID of the streamdata
- The data to provide as the write payloadpublic static byte[] generateClose(int localId, int remoteId)
localId
- The unique local ID of the streamremoteId
- The unique remote ID of the streampublic static byte[] generateReady(int localId, int remoteId)
localId
- The unique local ID of the streamremoteId
- The unique remote ID of the stream