cess running, not restarting"); onSuccessfulStart(); return; } dumpn("Didn't find ADB process running, restarting"); this._didRunInitially = true; const process = Cc["@mozilla.org/process/util;1"].createInstance( Ci.nsIProcess ); // FIXME: Bug 1481691 - We should avoid extracting files every time. const adbFile = await this._getAdbFile(); process.init(adbFile); // Hide command prompt window on Windows process.startHidden = true; process.noShell = true; const params = ["start-server"]; let isStarted = false; try { await this._runProcess(process, params); isStarted = await waitUntil(check); } catch (e) {} if (isStarted) { onSuccessfulStart(); } else { this._ready = false; throw new Error("ADB Process didn't start"); } } /** * Stop the ADB server, but only if we started it. If it was started before * us, we return immediately. */ async stop() { if (!this._didRunInitially) { return; // We didn't start the server, nothing to do } await this.kill(); } /** * Kill the ADB server. */ async kill() { try { await runCommand("host:kill"); } catch (e) { dumpn("Failed to send host:kill command"); } dumpn("adb server was terminated by host:kill"); this._ready = false; this._didRunInitially = false; } } exports.adbProcess = new AdbProcess(); PK