adbwp.header

Object representation of a message header.

class adbwp.header.Header(command, arg0, arg1, data_length, data_checksum, magic)

Represents the header of an ADB protocol message.

A header is 24 bytes consisting of 6 32-bit words in little-endian format.

Create new instance of Header(command, arg0, arg1, data_length, data_checksum, magic)

property connect

Indicates whether or not this header represents a connect message.

Returns

Bool indicating if it is a connect message or not.

Return type

bool

property auth

Indicates whether or not this header represents an auth message.

Returns

Bool indicating if it is an auth message or not.

Type

bool

property open

Indicates whether or not this header represents a open message.

Returns

Bool indicating if it is a open message or not.

Return type

bool

property ready

Indicates whether or not this header represents a ready message.

Returns

Bool indicating if it is a ready message or not.

Return type

bool

property write

Indicates whether or not this header represents a write message.

Returns

Bool indicating if it is a write message or not.

Return type

bool

property close

Indicates whether or not this header represents a close message.

Returns

Bool indicating if it is a close message or not.

Return type

bool

property sync

Indicates whether or not this header represents a sync message.

Returns

Bool indicating if it is a sync message or not.

Return type

bool

property okay

Indicates whether or not this header represents an okay response.

Returns

Bool indicating if it is an okay response or not.

Return type

bool

property fail

Indicates whether or not this header represents a fail response.

Returns

Bool indicating if it is a fail response or not.

Return type

bool

property arg0

Alias for field number 1

property arg1

Alias for field number 2

property command

Alias for field number 0

count(value, /)

Return number of occurrences of value.

property data_checksum

Alias for field number 4

property data_length

Alias for field number 3

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

Return first index of value.

Raises ValueError if the value is not present.

property magic

Alias for field number 5

adbwp.header.new(command: Union[int, adbwp.enums.Command], arg0: int = 0, arg1: int = 0, data_length: int = 0, data_checksum: int = 0, magic: int = 0)adbwp.header.Header

Create a new Header 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_length (int) – (Optional) Length of the payload

  • data_checksum (int) – (Optional) Computed checksum of the payload

  • magic (int) – (Optional) “Magic” XOR of the command

Returns

Header instance created from values

Return type

Header

adbwp.header.to_bytes(header: adbwp.header.Header)bytes

Create a bytes from the given Header.

Parameters

header (Header) – Message header

Returns

Header represented as bytes

Return type

bytes

Raises

PackError – when unable to pack instance into 6 bytes

adbwp.header.from_bytes(header: bytes)adbwp.header.Header

Create a Header from the given bytes.

Parameters

header (bytes) – Message header in bytes

Returns

Bytes converted to a header

Return type

Header

Raises

UnpackError – When unable to unpack instance from bytes