Loading libraries/adb-daemon-webusb/src/device.ts +20 −4 Original line number Diff line number Diff line Loading @@ -242,7 +242,7 @@ export class AdbDaemonWebUsbConnection } catch (e) { // On Windows, disconnecting the device will cause `NetworkError` to be thrown, // even before the `disconnect` event is fired. // We need to wait a little bit and check if the device is still connected. // Wait a little while and check if the device is still connected. // https://github.com/WICG/webusb/issues/219 if (isErrorName(e, "NetworkError")) { await new Promise<void>((resolve) => { Loading @@ -253,8 +253,6 @@ export class AdbDaemonWebUsbConnection if (closed) { return undefined; } else { throw e; } } Loading Loading @@ -318,7 +316,15 @@ export class AdbDaemonWebUsbDevice implements AdbDaemonDevice { } if (!interface_.claimed) { try { await this.#raw.claimInterface(interface_.interfaceNumber); } catch (e) { if (isErrorName(e, "NetworkError")) { throw new AdbDaemonWebUsbDevice.DeviceBusyError(e); } throw e; } } if ( Loading Loading @@ -350,3 +356,13 @@ export class AdbDaemonWebUsbDevice implements AdbDaemonDevice { ); } } export namespace AdbDaemonWebUsbDevice { export class DeviceBusyError extends Error { constructor(cause?: Error) { super("The device is already in used by another program", { cause, }); } } } libraries/adb-daemon-webusb/src/utils.ts +1 −1 Original line number Diff line number Diff line export function isErrorName(e: unknown, name: string): boolean { export function isErrorName(e: unknown, name: string): e is Error { // node-usb package doesn't use `DOMException`, // so use a looser check // https://github.com/node-usb/node-usb/issues/573 Loading libraries/adb/src/daemon/transport.ts +7 −5 Original line number Diff line number Diff line Loading @@ -114,13 +114,15 @@ interface AdbDaemonSocketConnectorConstructionOptions { /** * The number of bytes the device can send before receiving an ack packet. * Using delayed ack can improve the throughput, * especially when the device is connected over Wi-Fi (so the latency is higher). * * On Android 14 and newer, the Delayed Acknowledgement feature is added to * improve performance, especially for high-latency connections like ADB over Wi-Fi. * * When `features` doesn't include `AdbFeature.DelayedAck`, it must be set to 0. Otherwise, * the value must be in the range of unsigned 32-bit integer. If the device enabled * delayed ack but the client didn't, the device will throw an error when the client sends * the first data packet. And vice versa. * the value must be in the range of unsigned 32-bit integer. * * If the device enabled delayed ack but the client didn't, the device will throw an error * when the client sends the first data packet. And vice versa. */ initialDelayedAckBytes: number; Loading Loading
libraries/adb-daemon-webusb/src/device.ts +20 −4 Original line number Diff line number Diff line Loading @@ -242,7 +242,7 @@ export class AdbDaemonWebUsbConnection } catch (e) { // On Windows, disconnecting the device will cause `NetworkError` to be thrown, // even before the `disconnect` event is fired. // We need to wait a little bit and check if the device is still connected. // Wait a little while and check if the device is still connected. // https://github.com/WICG/webusb/issues/219 if (isErrorName(e, "NetworkError")) { await new Promise<void>((resolve) => { Loading @@ -253,8 +253,6 @@ export class AdbDaemonWebUsbConnection if (closed) { return undefined; } else { throw e; } } Loading Loading @@ -318,7 +316,15 @@ export class AdbDaemonWebUsbDevice implements AdbDaemonDevice { } if (!interface_.claimed) { try { await this.#raw.claimInterface(interface_.interfaceNumber); } catch (e) { if (isErrorName(e, "NetworkError")) { throw new AdbDaemonWebUsbDevice.DeviceBusyError(e); } throw e; } } if ( Loading Loading @@ -350,3 +356,13 @@ export class AdbDaemonWebUsbDevice implements AdbDaemonDevice { ); } } export namespace AdbDaemonWebUsbDevice { export class DeviceBusyError extends Error { constructor(cause?: Error) { super("The device is already in used by another program", { cause, }); } } }
libraries/adb-daemon-webusb/src/utils.ts +1 −1 Original line number Diff line number Diff line export function isErrorName(e: unknown, name: string): boolean { export function isErrorName(e: unknown, name: string): e is Error { // node-usb package doesn't use `DOMException`, // so use a looser check // https://github.com/node-usb/node-usb/issues/573 Loading
libraries/adb/src/daemon/transport.ts +7 −5 Original line number Diff line number Diff line Loading @@ -114,13 +114,15 @@ interface AdbDaemonSocketConnectorConstructionOptions { /** * The number of bytes the device can send before receiving an ack packet. * Using delayed ack can improve the throughput, * especially when the device is connected over Wi-Fi (so the latency is higher). * * On Android 14 and newer, the Delayed Acknowledgement feature is added to * improve performance, especially for high-latency connections like ADB over Wi-Fi. * * When `features` doesn't include `AdbFeature.DelayedAck`, it must be set to 0. Otherwise, * the value must be in the range of unsigned 32-bit integer. If the device enabled * delayed ack but the client didn't, the device will throw an error when the client sends * the first data packet. And vice versa. * the value must be in the range of unsigned 32-bit integer. * * If the device enabled delayed ack but the client didn't, the device will throw an error * when the client sends the first data packet. And vice versa. */ initialDelayedAckBytes: number; Loading