adb.fastboot module¶
A libusb1-based fastboot implementation.
Contents
-
FastbootCommands.__reset()
-
-
adb.fastboot.
CLASS
= 255¶ From fastboot.c
-
adb.fastboot.
DEFAULT_MESSAGE_CALLBACK
(m)¶ TODO
-
adb.fastboot.
DeviceIsAvailable
(device)¶ TODO
-
class
adb.fastboot.
FastbootCommands
[source]¶ Bases:
object
Encapsulates the fastboot commands.
-
_handle
¶ TODO
- Type
TODO, None
-
_protocol
¶ TODO
- Type
TODO, None
-
ConnectDevice
(port_path=None, serial=None, default_timeout_ms=None, chunk_kb=1024, **kwargs)[source]¶ Convenience function to get an adb device from usb path or serial.
- Parameters
port_path (TODO, None) – The filename of usb port to use.
serial (TODO, None) – The serial number of the device to use. If serial specifies a TCP address:port, then a TCP connection is used instead of a USB connection.
default_timeout_ms (TODO, None) – The default timeout in milliseconds to use.
chunk_kb (int) – Amount of data, in kilobytes, to break fastboot packets up into
**kwargs (dict) – Keyword arguments
handle (adb.common.TcpHandle, adb.common.UsbHandle) – Device handle to use
banner (TODO) – Connection banner to pass to the remote device
rsa_keys (list[adb_protocol.AuthSigner]) – List of AuthSigner subclass instances to be used for authentication. The device can either accept one of these via the
Sign
method, or we will send the result ofGetPublicKey
from the first one if the device doesn’t accept any of them.auth_timeout_ms (TODO) – Timeout to wait for when sending a new public key. This is only relevant when we send a new public key. The device shows a dialog and this timeout is how long to wait for that dialog. If used in automation, this should be low to catch such a case as a failure quickly; while in interactive settings it should be high to allow users to accept the dialog. We default to automation here, so it’s low by default.
- Returns
self – TODO
- Return type
-
Continue
()[source]¶ Continues execution past fastboot into the system.
- Returns
TODO
- Return type
TODO
-
classmethod
Devices
()[source]¶ Get a generator of UsbHandle for devices available.
- Returns
TODO
- Return type
TODO
-
Download
(source_file, source_len=0, info_cb=<function <lambda>>, progress_callback=None)[source]¶ Downloads a file to the device.
- Parameters
source_file (TODO) – A filename or file-like object to download to the device.
source_len (int) – Optional length of source_file. If
source_file
is a file-like object andsource_len
is not provided,source_file
is read into memory.info_cb (TODO) – Optional callback accepting FastbootMessage for text sent from the bootloader.
progress_callback (TODO, None) – Optional callback called with the percent of the source_file downloaded. Note, this doesn’t include progress of the actual flashing.
- Returns
Response to a download request, normally nothing.
- Return type
TODO
-
Erase
(partition, timeout_ms=None)[source]¶ Erases the given partition.
- Parameters
partition (TODO) – Partition to clear.
timeout_ms (TODO, None) – TODO
-
Flash
(partition, timeout_ms=0, info_cb=<function <lambda>>)[source]¶ Flashes the last downloaded file to the given partition.
- Parameters
partition (TODO) – Partition to overwrite with the new image.
timeout_ms (int) – Optional timeout in milliseconds to wait for it to finish.
info_cb (TODO) – See
FastbootCommands.Download()
. Usually no messages.
- Returns
Response to a download request, normally nothing.
- Return type
TODO
-
FlashFromFile
(partition, source_file, source_len=0, info_cb=<function <lambda>>, progress_callback=None)[source]¶ Flashes a partition from the file on disk.
- Parameters
partition (TODO) – Partition name to flash to.
source_file (TODO) – Filename to download to the device.
source_len (int) – Optional length of source_file, uses os.stat if not provided.
info_cb (TODO) – See Download.
progress_callback (TODO) – See Download.
- Returns
Download and flash responses, normally nothing.
- Return type
TODO
-
Getvar
(var, info_cb=<function <lambda>>)[source]¶ Returns the given variable’s definition.
- Parameters
var (TODO) – A variable the bootloader tracks. Use ‘all’ to get them all.
info_cb (TODO) – See
FastbootCommands.Download()
. Usually no messages.
- Returns
Value of
var
according to the current bootloader.- Return type
TODO
-
Oem
(command, timeout_ms=None, info_cb=<function <lambda>>)[source]¶ Executes an OEM command on the device.
- Parameters
command (TODO) – Command to execute, such as ‘poweroff’ or ‘bootconfig read’.
timeout_ms (TODO, None) – Optional timeout in milliseconds to wait for a response.
info_cb (TODO) – See
FastbootCommands.Download()
. Messages vary based on command.
- Returns
- Return type
The final response from the device.
-
Reboot
(target_mode=b'', timeout_ms=None)[source]¶ Reboots the device.
- Parameters
target_mode (bytes) – Normal reboot when unspecified. Can specify other target modes such as ‘recovery’ or ‘bootloader’.
timeout_ms (TODO, None) – Optional timeout in milliseconds to wait for a response.
- Returns
Usually the empty string. Depends on the bootloader and the target_mode.
- Return type
TODO
-
RebootBootloader
(timeout_ms=None)[source]¶ Reboots into the bootloader, usually equiv to Reboot(‘bootloader’).
- Parameters
timeout_ms (TODO, None) – TODO
- Returns
TODO
- Return type
TODO
-
_FastbootCommands__reset
()¶ TODO
-
_SimpleCommand
(command, arg=None, **kwargs)[source]¶ TODO
- Parameters
command (TODO) – TODO
arg (TODO, None) – TODO
**kwargs (dict) – Keyword arguments
TODO – TODO
- Returns
TODO
- Return type
TODO
-
property
usb_handle
¶ TODO
- Returns
self._handle – TODO
- Return type
TODO
-
-
exception
adb.fastboot.
FastbootInvalidResponse
(message, *args)[source]¶ Bases:
adb.usb_exceptions.FormatMessageWithArgumentsException
Fastboot responded with a header we didn’t expect.
-
class
adb.fastboot.
FastbootMessage
(message, header)¶ Bases:
tuple
FastbootMessage
-
_fields_defaults
= {}¶
-
-
class
adb.fastboot.
FastbootProtocol
(usb, chunk_kb=1024)[source]¶ Bases:
object
Encapsulates the fastboot protocol.
- Parameters
usb (adb.common.UsbHandle) –
adb.common.UsbHandle
instance.chunk_kb (int) – Packet size. For older devices, 4 may be required.
-
chunk_kb
¶ Packet size. For older devices, 4 may be required.
- Type
int
-
usb
¶ adb.common.UsbHandle
instance.- Type
-
FINAL_HEADERS
= {b'DATA', b'OKAY'}¶
-
HandleDataSending
(source_file, source_len, info_cb=<function <lambda>>, progress_callback=None, timeout_ms=None)[source]¶ Handles the protocol for sending data to the device.
- Parameters
source_file (TODO) – File-object to read from for the device.
source_len (TODO) – Amount of data, in bytes, to send to the device.
info_cb (TODO) – Optional callback for text sent from the bootloader.
progress_callback (TODO, None) – Callback that takes the current and the total progress of the current file.
timeout_ms (TODO, None) – Timeout in milliseconds to wait for each response.
- Returns
OKAY packet’s message.
- Return type
TODO
- Raises
adb.fastboot.FastbootTransferError – When fastboot can’t handle this amount of data.
adb.fastboot.FastbootStateMismatch – Fastboot responded with the wrong packet type.
adb.fastboot.FastbootRemoteFailure – Fastboot reported failure.
adb.fastboot.FastbootInvalidResponse – Fastboot responded with an unknown packet type.
-
HandleSimpleResponses
(timeout_ms=None, info_cb=<function <lambda>>)[source]¶ Accepts normal responses from the device.
- Parameters
timeout_ms (TODO, None) – Timeout in milliseconds to wait for each response.
info_cb (TODO) – Optional callback for text sent from the bootloader.
- Returns
OKAY packet’s message.
- Return type
TODO
-
SendCommand
(command, arg=None)[source]¶ Sends a command to the device.
- Parameters
command (str) – The command to send.
arg (str) – Optional argument to the command.
-
_AcceptResponses
(expected_header, info_cb, timeout_ms=None)[source]¶ Accepts responses until the expected header or a FAIL.
- Parameters
expected_header (TODO) –
OKAY
orDATA
info_cb (TODO) – Optional callback for text sent from the bootloader.
timeout_ms (TODO) – Timeout in milliseconds to wait for each response.
- Returns
OKAY packet’s message.
- Return type
TODO
- Raises
adb.fastboot.FastbootStateMismatch – Fastboot responded with the wrong packet type.
adb.fastboot.FastbootRemoteFailure – Fastboot reported failure.
adb.fastboot.FastbootInvalidResponse – Fastboot responded with an unknown packet type.
-
static
_HandleProgress
(total, progress_callback)[source]¶ Calls the callback with the current progress and total.
- Parameters
total (TODO) – TODO
progress_callback (TODO) – TODO
-
_Write
(data, length, progress_callback=None)[source]¶ Sends the data to the device, tracking progress with the callback.
- Parameters
data (TODO) – TODO
length (TODO) – TODO
progress_callback (TODO, None) – TODO
-
property
usb_handle
¶ TODO
- Returns
self.usb –
adb.common.UsbHandle
instance.- Return type
-
exception
adb.fastboot.
FastbootRemoteFailure
(message, *args)[source]¶ Bases:
adb.usb_exceptions.FormatMessageWithArgumentsException
Remote error.
-
exception
adb.fastboot.
FastbootStateMismatch
(message, *args)[source]¶ Bases:
adb.usb_exceptions.FormatMessageWithArgumentsException
Fastboot and uboot’s state machines are arguing. You Lose.
-
exception
adb.fastboot.
FastbootTransferError
(message, *args)[source]¶ Bases:
adb.usb_exceptions.FormatMessageWithArgumentsException
Transfer error.
-
adb.fastboot.
PROTOCOL
= 3¶ From fastboot.c
-
adb.fastboot.
SUBCLASS
= 66¶ From fastboot.c
-
adb.fastboot.
VENDORS
= {1105, 1282, 1478, 2389, 2996, 4046, 6353, 8888, 8980, 16700, 32903}¶ From fastboot.c