Program: 94855
Project: 94855
Buggy source:
@Override public void performAction(Action action) throws RemoteException {
  if (action == null)   return;
  final String type=action.getType();
  if (type == null)   return;
  Bundle data=action.getData();
switch (type) {
case MissionActions.ACTION_GENERATE_DRONIE:
    final float bearing=DroneApiUtils.generateDronie(getDrone());
  if (bearing != -1) {
    Bundle bundle=new Bundle(1);
    bundle.putFloat(AttributeEventExtra.EXTRA_MISSION_DRONIE_BEARING,bearing);
    notifyAttributeUpdate(AttributeEvent.MISSION_DRONIE_CREATED,bundle);
  }
break;
case MissionActions.ACTION_LOAD_WAYPOINTS:
DroneApiUtils.loadWaypoints(getDrone());
break;
case MissionActions.ACTION_SET_MISSION:
data.setClassLoader(Mission.class.getClassLoader());
Mission mission=data.getParcelable(MissionActions.EXTRA_MISSION);
boolean pushToDrone=data.getBoolean(MissionActions.EXTRA_PUSH_TO_DRONE);
DroneApiUtils.setMission(getDrone(),mission,pushToDrone);
break;
case MissionActions.ACTION_BUILD_COMPLEX_MISSION_ITEM:
DroneApiUtils.buildComplexMissionItem(getDrone(),data);
break;
case ConnectionActions.ACTION_CONNECT:
data.setClassLoader(ConnectionParameter.class.getClassLoader());
ConnectionParameter parameter=data.getParcelable(ConnectionActions.EXTRA_CONNECT_PARAMETER);
connect(parameter);
break;
case ConnectionActions.ACTION_DISCONNECT:
disconnect();
break;
case ExperimentalActions.ACTION_EPM_COMMAND:
boolean release=data.getBoolean(ExperimentalActions.EXTRA_EPM_RELEASE);
DroneApiUtils.epmCommand(getDrone(),release);
break;
case ExperimentalActions.ACTION_TRIGGER_CAMERA:
DroneApiUtils.triggerCamera(getDrone());
break;
case ExperimentalActions.ACTION_SET_ROI:
LatLongAlt roi=data.getParcelable(ExperimentalActions.EXTRA_SET_ROI_LAT_LONG_ALT);
Coord3D coord3DRoi=new Coord3D(roi.getLatitude(),roi.getLongitude(),roi.getAltitude());
MavLinkDoCmds.setROI(getDrone(),coord3DRoi);
break;
case ExperimentalActions.ACTION_SEND_MAVLINK_MESSAGE:
data.setClassLoader(MavlinkMessageWrapper.class.getClassLoader());
MavlinkMessageWrapper messageWrapper=data.getParcelable(ExperimentalActions.EXTRA_MAVLINK_MESSAGE);
DroneApiUtils.sendMavlinkMessage(getDrone(),messageWrapper);
break;
case ExperimentalActions.ACTION_SET_RELAY:
if (droneMgr != null) {
int relayNumber=data.getInt(ExperimentalActions.EXTRA_RELAY_NUMBER);
boolean isOn=data.getBoolean(ExperimentalActions.EXTRA_IS_RELAY_ON);
MavLinkDoCmds.setRelay(droneMgr.getDrone(),relayNumber,isOn);
}
case ExperimentalActions.ACTION_SET_SERVO:
if (droneMgr != null) {
int channel=data.getInt(ExperimentalActions.EXTRA_SERVO_CHANNEL);
int pwm=data.getInt(ExperimentalActions.EXTRA_SERVO_PWM);
MavLinkDoCmds.setServo(droneMgr.getDrone(),channel,pwm);
}
break;
case GuidedActions.ACTION_DO_GUIDED_TAKEOFF:
double takeoffAltitude=data.getDouble(GuidedActions.EXTRA_ALTITUDE);
DroneApiUtils.doGuidedTakeoff(getDrone(),takeoffAltitude);
break;
case GuidedActions.ACTION_SEND_GUIDED_POINT:
data.setClassLoader(LatLong.class.getClassLoader());
boolean force=data.getBoolean(GuidedActions.EXTRA_FORCE_GUIDED_POINT);
LatLong guidedPoint=data.getParcelable(GuidedActions.EXTRA_GUIDED_POINT);
DroneApiUtils.sendGuidedPoint(getDrone(),guidedPoint,force);
break;
case GuidedActions.ACTION_SET_GUIDED_ALTITUDE:
double guidedAltitude=data.getDouble(GuidedActions.EXTRA_ALTITUDE);
DroneApiUtils.setGuidedAltitude(getDrone(),guidedAltitude);
break;
case ParameterActions.ACTION_REFRESH_PARAMETERS:
DroneApiUtils.refreshParameters(getDrone());
break;
case ParameterActions.ACTION_WRITE_PARAMETERS:
data.setClassLoader(Parameters.class.getClassLoader());
Parameters parameters=data.getParcelable(ParameterActions.EXTRA_PARAMETERS);
DroneApiUtils.writeParameters(getDrone(),parameters);
break;
case StateActions.ACTION_ARM:
boolean doArm=data.getBoolean(StateActions.EXTRA_ARM);
DroneApiUtils.arm(getDrone(),doArm);
break;
case StateActions.ACTION_SET_VEHICLE_MODE:
data.setClassLoader(VehicleMode.class.getClassLoader());
VehicleMode newMode=data.getParcelable(StateActions.EXTRA_VEHICLE_MODE);
DroneApiUtils.changeVehicleMode(getDrone(),newMode);
break;
case CalibrationActions.ACTION_START_IMU_CALIBRATION:
if (!DroneApiUtils.startIMUCalibration(getDrone())) {
Bundle extrasBundle=new Bundle(1);
extrasBundle.putString(AttributeEventExtra.EXTRA_CALIBRATION_IMU_MESSAGE,context.getString(R.string.failed_start_calibration_message));
notifyAttributeUpdate(AttributeEvent.CALIBRATION_IMU_ERROR,extrasBundle);
}
break;
case CalibrationActions.ACTION_SEND_IMU_CALIBRATION_ACK:
int imuAck=data.getInt(CalibrationActions.EXTRA_IMU_STEP);
DroneApiUtils.sendIMUCalibrationAck(getDrone(),imuAck);
break;
case CalibrationActions.ACTION_START_MAGNETOMETER_CALIBRATION:
final boolean retryOnFailure=data.getBoolean(CalibrationActions.EXTRA_RETRY_ON_FAILURE,false);
final boolean saveAutomatically=data.getBoolean(CalibrationActions.EXTRA_SAVE_AUTOMATICALLY,true);
final int startDelay=data.getInt(CalibrationActions.EXTRA_START_DELAY,0);
DroneApiUtils.startMagnetometerCalibration(getDrone(),retryOnFailure,saveAutomatically,startDelay);
break;
case CalibrationActions.ACTION_CANCEL_MAGNETOMETER_CALIBRATION:
DroneApiUtils.cancelMagnetometerCalibration(getDrone());
break;
case CalibrationActions.ACTION_ACCEPT_MAGNETOMETER_CALIBRATION:
DroneApiUtils.acceptMagnetometerCalibration(getDrone());
break;
case FollowMeActions.ACTION_ENABLE_FOLLOW_ME:
data.setClassLoader(FollowType.class.getClassLoader());
FollowType followType=data.getParcelable(FollowMeActions.EXTRA_FOLLOW_TYPE);
DroneApiUtils.enableFollowMe(getDroneManager(),droneHandler,followType);
break;
case FollowMeActions.ACTION_UPDATE_FOLLOW_PARAMS:
if (droneMgr != null) {
data.setClassLoader(LatLong.class.getClassLoader());
final FollowAlgorithm followAlgorithm=this.droneMgr.getFollowMe().getFollowAlgorithm();
if (followAlgorithm != null) {
Map<String,Object> paramsMap=new HashMap<>();
Set<String> dataKeys=data.keySet();
for (String key : dataKeys) {
if (FollowType.EXTRA_FOLLOW_ROI_TARGET.equals(key)) {
LatLong target=data.getParcelable(key);
if (target != null) {
final Coord2D roiTarget;
if (target instanceof LatLongAlt) {
roiTarget=new Coord3D(target.getLatitude(),target.getLongitude(),((LatLongAlt)target).getAltitude());
}
 else {
roiTarget=new Coord2D(target.getLatitude(),target.getLongitude());
}
paramsMap.put(key,roiTarget);
}
}
 else paramsMap.put(key,data.get(key));
}
followAlgorithm.updateAlgorithmParams(paramsMap);
}
}
break;
case FollowMeActions.ACTION_DISABLE_FOLLOW_ME:
DroneApiUtils.disableFollowMe(getFollowMe());
break;
case CameraActions.ACTION_START_VIDEO_RECORDING:
DroneApiUtils.startVideoRecording(getDrone());
break;
case CameraActions.ACTION_STOP_VIDEO_RECORDING:
DroneApiUtils.stopVideoRecording(getDrone());
break;
}
}

