Program: 94675
Project: 94675
Buggy source:
/** 
 * Setup a MAVLink connection based on the connection parameters.
 */
@Override public synchronized void openConnection(){
  if (isConnected() || isConnecting())   return;
  final String tag=toString();
  final int connectionType=connParams.getConnectionType();
  final Bundle paramsBundle=connParams.getParamsBundle();
  if (mavlinkConn == null) {
switch (connectionType) {
case ConnectionType.TYPE_USB:
      final int baudRate=paramsBundle.getInt(ConnectionType.EXTRA_USB_BAUD_RATE,ConnectionType.DEFAULT_USB_BAUD_RATE);
    mavlinkConn=new UsbConnection(context,baudRate);
  Timber.i("String_Node_Str");
break;
case ConnectionType.TYPE_BLUETOOTH:
final String bluetoothAddress=paramsBundle.getString(ConnectionType.EXTRA_BLUETOOTH_ADDRESS);
mavlinkConn=new BluetoothConnection(context,bluetoothAddress);
Timber.i("String_Node_Str");
break;
case ConnectionType.TYPE_TCP:
final String tcpServerIp=paramsBundle.getString(ConnectionType.EXTRA_TCP_SERVER_IP);
final int tcpServerPort=paramsBundle.getInt(ConnectionType.EXTRA_TCP_SERVER_PORT,ConnectionType.DEFAULT_TCP_SERVER_PORT);
mavlinkConn=new AndroidTcpConnection(context,tcpServerIp,tcpServerPort);
Timber.i("String_Node_Str");
break;
case ConnectionType.TYPE_UDP:
final int udpServerPort=paramsBundle.getInt(ConnectionType.EXTRA_UDP_SERVER_PORT,ConnectionType.DEFAULT_UDP_SERVER_PORT);
mavlinkConn=new AndroidUdpConnection(context,udpServerPort);
Timber.i("String_Node_Str");
break;
case ConnectionType.TYPE_SOLO:
{
Timber.i("String_Node_Str");
final String soloLinkId=paramsBundle.getString(ConnectionType.EXTRA_SOLO_LINK_ID,null);
final String linkPassword=paramsBundle.getString(ConnectionType.EXTRA_SOLO_LINK_PASSWORD,null);
mavlinkConn=new SoloConnection(context,soloLinkId,linkPassword);
break;
}
default :
Timber.e("String_Node_Str",connectionType);
return;
}
}
mavlinkConn.addMavLinkConnectionListener(tag,mConnectionListener);
if (connectionType == ConnectionType.TYPE_UDP) {
final String pingIpAddress=paramsBundle.getString(ConnectionType.EXTRA_UDP_PING_RECEIVER_IP);
if (!TextUtils.isEmpty(pingIpAddress)) {
try {
final InetAddress resolvedAddress=InetAddress.getByName(pingIpAddress);
final int pingPort=paramsBundle.getInt(ConnectionType.EXTRA_UDP_PING_RECEIVER_PORT);
final long pingPeriod=paramsBundle.getLong(ConnectionType.EXTRA_UDP_PING_PERIOD,ConnectionType.DEFAULT_UDP_PING_PERIOD);
final byte[] pingPayload=paramsBundle.getByteArray(ConnectionType.EXTRA_UDP_PING_PAYLOAD);
((AndroidUdpConnection)mavlinkConn).addPingTarget(resolvedAddress,pingPort,pingPeriod,pingPayload);
}
 catch (UnknownHostException e) {
Timber.e(e,"String_Node_Str");
}
}
}
if (mavlinkConn.getConnectionStatus() == MavLinkConnection.MAVLINK_DISCONNECTED) {
mavlinkConn.connect();
GAUtils.sendEvent(new HitBuilders.EventBuilder().setCategory(GAUtils.Category.MAVLINK_CONNECTION).setAction("String_Node_Str").setLabel(connParams.toString()));
}
}

