mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-04 10:19:17 +02:00
feat: add utilities for read/write Uint8Array
This commit is contained in:
parent
d06b5f2ed6
commit
dcda6459ac
66 changed files with 2039 additions and 287 deletions
|
@ -3,6 +3,10 @@ import {
|
|||
PromiseResolver,
|
||||
delay,
|
||||
} from "@yume-chan/async";
|
||||
import {
|
||||
getUint32BigEndian,
|
||||
setUint32LittleEndian,
|
||||
} from "@yume-chan/no-data-view";
|
||||
import {
|
||||
AbortController,
|
||||
Consumable,
|
||||
|
@ -10,7 +14,7 @@ import {
|
|||
type ReadableWritablePair,
|
||||
type WritableStreamDefaultWriter,
|
||||
} from "@yume-chan/stream-extra";
|
||||
import { EMPTY_UINT8_ARRAY, NumberFieldType } from "@yume-chan/struct";
|
||||
import { EMPTY_UINT8_ARRAY } from "@yume-chan/struct";
|
||||
|
||||
import type { AdbIncomingSocketHandler, AdbSocket, Closeable } from "../adb.js";
|
||||
import { decodeUtf8, encodeUtf8 } from "../utils/index.js";
|
||||
|
@ -189,7 +193,7 @@ export class AdbPacketDispatcher implements Closeable {
|
|||
"Invalid OKAY packet. Payload size should be 4",
|
||||
);
|
||||
}
|
||||
ackBytes = NumberFieldType.Uint32.deserialize(packet.payload, true);
|
||||
ackBytes = getUint32BigEndian(packet.payload, 0);
|
||||
} else {
|
||||
if (packet.payload.byteLength !== 0) {
|
||||
throw new Error(
|
||||
|
@ -228,10 +232,7 @@ export class AdbPacketDispatcher implements Closeable {
|
|||
let payload: Uint8Array;
|
||||
if (this.options.initialDelayedAckBytes !== 0) {
|
||||
payload = new Uint8Array(4);
|
||||
payload[0] = ackBytes & 0xff;
|
||||
payload[1] = (ackBytes >> 8) & 0xff;
|
||||
payload[2] = (ackBytes >> 16) & 0xff;
|
||||
payload[3] = (ackBytes >> 24) & 0xff;
|
||||
setUint32LittleEndian(payload, 0, ackBytes);
|
||||
} else {
|
||||
payload = EMPTY_UINT8_ARRAY;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue