nus-yam/ex-repair huggingface dataset:
Program: 94819
Project: 94819
Buggy source:
/** 
 * Initiate a magnetometer calibration
 * @param drone vehicle to calibrate
 * @param retryOnFailure if true, automatically retry the magnetometer calibration if it fails
 * @param saveAutomatically if true, save the calibration automatically without user input.
 * @param startDelay positive delay in seconds before starting the calibration
 */
public static void startMagnetometerCalibration(Drone drone,boolean retryOnFailure,boolean saveAutomatically,int startDelay){
  msg_command_long msg=new msg_command_long();
  msg.target_system=drone.getSysid();
  msg.target_component=drone.getCompid();
  msg.command=(short)MAV_CMD.MAV_CMD_DO_START_MAG_CAL;
  msg.param1=0;
  msg.param2=retryOnFailure ? 1 : 0;
  msg.param3=saveAutomatically ? 1 : 0;
  msg.param4=startDelay > 0 ? startDelay : 0;
  msg.param5=0;
  msg.param6=0;
  msg.param7=0;
  drone.getMavClient().sendMavPacket(msg.pack());
}

Fixed version (ground truth):
/** 
 * Initiate a magnetometer calibration
 * @param drone vehicle to calibrate
 * @param retryOnFailure if true, automatically retry the magnetometer calibration if it fails
 * @param saveAutomatically if true, save the calibration automatically without user input.
 * @param startDelay positive delay in seconds before starting the calibration
 */
public static void startMagnetometerCalibration(Drone drone,boolean retryOnFailure,boolean saveAutomatically,int startDelay){
  msg_command_long msg=new msg_command_long();
  msg.target_system=drone.getSysid();
  msg.target_component=drone.getCompid();
  msg.command=MAV_CMD.MAV_CMD_DO_START_MAG_CAL;
  msg.param1=0;
  msg.param2=retryOnFailure ? 1 : 0;
  msg.param3=saveAutomatically ? 1 : 0;
  msg.param4=startDelay > 0 ? startDelay : 0;
  msg.param5=0;
  msg.param6=0;
  msg.param7=0;
  drone.getMavClient().sendMavPacket(msg.pack());
}
Program: 94820
Project: 94820
Buggy source:
/** 
 * Accept the magnetometer calibration result.
 * @param drone
 */
public static void acceptMagnetometerCalibration(Drone drone){
  msg_command_long msg=new msg_command_long();
  msg.target_system=drone.getSysid();
  msg.target_component=drone.getCompid();
  msg.command=(short)MAV_CMD.MAV_CMD_DO_ACCEPT_MAG_CAL;
  msg.param1=0;
  msg.param2=0;
  msg.param3=0;
  msg.param4=0;
  msg.param5=0;
  msg.param6=0;
  msg.param7=0;
  drone.getMavClient().sendMavPacket(msg.pack());
}

Fixed version (ground truth):
/** 
 * Accept the magnetometer calibration result.
 * @param drone
 */
public static void acceptMagnetometerCalibration(Drone drone){
  msg_command_long msg=new msg_command_long();
  msg.target_system=drone.getSysid();
  msg.target_component=drone.getCompid();
  msg.command=MAV_CMD.MAV_CMD_DO_ACCEPT_MAG_CAL;
  msg.param1=0;
  msg.param2=0;
  msg.param3=0;
  msg.param4=0;
  msg.param5=0;
  msg.param6=0;
  msg.param7=0;
  drone.getMavClient().sendMavPacket(msg.pack());
}
Program: 94821
Project: 94821
Buggy source:
/** 
 * Cancel the running magnetometer calibration.˛
 * @param drone
 */
public static void cancelMagnetometerCalibration(Drone drone){
  msg_command_long msg=new msg_command_long();
  msg.target_system=drone.getSysid();
  msg.target_component=drone.getCompid();
  msg.command=(short)MAV_CMD.MAV_CMD_DO_CANCEL_MAG_CAL;
  msg.param1=0;
  msg.param2=0;
  msg.param3=0;
  msg.param4=0;
  msg.param5=0;
  msg.param6=0;
  msg.param7=0;
  drone.getMavClient().sendMavPacket(msg.pack());
}

Fixed version (ground truth):
/** 
 * Cancel the running magnetometer calibration.˛
 * @param drone
 */
public static void cancelMagnetometerCalibration(Drone drone){
  msg_command_long msg=new msg_command_long();
  msg.target_system=drone.getSysid();
  msg.target_component=drone.getCompid();
  msg.command=MAV_CMD.MAV_CMD_DO_CANCEL_MAG_CAL;
  msg.param1=0;
  msg.param2=0;
  msg.param3=0;
  msg.param4=0;
  msg.param5=0;
  msg.param6=0;
  msg.param7=0;
  drone.getMavClient().sendMavPacket(msg.pack());
}
Program: 94822
Project: 94822
Buggy source:
private void checkArmState(msg_heartbeat msg_heart){
  drone.getState().setArmed((msg_heart.base_mode & (byte)MAV_MODE_FLAG.MAV_MODE_FLAG_SAFETY_ARMED) == (byte)MAV_MODE_FLAG.MAV_MODE_FLAG_SAFETY_ARMED);
}

Fixed version (ground truth):
private void checkArmState(msg_heartbeat msg_heart){
  drone.getState().setArmed((msg_heart.base_mode & MAV_MODE_FLAG.MAV_MODE_FLAG_SAFETY_ARMED) == MAV_MODE_FLAG.MAV_MODE_FLAG_SAFETY_ARMED);
}
Program: 94823
Project: 94823
Buggy source:
private void checkIfFlying(msg_heartbeat msg_heart){
  final byte systemStatus=msg_heart.system_status;
  final boolean wasFlying=drone.getState().isFlying();
  final boolean isFlying=systemStatus == MAV_STATE.MAV_STATE_ACTIVE || (wasFlying && (systemStatus == MAV_STATE.MAV_STATE_CRITICAL || systemStatus == MAV_STATE.MAV_STATE_EMERGENCY));
  drone.getState().setIsFlying(isFlying);
}

Fixed version (ground truth):
private void checkIfFlying(msg_heartbeat msg_heart){
  final short systemStatus=msg_heart.system_status;
  final boolean wasFlying=drone.getState().isFlying();
  final boolean isFlying=systemStatus == MAV_STATE.MAV_STATE_ACTIVE || (wasFlying && (systemStatus == MAV_STATE.MAV_STATE_CRITICAL || systemStatus == MAV_STATE.MAV_STATE_EMERGENCY));
  drone.getState().setIsFlying(isFlying);
}
Program: 94824
Project: 94824
Buggy source:
private void checkFailsafe(msg_heartbeat msg_heart){
  boolean failsafe2=msg_heart.system_status == (byte)MAV_STATE.MAV_STATE_CRITICAL || msg_heart.system_status == MAV_STATE.MAV_STATE_EMERGENCY;
  if (failsafe2) {
    drone.getState().repeatWarning();
  }
}

