Program: 94744
Project: 94744
Buggy source:
@Override public boolean executeAsyncAction(Action action,final ICommandListener listener){
  final String type=action.getType();
  Bundle data=action.getData();
  if (data == null) {
    data=new Bundle();
  }
switch (type) {
case MissionActions.ACTION_LOAD_WAYPOINTS:
    CommonApiUtils.loadWaypoints(this);
  return true;
case MissionActions.ACTION_SET_MISSION:
data.setClassLoader(com.o3dr.services.android.lib.drone.mission.Mission.class.getClassLoader());
com.o3dr.services.android.lib.drone.mission.Mission mission=data.getParcelable(MissionActions.EXTRA_MISSION);
boolean pushToDrone=data.getBoolean(MissionActions.EXTRA_PUSH_TO_DRONE);
CommonApiUtils.setMission(this,mission,pushToDrone);
return true;
case MissionActions.ACTION_START_MISSION:
boolean forceModeChange=data.getBoolean(MissionActions.EXTRA_FORCE_MODE_CHANGE);
boolean forceArm=data.getBoolean(MissionActions.EXTRA_FORCE_ARM);
CommonApiUtils.startMission(this,forceModeChange,forceArm,listener);
return true;
case ExperimentalActions.ACTION_EPM_COMMAND:
boolean release=data.getBoolean(ExperimentalActions.EXTRA_EPM_RELEASE);
CommonApiUtils.epmCommand(this,release,listener);
return true;
case ExperimentalActions.ACTION_TRIGGER_CAMERA:
CommonApiUtils.triggerCamera(this);
return true;
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(this,coord3DRoi,listener);
}
return true;
case ExperimentalActions.ACTION_SEND_MAVLINK_MESSAGE:
data.setClassLoader(MavlinkMessageWrapper.class.getClassLoader());
MavlinkMessageWrapper messageWrapper=data.getParcelable(ExperimentalActions.EXTRA_MAVLINK_MESSAGE);
CommonApiUtils.sendMavlinkMessage(this,messageWrapper);
return true;
case ExperimentalActions.ACTION_SET_RELAY:
int relayNumber=data.getInt(ExperimentalActions.EXTRA_RELAY_NUMBER);
boolean isOn=data.getBoolean(ExperimentalActions.EXTRA_IS_RELAY_ON);
MavLinkDoCmds.setRelay(this,relayNumber,isOn,listener);
return true;
case ExperimentalActions.ACTION_SET_SERVO:
int channel=data.getInt(ExperimentalActions.EXTRA_SERVO_CHANNEL);
int pwm=data.getInt(ExperimentalActions.EXTRA_SERVO_PWM);
MavLinkDoCmds.setServo(this,channel,pwm,listener);
return true;
case ControlActions.ACTION_DO_GUIDED_TAKEOFF:
double takeoffAltitude=data.getDouble(ControlActions.EXTRA_ALTITUDE);
CommonApiUtils.doGuidedTakeoff(this,takeoffAltitude,listener);
return true;
case ControlActions.ACTION_SEND_GUIDED_POINT:
data.setClassLoader(LatLong.class.getClassLoader());
boolean force=data.getBoolean(ControlActions.EXTRA_FORCE_GUIDED_POINT);
LatLong guidedPoint=data.getParcelable(ControlActions.EXTRA_GUIDED_POINT);
CommonApiUtils.sendGuidedPoint(this,guidedPoint,force,listener);
return true;
case ControlActions.ACTION_SET_GUIDED_ALTITUDE:
double guidedAltitude=data.getDouble(ControlActions.EXTRA_ALTITUDE);
CommonApiUtils.setGuidedAltitude(this,guidedAltitude);
return true;
case ControlActions.ACTION_SET_CONDITION_YAW:
final float targetAngle=data.getFloat(ControlActions.EXTRA_YAW_TARGET_ANGLE);
final float yawRate=data.getFloat(ControlActions.EXTRA_YAW_CHANGE_RATE);
final boolean isClockwise=data.getBoolean(ControlActions.EXTRA_YAW_IS_CLOCKWISE);
final boolean isRelative=data.getBoolean(ControlActions.EXTRA_YAW_IS_RELATIVE);
MavLinkModes.setConditionYaw(this,targetAngle,yawRate,isClockwise,isRelative,listener);
return true;
case ControlActions.ACTION_SET_VELOCITY:
final float xVel=data.getFloat(ControlActions.EXTRA_VELOCITY_X);
final float yVel=data.getFloat(ControlActions.EXTRA_VELOCITY_Y);
final float zVel=data.getFloat(ControlActions.EXTRA_VELOCITY_Z);
MavLinkModes.setVelocityInLocalFrame(this,xVel,yVel,zVel,listener);
return true;
case ParameterActions.ACTION_REFRESH_PARAMETERS:
CommonApiUtils.refreshParameters(this);
return true;
case ParameterActions.ACTION_WRITE_PARAMETERS:
data.setClassLoader(com.o3dr.services.android.lib.drone.property.Parameters.class.getClassLoader());
com.o3dr.services.android.lib.drone.property.Parameters parameters=data.getParcelable(ParameterActions.EXTRA_PARAMETERS);
CommonApiUtils.writeParameters(this,parameters);
return true;
case StateActions.ACTION_ARM:
boolean doArm=data.getBoolean(StateActions.EXTRA_ARM);
boolean emergencyDisarm=data.getBoolean(StateActions.EXTRA_EMERGENCY_DISARM);
CommonApiUtils.arm(this,doArm,emergencyDisarm,listener);
return true;
case StateActions.ACTION_SET_VEHICLE_HOME:
final LatLongAlt homeLoc=data.getParcelable(StateActions.EXTRA_VEHICLE_HOME_LOCATION);
if (homeLoc != null) {
MavLinkDoCmds.setVehicleHome(this,homeLoc,new AbstractCommandListener(){
@Override public void onSuccess(){
CommonApiUtils.postSuccessEvent(listener);
home.requestHomeUpdate();
}
@Override public void onError(int executionError){
CommonApiUtils.postErrorEvent(executionError,listener);
home.requestHomeUpdate();
}
@Override public void onTimeout(){
CommonApiUtils.postTimeoutEvent(listener);
home.requestHomeUpdate();
}
}
);
}
 else {
CommonApiUtils.postErrorEvent(CommandExecutionError.COMMAND_FAILED,listener);
}
return true;
case CalibrationActions.ACTION_START_IMU_CALIBRATION:
CommonApiUtils.startIMUCalibration(this,listener);
return true;
case CalibrationActions.ACTION_SEND_IMU_CALIBRATION_ACK:
int imuAck=data.getInt(CalibrationActions.EXTRA_IMU_STEP);
CommonApiUtils.sendIMUCalibrationAck(this,imuAck);
return true;
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);
CommonApiUtils.startMagnetometerCalibration(this,retryOnFailure,saveAutomatically,startDelay);
return true;
case CalibrationActions.ACTION_CANCEL_MAGNETOMETER_CALIBRATION:
CommonApiUtils.cancelMagnetometerCalibration(this);
return true;
case CalibrationActions.ACTION_ACCEPT_MAGNETOMETER_CALIBRATION:
CommonApiUtils.acceptMagnetometerCalibration(this);
return true;
case GimbalActions.ACTION_SET_GIMBAL_ORIENTATION:
float pitch=data.getFloat(GimbalActions.GIMBAL_PITCH);
float roll=data.getFloat(GimbalActions.GIMBAL_ROLL);
float yaw=data.getFloat(GimbalActions.GIMBAL_YAW);
MavLinkDoCmds.setGimbalOrientation(this,pitch,roll,yaw,listener);
return true;
case GimbalActions.ACTION_RESET_GIMBAL_MOUNT_MODE:
case GimbalActions.ACTION_SET_GIMBAL_MOUNT_MODE:
final int mountMode=data.getInt(GimbalActions.GIMBAL_MOUNT_MODE,MAV_MOUNT_MODE.MAV_MOUNT_MODE_RC_TARGETING);
Timber.i("String_Node_Str",mountMode);
Parameter mountParam=this.parameters.getParameter("String_Node_Str");
if (mountParam == null) {
msg_mount_configure msg=new msg_mount_configure();
msg.target_system=getSysid();
msg.target_component=getCompid();
msg.mount_mode=(byte)mountMode;
msg.stab_pitch=0;
msg.stab_roll=0;
msg.stab_yaw=0;
getMavClient().sendMavMessage(msg,listener);
}
 else {
MavLinkParameters.sendParameter(this,"String_Node_Str",1,mountMode);
}
return true;
default :
return super.executeAsyncAction(action,listener);
}
}

