feat(adb): support connect to adb server (#549)

This commit is contained in:
Simon Chan 2023-05-14 03:54:03 +08:00 committed by GitHub
parent c34eef1d89
commit 3beaad2055
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
111 changed files with 2926 additions and 1701 deletions

View file

@ -1,7 +1,7 @@
import { AdbCommandBase } from "./base.js";
export class AdbTcpIpCommand extends AdbCommandBase {
public async setPort(port: number): Promise<void> {
public async setPort(port: number): Promise<string> {
if (port <= 0) {
throw new Error(`Invalid port ${port}`);
}
@ -10,12 +10,14 @@ export class AdbTcpIpCommand extends AdbCommandBase {
if (output !== `restarting in TCP mode port: ${port}\n`) {
throw new Error("Invalid response");
}
return output;
}
public async disable(): Promise<void> {
public async disable(): Promise<string> {
const output = await this.adb.createSocketAndWait("usb:");
if (output !== "restarting in USB mode\n") {
throw new Error("Invalid response");
}
return output;
}
}