Program: 198607
Project: 198607
Buggy source:
public void noteScreenStateLocked(int state){
  if (mScreenState != state) {
    final int oldState=mScreenState;
    mScreenState=state;
    if (DEBUG)     Slog.v(TAG,"String_Node_Str" + Display.stateToString(oldState) + "String_Node_Str"+ Display.stateToString(state));
    if (state != Display.STATE_UNKNOWN) {
      int stepState=state - 1;
      if (stepState < 4) {
        mModStepMode|=(mCurStepMode & STEP_LEVEL_MODE_SCREEN_STATE) ^ stepState;
        mCurStepMode=(mCurStepMode & ~STEP_LEVEL_MODE_SCREEN_STATE) | stepState;
      }
 else {
        Slog.wtf(TAG,"String_Node_Str" + state);
      }
    }
    mInitStepMode=mCurStepMode;
    mModStepMode=0;
    if (state == Display.STATE_ON) {
      final long elapsedRealtime=SystemClock.elapsedRealtime();
      final long uptime=SystemClock.uptimeMillis();
      mHistoryCur.states|=HistoryItem.STATE_SCREEN_ON_FLAG;
      if (DEBUG_HISTORY)       Slog.v(TAG,"String_Node_Str" + Integer.toHexString(mHistoryCur.states));
      addHistoryRecordLocked(elapsedRealtime,uptime);
      mScreenOnTimer.startRunningLocked(elapsedRealtime);
      if (mScreenBrightnessBin >= 0) {
        mScreenBrightnessTimer[mScreenBrightnessBin].startRunningLocked(elapsedRealtime);
      }
      updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(),false,SystemClock.uptimeMillis() * 1000,elapsedRealtime * 1000);
      noteStartWakeLocked(-1,-1,"String_Node_Str",null,WAKE_TYPE_PARTIAL,false,elapsedRealtime,uptime);
      if (mOnBatteryInternal) {
        updateDischargeScreenLevelsLocked(false,true);
      }
    }
 else     if (oldState == Display.STATE_ON) {
      final long elapsedRealtime=SystemClock.elapsedRealtime();
      final long uptime=SystemClock.uptimeMillis();
      mHistoryCur.states&=~HistoryItem.STATE_SCREEN_ON_FLAG;
      if (DEBUG_HISTORY)       Slog.v(TAG,"String_Node_Str" + Integer.toHexString(mHistoryCur.states));
      addHistoryRecordLocked(elapsedRealtime,uptime);
      mScreenOnTimer.stopRunningLocked(elapsedRealtime);
      if (mScreenBrightnessBin >= 0) {
        mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(elapsedRealtime);
      }
      noteStopWakeLocked(-1,-1,"String_Node_Str","String_Node_Str",WAKE_TYPE_PARTIAL,elapsedRealtime,uptime);
      updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(),true,SystemClock.uptimeMillis() * 1000,elapsedRealtime * 1000);
      if (mOnBatteryInternal) {
        updateDischargeScreenLevelsLocked(true,false);
      }
    }
  }
}

Fixed version (ground truth):
public void noteScreenStateLocked(int state){
  if (mScreenState != state) {
    final int oldState=mScreenState;
    mScreenState=state;
    if (DEBUG)     Slog.v(TAG,"String_Node_Str" + Display.stateToString(oldState) + "String_Node_Str"+ Display.stateToString(state));
    if (state != Display.STATE_UNKNOWN) {
      int stepState=state - 1;
      if (stepState < 4) {
        mModStepMode|=(mCurStepMode & STEP_LEVEL_MODE_SCREEN_STATE) ^ stepState;
        mCurStepMode=(mCurStepMode & ~STEP_LEVEL_MODE_SCREEN_STATE) | stepState;
      }
 else {
        Slog.wtf(TAG,"String_Node_Str" + state);
      }
    }
    if (state == Display.STATE_ON) {
      final long elapsedRealtime=SystemClock.elapsedRealtime();
      final long uptime=SystemClock.uptimeMillis();
      mHistoryCur.states|=HistoryItem.STATE_SCREEN_ON_FLAG;
      if (DEBUG_HISTORY)       Slog.v(TAG,"String_Node_Str" + Integer.toHexString(mHistoryCur.states));
      addHistoryRecordLocked(elapsedRealtime,uptime);
      mScreenOnTimer.startRunningLocked(elapsedRealtime);
      if (mScreenBrightnessBin >= 0) {
        mScreenBrightnessTimer[mScreenBrightnessBin].startRunningLocked(elapsedRealtime);
      }
      updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(),false,SystemClock.uptimeMillis() * 1000,elapsedRealtime * 1000);
      noteStartWakeLocked(-1,-1,"String_Node_Str",null,WAKE_TYPE_PARTIAL,false,elapsedRealtime,uptime);
      if (mOnBatteryInternal) {
        updateDischargeScreenLevelsLocked(false,true);
      }
    }
 else     if (oldState == Display.STATE_ON) {
      final long elapsedRealtime=SystemClock.elapsedRealtime();
      final long uptime=SystemClock.uptimeMillis();
      mHistoryCur.states&=~HistoryItem.STATE_SCREEN_ON_FLAG;
      if (DEBUG_HISTORY)       Slog.v(TAG,"String_Node_Str" + Integer.toHexString(mHistoryCur.states));
      addHistoryRecordLocked(elapsedRealtime,uptime);
      mScreenOnTimer.stopRunningLocked(elapsedRealtime);
      if (mScreenBrightnessBin >= 0) {
        mScreenBrightnessTimer[mScreenBrightnessBin].stopRunningLocked(elapsedRealtime);
      }
      noteStopWakeLocked(-1,-1,"String_Node_Str","String_Node_Str",WAKE_TYPE_PARTIAL,elapsedRealtime,uptime);
      updateTimeBasesLocked(mOnBatteryTimeBase.isRunning(),true,SystemClock.uptimeMillis() * 1000,elapsedRealtime * 1000);
      if (mOnBatteryInternal) {
        updateDischargeScreenLevelsLocked(true,false);
      }
    }
  }
}