Program: 193436
Project: 193436
Buggy source:
void stepIdleStateLocked(){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + mState);
  EventLogTags.writeDeviceIdleStep();
  final long now=SystemClock.elapsedRealtime();
  if ((now + mConstants.MIN_TIME_TO_ALARM) > mAlarmManager.getNextWakeFromIdleTime()) {
    if (mState != STATE_ACTIVE) {
      becomeActiveLocked("String_Node_Str",Process.myUid());
    }
    return;
  }
switch (mState) {
case STATE_INACTIVE:
    startMonitoringSignificantMotion();
  scheduleAlarmLocked(mConstants.IDLE_AFTER_INACTIVE_TIMEOUT,false);
mNextIdlePendingDelay=mConstants.IDLE_PENDING_TIMEOUT;
mNextIdleDelay=mConstants.IDLE_TIMEOUT;
mState=STATE_IDLE_PENDING;
if (DEBUG) Slog.d(TAG,"String_Node_Str");
EventLogTags.writeDeviceIdle(mState,"String_Node_Str");
break;
case STATE_IDLE_PENDING:
mState=STATE_SENSING;
if (DEBUG) Slog.d(TAG,"String_Node_Str");
EventLogTags.writeDeviceIdle(mState,"String_Node_Str");
scheduleSensingAlarmLocked(mConstants.SENSING_TIMEOUT);
cancelSensingAlarmLocked();
cancelLocatingLocked();
mAnyMotionDetector.checkForAnyMotion();
mNotMoving=false;
mLocated=false;
mLastGenericLocation=null;
mLastGpsLocation=null;
break;
case STATE_SENSING:
mState=STATE_LOCATING;
if (DEBUG) Slog.d(TAG,"String_Node_Str");
EventLogTags.writeDeviceIdle(mState,"String_Node_Str");
cancelSensingAlarmLocked();
scheduleSensingAlarmLocked(mConstants.LOCATING_TIMEOUT);
mLocating=true;
mLocationManager.requestLocationUpdates(mLocationRequest,mGenericLocationListener,mHandler.getLooper());
if (mLocationManager.getProvider(LocationManager.GPS_PROVIDER) != null) {
mHaveGps=true;
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,5,mGpsLocationListener,mHandler.getLooper());
}
 else {
mHaveGps=false;
}
break;
case STATE_LOCATING:
cancelSensingAlarmLocked();
cancelLocatingLocked();
mAnyMotionDetector.stop();
case STATE_IDLE_MAINTENANCE:
scheduleAlarmLocked(mNextIdleDelay,true);
if (DEBUG) Slog.d(TAG,"String_Node_Str" + mNextIdleDelay + "String_Node_Str");
mNextIdleDelay=(long)(mNextIdleDelay * mConstants.IDLE_FACTOR);
if (DEBUG) Slog.d(TAG,"String_Node_Str" + mNextIdleDelay);
mNextIdleDelay=Math.min(mNextIdleDelay,mConstants.MAX_IDLE_TIMEOUT);
mState=STATE_IDLE;
EventLogTags.writeDeviceIdle(mState,"String_Node_Str");
mHandler.sendEmptyMessage(MSG_REPORT_IDLE_ON);
break;
case STATE_IDLE:
scheduleAlarmLocked(mNextIdlePendingDelay,false);
if (DEBUG) Slog.d(TAG,"String_Node_Str" + "String_Node_Str" + mNextIdlePendingDelay + "String_Node_Str");
mNextIdlePendingDelay=Math.min(mConstants.MAX_IDLE_PENDING_TIMEOUT,(long)(mNextIdlePendingDelay * mConstants.IDLE_PENDING_FACTOR));
mState=STATE_IDLE_MAINTENANCE;
EventLogTags.writeDeviceIdle(mState,"String_Node_Str");
mHandler.sendEmptyMessage(MSG_REPORT_IDLE_OFF);
break;
}
}

