Skip to content

Commit

Permalink
fix(adb): fix connecting old devices in server mode
Browse files Browse the repository at this point in the history
  • Loading branch information
yume-chan committed Dec 31, 2023
1 parent 06b3f47 commit 4fbd24f
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 0 additions & 5 deletions libraries/adb/src/commands/subprocess/protocols/shell.ts
Original file line number Diff line number Diff line change
@@ -89,13 +89,8 @@ export class AdbSubprocessShellProtocol implements AdbSubprocessProtocol {
constructor(socket: AdbSocket) {
this.#socket = socket;

// Check this image to help you understand the stream graph
// cspell: disable-next-line
// https://www.plantuml.com/plantuml/png/bL91QiCm4Bpx5SAdv90lb1JISmiw5XzaQKf5PIkiLZIqzEyLSg8ks13gYtOykpFhiOw93N6UGjVDqK7rZsxKqNw0U_NTgVAy4empOy2mm4_olC0VEVEE47GUpnGjKdgXoD76q4GIEpyFhOwP_m28hW0NNzxNUig1_JdW0bA7muFIJDco1daJ_1SAX9bgvoPJPyIkSekhNYctvIGXrCH6tIsPL5fs-s6J5yc9BpWXhKtNdF2LgVYPGM_6GlMwfhWUsIt4lbScANrwlgVVUifPSVi__t44qStnwPvZwobdSmHHlL57p2vFuHS0

let stdoutController!: PushReadableStreamController<Uint8Array>;
let stderrController!: PushReadableStreamController<Uint8Array>;

this.#stdout = new PushReadableStream<Uint8Array>((controller) => {
stdoutController = controller;
});
7 changes: 6 additions & 1 deletion libraries/adb/src/server/client.ts
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import type {
} from "@yume-chan/struct";
import {
BigIntFieldType,
EMPTY_UINT8_ARRAY,
SyncPromise,
decodeUtf8,
encodeUtf8,
@@ -92,7 +93,11 @@ export class AdbServerClient {
return SyncPromise.try(() => stream.readExactly(4))
.then((buffer) => {
const length = hexToNumber(buffer);
return stream.readExactly(length);
if (length === 0) {
return EMPTY_UINT8_ARRAY;
} else {
return stream.readExactly(length);
}
})
.then((valueBuffer) => {
return decodeUtf8(valueBuffer);

0 comments on commit 4fbd24f

Please sign in to comment.