Program: 193432
Project: 193432
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:
    startMonitoringMotionLocked();
  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);
if (mLocationManager != null && mLocationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null) {
mLocationManager.requestLocationUpdates(mLocationRequest,mGenericLocationListener,mHandler.getLooper());
mLocating=true;
}
 else {
mHasNetworkLocation=false;
}
if (mLocationManager != null && mLocationManager.getProvider(LocationManager.GPS_PROVIDER) != null) {
mHasGps=true;
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,5,mGpsLocationListener,mHandler.getLooper());
mLocating=true;
}
 else {
mHasGps=false;
}
if (mLocating) {
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:
    startMonitoringMotionLocked();
  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);
if (mLocationManager != null && mLocationManager.getProvider(LocationManager.NETWORK_PROVIDER) != null) {
mLocationManager.requestLocationUpdates(mLocationRequest,mGenericLocationListener,mHandler.getLooper());
mLocating=true;
}
 else {
mHasNetworkLocation=false;
}
if (mLocationManager != null && mLocationManager.getProvider(LocationManager.GPS_PROVIDER) != null) {
mHasGps=true;
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,5,mGpsLocationListener,mHandler.getLooper());
mLocating=true;
}
 else {
mHasGps=false;
}
if (mLocating) {
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;
}
}