aio_adb_shell.adb_message module

Functions and an AdbMessage class for packing and unpacking ADB messages.

Contents

class aio_adb_shell.adb_message.AdbMessage(command, arg0, arg1, data=b'')[source]

Bases: object

A helper class for packing ADB messages.

Parameters
  • command (bytes) – A command; examples used in this package include adb_shell.constants.AUTH, adb_shell.constants.CNXN, adb_shell.constants.CLSE, adb_shell.constants.OPEN, and adb_shell.constants.OKAY

  • arg0 (int) – Usually the local ID, but connect() provides adb_shell.constants.VERSION, adb_shell.constants.AUTH_SIGNATURE, and adb_shell.constants.AUTH_RSAPUBLICKEY

  • arg1 (int) – Usually the remote ID, but connect() provides adb_shell.constants.MAX_ADB_DATA

  • data (bytes) – The data that will be sent

arg0

Usually the local ID, but connect() provides adb_shell.constants.VERSION, adb_shell.constants.AUTH_SIGNATURE, and adb_shell.constants.AUTH_RSAPUBLICKEY

Type

int

arg1

Usually the remote ID, but connect() provides adb_shell.constants.MAX_ADB_DATA

Type

int

command

The input parameter command converted to an integer via adb_shell.constants.ID_TO_WIRE

Type

int

data

The data that will be sent

Type

bytes

magic

self.command with its bits flipped; in other words, self.command + self.magic == 2**32 - 1

Type

int

property checksum

Return checksum(self.data)

Returns

The checksum of self.data

Return type

int

pack()[source]

Returns this message in an over-the-wire format.

Returns

The message packed into the format required by ADB

Return type

bytes

aio_adb_shell.adb_message.checksum(data)[source]

Calculate the checksum of the provided data.

Parameters

data (bytearray, bytes, str) – The data

Returns

The checksum

Return type

int

aio_adb_shell.adb_message.unpack(message)[source]

Unpack a received ADB message.

Parameters

message (bytes) – The received message

Returns

  • cmd (int) – The ADB command

  • arg0 (int) – TODO

  • arg1 (int) – TODO

  • data_length (int) – The length of the data sent by the device (used by adb_shell.adb_device._read())

  • data_checksum (int) – The checksum of the data sent by the device

Raises

ValueError – Unable to unpack the ADB command.