/** {@inheritDoc} */
  public void notifyTestingDeviceDisconnected() {
    Log.d("Test.notifyTestingDeviceDisconnected() is called");
    if (mProgressObserver != null) {
      mProgressObserver.stop();
    }

    if (mTimeOutTimer != null) {
      synchronized (mTimeOutTimer) {
        mTimeOutTimer.cancel(false);
        mTimeOutTimer.sendNotify();
      }
    }
  }
  /**
   * Run the test over device given.
   *
   * @param device the device to run the test.
   */
  public void run(final TestDevice device)
      throws DeviceDisconnectedException, ADBServerNeedRestartException {

    if ((getName() == null) || (getName().length() == 0)) {
      return;
    }

    if (TestSession.exceedsMaxCount()) {
      throw new ADBServerNeedRestartException("Test count reached overflow point");
    } else {
      TestSession.incTestCount();
    }

    mTestStop = false;
    mDevice = device;
    mTimeOutTimer =
        new HostTimer(new TimeOutTask(this), HostConfig.Ints.individualStartTimeoutMs.value());
    mTimeOutTimer.start();
    mProgressObserver = new ProgressObserver();
    mProgressObserver.start();

    setStartTime(System.currentTimeMillis());
    String testFullName = getFullName();
    print(testFullName + "...");

    runImpl();

    synchronized (mTimeOutTimer) {
      if (!mTestStop) {
        try {
          mTimeOutTimer.waitOn();
        } catch (InterruptedException e) {
          Log.d("time out object interrupted");
        }
      }

      mProgressObserver.stop();
      if (mTimeOutTimer.isTimeOut()) {
        return;
      } else {
        // not caused by timer timing out
        // need to cancel timer
        mTimeOutTimer.cancel(false);
      }
    }

    setResult(mResult);
  }
  /**
   * Notify the result.
   *
   * @param result The result.
   */
  public void notifyResult(CtsTestResult result) {

    Log.d("Test.notifyResult() is called. (Test.getFullName()=" + getFullName());
    mResult = result;
    if (mTimeOutTimer != null) {
      synchronized (mTimeOutTimer) {
        // set result again in case timeout just happened
        mResult = result;
        Log.d("notifyUpdateResult() detects that it needs to cancel mTimeOutTimer");
        if (mTimeOutTimer != null) {
          mTimeOutTimer.sendNotify();
        }
      }
    }
  }