Constructor
# new FastbootDevice()
Create a new fastboot device instance. This doesn't actually connect to
any USB devices; call connect to do so.
Classes
Members
# isConnected
Returns whether a USB device is connected and ready for use.
Methods
# async connect()
Request the user to select a USB device and connect to it using the
fastboot protocol.
# async flashBlob(partition, blob, onProgress)
Flash the given Blob to the given partition on the device. Any image
format supported by the bootloader is allowed, e.g. sparse or raw images.
Large raw images will be converted to sparse images automatically, and
large sparse images will be split and flashed in multiple passes
depending on the bootloader's payload size limit.
Parameters:
Name | Type | Description |
---|---|---|
partition |
string | The name of the partition to flash. |
blob |
Blob | The Blob to retrieve data from. |
onProgress |
ProgressCallback | Callback for flashing progress updates. |
# async flashFactoryZip(device, blob, wipe, onReconnect, onProgress)
Flash the given factory images zip onto the device, with automatic handling
of firmware, system, and logical partitions as AOSP fastboot and
flash-all.sh would do.
Equivalent to `fastboot update name.zip`.
Parameters:
Name | Type | Description |
---|---|---|
device |
FastbootDevice | Fastboot device to flash. |
blob |
Blob | Blob containing the zip file to flash. |
wipe |
boolean | Whether to wipe super and userdata. Equivalent to `fastboot -w`. |
onReconnect |
ReconnectCallback | Callback to request device reconnection. |
onProgress |
FactoryFlashCallback | Progress callback for image flashing. |
# async getVariable(varName) → {value}
Read the value of a bootloader variable. Returns undefined if the variable
does not exist.
Parameters:
Name | Type | Description |
---|---|---|
varName |
string | The name of the variable to get. |
Textual content of the variable.
value
# async reboot(target, wait, onReconnect)
Reboot to the given target, and optionally wait for the device to
reconnect.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
target |
string | Where to reboot to, i.e. fastboot or bootloader. | |
wait |
boolean | false | Whether to wait for the device to reconnect. |
onReconnect |
ReconnectCallback | Callback to request device reconnection, if wait is enabled. |
# async runCommand(command) → {response}
Send a textual command to the bootloader.
This is in raw fastboot format, not AOSP fastboot syntax.
Parameters:
Name | Type | Description |
---|---|---|
command |
string | The command to send. |
Object containing response text and data size, if any.
response
# async upload(partition, buffer, onProgress)
Upload a payload to the bootloader for further use, e.g. for flashing.
Does not handle raw images, flashing, or splitting.
Parameters:
Name | Type | Description |
---|---|---|
partition |
string | Name of the partition the payload is intended for. |
buffer |
ArrayBuffer | Buffer containing the data to upload. |
onProgress |
ProgressCallback | Callback for upload progress updates. |
# async waitForConnect(onReconnect)
Wait for the USB device to connect. Returns at the next connection,
regardless of whether the connected USB device matches the previous one.
Parameters:
Name | Type | Description |
---|---|---|
onReconnect |
ReconnectCallback | Callback to request device reconnection on Android. |
# async waitForDisconnect()
Wait for the current USB device to disconnect, if it's still connected.
Returns immediately if no device is connected.