Fixed version (ground truth):
private void checkFailsafe(msg_heartbeat msg_heart){
  boolean failsafe2=msg_heart.system_status == MAV_STATE.MAV_STATE_CRITICAL || msg_heart.system_status == MAV_STATE.MAV_STATE_EMERGENCY;
  if (failsafe2) {
    drone.getState().repeatWarning();
  }
}
Program: 94825
Project: 94825
Buggy source:
private static void requestMavlinkDataStream(MAVLinkOutputStream mAVClient,byte sysid,byte compid,int stream_id,int rate){
  msg_request_data_stream msg=new msg_request_data_stream();
  msg.target_system=sysid;
  msg.target_component=compid;
  msg.req_message_rate=(short)rate;
  msg.req_stream_id=(byte)stream_id;
  if (rate > 0) {
    msg.start_stop=1;
  }
 else {
    msg.start_stop=0;
  }
  mAVClient.sendMavPacket(msg.pack());
}

Fixed version (ground truth):
private static void requestMavlinkDataStream(MAVLinkOutputStream mAVClient,byte sysid,byte compid,int stream_id,int rate){
  msg_request_data_stream msg=new msg_request_data_stream();
  msg.target_system=sysid;
  msg.target_component=compid;
  msg.req_message_rate=rate;
  msg.req_stream_id=(short)stream_id;
  if (rate > 0) {
    msg.start_stop=1;
  }
 else {
    msg.start_stop=0;
  }
  mAVClient.sendMavPacket(msg.pack());
}
Program: 94826
Project: 94826
Buggy source:
public static void sendWaypointCount(Drone drone,int count){
  msg_mission_count msg=new msg_mission_count();
  msg.target_system=drone.getSysid();
  msg.target_component=drone.getCompid();
  msg.count=(short)count;
  drone.getMavClient().sendMavPacket(msg.pack());
}

Fixed version (ground truth):
public static void sendWaypointCount(Drone drone,int count){
  msg_mission_count msg=new msg_mission_count();
  msg.target_system=drone.getSysid();
  msg.target_component=drone.getCompid();
  msg.count=count;
  drone.getMavClient().sendMavPacket(msg.pack());
}
Program: 94827
Project: 94827
Buggy source:
public static void requestWayPoint(Drone drone,int index){
  msg_mission_request msg=new msg_mission_request();
  msg.target_system=drone.getSysid();
  msg.target_component=drone.getCompid();
  msg.seq=(short)index;
  drone.getMavClient().sendMavPacket(msg.pack());
}

Fixed version (ground truth):
public static void requestWayPoint(Drone drone,int index){
  msg_mission_request msg=new msg_mission_request();
  msg.target_system=drone.getSysid();
  msg.target_component=drone.getCompid();
  msg.seq=index;
  drone.getMavClient().sendMavPacket(msg.pack());
}
Program: 94828
Project: 94828
Buggy source:
/** 
 * Callback for a change in the current waypoint the MAV is heading for
 * @param seq number of the updated waypoint
 */
private void onCurrentWaypointUpdate(short seq){
}

Fixed version (ground truth):
/** 
 * Callback for a change in the current waypoint the MAV is heading for
 * @param seq number of the updated waypoint
 */
private void onCurrentWaypointUpdate(int seq){
}
Program: 94829
Project: 94829
Buggy source:
public abstract void onResponse(byte commandId,boolean success);

Fixed version (ground truth):
public abstract void onResponse(short commandId,boolean success);
Program: 94830
Project: 94830
Buggy source:
public void startRecording(){
  if (!isConnected() || isRecording())   return;
  sendSetRequest(GOPRO_COMMAND.GOPRO_COMMAND_SHUTTER,1,new SetResponseHandler(){
    @Override public void onResponse(    byte commandId,    boolean success){
      if (success != isRecording) {
        isRecording=success;
        drone.notifyDroneEvent(DroneEventsType.GOPRO_STATUS_UPDATE);
      }
    }
  }
);
}

Fixed version (ground truth):
public void startRecording(){
  if (!isConnected() || isRecording())   return;
  sendSetRequest(GOPRO_COMMAND.GOPRO_COMMAND_SHUTTER,1,new SetResponseHandler(){
    @Override public void onResponse(    short commandId,    boolean success){
      if (success != isRecording) {
        isRecording=success;
        drone.notifyDroneEvent(DroneEventsType.GOPRO_STATUS_UPDATE);
      }
    }
  }
);
}
Program: 94831
Project: 94831
Buggy source:
public void stopRecording(){
  if (!isConnected() || !isRecording())   return;
  sendSetRequest(GOPRO_COMMAND.GOPRO_COMMAND_SHUTTER,0,new SetResponseHandler(){
    @Override public void onResponse(    byte commandId,    boolean success){
      if (success == isRecording) {
        isRecording=!success;
        drone.notifyDroneEvent(DroneEventsType.GOPRO_STATUS_UPDATE);
      }
    }
  }
);
}

Fixed version (ground truth):
public void stopRecording(){
  if (!isConnected() || !isRecording())   return;
  sendSetRequest(GOPRO_COMMAND.GOPRO_COMMAND_SHUTTER,0,new SetResponseHandler(){
    @Override public void onResponse(    short commandId,    boolean success){
      if (success == isRecording) {
        isRecording=!success;
        drone.notifyDroneEvent(DroneEventsType.GOPRO_STATUS_UPDATE);
      }
    }
  }
);
}
Program: 94832
Project: 94832
Buggy source:
/** 
 * @return the version of the mavlink protocol.
 */
public byte getMavlinkVersion(){
  return mMavlinkVersion;
}

Fixed version (ground truth):
/** 
 * @return the version of the mavlink protocol.
 */
public short getMavlinkVersion(){
  return mMavlinkVersion;
}
Program: 94833
Project: 94833
Buggy source:
public void setWpno(short seq){
  if (seq != currentWP) {
    this.currentWP=seq;
    myDrone.notifyDroneEvent(DroneEventsType.MISSION_WP_UPDATE);
  }
}

Fixed version (ground truth):
public void setWpno(int seq){
  if (seq != currentWP) {
    this.currentWP=seq;
    myDrone.notifyDroneEvent(DroneEventsType.MISSION_WP_UPDATE);
  }
}
Program: 94834
Project: 94834
Buggy source:
public void setRadioState(short rxerrors,short fixed,byte rssi,byte remrssi,byte txbuf,byte noise,byte remnoise){
  isValid=true;
  if (this.rxerrors != rxerrors || this.fixed != fixed || this.rssi != rssi || this.remrssi != remrssi || this.txbuf != txbuf || this.noise != noise || this.remnoise != remnoise) {
    this.rxerrors=rxerrors & 0xFFFF;
    this.fixed=fixed & 0xFFFF;
    this.rssi=SikValueToDB(rssi & 0xFF);
    this.remrssi=SikValueToDB(remrssi & 0xFF);
    this.noise=SikValueToDB(noise & 0xFF);
    this.remnoise=SikValueToDB(remnoise & 0xFF);
    this.txbuf=txbuf & 0xFF;
    int currentSignalStrength=getSignalStrength();
    if (currentSignalStrength < 10.0 && previousSignalStrength >= 10.0) {
      myDrone.notifyDroneEvent(DroneEventsType.WARNING_SIGNAL_WEAK);
    }
    previousSignalStrength=currentSignalStrength;
    myDrone.notifyDroneEvent(DroneEventsType.RADIO);
  }
}

