Back to Solopi

AdbProtocol

src/AdbLib/doc/com/cgutman/adblib/AdbProtocol.html

0.12.010.6 KB
Original Source

com.cgutman.adblib

Class AdbProtocol

  • java.lang.Object

    • com.cgutman.adblib.AdbProtocol

public classAdbProtocolextends java.lang.Object

This class provides useful functions and fields for ADB protocol details. Author:Cameron Gutman

Field Summary

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 |

Constructor Summary

Constructors | Constructor and Description | | --- | | AdbProtocol() |

Method Summary

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. |

- 

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail

- 

ADB_HEADER_LENGTH

public static final int ADB_HEADER_LENGTH

The length of the ADB message header See Also:Constant Field Values

- 

CMD_SYNC

public static final int CMD_SYNC

See Also:Constant Field Values

- 

CMD_CNXN

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

- 

CONNECT_VERSION

public static final int CONNECT_VERSION

The current version of the ADB protocol See Also:Constant Field Values

- 

CONNECT_MAXDATA

public static final int CONNECT_MAXDATA

The maximum data payload supported by the ADB implementation See Also:Constant Field Values

- 

CONNECT_PAYLOAD

public static byte[] CONNECT_PAYLOAD

The payload sent with the connect message

- 

CMD_AUTH

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

- 

AUTH_TYPE_TOKEN

public static final int AUTH_TYPE_TOKEN

This authentication type represents a SHA1 hash to sign See Also:Constant Field Values

- 

AUTH_TYPE_SIGNATURE

public static final int AUTH_TYPE_SIGNATURE

This authentication type represents the signed SHA1 hash See Also:Constant Field Values

- 

AUTH_TYPE_RSA_PUBLIC

public static final int AUTH_TYPE_RSA_PUBLIC

This authentication type represents a RSA public key See Also:Constant Field Values

- 

CMD_OPEN

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

- 

CMD_OKAY

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

- 

CMD_CLSE

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

- 

CMD_WRTE

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

Constructor Detail

- 

AdbProtocol

public AdbProtocol()

Method Detail

- 

validateMessage

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

- 

generateMessage

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

- 

generateConnect

public static byte[] generateConnect()

Generates a connect message with default parameters. Returns:Byte array containing the message

- 

generateAuth

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

- 

generateOpen

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

- 

generateWrite

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

- 

generateClose

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

- 

generateReady

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