Program: 162054
Project: 162054
Buggy source:
@Override public final void onSensorChanged(SensorEvent event){
  int type=event.sensor.getType();
  if (type == Sensor.TYPE_PROXIMITY) {
    float lux=event.values[0];
    long tsCurrent=System.currentTimeMillis();
    if (lux != currentSensorValue) {
      currentSensorValue=lux;
      if (tsCurrent - tsLastChange < 2000) {
        swipeCount+=1;
      }
 else {
        swipeCount=1;
        tsLastChange=tsCurrent;
      }
    }
    CV.logv("String_Node_Str",swipeCount);
    CV.logv("String_Node_Str",lux);
    if (isActiveAdmin()) {
      if (handler.hasMessages(CALLBACK_EXISTS)) {
        CV.logv("String_Node_Str");
        resetHandler();
        return;
      }
      if (lux == 0f) {
        if (mPowerManager.isScreenOn()) {
          if (CV.getPrefDisableInLandscape(this) && isOrientationLandscape()) {
            return;
          }
 else {
            long timeout=(long)CV.getPrefTimeoutLock(this);
            if (timeout == 0)             turnOff();
 else             if (timeout == 2) {
              if (swipeCount >= 4) {
                resetSwipeCount();
                turnOff();
              }
            }
 else             if (timeout == 10) {
              return;
            }
 else             handler.postDelayed(runnableTurnOff,timeout);
          }
        }
      }
 else {
        if (!mPowerManager.isScreenOn()) {
          long timeout=(long)CV.getPrefTimeoutUnlock(this);
          if (timeout == 0)           turnOn();
 else           if (timeout == 2) {
            if (swipeCount >= 4) {
              resetSwipeCount();
              turnOn();
            }
          }
 else           if (timeout == 10) {
            return;
          }
 else           handler.postDelayed(runnableTurnOn,timeout);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public final void onSensorChanged(SensorEvent event){
  int type=event.sensor.getType();
  if (type == Sensor.TYPE_PROXIMITY) {
    float lux=event.values[0];
    long tsCurrent=System.currentTimeMillis();
    if (lux != currentSensorValue) {
      currentSensorValue=lux;
      if (tsCurrent - tsLastChange < 2000) {
        swipeCount+=1;
      }
 else {
        swipeCount=1;
        tsLastChange=tsCurrent;
      }
    }
    CV.logv("String_Node_Str",swipeCount);
    CV.logv("String_Node_Str",lux);
    if (isActiveAdmin()) {
      if (handler.hasMessages(CALLBACK_EXISTS)) {
        CV.logv("String_Node_Str");
        resetHandler();
        return;
      }
      if (2 == CV.getPrefTimeoutLock(this)) {
        if (mPowerManager.isScreenOn() && swipeCount >= 4) {
          resetSwipeCount();
          turnOff();
          return;
        }
      }
      if (2 == CV.getPrefTimeoutUnlock(this)) {
        if (!mPowerManager.isScreenOn() && swipeCount >= 4) {
          resetSwipeCount();
          turnOn();
          return;
        }
      }
      if (lux == 0f) {
        if (mPowerManager.isScreenOn()) {
          if (CV.getPrefDisableInLandscape(this) && isOrientationLandscape()) {
            return;
          }
 else {
            long timeout=(long)CV.getPrefTimeoutLock(this);
            if (timeout == 0)             turnOff();
 else             if (timeout == 10 || timeout == 2) {
              return;
            }
 else             handler.postDelayed(runnableTurnOff,timeout);
          }
        }
      }
 else {
        if (!mPowerManager.isScreenOn()) {
          long timeout=(long)CV.getPrefTimeoutUnlock(this);
          if (timeout == 0)           turnOn();
 else           if (timeout == 10 || timeout == 2) {
            return;
          }
 else           handler.postDelayed(runnableTurnOn,timeout);
        }
      }
    }
  }
}