Fixed version (ground truth):
void stepIdleStateLocked(){
  if (DEBUG)   Slog.d(TAG,"String_Node_Str" + mState);
  EventLogTags.writeDeviceIdleStep();
  final long now=SystemClock.elapsedRealtime();
  if ((now + mConstants.MIN_TIME_TO_ALARM) > mAlarmManager.getNextWakeFromIdleTime()) {
    if (mState != STATE_ACTIVE) {
      becomeActiveLocked("String_Node_Str",Process.myUid());
    }
    return;
  }
switch (mState) {
case STATE_INACTIVE:
    startMonitoringSignificantMotion();
  scheduleAlarmLocked(mConstants.IDLE_AFTER_INACTIVE_TIMEOUT,false);
mNextIdlePendingDelay=mConstants.IDLE_PENDING_TIMEOUT;
mNextIdleDelay=mConstants.IDLE_TIMEOUT;
mState=STATE_IDLE_PENDING;
if (DEBUG) Slog.d(TAG,"String_Node_Str");
EventLogTags.writeDeviceIdle(mState,"String_Node_Str");
break;
case STATE_IDLE_PENDING:
mState=STATE_SENSING;
if (DEBUG) Slog.d(TAG,"String_Node_Str");
EventLogTags.writeDeviceIdle(mState,"String_Node_Str");
scheduleSensingAlarmLocked(mConstants.SENSING_TIMEOUT);
cancelLocatingLocked();
mAnyMotionDetector.checkForAnyMotion();
mNotMoving=false;
mLocated=false;
mLastGenericLocation=null;
mLastGpsLocation=null;
break;
case STATE_SENSING:
mState=STATE_LOCATING;
if (DEBUG) Slog.d(TAG,"String_Node_Str");
EventLogTags.writeDeviceIdle(mState,"String_Node_Str");
scheduleSensingAlarmLocked(mConstants.LOCATING_TIMEOUT);
mLocating=true;
mLocationManager.requestLocationUpdates(mLocationRequest,mGenericLocationListener,mHandler.getLooper());
if (mLocationManager.getProvider(LocationManager.GPS_PROVIDER) != null) {
mHaveGps=true;
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,5,mGpsLocationListener,mHandler.getLooper());
}
 else {
mHaveGps=false;
}
break;
case STATE_LOCATING:
cancelSensingAlarmLocked();
cancelLocatingLocked();
mAnyMotionDetector.stop();
case STATE_IDLE_MAINTENANCE:
scheduleAlarmLocked(mNextIdleDelay,true);
if (DEBUG) Slog.d(TAG,"String_Node_Str" + mNextIdleDelay + "String_Node_Str");
mNextIdleDelay=(long)(mNextIdleDelay * mConstants.IDLE_FACTOR);
if (DEBUG) Slog.d(TAG,"String_Node_Str" + mNextIdleDelay);
mNextIdleDelay=Math.min(mNextIdleDelay,mConstants.MAX_IDLE_TIMEOUT);
mState=STATE_IDLE;
EventLogTags.writeDeviceIdle(mState,"String_Node_Str");
mHandler.sendEmptyMessage(MSG_REPORT_IDLE_ON);
break;
case STATE_IDLE:
scheduleAlarmLocked(mNextIdlePendingDelay,false);
if (DEBUG) Slog.d(TAG,"String_Node_Str" + "String_Node_Str" + mNextIdlePendingDelay + "String_Node_Str");
mNextIdlePendingDelay=Math.min(mConstants.MAX_IDLE_PENDING_TIMEOUT,(long)(mNextIdlePendingDelay * mConstants.IDLE_PENDING_FACTOR));
mState=STATE_IDLE_MAINTENANCE;
EventLogTags.writeDeviceIdle(mState,"String_Node_Str");
mHandler.sendEmptyMessage(MSG_REPORT_IDLE_OFF);
break;
}
}