Loading libraries/adb-scrcpy/src/client.ts +2 −2 Original line number Diff line number Diff line Loading @@ -144,14 +144,14 @@ export class AdbScrcpyClient<TOptions extends AdbScrcpyOptions<object>> { ]; if (options.spawner) { process = await options.spawner.spawn(args); process = await options.spawner(args); } else { process = await adb.subprocess.noneProtocol.spawn(args); } const output = process.output .pipeThrough(new TextDecoderStream()) .pipeThrough(new SplitStringStream("\n")); .pipeThrough(new SplitStringStream("\n", { trimEnd: true })); // Must read all streams, otherwise the whole connection will be blocked. const lines: string[] = []; Loading libraries/adb/src/adb.ts +11 −5 Original line number Diff line number Diff line Loading @@ -125,10 +125,12 @@ export class Adb implements Closeable { .pipeThrough(new ConcatStringStream()); } getProp(key: string): Promise<string> { return this.subprocess.noneProtocol .spawnWaitText(["getprop", key]) .then((output) => output.trim()); async getProp(key: string): Promise<string> { const output = await this.subprocess.noneProtocol .spawn(["getprop", key]) .wait() .toString(); return output.trim(); } rm( Loading @@ -154,7 +156,11 @@ export class Adb implements Closeable { // https://android.googlesource.com/platform/packages/modules/adb/+/1a0fb8846d4e6b671c8aa7f137a8c21d7b248716/client/adb_install.cpp#984 args.push("</dev/null"); return this.subprocess.noneProtocol.spawnWaitText(args); return this.subprocess.noneProtocol .spawn(args) .wait() .toString() .then((output) => output.trim()); } async sync(): Promise<AdbSync> { Loading libraries/adb/src/commands/power.ts +5 −2 Original line number Diff line number Diff line Loading @@ -36,7 +36,10 @@ export class AdbPower extends AdbServiceBase { } powerOff(): Promise<string> { return this.adb.subprocess.noneProtocol.spawnWaitText(["reboot", "-p"]); return this.adb.subprocess.noneProtocol .spawn(["reboot", "-p"]) .wait() .toString(); } powerButton(longPress = false): Promise<string> { Loading @@ -46,7 +49,7 @@ export class AdbPower extends AdbServiceBase { } args.push("POWER"); return this.adb.subprocess.noneProtocol.spawnWaitText(args); return this.adb.subprocess.noneProtocol.spawn(args).wait().toString(); } /** Loading libraries/adb/src/commands/subprocess/index.ts +1 −0 Original line number Diff line number Diff line export * from "./none/index.js"; export * from "./service.js"; export * from "./shell/index.js"; export * from "./types.js"; export * from "./utils.js"; libraries/adb/src/commands/subprocess/none/service.ts +17 −16 Original line number Diff line number Diff line Loading @@ -2,16 +2,19 @@ import type { Adb } from "../../../adb.js"; import { AdbNoneProtocolProcessImpl } from "./process.js"; import { AdbNoneProtocolPtyProcess } from "./pty.js"; import { AdbNoneProtocolSpawner } from "./spawner.js"; import { adbNoneProtocolSpawner } from "./spawner.js"; export class AdbNoneProtocolSubprocessService extends AdbNoneProtocolSpawner { export class AdbNoneProtocolSubprocessService { readonly #adb: Adb; get adb(): Adb { return this.#adb; } constructor(adb: Adb) { super(async (command, signal) => { this.#adb = adb; } spawn = adbNoneProtocolSpawner(async (command, signal) => { // `shell,raw:${command}` also triggers raw mode, // But is not supported on Android version <7. const socket = await this.#adb.createSocket( Loading @@ -25,8 +28,6 @@ export class AdbNoneProtocolSubprocessService extends AdbNoneProtocolSpawner { return new AdbNoneProtocolProcessImpl(socket, signal); }); this.#adb = adb; } async pty( command?: string | readonly string[], Loading Loading
libraries/adb-scrcpy/src/client.ts +2 −2 Original line number Diff line number Diff line Loading @@ -144,14 +144,14 @@ export class AdbScrcpyClient<TOptions extends AdbScrcpyOptions<object>> { ]; if (options.spawner) { process = await options.spawner.spawn(args); process = await options.spawner(args); } else { process = await adb.subprocess.noneProtocol.spawn(args); } const output = process.output .pipeThrough(new TextDecoderStream()) .pipeThrough(new SplitStringStream("\n")); .pipeThrough(new SplitStringStream("\n", { trimEnd: true })); // Must read all streams, otherwise the whole connection will be blocked. const lines: string[] = []; Loading
libraries/adb/src/adb.ts +11 −5 Original line number Diff line number Diff line Loading @@ -125,10 +125,12 @@ export class Adb implements Closeable { .pipeThrough(new ConcatStringStream()); } getProp(key: string): Promise<string> { return this.subprocess.noneProtocol .spawnWaitText(["getprop", key]) .then((output) => output.trim()); async getProp(key: string): Promise<string> { const output = await this.subprocess.noneProtocol .spawn(["getprop", key]) .wait() .toString(); return output.trim(); } rm( Loading @@ -154,7 +156,11 @@ export class Adb implements Closeable { // https://android.googlesource.com/platform/packages/modules/adb/+/1a0fb8846d4e6b671c8aa7f137a8c21d7b248716/client/adb_install.cpp#984 args.push("</dev/null"); return this.subprocess.noneProtocol.spawnWaitText(args); return this.subprocess.noneProtocol .spawn(args) .wait() .toString() .then((output) => output.trim()); } async sync(): Promise<AdbSync> { Loading
libraries/adb/src/commands/power.ts +5 −2 Original line number Diff line number Diff line Loading @@ -36,7 +36,10 @@ export class AdbPower extends AdbServiceBase { } powerOff(): Promise<string> { return this.adb.subprocess.noneProtocol.spawnWaitText(["reboot", "-p"]); return this.adb.subprocess.noneProtocol .spawn(["reboot", "-p"]) .wait() .toString(); } powerButton(longPress = false): Promise<string> { Loading @@ -46,7 +49,7 @@ export class AdbPower extends AdbServiceBase { } args.push("POWER"); return this.adb.subprocess.noneProtocol.spawnWaitText(args); return this.adb.subprocess.noneProtocol.spawn(args).wait().toString(); } /** Loading
libraries/adb/src/commands/subprocess/index.ts +1 −0 Original line number Diff line number Diff line export * from "./none/index.js"; export * from "./service.js"; export * from "./shell/index.js"; export * from "./types.js"; export * from "./utils.js";
libraries/adb/src/commands/subprocess/none/service.ts +17 −16 Original line number Diff line number Diff line Loading @@ -2,16 +2,19 @@ import type { Adb } from "../../../adb.js"; import { AdbNoneProtocolProcessImpl } from "./process.js"; import { AdbNoneProtocolPtyProcess } from "./pty.js"; import { AdbNoneProtocolSpawner } from "./spawner.js"; import { adbNoneProtocolSpawner } from "./spawner.js"; export class AdbNoneProtocolSubprocessService extends AdbNoneProtocolSpawner { export class AdbNoneProtocolSubprocessService { readonly #adb: Adb; get adb(): Adb { return this.#adb; } constructor(adb: Adb) { super(async (command, signal) => { this.#adb = adb; } spawn = adbNoneProtocolSpawner(async (command, signal) => { // `shell,raw:${command}` also triggers raw mode, // But is not supported on Android version <7. const socket = await this.#adb.createSocket( Loading @@ -25,8 +28,6 @@ export class AdbNoneProtocolSubprocessService extends AdbNoneProtocolSpawner { return new AdbNoneProtocolProcessImpl(socket, signal); }); this.#adb = adb; } async pty( command?: string | readonly string[], Loading