@aepyornis/fastboot.ts 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,7 +13,11 @@ npm run build
13
13
  src/sparse.ts sparse image utilities Copyright (c) 2021 Danny Lin <danny@kdrag0n.dev>
14
14
 
15
15
  ```js
16
- import { FastbootClient, FastbootFlasher } from "@aepyornis/fastboot.ts"
16
+ import {
17
+ FastbootDevice,
18
+ FastbootClient,
19
+ FastbootFlasher,
20
+ } from "@aepyornis/fastboot.ts"
17
21
 
18
22
  const client = await FastbootClient.create()
19
23
 
package/mise.toml ADDED
@@ -0,0 +1,2 @@
1
+ [tools]
2
+ node = "22"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aepyornis/fastboot.ts",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Fastboot using WebUSB",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
package/src/client.ts CHANGED
@@ -152,7 +152,14 @@ export class FastbootClient {
152
152
  }
153
153
  this.logger.log(`ACTION NEEDED: flashing ${command}`)
154
154
  await this.fd.exec(`flashing ${command}`)
155
- await this.fd.waitForReconnect()
155
+
156
+ // some devices might register before we have a chance to call
157
+ // waitForReconnect()
158
+ if (this.getVarCache("product") === "bangkk" && (await navigator.usb.getDevices()).length > 0) {
159
+ await this.fd.reconnect()
160
+ } else {
161
+ await this.fd.waitForReconnect()
162
+ }
156
163
  }
157
164
 
158
165
  // run text, typically the contents of fastboot-info.txt
package/src/flasher.ts CHANGED
@@ -57,6 +57,8 @@ function parseInstruction(text: string): Instruction {
57
57
  options.wipe = true
58
58
  } else if (word === "--set-active=other") {
59
59
  options.setActive = "other"
60
+ } else if (word === "--set-active=a" || word === "--set-active=b") {
61
+ options.setActive = word.slice(-1)
60
62
  } else if (word === "--slot-other") {
61
63
  options.slot = "other"
62
64
  } else if (word.slice(0, 6) === "--slot") {
@@ -143,6 +145,10 @@ export class FastbootFlasher {
143
145
  } else if (command.command === "reboot-bootloader") {
144
146
  if (command.options.setActive === "other") {
145
147
  await this.client.setActiveOtherSlot()
148
+ } else if (command.options.setActive === "a") {
149
+ await this.client.fd.exec("set_active:a")
150
+ } else if (command.options.setActive === "b") {
151
+ await this.client.fd.exec("set_active:b")
146
152
  }
147
153
  await this.client.rebootBootloader()
148
154
  } else if (command.command === "update") {
@@ -183,6 +189,19 @@ export class FastbootFlasher {
183
189
  } else if (command.command === "sleep") {
184
190
  const ms = command.args[0] ? parseInt(command.args[0]) * 1000 : 5000
185
191
  await new Promise((resolve) => setTimeout(resolve, ms))
192
+ // do_oem_command in cpp is raw command?
193
+ } else if (command.command === "oem") {
194
+ // motorola setting that does nothing useful here?
195
+ if (
196
+ command.args[0] === "fb_mode_set" ||
197
+ command.args[0] === "fb_mode_clear"
198
+ ) {
199
+ await new Promise((resolve) => setTimeout(resolve, 10))
200
+ } else {
201
+ throw new Error(
202
+ `Fastboot oem command ${command.args[0]} not implemented`,
203
+ )
204
+ }
186
205
  } else {
187
206
  throw new Error(`Fastboot command ${command.command} not implemented`)
188
207
  }