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:
objectA 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
arg1return 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 thearg0return 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
arg0return value from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()methodsarg1 (int) – The
arg1return 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
arg0andarg1.- Parameters:
arg0 (int, None) – The
arg0value that we are looking for;Noneserves as a wildcardarg1 (int, None) – The
arg1value that we are looking for;Noneserves as a wildcard
- Returns:
The
(arg0, arg1)pair that was found in the dictionary of dictionaries, orNoneif no match was found- Return type:
tuple[int, int], None
- find_allow_zeros(arg0, arg1)[source]
Find the entry corresponding to (
arg0or 0) and (arg1or 0).- Parameters:
arg0 (int, None) – The
arg0value that we are looking for;Noneserves as a wildcardarg1 (int, None) – The
arg1value that we are looking for;Noneserves as a wildcard
- Returns:
The first matching
(arg0, arg1)pair that was found in the dictionary of dictionaries, orNoneif no match was found- Return type:
tuple[int, int], None
- get(arg0, arg1)[source]
Get the next entry from the queue for
arg0andarg1.This function assumes you have already checked that
(arg0, arg1) in self.- Parameters:
arg0 (int, None) – The
arg0return value from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()methods;Noneserves as a wildcardarg1 (int, None) – The
arg1return value from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()methods;Noneserves as a wildcard
- Returns:
cmd (bytes) – The ADB packet’s command
arg0 (int) – The
arg0value from the returned packetarg1 (int) – The
arg1value from the returned packetdata (bytes) – The ADB packet’s data
- put(arg0, arg1, cmd, data)[source]
Add an entry to the queue for
arg0andarg1.Note that a new dictionary entry will not be created if
cmd == constants.CLSE.- Parameters:
arg0 (int) – The
arg0return value from theadb_shell.adb_device._AdbIOManager._read_packet_from_device()andadb_shell.adb_device_async._AdbIOManagerAsync._read_packet_from_device()methodsarg1 (int) – The
arg1return 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:
objectA class for storing info and settings used during a single ADB “transaction.”
Note that if
timeout_sis notNone, then:self.transport_timeout_s <= self.read_timeout_s <= self.timeout_s
If
timeout_sisNone, 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
arg0andarg1match this object’sremote_idandlocal_idattributes, respectively.- Parameters:
arg0 (int) – The
arg0value from an ADB packet, which will be compared to this object’sremote_idattributearg1 (int) – The
arg1value from an ADB packet, which will be compared to this object’slocal_idattributeallow_zeros (bool) – Whether to check if
arg0andarg1match 0, in addition to this object’slocal_idandremote_idattributes
- Returns:
Whether
arg0andarg1match this object’slocal_idandremote_idattributes- Return type:
bool
- class adb_shell.hidden_helpers._FileSyncTransactionInfo(recv_message_format, maxdata=1048576)[source]
Bases:
objectA 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_bufferthat will be the start of the next data packet sent- Type:
int
- can_add_to_send_buffer(data_len)[source]
Determine whether
data_lenbytes 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_lenbytes 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
bannerthat 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_pathis 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