Fixed version (ground truth):
@Override public void performAction(Action action) throws RemoteException {
  if (action == null)   return;
  final String type=action.getType();
  if (type == null)   return;
  Bundle data=action.getData();
switch (type) {
case MissionActions.ACTION_GENERATE_DRONIE:
    final float bearing=DroneApiUtils.generateDronie(getDrone());
  if (bearing != -1) {
    Bundle bundle=new Bundle(1);
    bundle.putFloat(AttributeEventExtra.EXTRA_MISSION_DRONIE_BEARING,bearing);
    notifyAttributeUpdate(AttributeEvent.MISSION_DRONIE_CREATED,bundle);
  }
break;
case MissionActions.ACTION_LOAD_WAYPOINTS:
DroneApiUtils.loadWaypoints(getDrone());
break;
case MissionActions.ACTION_SET_MISSION:
data.setClassLoader(Mission.class.getClassLoader());
Mission mission=data.getParcelable(MissionActions.EXTRA_MISSION);
boolean pushToDrone=data.getBoolean(MissionActions.EXTRA_PUSH_TO_DRONE);
DroneApiUtils.setMission(getDrone(),mission,pushToDrone);
break;
case MissionActions.ACTION_BUILD_COMPLEX_MISSION_ITEM:
DroneApiUtils.buildComplexMissionItem(getDrone(),data);
break;
case ConnectionActions.ACTION_CONNECT:
data.setClassLoader(ConnectionParameter.class.getClassLoader());
ConnectionParameter parameter=data.getParcelable(ConnectionActions.EXTRA_CONNECT_PARAMETER);
connect(parameter);
break;
case ConnectionActions.ACTION_DISCONNECT:
disconnect();
break;
case ExperimentalActions.ACTION_EPM_COMMAND:
boolean release=data.getBoolean(ExperimentalActions.EXTRA_EPM_RELEASE);
DroneApiUtils.epmCommand(getDrone(),release);
break;
case ExperimentalActions.ACTION_TRIGGER_CAMERA:
DroneApiUtils.triggerCamera(getDrone());
break;
case ExperimentalActions.ACTION_SET_ROI:
LatLongAlt roi=data.getParcelable(ExperimentalActions.EXTRA_SET_ROI_LAT_LONG_ALT);
if (roi != null) {
Coord3D coord3DRoi=new Coord3D(roi.getLatitude(),roi.getLongitude(),roi.getAltitude());
MavLinkDoCmds.setROI(getDrone(),coord3DRoi);
}
break;
case ExperimentalActions.ACTION_SEND_MAVLINK_MESSAGE:
data.setClassLoader(MavlinkMessageWrapper.class.getClassLoader());
MavlinkMessageWrapper messageWrapper=data.getParcelable(ExperimentalActions.EXTRA_MAVLINK_MESSAGE);
DroneApiUtils.sendMavlinkMessage(getDrone(),messageWrapper);
break;
case ExperimentalActions.ACTION_SET_RELAY:
if (droneMgr != null) {
int relayNumber=data.getInt(ExperimentalActions.EXTRA_RELAY_NUMBER);
boolean isOn=data.getBoolean(ExperimentalActions.EXTRA_IS_RELAY_ON);
MavLinkDoCmds.setRelay(droneMgr.getDrone(),relayNumber,isOn);
}
case ExperimentalActions.ACTION_SET_SERVO:
if (droneMgr != null) {
int channel=data.getInt(ExperimentalActions.EXTRA_SERVO_CHANNEL);
int pwm=data.getInt(ExperimentalActions.EXTRA_SERVO_PWM);
MavLinkDoCmds.setServo(droneMgr.getDrone(),channel,pwm);
}
break;
case GuidedActions.ACTION_DO_GUIDED_TAKEOFF:
double takeoffAltitude=data.getDouble(GuidedActions.EXTRA_ALTITUDE);
DroneApiUtils.doGuidedTakeoff(getDrone(),takeoffAltitude);
break;
case GuidedActions.ACTION_SEND_GUIDED_POINT:
data.setClassLoader(LatLong.class.getClassLoader());
boolean force=data.getBoolean(GuidedActions.EXTRA_FORCE_GUIDED_POINT);
LatLong guidedPoint=data.getParcelable(GuidedActions.EXTRA_GUIDED_POINT);
DroneApiUtils.sendGuidedPoint(getDrone(),guidedPoint,force);
break;
case GuidedActions.ACTION_SET_GUIDED_ALTITUDE:
double guidedAltitude=data.getDouble(GuidedActions.EXTRA_ALTITUDE);
DroneApiUtils.setGuidedAltitude(getDrone(),guidedAltitude);
break;
case ParameterActions.ACTION_REFRESH_PARAMETERS:
DroneApiUtils.refreshParameters(getDrone());
break;
case ParameterActions.ACTION_WRITE_PARAMETERS:
data.setClassLoader(Parameters.class.getClassLoader());
Parameters parameters=data.getParcelable(ParameterActions.EXTRA_PARAMETERS);
DroneApiUtils.writeParameters(getDrone(),parameters);
break;
case StateActions.ACTION_ARM:
boolean doArm=data.getBoolean(StateActions.EXTRA_ARM);
DroneApiUtils.arm(getDrone(),doArm);
break;
case StateActions.ACTION_SET_VEHICLE_MODE:
data.setClassLoader(VehicleMode.class.getClassLoader());
VehicleMode newMode=data.getParcelable(StateActions.EXTRA_VEHICLE_MODE);
DroneApiUtils.changeVehicleMode(getDrone(),newMode);
break;
case CalibrationActions.ACTION_START_IMU_CALIBRATION:
if (!DroneApiUtils.startIMUCalibration(getDrone())) {
Bundle extrasBundle=new Bundle(1);
extrasBundle.putString(AttributeEventExtra.EXTRA_CALIBRATION_IMU_MESSAGE,context.getString(R.string.failed_start_calibration_message));
notifyAttributeUpdate(AttributeEvent.CALIBRATION_IMU_ERROR,extrasBundle);
}
break;
case CalibrationActions.ACTION_SEND_IMU_CALIBRATION_ACK:
int imuAck=data.getInt(CalibrationActions.EXTRA_IMU_STEP);
DroneApiUtils.sendIMUCalibrationAck(getDrone(),imuAck);
break;
case CalibrationActions.ACTION_START_MAGNETOMETER_CALIBRATION:
final boolean retryOnFailure=data.getBoolean(CalibrationActions.EXTRA_RETRY_ON_FAILURE,false);
final boolean saveAutomatically=data.getBoolean(CalibrationActions.EXTRA_SAVE_AUTOMATICALLY,true);
final int startDelay=data.getInt(CalibrationActions.EXTRA_START_DELAY,0);
DroneApiUtils.startMagnetometerCalibration(getDrone(),retryOnFailure,saveAutomatically,startDelay);
break;
case CalibrationActions.ACTION_CANCEL_MAGNETOMETER_CALIBRATION:
DroneApiUtils.cancelMagnetometerCalibration(getDrone());
break;
case CalibrationActions.ACTION_ACCEPT_MAGNETOMETER_CALIBRATION:
DroneApiUtils.acceptMagnetometerCalibration(getDrone());
break;
case FollowMeActions.ACTION_ENABLE_FOLLOW_ME:
data.setClassLoader(FollowType.class.getClassLoader());
FollowType followType=data.getParcelable(FollowMeActions.EXTRA_FOLLOW_TYPE);
DroneApiUtils.enableFollowMe(getDroneManager(),droneHandler,followType);
break;
case FollowMeActions.ACTION_UPDATE_FOLLOW_PARAMS:
if (droneMgr != null) {
data.setClassLoader(LatLong.class.getClassLoader());
final FollowAlgorithm followAlgorithm=this.droneMgr.getFollowMe().getFollowAlgorithm();
if (followAlgorithm != null) {
Map<String,Object> paramsMap=new HashMap<>();
Set<String> dataKeys=data.keySet();
for (String key : dataKeys) {
if (FollowType.EXTRA_FOLLOW_ROI_TARGET.equals(key)) {
LatLong target=data.getParcelable(key);
if (target != null) {
final Coord2D roiTarget;
if (target instanceof LatLongAlt) {
roiTarget=new Coord3D(target.getLatitude(),target.getLongitude(),((LatLongAlt)target).getAltitude());
}
 else {
roiTarget=new Coord2D(target.getLatitude(),target.getLongitude());
}
paramsMap.put(key,roiTarget);
}
}
 else paramsMap.put(key,data.get(key));
}
followAlgorithm.updateAlgorithmParams(paramsMap);
}
}
break;
case FollowMeActions.ACTION_DISABLE_FOLLOW_ME:
DroneApiUtils.disableFollowMe(getFollowMe());
break;
case CameraActions.ACTION_START_VIDEO_RECORDING:
DroneApiUtils.startVideoRecording(getDrone());
break;
case CameraActions.ACTION_STOP_VIDEO_RECORDING:
DroneApiUtils.stopVideoRecording(getDrone());
break;
}
}