adbwp.message

Object representation of a message.

class adbwp.message.Message(header, data)

Represents an entire ADB protocol message.

A message consists of a 24-byte header followed by an optional data payload.

Create new instance of Message(header, data)

count(value, /)

Return number of occurrences of value.

property data

Alias for field number 1

property header

Alias for field number 0

index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

adbwp.message.new(command: Union[int, adbwp.enums.Command], arg0: int = 0, arg1: int = 0, data: Union[bytes, bytearray, str, memoryview] = b'')adbwp.message.Message

Create a new Message instance with optional default values.

Parameters
  • command (Command or int) – Command identifier

  • arg0 (int) – (Optional) First argument of the command

  • arg1 (int) – (Optional) Second argument of the command

  • data (bytes, bytearray, str, or memoryview) – (Optional) Message payload

Returns

Message instance from given values

Return type

Message

Raises

ValueError – When data payload is greater than MAXDATA

adbwp.message.from_header(header: adbwp.header.Header, data: Union[bytes, bytearray, str, memoryview] = b'')adbwp.message.Message

Create a new Message instance from an existing Header.

Parameters
Returns

Message instance from given values

Return type

Message

Raises
adbwp.message.connect(serial: str, banner: str, system_type: Union[str, adbwp.enums.SystemType] = <SystemType.HOST: 'host'>)adbwp.message.Message

Create a Message instance that represents a connect message.

Parameters
  • serial (str) – Unique identifier

  • banner (str) – Human readable version/identifier string

  • system_type (SystemType or str) – System type creating the message

Returns

Message used to connect to a remote system

Return type

Message

Raises

ValueError – When data payload is greater than CONNECT_AUTH_MAXDATA

adbwp.message.auth_signature(signature: bytes)adbwp.message.Message

Create a Message instance that represents a signature authentication message.

Parameters

signature (bytes) – Signed data payload

Returns

Message used to verify key pair

Return type

Message

Raises

ValueError – When data payload is greater than CONNECT_AUTH_MAXDATA

adbwp.message.auth_rsa_public_key(public_key: bytes)adbwp.message.Message

Create a Message instance that represents a RSA public key authentication message.

Parameters

public_key (bytes) – Public key for remote system to conditionally accept

Returns

Message used to share public key

Return type

Message

Raises

ValueError – When data payload is greater than CONNECT_AUTH_MAXDATA

adbwp.message.open(local_id: int, destination: str)adbwp.message.Message

Create a Message instance that represents a open message.

Parameters
  • local_id (int) – Stream id on remote system to connect with

  • destination (str) – Stream destination

Returns

Message used to open a stream by id on a remote system

Return type

Message

Raises
adbwp.message.ready(local_id: int, remote_id: int)adbwp.message.Message

Create a Message instance that represents a ready message.

Parameters
  • local_id (int) – Identifier for the stream on the local end

  • remote_id (int) – Identifier for the stream on the remote system

Returns

Message used to inform remote system it’s ready for write messages

Return type

Message

Raises
adbwp.message.write(local_id: int, remote_id: int, data: Union[bytes, bytearray, str, memoryview])adbwp.message.Message

Create a Message instance that represents a write message.

Parameters
  • local_id (int) – Identifier for the stream on the local end

  • remote_id (int) – Identifier for the stream on the remote system

  • data (bytes, bytearray, str, or memoryview) – Data payload sent to the stream

Returns

Message used to write data to remote stream

Return type

Message

Raises
adbwp.message.close(local_id: int, remote_id: int)adbwp.message.Message

Create a Message instance that represents a close message.

Parameters
  • local_id (int) – Identifier for the stream on the local end

  • remote_id (int) – Identifier for the stream on the remote system

Returns

Message used to inform the remote system of stream closing

Return type

Message

Raises