adb_shell.hidden_helpers module
Implement helpers for the AdbDevice
and AdbDeviceAsync
classes.
Contents
-
_AdbPacketStore.__contains__()
_AdbPacketStore.__len__()
-
-
- class adb_shell.hidden_helpers.DeviceFile(filename, mode, size, mtime)
Bases:
tuple
- _asdict()
Return a new dict which maps field names to their values.
- _field_defaults = {}
- _fields = ('filename', 'mode', 'size', 'mtime')
- classmethod _make(iterable)
Make a new DeviceFile object from a sequence or iterable
- _replace(**kwds)
Return a new DeviceFile object replacing specified fields with new values
- filename
Alias for field number 0
- mode
Alias for field number 1
- mtime
Alias for field number 3
- size
Alias for field number 2
- class adb_shell.hidden_helpers._AdbPacketStore[source]
Bases:
object
A class for storing ADB packets.
This class is used to support multiple streams.
- _dict
A dictionary of dictionaries of queues. The first (outer) dictionary keys are the
arg1
return values from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()
andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()
methods. The second (inner) dictionary keys are thearg0
return values from those methods. And the values of this inner dictionary are queues of(cmd, data)
tuples.- Type:
dict[int: dict[int: Queue]]
- clear(arg0, arg1)[source]
Delete the entry for
(arg0, arg1)
, if it exists.- Parameters:
arg0 (int) – The
arg0
return value from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()
andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()
methodsarg1 (int) – The
arg1
return value from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()
andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()
methods
- find(arg0, arg1)[source]
Find the entry corresponding to
arg0
andarg1
.- Parameters:
arg0 (int, None) – The
arg0
value that we are looking for;None
serves as a wildcardarg1 (int, None) – The
arg1
value that we are looking for;None
serves as a wildcard
- Returns:
The
(arg0, arg1)
pair that was found in the dictionary of dictionaries, orNone
if no match was found- Return type:
tuple[int, int], None
- find_allow_zeros(arg0, arg1)[source]
Find the entry corresponding to (
arg0
or 0) and (arg1
or 0).- Parameters:
arg0 (int, None) – The
arg0
value that we are looking for;None
serves as a wildcardarg1 (int, None) – The
arg1
value that we are looking for;None
serves as a wildcard
- Returns:
The first matching
(arg0, arg1)
pair that was found in the dictionary of dictionaries, orNone
if no match was found- Return type:
tuple[int, int], None
- get(arg0, arg1)[source]
Get the next entry from the queue for
arg0
andarg1
.This function assumes you have already checked that
(arg0, arg1) in self
.- Parameters:
arg0 (int, None) – The
arg0
return value from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()
andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()
methods;None
serves as a wildcardarg1 (int, None) – The
arg1
return value from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()
andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()
methods;None
serves as a wildcard
- Returns:
cmd (bytes) – The ADB packet’s command
arg0 (int) – The
arg0
value from the returned packetarg1 (int) – The
arg1
value from the returned packetdata (bytes) – The ADB packet’s data
- put(arg0, arg1, cmd, data)[source]
Add an entry to the queue for
arg0
andarg1
.Note that a new dictionary entry will not be created if
cmd == constants.CLSE
.- Parameters:
arg0 (int) – The
arg0
return value from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()
andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()
methodsarg1 (int) – The
arg1
return value from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()
andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()
methodscmd (bytes) – The ADB packet’s command
data (bytes) – The ADB packet’s data
- class adb_shell.hidden_helpers._AdbTransactionInfo(local_id, remote_id, transport_timeout_s=None, read_timeout_s=10.0, timeout_s=None)[source]
Bases:
object
A class for storing info and settings used during a single ADB “transaction.”
Note that if
timeout_s
is notNone
, then:self.transport_timeout_s <= self.read_timeout_s <= self.timeout_s
If
timeout_s
isNone
, the first inequality still applies.- Parameters:
local_id (int) – The ID for the sender (i.e., the device running this code)
remote_id (int) – The ID for the recipient
transport_timeout_s (float, None) – Timeout in seconds for sending and receiving data, or
None
; seeBaseTransport.bulk_read()
,BaseTransport.bulk_write()
,BaseTransportAsync.bulk_read()
, andBaseTransportAsync.bulk_write()
read_timeout_s (float) – The total time in seconds to wait for data and packets from the device
timeout_s (float, None) – The total time in seconds to wait for the ADB command to finish
- local_id
The ID for the sender (i.e., the device running this code)
- Type:
int
- read_timeout_s
The total time in seconds to wait for data and packets from the device
- Type:
float
- remote_id
The ID for the recipient
- Type:
int
- timeout_s
The total time in seconds to wait for the ADB command to finish
- Type:
float, None
- transport_timeout_s
Timeout in seconds for sending and receiving data, or
None
; seeBaseTransport.bulk_read()
,BaseTransport.bulk_write()
,BaseTransportAsync.bulk_read()
, andBaseTransportAsync.bulk_write()
- Type:
float, None
- args_match(arg0, arg1, allow_zeros=False)[source]
Check if
arg0
andarg1
match this object’sremote_id
andlocal_id
attributes, respectively.- Parameters:
arg0 (int) – The
arg0
value from an ADB packet, which will be compared to this object’sremote_id
attributearg1 (int) – The
arg1
value from an ADB packet, which will be compared to this object’slocal_id
attributeallow_zeros (bool) – Whether to check if
arg0
andarg1
match 0, in addition to this object’slocal_id
andremote_id
attributes
- Returns:
Whether
arg0
andarg1
match this object’slocal_id
andremote_id
attributes- Return type:
bool
- class adb_shell.hidden_helpers._FileSyncTransactionInfo(recv_message_format, maxdata=1048576)[source]
Bases:
object
A class for storing info used during a single FileSync “transaction.”
- Parameters:
recv_message_format (bytes) – The FileSync message format
maxdata (int) – Maximum amount of data in an ADB packet
- _maxdata
Maximum amount of data in an ADB packet
- Type:
int
- recv_buffer
A buffer for storing received data
- Type:
bytearray
- recv_message_format
The FileSync message format
- Type:
bytes
- recv_message_size
The FileSync message size
- Type:
int
- send_buffer
A buffer for storing data to be sent
- Type:
bytearray
- send_idx
The index in
recv_buffer
that will be the start of the next data packet sent- Type:
int
- can_add_to_send_buffer(data_len)[source]
Determine whether
data_len
bytes of data can be added to the send buffer without exceedingconstants.MAX_ADB_DATA
.- Parameters:
data_len (int) – The length of the data to be potentially added to the send buffer (not including the length of its header)
- Returns:
Whether
data_len
bytes of data can be added to the send buffer without exceedingconstants.MAX_ADB_DATA
- Return type:
bool
- adb_shell.hidden_helpers.get_banner()[source]
Get the
banner
that will be signed inadb_shell.adb_device.AdbDevice.connect()
/adb_shell.adb_device_async.AdbDeviceAsync.connect()
.- Returns:
The hostname, or “unknown” if it could not be determined
- Return type:
bytearray
- adb_shell.hidden_helpers.get_files_to_push(local_path, device_path)[source]
Get a list of the file(s) to push.
- Parameters:
local_path (str) – A path to a local file or directory
device_path (str) – A path to a file or directory on the device
- Returns:
local_path_is_dir (bool) – Whether or not
local_path
is a directorylocal_paths (list[str]) – A list of the file(s) to push
device_paths (list[str]) – A list of destination paths on the device that corresponds to
local_paths