Fixed version (ground truth):
@Override public boolean executeAsyncAction(Action action,final ICommandListener listener){
  final String type=action.getType();
  Bundle data=action.getData();
  if (data == null) {
    data=new Bundle();
  }
switch (type) {
case MissionActions.ACTION_LOAD_WAYPOINTS:
    CommonApiUtils.loadWaypoints(this);
  return true;
case MissionActions.ACTION_SET_MISSION:
data.setClassLoader(com.o3dr.services.android.lib.drone.mission.Mission.class.getClassLoader());
com.o3dr.services.android.lib.drone.mission.Mission mission=data.getParcelable(MissionActions.EXTRA_MISSION);
boolean pushToDrone=data.getBoolean(MissionActions.EXTRA_PUSH_TO_DRONE);
CommonApiUtils.setMission(this,mission,pushToDrone);
return true;
case MissionActions.ACTION_START_MISSION:
boolean forceModeChange=data.getBoolean(MissionActions.EXTRA_FORCE_MODE_CHANGE);
boolean forceArm=data.getBoolean(MissionActions.EXTRA_FORCE_ARM);
CommonApiUtils.startMission(this,forceModeChange,forceArm,listener);
return true;
case ExperimentalActions.ACTION_EPM_COMMAND:
boolean release=data.getBoolean(ExperimentalActions.EXTRA_EPM_RELEASE);
CommonApiUtils.epmCommand(this,release,listener);
return true;
case ExperimentalActions.ACTION_TRIGGER_CAMERA:
CommonApiUtils.triggerCamera(this);
return true;
case ExperimentalActions.ACTION_SET_ROI:
LatLongAlt roi=data.getParcelable(ExperimentalActions.EXTRA_SET_ROI_LAT_LONG_ALT);
if (roi != null) {
MavLinkDoCmds.setROI(this,roi,listener);
}
return true;
case ExperimentalActions.ACTION_SEND_MAVLINK_MESSAGE:
data.setClassLoader(MavlinkMessageWrapper.class.getClassLoader());
MavlinkMessageWrapper messageWrapper=data.getParcelable(ExperimentalActions.EXTRA_MAVLINK_MESSAGE);
CommonApiUtils.sendMavlinkMessage(this,messageWrapper);
return true;
case ExperimentalActions.ACTION_SET_RELAY:
int relayNumber=data.getInt(ExperimentalActions.EXTRA_RELAY_NUMBER);
boolean isOn=data.getBoolean(ExperimentalActions.EXTRA_IS_RELAY_ON);
MavLinkDoCmds.setRelay(this,relayNumber,isOn,listener);
return true;
case ExperimentalActions.ACTION_SET_SERVO:
int channel=data.getInt(ExperimentalActions.EXTRA_SERVO_CHANNEL);
int pwm=data.getInt(ExperimentalActions.EXTRA_SERVO_PWM);
MavLinkDoCmds.setServo(this,channel,pwm,listener);
return true;
case ControlActions.ACTION_DO_GUIDED_TAKEOFF:
double takeoffAltitude=data.getDouble(ControlActions.EXTRA_ALTITUDE);
CommonApiUtils.doGuidedTakeoff(this,takeoffAltitude,listener);
return true;
case ControlActions.ACTION_SEND_GUIDED_POINT:
data.setClassLoader(LatLong.class.getClassLoader());
boolean force=data.getBoolean(ControlActions.EXTRA_FORCE_GUIDED_POINT);
LatLong guidedPoint=data.getParcelable(ControlActions.EXTRA_GUIDED_POINT);
CommonApiUtils.sendGuidedPoint(this,guidedPoint,force,listener);
return true;
case ControlActions.ACTION_SET_GUIDED_ALTITUDE:
double guidedAltitude=data.getDouble(ControlActions.EXTRA_ALTITUDE);
CommonApiUtils.setGuidedAltitude(this,guidedAltitude);
return true;
case ControlActions.ACTION_SET_CONDITION_YAW:
final float targetAngle=data.getFloat(ControlActions.EXTRA_YAW_TARGET_ANGLE);
final float yawRate=data.getFloat(ControlActions.EXTRA_YAW_CHANGE_RATE);
final boolean isClockwise=data.getBoolean(ControlActions.EXTRA_YAW_IS_CLOCKWISE);
final boolean isRelative=data.getBoolean(ControlActions.EXTRA_YAW_IS_RELATIVE);
MavLinkModes.setConditionYaw(this,targetAngle,yawRate,isClockwise,isRelative,listener);
return true;
case ControlActions.ACTION_SET_VELOCITY:
final float xVel=data.getFloat(ControlActions.EXTRA_VELOCITY_X);
final float yVel=data.getFloat(ControlActions.EXTRA_VELOCITY_Y);
final float zVel=data.getFloat(ControlActions.EXTRA_VELOCITY_Z);
MavLinkModes.setVelocityInLocalFrame(this,xVel,yVel,zVel,listener);
return true;
case ParameterActions.ACTION_REFRESH_PARAMETERS:
CommonApiUtils.refreshParameters(this);
return true;
case ParameterActions.ACTION_WRITE_PARAMETERS:
data.setClassLoader(com.o3dr.services.android.lib.drone.property.Parameters.class.getClassLoader());
com.o3dr.services.android.lib.drone.property.Parameters parameters=data.getParcelable(ParameterActions.EXTRA_PARAMETERS);
CommonApiUtils.writeParameters(this,parameters);
return true;
case StateActions.ACTION_ARM:
boolean doArm=data.getBoolean(StateActions.EXTRA_ARM);
boolean emergencyDisarm=data.getBoolean(StateActions.EXTRA_EMERGENCY_DISARM);
CommonApiUtils.arm(this,doArm,emergencyDisarm,listener);
return true;
case StateActions.ACTION_SET_VEHICLE_HOME:
final LatLongAlt homeLoc=data.getParcelable(StateActions.EXTRA_VEHICLE_HOME_LOCATION);
if (homeLoc != null) {
MavLinkDoCmds.setVehicleHome(this,homeLoc,new AbstractCommandListener(){
@Override public void onSuccess(){
CommonApiUtils.postSuccessEvent(listener);
home.requestHomeUpdate();
}
@Override public void onError(int executionError){
CommonApiUtils.postErrorEvent(executionError,listener);
home.requestHomeUpdate();
}
@Override public void onTimeout(){
CommonApiUtils.postTimeoutEvent(listener);
home.requestHomeUpdate();
}
}
);
}
 else {
CommonApiUtils.postErrorEvent(CommandExecutionError.COMMAND_FAILED,listener);
}
return true;
case CalibrationActions.ACTION_START_IMU_CALIBRATION:
CommonApiUtils.startIMUCalibration(this,listener);
return true;
case CalibrationActions.ACTION_SEND_IMU_CALIBRATION_ACK:
int imuAck=data.getInt(CalibrationActions.EXTRA_IMU_STEP);
CommonApiUtils.sendIMUCalibrationAck(this,imuAck);
return true;
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);
CommonApiUtils.startMagnetometerCalibration(this,retryOnFailure,saveAutomatically,startDelay);
return true;
case CalibrationActions.ACTION_CANCEL_MAGNETOMETER_CALIBRATION:
CommonApiUtils.cancelMagnetometerCalibration(this);
return true;
case CalibrationActions.ACTION_ACCEPT_MAGNETOMETER_CALIBRATION:
CommonApiUtils.acceptMagnetometerCalibration(this);
return true;
case GimbalActions.ACTION_SET_GIMBAL_ORIENTATION:
float pitch=data.getFloat(GimbalActions.GIMBAL_PITCH);
float roll=data.getFloat(GimbalActions.GIMBAL_ROLL);
float yaw=data.getFloat(GimbalActions.GIMBAL_YAW);
MavLinkDoCmds.setGimbalOrientation(this,pitch,roll,yaw,listener);
return true;
case GimbalActions.ACTION_RESET_GIMBAL_MOUNT_MODE:
case GimbalActions.ACTION_SET_GIMBAL_MOUNT_MODE:
final int mountMode=data.getInt(GimbalActions.GIMBAL_MOUNT_MODE,MAV_MOUNT_MODE.MAV_MOUNT_MODE_RC_TARGETING);
Timber.i("String_Node_Str",mountMode);
Parameter mountParam=this.parameters.getParameter("String_Node_Str");
if (mountParam == null) {
msg_mount_configure msg=new msg_mount_configure();
msg.target_system=getSysid();
msg.target_component=getCompid();
msg.mount_mode=(byte)mountMode;
msg.stab_pitch=0;
msg.stab_roll=0;
msg.stab_yaw=0;
getMavClient().sendMavMessage(msg,listener);
}
 else {
MavLinkParameters.sendParameter(this,"String_Node_Str",1,mountMode);
}
return true;
default :
return super.executeAsyncAction(action,listener);
}
}