Skip to content

Commit

Permalink
feat(usb): generate serial numbers for devices without it
Browse files Browse the repository at this point in the history
  • Loading branch information
yume-chan committed Oct 19, 2023
1 parent d82e745 commit 70dd341
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libraries/adb-daemon-webusb/src/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ export class AdbDaemonWebUsbDevice implements AdbDaemonDevice {
return this.#raw;
}

#serial: string;
get serial(): string {
return this.#raw.serialNumber!;
return this.#serial;
}

get name(): string {
Expand All @@ -300,6 +301,14 @@ export class AdbDaemonWebUsbDevice implements AdbDaemonDevice {
usbManager: USB,
) {
this.#raw = device;
if (device.serialNumber) {
this.#serial = device.serialNumber;
} else {
this.#serial =
device.vendorId.toString(16).padStart(4, "0") +
"x" +
device.productId.toString(16).padStart(4, "0");
}
this.#filters = filters;
this.#usbManager = usbManager;
}
Expand Down

0 comments on commit 70dd341

Please sign in to comment.