@aepyornis/fastboot.ts 0.0.7 → 0.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aepyornis/fastboot.ts",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Fastboot using WebUSB",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
package/src/client.ts CHANGED
@@ -11,6 +11,8 @@ const FastbootUSBDeviceFilter = {
11
11
  protocolCode: 0x03,
12
12
  }
13
13
 
14
+ const MotorolaProducts = ["bangkk", "fogos"]
15
+
14
16
  interface Logger {
15
17
  log(message: string): void
16
18
  }
@@ -135,7 +137,7 @@ export class FastbootClient {
135
137
  )
136
138
  }
137
139
 
138
- // fb->ResizePartition ?
140
+ // fb->ResizePartition
139
141
  async resizePartition(name: string, totalBytes: number) {
140
142
  // As per AOSP fastboot, we reset the partition to 0 bytes first
141
143
  // to optimize extent allocation before setting the actual size.
@@ -155,7 +157,7 @@ export class FastbootClient {
155
157
 
156
158
  // some devices might register before we have a chance to call
157
159
  // waitForReconnect()
158
- if (this.getVarCache("product") === "bangkk" && (await navigator.usb.getDevices()).length > 0) {
160
+ if (MotorolaProducts.includes(await this.getVarCache("product")) && (await navigator.usb.getDevices()).length > 0) {
159
161
  await this.fd.reconnect()
160
162
  } else {
161
163
  await this.fd.waitForReconnect()
@@ -290,8 +292,7 @@ export class FastbootClient {
290
292
  }
291
293
 
292
294
  async unlocked() {
293
- const product = await this.getVarCache("product")
294
- if (product === "bangkk") {
295
+ if (MotorolaProducts.includes(await this.getVarCache("product"))) {
295
296
  return (await this.getVar("securestate")) === "flashing_unlocked"
296
297
  } else {
297
298
  return (await this.getVar("unlocked")) === "yes"
@@ -299,8 +300,7 @@ export class FastbootClient {
299
300
  }
300
301
 
301
302
  async locked() {
302
- const product = await this.getVarCache("product")
303
- if (product === "bangkk") {
303
+ if (MotorolaProducts.includes(await this.getVarCache("product"))) {
304
304
  return (await this.getVar("securestate")) === "flashing_locked"
305
305
  } else {
306
306
  return (await this.getVar("unlocked")) === "no"
package/src/flasher.ts CHANGED
@@ -111,6 +111,7 @@ export class FastbootFlasher {
111
111
  new TextWriter(),
112
112
  )
113
113
 
114
+ this.client.logger.log("flash-all.sh\n" + flashAllSh)
114
115
  const instructions = flashAllSh
115
116
  .split("\n")
116
117
  .map((x) => x.trim())
@@ -123,7 +124,6 @@ export class FastbootFlasher {
123
124
  async run(instructions: text) {
124
125
  const entries: Entry[] = await this.reader.getEntries() // io with factory.zip
125
126
  const commands: Instruction[] = parseInstructions(instructions)
126
- console.log(commands)
127
127
 
128
128
  for (const command of commands) {
129
129
  this.client.logger.log(`‣ ${JSON.stringify(command)}`)
@@ -191,7 +191,7 @@ export class FastbootFlasher {
191
191
  await new Promise((resolve) => setTimeout(resolve, ms))
192
192
  // do_oem_command in cpp is raw command?
193
193
  } else if (command.command === "oem") {
194
- // motorola setting that does nothing useful here?
194
+ // ignore motorola oem commands that do nothing useful?
195
195
  if (
196
196
  command.args[0] === "fb_mode_set" ||
197
197
  command.args[0] === "fb_mode_clear"