Fixed version (ground truth):
public void setRadioState(int rxerrors,int fixed,short rssi,short remrssi,short txbuf,short noise,short remnoise){
  isValid=true;
  if (this.rxerrors != rxerrors || this.fixed != fixed || this.rssi != rssi || this.remrssi != remrssi || this.txbuf != txbuf || this.noise != noise || this.remnoise != remnoise) {
    this.rxerrors=rxerrors & 0xFFFF;
    this.fixed=fixed & 0xFFFF;
    this.rssi=SikValueToDB(rssi & 0xFF);
    this.remrssi=SikValueToDB(remrssi & 0xFF);
    this.noise=SikValueToDB(noise & 0xFF);
    this.remnoise=SikValueToDB(remnoise & 0xFF);
    this.txbuf=txbuf & 0xFF;
    int currentSignalStrength=getSignalStrength();
    if (currentSignalStrength < 10.0 && previousSignalStrength >= 10.0) {
      myDrone.notifyDroneEvent(DroneEventsType.WARNING_SIGNAL_WEAK);
    }
    previousSignalStrength=currentSignalStrength;
    myDrone.notifyDroneEvent(DroneEventsType.RADIO);
  }
}
Program: 94835
Project: 94835
Buggy source:
private void checkEkfPositionState(msg_ekf_status_report ekfStatus){
  if (ekfStatus == null)   return;
  final short flags=ekfStatus.flags;
  final boolean isOk=this.armed ? (flags & EKF_STATUS_FLAGS.EKF_POS_HORIZ_ABS) != 0 && (flags & EKF_STATUS_FLAGS.EKF_CONST_POS_MODE) == 0 : (flags & EKF_STATUS_FLAGS.EKF_POS_HORIZ_ABS) != 0 || (flags & EKF_STATUS_FLAGS.EKF_PRED_POS_HORIZ_ABS) != 0;
  if (isEkfPositionOk != isOk) {
    isEkfPositionOk=isOk;
    myDrone.notifyDroneEvent(DroneEventsType.EKF_POSITION_STATE_UPDATE);
  }
}

Fixed version (ground truth):
private void checkEkfPositionState(msg_ekf_status_report ekfStatus){
  if (ekfStatus == null)   return;
  final int flags=ekfStatus.flags;
  final boolean isOk=this.armed ? (flags & EKF_STATUS_FLAGS.EKF_POS_HORIZ_ABS) != 0 && (flags & EKF_STATUS_FLAGS.EKF_CONST_POS_MODE) == 0 : (flags & EKF_STATUS_FLAGS.EKF_POS_HORIZ_ABS) != 0 || (flags & EKF_STATUS_FLAGS.EKF_PRED_POS_HORIZ_ABS) != 0;
  if (isEkfPositionOk != isOk) {
    isEkfPositionOk=isOk;
    myDrone.notifyDroneEvent(DroneEventsType.EKF_POSITION_STATE_UPDATE);
  }
}
Program: 94836
Project: 94836
Buggy source:
public HashMap<Byte,Info> getMagCalibrationTracker(){
  return magCalibrationTracker;
}

