Skip to content

Commit 3f174e4

Browse files
committed
1.1.4-commaai
1 parent f5ae72f commit 3f174e4

File tree

9 files changed

+69
-35
lines changed

9 files changed

+69
-35
lines changed

dist/fastboot.cjs

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9584,8 +9584,16 @@ class FastbootDevice {
95849584
try {
95859585
let resp = (await this.getVariable("max-download-size")).toLowerCase();
95869586
if (resp) {
9587-
// AOSP fastboot requires hex
9588-
return Math.min(parseInt(resp, 16), MAX_DOWNLOAD_SIZE);
9587+
let size;
9588+
try {
9589+
// Some bootloaders return decimal
9590+
size = parseInt(resp, 10);
9591+
}
9592+
catch (e) {
9593+
// Some bootloaders return hex
9594+
size = parseInt(resp, 16);
9595+
}
9596+
return Math.min(size, MAX_DOWNLOAD_SIZE);
95899597
}
95909598
}
95919599
catch (error) {
@@ -9665,6 +9673,23 @@ class FastbootDevice {
96659673
await this.waitForConnect(onReconnect);
96669674
}
96679675
}
9676+
/**
9677+
* Determine the target name for the given partition and slot.
9678+
* @param {string} partition
9679+
* @param {"a" | "b" | "current" | "other"} targetSlot
9680+
*/
9681+
async getTargetForSlotPartition(partition, targetSlot) {
9682+
if (targetSlot === "a" || targetSlot === "b") {
9683+
return partition + "_" + targetSlot;
9684+
}
9685+
else {
9686+
let slot = await this.getVariable("current-slot");
9687+
if (targetSlot === "other") {
9688+
slot = slot === "a" ? "b" : "a";
9689+
}
9690+
return partition + "_" + slot;
9691+
}
9692+
}
96689693
/**
96699694
* Flash the given Blob to the given partition on the device. Any image
96709695
* format supported by the bootloader is allowed, e.g. sparse or raw images.
@@ -9682,18 +9707,10 @@ class FastbootDevice {
96829707
async flashBlob(partition, blob, onProgress = (_progress) => { }, targetSlot = "current") {
96839708
let hasSlot = await this.getVariable(`has-slot:${partition}`) == "yes";
96849709
if (!hasSlot && targetSlot !== "current") {
9685-
throw new FastbootError("FAIL", `Partition ${partition} does not have a slot, cannot flash to slot ${targetSlot}`);
9686-
}
9687-
if (hasSlot) {
9688-
if (targetSlot === "a" || targetSlot === "b") {
9689-
partition += "_" + targetSlot;
9690-
}
9691-
else {
9692-
let slot = await this.getVariable("current-slot");
9693-
if (targetSlot === "other") {
9694-
slot = slot === "a" ? "b" : "a";
9695-
}
9696-
partition += "_" + slot;
9710+
partition = await this.getTargetForSlotPartition(partition, targetSlot);
9711+
hasSlot = await this.getVariable(`partition-type:${partition}`) !== null;
9712+
if (!hasSlot) {
9713+
throw new FastbootError("FAIL", `Partition ${partition} does not have a slot, cannot flash to slot ${targetSlot}`);
96979714
}
96989715
}
96999716
let maxDlSize = await this._getDownloadSize();

dist/fastboot.cjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/fastboot.min.cjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fastboot.min.cjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/fastboot.min.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

dist/fastboot.min.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/fastboot.mjs

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9582,8 +9582,16 @@ class FastbootDevice {
95829582
try {
95839583
let resp = (await this.getVariable("max-download-size")).toLowerCase();
95849584
if (resp) {
9585-
// AOSP fastboot requires hex
9586-
return Math.min(parseInt(resp, 16), MAX_DOWNLOAD_SIZE);
9585+
let size;
9586+
try {
9587+
// Some bootloaders return decimal
9588+
size = parseInt(resp, 10);
9589+
}
9590+
catch (e) {
9591+
// Some bootloaders return hex
9592+
size = parseInt(resp, 16);
9593+
}
9594+
return Math.min(size, MAX_DOWNLOAD_SIZE);
95879595
}
95889596
}
95899597
catch (error) {
@@ -9663,6 +9671,23 @@ class FastbootDevice {
96639671
await this.waitForConnect(onReconnect);
96649672
}
96659673
}
9674+
/**
9675+
* Determine the target name for the given partition and slot.
9676+
* @param {string} partition
9677+
* @param {"a" | "b" | "current" | "other"} targetSlot
9678+
*/
9679+
async getTargetForSlotPartition(partition, targetSlot) {
9680+
if (targetSlot === "a" || targetSlot === "b") {
9681+
return partition + "_" + targetSlot;
9682+
}
9683+
else {
9684+
let slot = await this.getVariable("current-slot");
9685+
if (targetSlot === "other") {
9686+
slot = slot === "a" ? "b" : "a";
9687+
}
9688+
return partition + "_" + slot;
9689+
}
9690+
}
96669691
/**
96679692
* Flash the given Blob to the given partition on the device. Any image
96689693
* format supported by the bootloader is allowed, e.g. sparse or raw images.
@@ -9680,18 +9705,10 @@ class FastbootDevice {
96809705
async flashBlob(partition, blob, onProgress = (_progress) => { }, targetSlot = "current") {
96819706
let hasSlot = await this.getVariable(`has-slot:${partition}`) == "yes";
96829707
if (!hasSlot && targetSlot !== "current") {
9683-
throw new FastbootError("FAIL", `Partition ${partition} does not have a slot, cannot flash to slot ${targetSlot}`);
9684-
}
9685-
if (hasSlot) {
9686-
if (targetSlot === "a" || targetSlot === "b") {
9687-
partition += "_" + targetSlot;
9688-
}
9689-
else {
9690-
let slot = await this.getVariable("current-slot");
9691-
if (targetSlot === "other") {
9692-
slot = slot === "a" ? "b" : "a";
9693-
}
9694-
partition += "_" + slot;
9708+
partition = await this.getTargetForSlotPartition(partition, targetSlot);
9709+
hasSlot = await this.getVariable(`partition-type:${partition}`) !== null;
9710+
if (!hasSlot) {
9711+
throw new FastbootError("FAIL", `Partition ${partition} does not have a slot, cannot flash to slot ${targetSlot}`);
96959712
}
96969713
}
96979714
let maxDlSize = await this._getDownloadSize();

dist/fastboot.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "android-fastboot",
3-
"version": "1.1.3-commaai",
3+
"version": "1.1.4-commaai",
44
"description": "JavaScript implementation of fastboot, using WebUSB",
55
"main": "dist/fastboot.cjs",
66
"repository": "https://github.com/kdrag0n/fastboot.js",

0 commit comments

Comments
 (0)