refactor: code cleanup, add tests

This commit is contained in:
Simon Chan 2024-03-05 12:41:48 +08:00
parent cbc0fa8f1e
commit 31656652db
No known key found for this signature in database
GPG key ID: A8B69F750B9BCEDD
4 changed files with 156 additions and 41 deletions

View file

@ -214,9 +214,10 @@ export class AdbPacketDispatcher implements Closeable {
const socket = this.#sockets.get(packet.arg1);
if (socket) {
// When delayed ack is enabled, device has received `ackBytes` from the socket.
// When delayed ack is disabled, device has received last `WRTE` packet from the socket,
// `ackBytes` is `Infinity` in this case.
// When delayed ack is enabled, `ackBytes` is a positive number represents
// how many bytes the device has received from this socket.
// When delayed ack is disabled, `ackBytes` is always `Infinity` represents
// the device has received last `WRTE` packet from the socket.
socket.ack(ackBytes);
return;
}
@ -332,7 +333,7 @@ export class AdbPacketDispatcher implements Closeable {
service,
);
// Fulfilled by `handleOk`
// Fulfilled by `handleOkay`
const { remoteId, availableWriteBytes } = await initializer;
const controller = new AdbDaemonSocketController({
dispatcher: this,