Fixed version (ground truth):
public HashMap<Short,Info> getMagCalibrationTracker(){
  return magCalibrationTracker;
}
Program: 94837
Project: 94837
Buggy source:
public void putUnsignedByte(short data){
  if (data < UNSIGNED_BYTE_MIN_VALUE || data > UNSIGNED_BYTE_MAX_VALUE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  putByte((byte)data);
}

Fixed version (ground truth):
public void putUnsignedByte(short data){
  if (data < UNSIGNED_BYTE_MIN_VALUE || data > UNSIGNED_BYTE_MAX_VALUE) {
    throw new IllegalArgumentException("String_Node_Str" + data);
  }
  putByte((byte)data);
}
Program: 94838
Project: 94838
Buggy source:
public void putUnsignedShort(int data){
  if (data < UNSIGNED_SHORT_MIN_VALUE || data > UNSIGNED_SHORT_MAX_VALUE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  putShort((short)data);
}

Fixed version (ground truth):
public void putUnsignedShort(int data){
  if (data < UNSIGNED_SHORT_MIN_VALUE || data > UNSIGNED_SHORT_MAX_VALUE) {
    throw new IllegalArgumentException("String_Node_Str" + data);
  }
  putShort((short)data);
}
Program: 94839
Project: 94839
Buggy source:
public void putUnsignedLong(long data){
  if (data < UNSIGNED_LONG_MIN_VALUE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  putLong(data);
}

Fixed version (ground truth):
public void putUnsignedLong(long data){
  if (data < UNSIGNED_LONG_MIN_VALUE) {
    throw new IllegalArgumentException("String_Node_Str" + data);
  }
  putLong(data);
}
Program: 94840
Project: 94840
Buggy source:
public void putUnsignedInt(long data){
  if (data < UNSIGNED_INT_MIN_VALUE || data > UNSIGNED_INT_MAX_VALUE) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  putInt((int)data);
}

Fixed version (ground truth):
public void putUnsignedInt(long data){
  if (data < UNSIGNED_INT_MIN_VALUE || data > UNSIGNED_INT_MAX_VALUE) {
    throw new IllegalArgumentException("String_Node_Str" + data);
  }
  putInt((int)data);
}
Program: 94842
Project: 94842
Buggy source:
public DroneImpl(MAVLinkStreams.MAVLinkOutputStream mavClient,DroneInterfaces.Clock clock,DroneInterfaces.Handler handler,Preferences pref,AutopilotWarningParser warningParser,LogMessageListener logListener){
  this.MavClient=mavClient;
  this.preferences=pref;
  this.logListener=logListener;
  events=new DroneEvents(this,handler);
  state=new State(this,clock,handler,warningParser);
  heartbeat=new HeartBeat(this,handler);
  parameters=new Parameters(this,handler);
  this.waypointManager=new WaypointManager(this,handler);
  RC=new RC(this);
  GPS=new GPS(this);
  this.type=new Type(this);
  this.speed=new Speed(this);
  this.battery=new Battery(this);
  this.radio=new Radio(this);
  this.home=new Home(this);
  this.mission=new Mission(this);
  this.missionStats=new MissionStats(this);
  this.streamRates=new StreamRates(this);
  this.altitude=new Altitude(this);
  this.orientation=new Orientation(this);
  this.navigation=new Navigation(this);
  this.guidedPoint=new GuidedPoint(this,handler);
  this.accelCalibrationSetup=new AccelCalibration(this);
  this.magCalibration=new MagnetometerCalibrationImpl(this);
  this.mag=new Magnetometer(this);
  this.footprints=new Camera(this);
  this.goProImpl=new GoProImpl(this,handler);
  loadVehicleProfile();
}

Fixed version (ground truth):
public DroneImpl(MAVLinkStreams.MAVLinkOutputStream mavClient,DroneInterfaces.Clock clock,DroneInterfaces.Handler handler,Preferences pref,AutopilotWarningParser warningParser,LogMessageListener logListener){
  this.MavClient=mavClient;
  this.preferences=pref;
  this.logListener=logListener;
  events=new DroneEvents(this,handler);
  state=new State(this,clock,handler,warningParser);
  heartbeat=new HeartBeat(this,handler);
  parameters=new Parameters(this,handler);
  this.waypointManager=new WaypointManager(this,handler);
  RC=new RC(this);
  GPS=new GPS(this);
  this.type=new Type(this);
  this.speed=new Speed(this);
  this.battery=new Battery(this);
  this.radio=new Radio(this);
  this.home=new Home(this);
  this.mission=new Mission(this);
  this.missionStats=new MissionStats(this);
  this.streamRates=new StreamRates(this);
  this.altitude=new Altitude(this);
  this.orientation=new Orientation(this);
  this.navigation=new Navigation(this);
  this.guidedPoint=new GuidedPoint(this,handler);
  this.accelCalibrationSetup=new AccelCalibration(this,handler);
  this.magCalibration=new MagnetometerCalibrationImpl(this);
  this.mag=new Magnetometer(this);
  this.footprints=new Camera(this);
  this.goProImpl=new GoProImpl(this,handler);
  loadVehicleProfile();
}
Program: 94843
Project: 94843
Buggy source:
public boolean setMode(ApmModes mode){
  if (this.mode != mode) {
    this.mode=mode;
    myDrone.notifyDroneEvent(DroneEventsType.MODE);
    return true;
  }
  return false;
}

Fixed version (ground truth):
public void setMode(ApmModes mode){
  if (this.mode != mode) {
    this.mode=mode;
    myDrone.notifyDroneEvent(DroneEventsType.MODE);
  }
}
Program: 94844
Project: 94844
Buggy source:
@Override public void onError(int executionError){
  if (listener != null) {
    try {
      listener.onError(executionError);
    }
 catch (    RemoteException e) {
      Timber.e(e,e.getMessage());
    }
  }
}

Fixed version (ground truth):
@Override public void onError(int executionError){
  final ICommandListener listener=listenerRef.getAndSet(null);
  if (listener != null) {
    try {
      listener.onError(executionError);
    }
 catch (    RemoteException e) {
      Timber.e(e,e.getMessage());
    }
  }
}
Program: 94845
Project: 94845
Buggy source:
public void processMessage(MAVLinkMessage msg){
  if (calibrating && msg.msgid == msg_statustext.MAVLINK_MSG_ID_STATUSTEXT) {
    msg_statustext statusMsg=(msg_statustext)msg;
    final String message=statusMsg.getText();
    if (message != null && (message.startsWith("String_Node_Str") || message.startsWith("String_Node_Str"))) {
      mavMsg=message;
      if (message.startsWith("String_Node_Str"))       calibrating=false;
      myDrone.notifyDroneEvent(DroneEventsType.CALIBRATION_IMU);
    }
  }
}

Fixed version (ground truth):
public void processMessage(MAVLinkMessage msg){
  if (calibrating && msg.msgid == msg_statustext.MAVLINK_MSG_ID_STATUSTEXT) {
    msg_statustext statusMsg=(msg_statustext)msg;
    final String message=statusMsg.getText();
    if (message != null && (message.startsWith("String_Node_Str") || message.startsWith("String_Node_Str"))) {
      handler.post(onCalibrationStart);
      mavMsg=message;
      if (message.startsWith("String_Node_Str"))       calibrating=false;
      myDrone.notifyDroneEvent(DroneEventsType.CALIBRATION_IMU);
    }
  }
}
Program: 94846
Project: 94846
Buggy source:
@Override public void onTimeout(){
  if (listener != null) {
    try {
      listener.onTimeout();
    }
 catch (    RemoteException e) {
      Timber.e(e,e.getMessage());
    }
  }
}

Fixed version (ground truth):
@Override public void onTimeout(){
  final ICommandListener listener=listenerRef.getAndSet(null);
  if (listener != null) {
    try {
      listener.onTimeout();
    }
 catch (    RemoteException e) {
      Timber.e(e,e.getMessage());
    }
  }
}
Program: 94847
Project: 94847
Buggy source:
public void startCalibration(final ICommandListener listener){
  if (calibrating) {
    if (listener != null) {
      try {
        listener.onSuccess();
      }
 catch (      RemoteException e) {
        Timber.e(e,e.getMessage());
      }
    }
    return;
  }
  if (myDrone.getState().isFlying()) {
    calibrating=false;
  }
 else {
    MavLinkCalibration.startAccelerometerCalibration(myDrone,new SimpleCommandListener(){
      @Override public void onSuccess(){
        calibrating=true;
        mavMsg="String_Node_Str";
        if (listener != null) {
          try {
            listener.onSuccess();
          }
 catch (          RemoteException e) {
            Timber.e(e,e.getMessage());
          }
        }
      }
      @Override public void onError(      int executionError){
        if (listener != null) {
          try {
            listener.onError(executionError);
          }
 catch (          RemoteException e) {
            Timber.e(e,e.getMessage());
          }
        }
      }
      @Override public void onTimeout(){
        if (listener != null) {
          try {
            listener.onTimeout();
          }
 catch (          RemoteException e) {
            Timber.e(e,e.getMessage());
          }
        }
      }
    }
);
  }
}

Fixed version (ground truth):
public void startCalibration(ICommandListener listener){
  if (calibrating) {
    if (listener != null) {
      try {
        listener.onSuccess();
      }
 catch (      RemoteException e) {
        Timber.e(e,e.getMessage());
      }
    }
    return;
  }
  if (myDrone.getState().isFlying()) {
    calibrating=false;
  }
 else {
    calibrating=true;
    mavMsg="String_Node_Str";
    listenerRef.set(listener);
    MavLinkCalibration.startAccelerometerCalibration(myDrone,new SimpleCommandListener(){
      @Override public void onSuccess(){
        final ICommandListener listener=listenerRef.getAndSet(null);
        if (listener != null) {
          try {
            listener.onSuccess();
          }
 catch (          RemoteException e) {
            Timber.e(e,e.getMessage());
          }
        }
      }
      @Override public void onError(      int executionError){
        final ICommandListener listener=listenerRef.getAndSet(null);
        if (listener != null) {
          try {
            listener.onError(executionError);
          }
 catch (          RemoteException e) {
            Timber.e(e,e.getMessage());
          }
        }
      }
      @Override public void onTimeout(){
        final ICommandListener listener=listenerRef.getAndSet(null);
        if (listener != null) {
          try {
            listener.onTimeout();
          }
 catch (          RemoteException e) {
            Timber.e(e,e.getMessage());
          }
        }
      }
    }
);
  }
}
Program: 94848
Project: 94848
Buggy source:
public AccelCalibration(Drone drone){
  super(drone);
  drone.addDroneListener(this);
}

Fixed version (ground truth):
public AccelCalibration(Drone drone,DroneInterfaces.Handler handler){
  super(drone);
  this.handler=handler;
  drone.addDroneListener(this);
}
Program: 94849
Project: 94849
Buggy source:
@Override public void onSuccess(){
  calibrating=true;
  mavMsg="String_Node_Str";
  if (listener != null) {
    try {
      listener.onSuccess();
    }
 catch (    RemoteException e) {
      Timber.e(e,e.getMessage());
    }
  }
}

Fixed version (ground truth):
@Override public void onSuccess(){
  final ICommandListener listener=listenerRef.getAndSet(null);
  if (listener != null) {
    try {
      listener.onSuccess();
    }
 catch (    RemoteException e) {
      Timber.e(e,e.getMessage());
    }
  }
}
Program: 94850
Project: 94850
Buggy source:
@Override public void sendMavMessage(MAVLinkMessage message,int sysId,int compId,ICommandListener listener){
  if (this.connParams == null || message == null) {
    return;
  }
  final MAVLinkPacket packet=message.pack();
  packet.sysid=sysId;
  packet.compid=compId;
  packet.seq=packetSeqNumber;
  if (mavLinkApi.sendData(this.connParams,packet)) {
    packetSeqNumber=(packetSeqNumber + 1) % (MAX_PACKET_SEQUENCE + 1);
    if (commandTracker != null && listener != null) {
      if (message instanceof msg_command_long) {
        commandTracker.onCommandSubmitted((msg_command_long)message,listener);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void sendMavMessage(MAVLinkMessage message,int sysId,int compId,ICommandListener listener){
  if (this.connParams == null || message == null) {
    return;
  }
  final MAVLinkPacket packet=message.pack();
  packet.sysid=sysId;
  packet.compid=compId;
  packet.seq=packetSeqNumber;
  if (mavLinkApi.sendData(this.connParams,packet)) {
    packetSeqNumber=(packetSeqNumber + 1) % (MAX_PACKET_SEQUENCE + 1);
    if (commandTracker != null && listener != null) {
      commandTracker.onCommandSubmitted(message,listener);
    }
  }
}
Program: 94851
Project: 94851
Buggy source:
private void onCommandSubmittedImpl(final msg_set_mode command,ICommandListener listener){
  final int commandId=command.msgid;
  final CallbackKey<ApmModes> key=new CallbackKey<ApmModes>(commandId){
    @Override public int checkAckResult(    ApmModes result){
      return result.getNumber() == command.custom_mode ? AckCallback.COMMAND_SUCCEED : CommandExecutionError.COMMAND_FAILED;
    }
  }
;
  final AckCallback callback=new AckCallback(listener,commandId);
  keyStore.put(commandId,key);
  callbackStore.put(key,callback);
  handler.postDelayed(callback,COMMAND_TIMEOUT_PERIOD);
}

Fixed version (ground truth):
private void onCommandSubmittedImpl(final msg_set_mode command,ICommandListener listener){
  final int commandId=command.msgid;
  final CallbackKey<msg_command_ack> key=new CallbackKey<msg_command_ack>(commandId){
    @Override public int checkAckResult(    msg_command_ack result){
      return result.result;
    }
  }
;
  final AckCallback callback=new AckCallback(listener,commandId);
  keyStore.put(commandId,key);
  callbackStore.put(key,callback);
  handler.postDelayed(callback,COMMAND_TIMEOUT_PERIOD);
}
Program: 94852
Project: 94852
Buggy source:
@Override public void onCommandAck(int commandId,Object ack){
switch (commandId) {
case msg_command_ack.MAVLINK_MSG_ID_COMMAND_ACK:
    onCommandAckImpl((msg_command_ack)ack);
  break;
case msg_set_mode.MAVLINK_MSG_ID_SET_MODE:
onCommandAckImpl((ApmModes)ack);
break;
}
}

Fixed version (ground truth):
@Override public void onCommandAck(int commandId,Object ack){
switch (commandId) {
case msg_command_ack.MAVLINK_MSG_ID_COMMAND_ACK:
    onCommandAckImpl((msg_command_ack)ack);
  break;
}
}
Program: 94853
Project: 94853
Buggy source:
private void onCommandAckImpl(ApmModes mode){
  final CallbackKey<ApmModes> key=keyStore.get(msg_set_mode.MAVLINK_MSG_ID_SET_MODE);
  if (key == null)   return;
  final AckCallback callback=callbackStore.remove(key);
  if (callback != null) {
    handler.removeCallbacks(callback);
    callback.setAckResult(key.checkAckResult(mode));
    handler.post(callback);
  }
}

Fixed version (ground truth):
private void onCommandAckImpl(msg_command_ack ack){
  final CallbackKey<msg_command_ack> key=keyStore.get(ack.command);
  if (key == null)   return;
  final AckCallback callback=callbackStore.remove(key);
  if (callback != null) {
    handler.removeCallbacks(callback);
    callback.setAckResult(key.checkAckResult(ack));
    handler.post(callback);
  }
}
Program: 94856
Project: 94856
Buggy source:
/** 
 * Basic MAVLink message test
 */
@Test public void testArm(){
  MavLinkArm.sendArmMessage(drone,true);
  MAVLinkPacket data=mavlinkApi.getData();
  Assert.assertTrue(data != null);
  MAVLinkMessage msg=data.unpack();
  msg_command_long longMsg=(msg_command_long)msg;
  Assert.assertEquals(MAV_CMD.MAV_CMD_COMPONENT_ARM_DISARM,longMsg.command);
  Assert.assertEquals(1f,longMsg.param1,0.001);
}

Fixed version (ground truth):
/** 
 * Basic MAVLink message test
 */
@Test public void testArm(){
  MavLinkArm.sendArmMessage(drone,true,null);
  MAVLinkPacket data=mavlinkApi.getData();
  Assert.assertTrue(data != null);
  MAVLinkMessage msg=data.unpack();
  msg_command_long longMsg=(msg_command_long)msg;
  Assert.assertEquals(MAV_CMD.MAV_CMD_COMPONENT_ARM_DISARM,longMsg.command);
  Assert.assertEquals(1f,longMsg.param1,0.001);
}
Program: 94857
Project: 94857
Buggy source:
public void disableFollowMe(){
  FollowApi.disableFollowMe(this);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link FollowApi#disableFollowMe(Drone)} instead.
 */
public void disableFollowMe(){
  FollowApi.disableFollowMe(this);
}
Program: 94858
Project: 94858
Buggy source:
public void generateDronie(){
  MissionApi.generateDronie(this);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link MissionApi#generateDronie(Drone)} instead.
 */
public void generateDronie(){
  MissionApi.generateDronie(this);
}
Program: 94859
Project: 94859
Buggy source:
void destroy(){
  removeAttributesObserver(this.droneObserver);
  try {
    if (isStarted()) {
      this.droneApi.asBinder().unlinkToDeath(binderDeathRecipient,0);
      serviceMgr.get3drServices().releaseDroneApi(this.droneApi);
    }
  }
 catch (  RemoteException e) {
    Log.e(TAG,e.getMessage(),e);
  }
  if (asyncScheduler != null) {
    asyncScheduler.shutdownNow();
    asyncScheduler=null;
  }
  this.droneApi=null;
  droneListeners.clear();
}

Fixed version (ground truth):
void destroy(){
  removeAttributesObserver(this.droneObserver);
  try {
    if (isStarted()) {
      this.droneApi.asBinder().unlinkToDeath(binderDeathRecipient,0);
      serviceMgr.get3drServices().releaseDroneApi(this.droneApi);
    }
  }
 catch (  RemoteException e) {
    Log.e(TAG,e.getMessage(),e);
  }
  if (asyncScheduler != null) {
    asyncScheduler.shutdownNow();
    asyncScheduler=null;
  }
  droneListeners.clear();
}
Program: 94860
Project: 94860
Buggy source:
public void changeVehicleMode(VehicleMode newMode){
  DroneStateApi.setVehicleMode(this,newMode);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link DroneStateApi#setVehicleMode(Drone,VehicleMode)} instead.
 */
public void changeVehicleMode(VehicleMode newMode){
  DroneStateApi.setVehicleMode(this,newMode);
}
Program: 94861
Project: 94861
Buggy source:
public void enableFollowMe(FollowType followType){
  FollowApi.enableFollowMe(this,followType);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link FollowApi#enableFollowMe(Drone,FollowType)} instead.
 */
public void enableFollowMe(FollowType followType){
  FollowApi.enableFollowMe(this,followType);
}
Program: 94862
Project: 94862
Buggy source:
public void pauseAtCurrentLocation(){
  GuidedApi.pauseAtCurrentLocation(this);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link GuidedApi#pauseAtCurrentLocation(Drone)} instead.
 */
public void pauseAtCurrentLocation(){
  GuidedApi.pauseAtCurrentLocation(this);
}
Program: 94863
Project: 94863
Buggy source:
public void setMission(Mission mission,boolean pushToDrone){
  MissionApi.setMission(this,mission,pushToDrone);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link MissionApi#setMission(Drone,Mission,boolean)} instead.
 */
public void setMission(Mission mission,boolean pushToDrone){
  MissionApi.setMission(this,mission,pushToDrone);
}
Program: 94864
Project: 94864
Buggy source:
public void loadWaypoints(){
  MissionApi.loadWaypoints(this);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link MissionApi#loadWaypoints(Drone)} instead.
 */
public void loadWaypoints(){
  MissionApi.loadWaypoints(this);
}
Program: 94865
Project: 94865
Buggy source:
public void sendGuidedPoint(LatLong point,boolean force){
  GuidedApi.sendGuidedPoint(this,point,force);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link GuidedApi#sendGuidedPoint(Drone,LatLong,boolean)} instead.
 */
public void sendGuidedPoint(LatLong point,boolean force){
  GuidedApi.sendGuidedPoint(this,point,force);
}
Program: 94866
Project: 94866
Buggy source:
public void sendMavlinkMessage(MavlinkMessageWrapper messageWrapper){
  ExperimentalApi.sendMavlinkMessage(this,messageWrapper);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ExperimentalApi#sendMavlinkMessage(Drone,MavlinkMessageWrapper)} instead.
 */
public void sendMavlinkMessage(MavlinkMessageWrapper messageWrapper){
  ExperimentalApi.sendMavlinkMessage(this,messageWrapper);
}
Program: 94867
Project: 94867
Buggy source:
public void doGuidedTakeoff(double altitude){
  GuidedApi.takeoff(this,altitude);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link GuidedApi#takeoff(Drone,double)} instead.
 */
public void doGuidedTakeoff(double altitude){
  GuidedApi.takeoff(this,altitude);
}
Program: 94868
Project: 94868
Buggy source:
public void writeParameters(Parameters parameters){
  ParameterApi.writeParameters(this,parameters);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ParameterApi#writeParameters(Drone,Parameters)} instead.
 */
public void writeParameters(Parameters parameters){
  ParameterApi.writeParameters(this,parameters);
}
Program: 94869
Project: 94869
Buggy source:
public void refreshParameters(){
  ParameterApi.refreshParameters(this);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ParameterApi#refreshParameters(Drone)} instead.
 */
public void refreshParameters(){
  ParameterApi.refreshParameters(this);
}
Program: 94870
Project: 94870
Buggy source:
public void arm(boolean arm){
  DroneStateApi.arm(this,arm);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link DroneStateApi#arm(Drone,boolean)} instead.
 */
public void arm(boolean arm){
  DroneStateApi.arm(this,arm);
}
Program: 94871
Project: 94871
Buggy source:
public void epmCommand(boolean release){
  ExperimentalApi.epmCommand(this,release);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ExperimentalApi#epmCommand(Drone,boolean)} instead.
 */
public void epmCommand(boolean release){
  ExperimentalApi.epmCommand(this,release);
}
Program: 94872
Project: 94872
Buggy source:
public void triggerCamera(){
  ExperimentalApi.triggerCamera(this);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link ExperimentalApi#triggerCamera(Drone)} instead.
 */
public void triggerCamera(){
  ExperimentalApi.triggerCamera(this);
}
Program: 94873
Project: 94873
Buggy source:
public void setGuidedAltitude(double altitude){
  GuidedApi.setGuidedAltitude(this,altitude);
}

Fixed version (ground truth):
/** 
 * @deprecated Use {@link GuidedApi#setGuidedAltitude(Drone,double)} instead.
 */
public void setGuidedAltitude(double altitude){
  GuidedApi.setGuidedAltitude(this,altitude);
}
Program: 94875
Project: 94875
Buggy source:
public void connect(String appId,DroneEventsListener listener) throws ConnectionException {
  if (listener == null || TextUtils.isEmpty(appId))   return;
  connectedApps.put(appId,listener);
  MAVLinkClient mavClient=(MAVLinkClient)drone.getMavClient();
  if (!mavClient.isConnected()) {
    mavClient.openConnection();
  }
 else {
    listener.onDroneEvent(DroneInterfaces.DroneEventsType.CONNECTED,drone);
    if (drone.isConnectionAlive())     listener.onDroneEvent(DroneInterfaces.DroneEventsType.HEARTBEAT_FIRST,drone);
 else     listener.onDroneEvent(DroneInterfaces.DroneEventsType.HEARTBEAT_TIMEOUT,drone);
    notifyConnected(appId,listener);
  }
  mavClient.addLoggingFile(appId);
}

Fixed version (ground truth):
public void connect(String appId,DroneEventsListener listener) throws ConnectionException {
  if (listener == null || TextUtils.isEmpty(appId))   return;
  connectedApps.put(appId,listener);
  MAVLinkClient mavClient=(MAVLinkClient)drone.getMavClient();
  if (!mavClient.isConnected()) {
    mavClient.openConnection();
  }
 else {
    if (drone.isConnected()) {
      if (drone.isConnectionAlive())       listener.onDroneEvent(DroneInterfaces.DroneEventsType.HEARTBEAT_FIRST,drone);
 else {
        listener.onDroneEvent(DroneInterfaces.DroneEventsType.CONNECTED,drone);
        listener.onDroneEvent(DroneInterfaces.DroneEventsType.HEARTBEAT_TIMEOUT,drone);
      }
      notifyConnected(appId,listener);
    }
  }
  mavClient.addLoggingFile(appId);
}
Program: 94876
Project: 94876
Buggy source:
@Override public int hashCode(){
  return toString().hashCode();
}

Fixed version (ground truth):
@Override public int hashCode(){
  return getUniqueId().hashCode();
}
Program: 94877
Project: 94877
Buggy source:
@Override public boolean equals(Object o){
  if (this == o)   return true;
  if (!(o instanceof ConnectionParameter))   return false;
  ConnectionParameter that=(ConnectionParameter)o;
  return toString().equals(that.toString());
}

Fixed version (ground truth):
@Override public boolean equals(Object o){
  if (this == o)   return true;
  if (!(o instanceof ConnectionParameter))   return false;
  ConnectionParameter that=(ConnectionParameter)o;
  return getUniqueId().equals(that.getUniqueId());
}
Program: 94878
Project: 94878
Buggy source:
public String getUniqueId(){
  final String uniqueId;
switch (connectionType) {
case ConnectionType.TYPE_UDP:
    int udpPort=ConnectionType.DEFAULT_UDP_SERVER_PORT;
  if (paramsBundle != null) {
    udpPort=paramsBundle.getInt(ConnectionType.EXTRA_UDP_SERVER_PORT,udpPort);
  }
uniqueId="String_Node_Str" + udpPort;
break;
case ConnectionType.TYPE_BLUETOOTH:
String btAddress=null;
if (paramsBundle != null) {
btAddress=paramsBundle.getString(ConnectionType.EXTRA_BLUETOOTH_ADDRESS);
}
uniqueId=btAddress == null ? "String_Node_Str" : "String_Node_Str" + btAddress;
break;
case ConnectionType.TYPE_TCP:
String tcpIp=null;
int tcpPort=ConnectionType.DEFAULT_TCP_SERVER_PORT;
if (paramsBundle != null) {
tcpIp=paramsBundle.getString(ConnectionType.EXTRA_TCP_SERVER_IP);
tcpPort=paramsBundle.getInt(ConnectionType.EXTRA_TCP_SERVER_PORT,tcpPort);
}
uniqueId="String_Node_Str" + "String_Node_Str" + tcpPort + (tcpIp == null ? "String_Node_Str" : "String_Node_Str" + tcpIp);
break;
case ConnectionType.TYPE_USB:
uniqueId="String_Node_Str";
break;
default :
uniqueId=null;
break;
}
return uniqueId;
}

Fixed version (ground truth):
public String getUniqueId(){
  final String uniqueId;
switch (connectionType) {
case ConnectionType.TYPE_UDP:
    int udpPort=ConnectionType.DEFAULT_UDP_SERVER_PORT;
  if (paramsBundle != null) {
    udpPort=paramsBundle.getInt(ConnectionType.EXTRA_UDP_SERVER_PORT,udpPort);
  }
uniqueId="String_Node_Str" + udpPort;
break;
case ConnectionType.TYPE_BLUETOOTH:
String btAddress=null;
if (paramsBundle != null) {
btAddress=paramsBundle.getString(ConnectionType.EXTRA_BLUETOOTH_ADDRESS);
}
uniqueId=btAddress == null ? "String_Node_Str" : "String_Node_Str" + btAddress;
break;
case ConnectionType.TYPE_TCP:
String tcpIp=null;
int tcpPort=ConnectionType.DEFAULT_TCP_SERVER_PORT;
if (paramsBundle != null) {
tcpIp=paramsBundle.getString(ConnectionType.EXTRA_TCP_SERVER_IP);
tcpPort=paramsBundle.getInt(ConnectionType.EXTRA_TCP_SERVER_PORT,tcpPort);
}
uniqueId="String_Node_Str" + "String_Node_Str" + tcpPort + (tcpIp == null ? "String_Node_Str" : "String_Node_Str" + tcpIp);
break;
case ConnectionType.TYPE_USB:
uniqueId="String_Node_Str";
break;
default :
uniqueId="String_Node_Str";
break;
}
return uniqueId;
}
Program: 94881
Project: 94881
Buggy source:
@Override protected void openConnection() throws IOException {
  mConnectionImpl.openConnection();
  if (pingHandler != null) {
    for (    PingTask pingTask : pingTasks)     pingHandler.post(pingTask);
  }
}

Fixed version (ground truth):
@Override protected void openConnection() throws IOException {
  Log.d(TAG,"String_Node_Str");
  mConnectionImpl.openConnection();
  if (pingRunner == null || pingRunner.isShutdown())   pingRunner=Executors.newSingleThreadScheduledExecutor();
  for (  PingTask pingTask : pingTasks)   pingRunner.scheduleWithFixedDelay(pingTask,0,pingTask.period,TimeUnit.MILLISECONDS);
}
Program: 94882
Project: 94882
Buggy source:
public AndroidUdpConnection(Context context,int udpServerPort,Handler pingHandler){
  super(context);
  this.serverPort=udpServerPort;
  this.pingHandler=pingHandler;
  mConnectionImpl=new UdpConnection(){
    @Override protected int loadServerPort(){
      return serverPort;
    }
    @Override protected Logger initLogger(){
      return AndroidUdpConnection.this.initLogger();
    }
    @Override protected void onConnectionOpened(){
      AndroidUdpConnection.this.onConnectionOpened();
    }
    @Override protected void onConnectionFailed(    String errMsg){
      AndroidUdpConnection.this.onConnectionFailed(errMsg);
    }
  }
;
}

Fixed version (ground truth):
public AndroidUdpConnection(Context context,int udpServerPort){
  super(context);
  this.serverPort=udpServerPort;
  mConnectionImpl=new UdpConnection(){
    @Override protected int loadServerPort(){
      return serverPort;
    }
    @Override protected Logger initLogger(){
      return AndroidUdpConnection.this.initLogger();
    }
    @Override protected void onConnectionOpened(){
      AndroidUdpConnection.this.onConnectionOpened();
    }
    @Override protected void onConnectionFailed(    String errMsg){
      AndroidUdpConnection.this.onConnectionFailed(errMsg);
    }
  }
;
}
Program: 94883
Project: 94883
Buggy source:
@Override public void run(){
  try {
    mConnectionImpl.sendBuffer(address,port,payload);
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
  if (getConnectionStatus() == AndroidMavLinkConnection.MAVLINK_CONNECTED)   pingHandler.postDelayed(this,period);
}

Fixed version (ground truth):
@Override public void run(){
  try {
    mConnectionImpl.sendBuffer(address,port,payload);
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str",e);
  }
}
Program: 94884
Project: 94884
Buggy source:
public void addPingTarget(final InetAddress address,final int port,final long period,final byte[] payload){
  if (pingHandler == null || address == null || payload == null || period <= 0)   return;
  final PingTask pingTask=new PingTask(address,port,period,payload);
  pingTasks.add(pingTask);
  if (getConnectionStatus() == AndroidMavLinkConnection.MAVLINK_CONNECTED)   pingHandler.postDelayed(pingTask,period);
}

Fixed version (ground truth):
public void addPingTarget(final InetAddress address,final int port,final long period,final byte[] payload){
  if (address == null || payload == null || period <= 0)   return;
  final PingTask pingTask=new PingTask(address,port,period,payload);
  pingTasks.add(pingTask);
  if (getConnectionStatus() == AndroidMavLinkConnection.MAVLINK_CONNECTED && pingRunner != null && !pingRunner.isShutdown())   pingRunner.scheduleWithFixedDelay(pingTask,0,period,TimeUnit.MILLISECONDS);
}
Program: 94885
Project: 94885
Buggy source:
@Override protected void closeConnection() throws IOException {
  if (pingHandler != null) {
    for (    PingTask pingTask : pingTasks)     pingHandler.removeCallbacks(pingTask);
  }
  mConnectionImpl.closeConnection();
}

Fixed version (ground truth):
@Override protected void closeConnection() throws IOException {
  Log.d(TAG,"String_Node_Str");
  if (pingRunner != null) {
    Log.d(TAG,"String_Node_Str");
    pingRunner.shutdownNow();
    pingRunner=null;
  }
  mConnectionImpl.closeConnection();
}
Program: 94886
Project: 94886
Buggy source:
@Override public boolean equals(Object other){
  if (this == other)   return true;
  if (!(other instanceof AndroidUdpConnection))   return false;
  PingTask that=(PingTask)other;
  return this.address.equals(that.address) && this.port == that.port && this.period == that.period;
}

Fixed version (ground truth):
@Override public boolean equals(Object other){
  if (this == other)   return true;
  if (!(other instanceof PingTask))   return false;
  PingTask that=(PingTask)other;
  return this.address.equals(that.address) && this.port == that.port && this.period == that.period;
}
Program: 94887
Project: 94887
Buggy source:
@Override public void openConnection(){
  if (this.connParams == null)   return;
  final String tag=toString();
  if (mavLinkApi.getConnectionStatus(this.connParams,tag) == MavLinkConnection.MAVLINK_DISCONNECTED) {
    mavLinkApi.connectMavLink(this.connParams,tag,mConnectionListener);
  }
}

Fixed version (ground truth):
@Override public void openConnection(){
  if (this.connParams == null)   return;
  final String tag=toString();
  final int connectionStatus=mavLinkApi.getConnectionStatus(this.connParams,tag);
  if (connectionStatus == MavLinkConnection.MAVLINK_DISCONNECTED || connectionStatus == MavLinkConnection.MAVLINK_CONNECTING) {
    mavLinkApi.connectMavLink(this.connParams,tag,mConnectionListener);
  }
}
Program: 94888
Project: 94888
Buggy source:
public void disconnect(String appId) throws ConnectionException {
  if (TextUtils.isEmpty(appId))   return;
  DroneEventsListener listener=connectedApps.remove(appId);
  if (listener != null) {
    MAVLinkClient mavClient=(MAVLinkClient)drone.getMavClient();
    mavClient.removeLoggingFile(appId);
    if (mavClient.isConnected() && connectedApps.isEmpty()) {
      mavClient.closeConnection();
    }
    listener.onDroneEvent(DroneInterfaces.DroneEventsType.DISCONNECTED,drone);
    notifyDisconnected(appId,listener);
  }
}

Fixed version (ground truth):
public void disconnect(String appId) throws ConnectionException {
  if (TextUtils.isEmpty(appId))   return;
  Log.d(TAG,"String_Node_Str" + appId);
  DroneEventsListener listener=connectedApps.remove(appId);
  final MAVLinkClient mavClient=(MAVLinkClient)drone.getMavClient();
  if (listener != null) {
    mavClient.removeLoggingFile(appId);
    listener.onDroneEvent(DroneInterfaces.DroneEventsType.DISCONNECTED,drone);
    notifyDisconnected(appId,listener);
  }
  if (mavClient.isConnected() && connectedApps.isEmpty()) {
    mavClient.closeConnection();
  }
}
Program: 94889
Project: 94889
Buggy source:
static void sendIMUCalibrationAck(Drone drone,int step){
  if (drone == null)   return;
  drone.getCalibrationSetup().sendAckk(step);
}

Fixed version (ground truth):
static void sendIMUCalibrationAck(Drone drone,int step){
  if (drone == null)   return;
  drone.getCalibrationSetup().sendAck(step);
}
Program: 94890
Project: 94890
Buggy source:
public void processMessage(MAVLinkMessage msg){
  if (msg.msgid == msg_statustext.MAVLINK_MSG_ID_STATUSTEXT) {
    msg_statustext statusMsg=(msg_statustext)msg;
    mavMsg=statusMsg.getText();
    if (mavMsg.contains("String_Node_Str"))     calibrating=false;
    myDrone.notifyDroneEvent(DroneEventsType.CALIBRATION_IMU);
  }
}

Fixed version (ground truth):
public void processMessage(MAVLinkMessage msg){
  if (msg.msgid == msg_statustext.MAVLINK_MSG_ID_STATUSTEXT) {
    msg_statustext statusMsg=(msg_statustext)msg;
    final String message=statusMsg.getText();
    if (message != null && (message.startsWith("String_Node_Str") || message.startsWith("String_Node_Str"))) {
      mavMsg=message;
      if (message.startsWith("String_Node_Str"))       calibrating=false;
      myDrone.notifyDroneEvent(DroneEventsType.CALIBRATION_IMU);
    }
  }
}
Program: 94891
Project: 94891
Buggy source:
public boolean startCalibration(){
  if (myDrone.getState().isFlying()) {
    calibrating=false;
  }
 else {
    calibrating=true;
    MavLinkCalibration.sendStartCalibrationMessage(myDrone);
  }
  return calibrating;
}

Fixed version (ground truth):
public boolean startCalibration(){
  if (myDrone.getState().isFlying()) {
    calibrating=false;
  }
 else {
    calibrating=true;
    mavMsg="String_Node_Str";
    MavLinkCalibration.sendStartCalibrationMessage(myDrone);
  }
  return calibrating;
}