aio_androidtv.adb_manager module

Classes to manage ADB connections.

  • ADBPython utilizes a Python implementation of the ADB protocol.

class aio_androidtv.adb_manager.ADBPython(host, port, adbkey='')[source]

Bases: object

A manager for ADB connections that uses a Python implementation of the ADB protocol.

Parameters
  • host (str) – The address of the device; may be an IP address or a host name

  • port (int) – The device port to which we are connecting (default is 5555)

  • adbkey (str) – The path to the adbkey file for ADB authentication

property available

Check whether the ADB connection is intact.

Returns

Whether or not the ADB connection is intact

Return type

bool

async close()[source]

Close the ADB socket connection.

async connect(always_log_errors=True, auth_timeout_s=0.1)[source]

Connect to an Android TV / Fire TV device.

Parameters
  • always_log_errors (bool) – If True, errors will always be logged; otherwise, errors will only be logged on the first failed reconnect attempt

  • auth_timeout_s (float) – Authentication timeout (in seconds)

Returns

Whether or not the connection was successfully established and the device is available

Return type

bool

async pull(local_path, device_path)[source]

Pull a file from the device using the Python ADB implementation.

Parameters
  • local_path (str) – The path where the file will be saved

  • device_path (str) – The file on the device that will be pulled

async push(local_path, device_path)[source]

Push a file to the device using the Python ADB implementation.

Parameters
  • local_path (str) – The file that will be pushed to the device

  • device_path (str) – The path where the file will be saved on the device

async screencap()[source]

Take a screenshot using the Python ADB implementation.

Returns

The screencap as a binary .png image

Return type

bytes

async shell(cmd)[source]

Send an ADB command using the Python ADB implementation.

Parameters

cmd (str) – The ADB command to be sent

Returns

The response from the device, if there is a response

Return type

str, None

aio_androidtv.adb_manager.DEFAULT_TIMEOUT = 3.0

Default timeout for acquiring the async lock that protects ADB commands

aio_androidtv.adb_manager._acquire(lock, timeout=3.0)[source]

Handle acquisition and release of an asyncio.Lock object with a timeout.

Parameters
  • lock (asyncio.Lock) – The lock that we will try to acquire

  • timeout (float) – The timeout in seconds

Yields

acquired (bool) – Whether or not the lock was acquired

Raises

LockNotAcquiredException – Raised if the lock was not acquired