Example #1
0
File: adb.js Project: jld/gecko-dev
  async _stopTracking() {
    clearInterval(this._timer);
    this._isTrackingDevices = false;
    this._trackDevicesCommand.stop();

    this._devices = new Map();
    this._runtimes = [];
    this.updateRuntimes();
  }
Example #2
0
  async _startAdb() {
    this._isTrackingDevices = true;
    await adbProcess.start();

    this._trackDevicesCommand.run();

    // Device runtimes are detected by running a shell command and checking for
    // "firefox-debugger-socket" in the list of currently running processes.
    this._timer = setInterval(this.updateRuntimes.bind(this), UPDATE_RUNTIMES_INTERVAL);
  }
Example #3
0
    return new Promise((resolve, reject) => {
      if (!this.ready) {
        setTimeout(function() {
          reject("ADB_NOT_READY");
        });
        return;
      }

      const socket = client.connect();

      socket.s.onopen = function() {
        dumpn("runCommand onopen");
        const req = client.createRequest(command);
        socket.send(req);
      };

      socket.s.onerror = function() {
        dumpn("runCommand onerror");
        reject("NETWORK_ERROR");
      };

      socket.s.onclose = function() {
        dumpn("runCommand onclose");
      };

      socket.s.ondata = function(event) {
        dumpn("runCommand ondata");
        const data = event.data;

        const packet = client.unpackPacket(data, false);
        if (!client.checkResponse(data, OKAY)) {
          socket.close();
          dumpn("Error: " + packet.data);
          reject("PROTOCOL_ERROR");
          return;
        }

        resolve(packet.data);
      };
    });
Example #4
0
    socket.s.onclose = function() {
      dumpn("trackDevices onclose");

      // Report all devices as disconnected
      for (const dev in devices) {
        devices[dev] = false;
        EventEmitter.emit(ADB, "device-disconnected", dev);
      }

      Services.obs.notifyObservers(null, "adb-track-devices-stop");

      // When we lose connection to the server,
      // and the adb is still on, we most likely got our server killed
      // by local adb. So we do try to reconnect to it.
      setTimeout(function() { // Give some time to the new adb to start
        if (ADB.ready) { // Only try to reconnect/restart if the add-on is still enabled
          ADB.start().then(function() { // try to connect to the new local adb server
                                         // or, spawn a new one
            ADB.trackDevices(); // Re-track devices
          });
        }
      }, 2000);
    };
Example #5
0
 await new Promise(resolve => setTimeout(resolve, 100));