From 411e9efe377fb9df5f043915e58b4286d3ffec19 Mon Sep 17 00:00:00 2001 From: maade69 <70593890+maade69@users.noreply.github.com> Date: Sun, 23 Jul 2023 16:49:44 +0300 Subject: [PATCH] fastboot: initial implementation of stagePayload() --- src/fastboot.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/fastboot.ts b/src/fastboot.ts index b0c64a6..d5c89fb 100644 --- a/src/fastboot.ts +++ b/src/fastboot.ts @@ -606,6 +606,24 @@ export class FastbootDevice { common.logDebug(`Booted ${blob.size} bytes image`); } + /** + * Stage Blob on the connected deivce. + * Equivalent to `fastboot stage BlobName`. + * @param {string} filename - Filename + * @param {Blob} blob - The Blob to retrieve data from. + * @param {FlashProgressCallback} onProgress - Callback for flashing progress updates. + * @throws {FastbootError} + */ + async stagePayload( + filename: string, + blob: Blob, + onProgress: FlashProgressCallback = (_progress) => {} + ) { + let buffer = await common.readBlobAsBuffer(blob); + common.logDebug(`Sending payload: ${buffer.byteLength} bytes`); + await this.upload(filename, buffer, onProgress); + } + /** * Flash the given factory images zip onto the device, with automatic handling * of firmware, system, and logical partitions as AOSP fastboot and