src/AdbLib/doc/com/cgutman/adblib/AdbProtocol.html
com.cgutman.adblib
java.lang.Object
public classAdbProtocolextends java.lang.Object
This class provides useful functions and fields for ADB protocol details. Author:Cameron Gutman
Fields | 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
|
Constructors | Constructor and Description |
| --- |
| AdbProtocol() |
Methods | 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.
|
-
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
public static final int ADB_HEADER_LENGTH
The length of the ADB message header See Also:Constant Field Values
-
public static final int CMD_SYNC
See Also:Constant Field Values
-
public static final int CMD_CNXN
CNXN is the connect message. No messages (except AUTH) are valid before this message is received. See Also:Constant Field Values
-
public static final int CONNECT_VERSION
The current version of the ADB protocol See Also:Constant Field Values
-
public static final int CONNECT_MAXDATA
The maximum data payload supported by the ADB implementation See Also:Constant Field Values
-
public static byte[] CONNECT_PAYLOAD
The payload sent with the connect message
-
public static final int CMD_AUTH
AUTH is the authentication message. It is part of the RSA public key authentication added in Android 4.2.2. See Also:Constant Field Values
-
public static final int AUTH_TYPE_TOKEN
This authentication type represents a SHA1 hash to sign See Also:Constant Field Values
-
public static final int AUTH_TYPE_SIGNATURE
This authentication type represents the signed SHA1 hash See Also:Constant Field Values
-
public static final int AUTH_TYPE_RSA_PUBLIC
This authentication type represents a RSA public key See Also:Constant Field Values
-
public static final int CMD_OPEN
OPEN is the open stream message. It is sent to open a new stream on the target device. See Also:Constant Field Values
-
public static final int CMD_OKAY
OKAY is a success message. It is sent when a write is processed successfully. See Also:Constant Field Values
-
public static final int CMD_CLSE
CLSE is the close stream message. It it sent to close an existing stream on the target device. See Also:Constant Field Values
-
public static final int CMD_WRTE
WRTE is the write stream message. It is sent with a payload that is the data to write to the stream. See Also:Constant Field Values
-
public AdbProtocol()
-
public static boolean validateMessage(com.cgutman.adblib.AdbProtocol.AdbMessage msg)
This function validate the ADB message by checking its command, magic, and payload checksum.
Parameters:msg - ADB message to validateReturns:True if the message was valid, false otherwise
-
public static byte[] generateMessage(int cmd,
int arg0,
int arg1,
byte[] payload)
This function generates an ADB message given the fields.
Parameters:cmd - Command identifierarg0 - First argumentarg1 - Second argumentpayload - Data payloadReturns:Byte array containing the message
-
public static byte[] generateConnect()
Generates a connect message with default parameters. Returns:Byte array containing the message
-
public static byte[] generateAuth(int type,
byte[] data)
Generates an auth message with the specified type and payload.
Parameters:type - Authentication type (see AUTH_TYPE_* constants)data - The payload for the messageReturns:Byte array containing the message
-
public static byte[] generateOpen(int localId,
java.lang.String dest)
throws java.io.UnsupportedEncodingException
Generates an open stream message with the specified local ID and destination.
Parameters:localId - A unique local ID identifying the streamdest - The destination of the stream on the targetReturns:Byte array containing the messageThrows:java.io.UnsupportedEncodingException - If the destination cannot be encoded to UTF-8
-
public static byte[] generateWrite(int localId,
int remoteId,
byte[] data)
Generates a write stream message with the specified IDs and payload.
Parameters:localId - The unique local ID of the streamremoteId - The unique remote ID of the streamdata - The data to provide as the write payloadReturns:Byte array containing the message
-
public static byte[] generateClose(int localId,
int remoteId)
Generates a close stream message with the specified IDs.
Parameters:localId - The unique local ID of the streamremoteId - The unique remote ID of the streamReturns:Byte array containing the message
-
public static byte[] generateReady(int localId,
int remoteId)
Generates an okay message with the specified IDs.
Parameters:localId - The unique local ID of the streamremoteId - The unique remote ID of the streamReturns:Byte array containing the message