refactor: improve readability

This commit is contained in:
Simon Chan 2023-04-12 03:37:27 +08:00
parent c5786fefd9
commit 094b859791
No known key found for this signature in database
GPG key ID: A8B69F750B9BCEDD
4 changed files with 55 additions and 68 deletions

View file

@ -38,27 +38,27 @@ export class Cmd extends AdbCommandBase {
command: string,
...args: string[]
) {
let supportAbb: boolean;
let supportCmd: boolean = this.supportsCmd;
let supportsAbb: boolean;
let supportsCmd: boolean = this.supportsCmd;
let service: string;
let Protocol: AdbSubprocessProtocolConstructor;
if (shellProtocol) {
supportAbb = this._supportsAbb;
supportCmd &&= this.supportsShellV2;
supportsAbb = this._supportsAbb;
supportsCmd &&= this.supportsShellV2;
service = "abb";
Protocol = AdbSubprocessShellProtocol;
} else {
supportAbb = this._supportsAbbExec;
supportsAbb = this._supportsAbbExec;
service = "abb_exec";
Protocol = AdbSubprocessNoneProtocol;
}
if (supportAbb) {
if (supportsAbb) {
const socket = await this.adb.createSocket(
`${service}:${command}\0${args.join("\0")}\0`
);
return new Protocol(socket);
} else if (supportCmd) {
} else if (supportsCmd) {
return Protocol.raw(this.adb, `cmd ${command} ${args.join(" ")}`);
} else {
throw new Error("Not supported");