Program: 183784
Project: 183784
Buggy source:
/** 
 * Registers a   {@link android.hardware.SensorEventListener SensorEventListener}for the given sensor.
 * @param listener A {@link android.hardware.SensorEventListener SensorEventListener} object.
 * @param sensor The {@link android.hardware.Sensor Sensor} to register to.
 * @param rate The rate {@link android.hardware.SensorEvent sensor events} are delivered at.This is only a hint to the system. Events may be received faster or slower than the specified rate. Usually events are received faster.
 * @param handler The {@link android.os.Handler Handler} the{@link android.hardware.SensorEvent sensor events} will be delivered to.
 * @return true if the sensor is supported and successfully enabled.
 */
public boolean registerListener(SensorEventListener listener,Sensor sensor,int rate,Handler handler){
  if (listener == null || sensor == null) {
    return false;
  }
  boolean result;
  int delay=-1;
switch (rate) {
case SENSOR_DELAY_FASTEST:
    delay=0;
  break;
case SENSOR_DELAY_GAME:
delay=20;
break;
case SENSOR_DELAY_UI:
delay=60;
break;
case SENSOR_DELAY_NORMAL:
delay=200;
break;
default :
return false;
}
try {
synchronized (sListeners) {
ListenerDelegate l=null;
for (ListenerDelegate i : sListeners) {
if (i.getListener() == listener) {
l=i;
break;
}
}
String name=sensor.getName();
int handle=sensor.getHandle();
if (l == null) {
l=new ListenerDelegate(listener,sensor,handler);
result=mSensorService.enableSensor(l,name,handle,delay);
if (result) {
sListeners.add(l);
sListeners.notify();
}
if (!sListeners.isEmpty()) {
sSensorThread.startLocked(mSensorService);
}
}
 else {
result=mSensorService.enableSensor(l,name,handle,delay);
if (result) {
l.addSensor(sensor);
}
}
}
}
 catch (RemoteException e) {
Log.e(TAG,"String_Node_Str",e);
result=false;
}
return result;
}

Fixed version (ground truth):
/** 
 * Registers a   {@link android.hardware.SensorEventListener SensorEventListener}for the given sensor.
 * @param listener A {@link android.hardware.SensorEventListener SensorEventListener} object.
 * @param sensor The {@link android.hardware.Sensor Sensor} to register to.
 * @param rate The rate {@link android.hardware.SensorEvent sensor events} are delivered at.This is only a hint to the system. Events may be received faster or slower than the specified rate. Usually events are received faster. The value must be one of  {@link #SENSOR_DELAY_NORMAL},   {@link #SENSOR_DELAY_UI},   {@link #SENSOR_DELAY_GAME}, or  {@link #SENSOR_DELAY_FASTEST}.
 * @param handler The {@link android.os.Handler Handler} the{@link android.hardware.SensorEvent sensor events} will be delivered to.
 * @return true if the sensor is supported and successfully enabled.
 */
public boolean registerListener(SensorEventListener listener,Sensor sensor,int rate,Handler handler){
  if (listener == null || sensor == null) {
    return false;
  }
  boolean result;
  int delay=-1;
switch (rate) {
case SENSOR_DELAY_FASTEST:
    delay=0;
  break;
case SENSOR_DELAY_GAME:
delay=20;
break;
case SENSOR_DELAY_UI:
delay=60;
break;
case SENSOR_DELAY_NORMAL:
delay=200;
break;
default :
return false;
}
try {
synchronized (sListeners) {
ListenerDelegate l=null;
for (ListenerDelegate i : sListeners) {
if (i.getListener() == listener) {
l=i;
break;
}
}
String name=sensor.getName();
int handle=sensor.getHandle();
if (l == null) {
l=new ListenerDelegate(listener,sensor,handler);
result=mSensorService.enableSensor(l,name,handle,delay);
if (result) {
sListeners.add(l);
sListeners.notify();
}
if (!sListeners.isEmpty()) {
sSensorThread.startLocked(mSensorService);
}
}
 else {
result=mSensorService.enableSensor(l,name,handle,delay);
if (result) {
l.addSensor(sensor);
}
}
}
}
 catch (RemoteException e) {
Log.e(TAG,"String_Node_Str",e);
result=false;
}
return result;
}