Fixed version (ground truth):
/** 
 * Setup a MAVLink connection based on the connection parameters.
 */
@Override public synchronized void openConnection(){
  if (isConnected() || isConnecting())   return;
  final String tag=toString();
  final int connectionType=connParams.getConnectionType();
  final Bundle paramsBundle=connParams.getParamsBundle();
  if (mavlinkConn == null) {
switch (connectionType) {
case ConnectionType.TYPE_USB:
      final int baudRate=paramsBundle.getInt(ConnectionType.EXTRA_USB_BAUD_RATE,ConnectionType.DEFAULT_USB_BAUD_RATE);
    mavlinkConn=new UsbConnection(context,baudRate);
  Timber.i("String_Node_Str");
break;
case ConnectionType.TYPE_BLUETOOTH:
final String bluetoothAddress=paramsBundle.getString(ConnectionType.EXTRA_BLUETOOTH_ADDRESS);
mavlinkConn=new BluetoothConnection(context,bluetoothAddress);
Timber.i("String_Node_Str");
break;
case ConnectionType.TYPE_TCP:
final String tcpServerIp=paramsBundle.getString(ConnectionType.EXTRA_TCP_SERVER_IP);
final int tcpServerPort=paramsBundle.getInt(ConnectionType.EXTRA_TCP_SERVER_PORT,ConnectionType.DEFAULT_TCP_SERVER_PORT);
mavlinkConn=new AndroidTcpConnection(context,tcpServerIp,tcpServerPort,new WifiConnectionHandler(context));
Timber.i("String_Node_Str");
break;
case ConnectionType.TYPE_UDP:
final int udpServerPort=paramsBundle.getInt(ConnectionType.EXTRA_UDP_SERVER_PORT,ConnectionType.DEFAULT_UDP_SERVER_PORT);
mavlinkConn=new AndroidUdpConnection(context,udpServerPort,new WifiConnectionHandler(context));
Timber.i("String_Node_Str");
break;
case ConnectionType.TYPE_SOLO:
{
Timber.i("String_Node_Str");
final String soloLinkId=paramsBundle.getString(ConnectionType.EXTRA_SOLO_LINK_ID,null);
final String linkPassword=paramsBundle.getString(ConnectionType.EXTRA_SOLO_LINK_PASSWORD,null);
mavlinkConn=new SoloConnection(context,soloLinkId,linkPassword);
break;
}
default :
Timber.e("String_Node_Str",connectionType);
return;
}
}
mavlinkConn.addMavLinkConnectionListener(tag,mConnectionListener);
if (connectionType == ConnectionType.TYPE_UDP) {
final String pingIpAddress=paramsBundle.getString(ConnectionType.EXTRA_UDP_PING_RECEIVER_IP);
if (!TextUtils.isEmpty(pingIpAddress)) {
try {
final InetAddress resolvedAddress=InetAddress.getByName(pingIpAddress);
final int pingPort=paramsBundle.getInt(ConnectionType.EXTRA_UDP_PING_RECEIVER_PORT);
final long pingPeriod=paramsBundle.getLong(ConnectionType.EXTRA_UDP_PING_PERIOD,ConnectionType.DEFAULT_UDP_PING_PERIOD);
final byte[] pingPayload=paramsBundle.getByteArray(ConnectionType.EXTRA_UDP_PING_PAYLOAD);
((AndroidUdpConnection)mavlinkConn).addPingTarget(resolvedAddress,pingPort,pingPeriod,pingPayload);
}
 catch (UnknownHostException e) {
Timber.e(e,"String_Node_Str");
}
}
}
if (mavlinkConn.getConnectionStatus() == MavLinkConnection.MAVLINK_DISCONNECTED) {
mavlinkConn.connect();
GAUtils.sendEvent(new HitBuilders.EventBuilder().setCategory(GAUtils.Category.MAVLINK_CONNECTION).setAction("String_Node_Str").setLabel(connParams.toString()));
}
}