@aepyornis/fastboot.ts 0.0.7 → 0.0.9
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 +1 -1
- package/src/client.ts +18 -7
- package/src/flasher.ts +2 -2
package/package.json
CHANGED
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
|
}
|
|
@@ -67,8 +69,19 @@ export class FastbootClient {
|
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
async rebootFastboot() {
|
|
72
|
+
const serialNumber = this.fd.serialNumber
|
|
70
73
|
this.logger.log("rebooting into fastboot")
|
|
71
|
-
this.fd.exec("reboot-fastboot")
|
|
74
|
+
await this.fd.exec("reboot-fastboot")
|
|
75
|
+
// Devices may not automatically reconnect after entering fastbootd, so
|
|
76
|
+
// after 30 seconds if the device has not been connected we prompt again.
|
|
77
|
+
setTimeout(async () => {
|
|
78
|
+
const devices = await navigator.usb.getDevices()
|
|
79
|
+
if (!devices.some(device => device.serialNumber === serialNumber)) {
|
|
80
|
+
this.logger.log("Device did not reconnect, requesting new device")
|
|
81
|
+
await this.requestUsbDevice()
|
|
82
|
+
}
|
|
83
|
+
}, 30000)
|
|
84
|
+
|
|
72
85
|
await this.fd.waitForReconnect()
|
|
73
86
|
}
|
|
74
87
|
|
|
@@ -135,7 +148,7 @@ export class FastbootClient {
|
|
|
135
148
|
)
|
|
136
149
|
}
|
|
137
150
|
|
|
138
|
-
// fb->ResizePartition
|
|
151
|
+
// fb->ResizePartition
|
|
139
152
|
async resizePartition(name: string, totalBytes: number) {
|
|
140
153
|
// As per AOSP fastboot, we reset the partition to 0 bytes first
|
|
141
154
|
// to optimize extent allocation before setting the actual size.
|
|
@@ -155,7 +168,7 @@ export class FastbootClient {
|
|
|
155
168
|
|
|
156
169
|
// some devices might register before we have a chance to call
|
|
157
170
|
// waitForReconnect()
|
|
158
|
-
if (this.getVarCache("product")
|
|
171
|
+
if (MotorolaProducts.includes(await this.getVarCache("product")) && (await navigator.usb.getDevices()).length > 0) {
|
|
159
172
|
await this.fd.reconnect()
|
|
160
173
|
} else {
|
|
161
174
|
await this.fd.waitForReconnect()
|
|
@@ -290,8 +303,7 @@ export class FastbootClient {
|
|
|
290
303
|
}
|
|
291
304
|
|
|
292
305
|
async unlocked() {
|
|
293
|
-
|
|
294
|
-
if (product === "bangkk") {
|
|
306
|
+
if (MotorolaProducts.includes(await this.getVarCache("product"))) {
|
|
295
307
|
return (await this.getVar("securestate")) === "flashing_unlocked"
|
|
296
308
|
} else {
|
|
297
309
|
return (await this.getVar("unlocked")) === "yes"
|
|
@@ -299,8 +311,7 @@ export class FastbootClient {
|
|
|
299
311
|
}
|
|
300
312
|
|
|
301
313
|
async locked() {
|
|
302
|
-
|
|
303
|
-
if (product === "bangkk") {
|
|
314
|
+
if (MotorolaProducts.includes(await this.getVarCache("product"))) {
|
|
304
315
|
return (await this.getVar("securestate")) === "flashing_locked"
|
|
305
316
|
} else {
|
|
306
317
|
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
|
|
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"
|