Esempio n. 1
0
  public void kill(boolean force) {
    int trycount = 4;

    if (workingProcess != null && running) {

      Log.writeByLevel(LogLevel.CORE, "Trying to stop logcat process");

      consume = false;

      while (consumeWorker.getState() != Thread.State.TERMINATED) {

        if (force) {
          internalStop();
          return;
        }

        Log.writeByLevel(LogLevel.CORE, "Waiting worker thread to finish #%d", trycount);

        try {
          workerLock.waitForLock(100);
        } catch (TimedOutException e) {
          if (trycount <= 0) {
            Log.writeByLevel(LogLevel.CORE, "Thread finish wait threshold limit exceeded.");
            internalStop();
            return;
          }

          trycount--;
        }
      }

      internalStop();
    }
  }
Esempio n. 2
0
  public boolean start() {
    workerLock.lock();
    processStartWaitLock.lock();

    Log.writeByLevel(LogLevel.CORE, "Starting adb process worker thread");

    consumeWorker = new Thread(this);
    consumeWorker.start();

    Log.writeByLevel(LogLevel.CORE, "Waiting process to be ready");

    try {
      processStartWaitLock.waitForLock(10 * 1000);
    } catch (TimedOutException e) {
      Log.writeByLevel(LogLevel.CORE, "process start wait timed out!");
      return false;
    }

    Log.writeByLevel(LogLevel.CORE, "It seems ok");

    return isRunning();
  }