Program: 94879
Project: 94879
Buggy source:
void connectMAVConnection(ConnectionParameter connParams,String listenerTag,MavLinkConnectionListener listener){
  AndroidMavLinkConnection conn=mavConnections.get(connParams.getUniqueId());
  final int connectionType=connParams.getConnectionType();
  final Bundle paramsBundle=connParams.getParamsBundle();
  if (conn == null) {
switch (connectionType) {
case ConnectionType.TYPE_USB:
      final int baudRate=paramsBundle.getInt(ConnectionType.EXTRA_USB_BAUD_RATE,ConnectionType.DEFAULT_USB_BAUD_RATE);
    conn=new UsbConnection(getApplicationContext(),baudRate);
  Log.d(TAG,"String_Node_Str");
break;
case ConnectionType.TYPE_BLUETOOTH:
final String bluetoothAddress=paramsBundle.getString(ConnectionType.EXTRA_BLUETOOTH_ADDRESS);
conn=new BluetoothConnection(getApplicationContext(),bluetoothAddress);
Log.d(TAG,"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);
conn=new AndroidTcpConnection(getApplicationContext(),tcpServerIp,tcpServerPort);
Log.d(TAG,"String_Node_Str");
break;
case ConnectionType.TYPE_UDP:
final int udpServerPort=paramsBundle.getInt(ConnectionType.EXTRA_UDP_SERVER_PORT,ConnectionType.DEFAULT_UDP_SERVER_PORT);
conn=new AndroidUdpConnection(getApplicationContext(),udpServerPort,new Handler(Looper.getMainLooper()));
Log.d(TAG,"String_Node_Str");
break;
default :
Log.e(TAG,"String_Node_Str" + connectionType);
return;
}
mavConnections.put(connParams.getUniqueId(),conn);
}
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)conn).addPingTarget(resolvedAddress,pingPort,pingPeriod,pingPayload);
}
 catch (UnknownHostException e) {
Log.e(TAG,"String_Node_Str",e);
}
}
}
conn.addMavLinkConnectionListener(listenerTag,listener);
if (conn.getConnectionStatus() == MavLinkConnection.MAVLINK_DISCONNECTED) {
conn.connect();
GAUtils.sendEvent(new HitBuilders.EventBuilder().setCategory(GAUtils.Category.MAVLINK_CONNECTION).setAction("String_Node_Str").setLabel(connParams.toString()));
}
}

Fixed version (ground truth):
void connectMAVConnection(ConnectionParameter connParams,String listenerTag,MavLinkConnectionListener listener){
  AndroidMavLinkConnection conn=mavConnections.get(connParams.getUniqueId());
  final int connectionType=connParams.getConnectionType();
  final Bundle paramsBundle=connParams.getParamsBundle();
  if (conn == null) {
switch (connectionType) {
case ConnectionType.TYPE_USB:
      final int baudRate=paramsBundle.getInt(ConnectionType.EXTRA_USB_BAUD_RATE,ConnectionType.DEFAULT_USB_BAUD_RATE);
    conn=new UsbConnection(getApplicationContext(),baudRate);
  Log.d(TAG,"String_Node_Str");
break;
case ConnectionType.TYPE_BLUETOOTH:
final String bluetoothAddress=paramsBundle.getString(ConnectionType.EXTRA_BLUETOOTH_ADDRESS);
conn=new BluetoothConnection(getApplicationContext(),bluetoothAddress);
Log.d(TAG,"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);
conn=new AndroidTcpConnection(getApplicationContext(),tcpServerIp,tcpServerPort);
Log.d(TAG,"String_Node_Str");
break;
case ConnectionType.TYPE_UDP:
final int udpServerPort=paramsBundle.getInt(ConnectionType.EXTRA_UDP_SERVER_PORT,ConnectionType.DEFAULT_UDP_SERVER_PORT);
conn=new AndroidUdpConnection(getApplicationContext(),udpServerPort);
Log.d(TAG,"String_Node_Str");
break;
default :
Log.e(TAG,"String_Node_Str" + connectionType);
return;
}
mavConnections.put(connParams.getUniqueId(),conn);
}
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)conn).addPingTarget(resolvedAddress,pingPort,pingPeriod,pingPayload);
}
 catch (UnknownHostException e) {
Log.e(TAG,"String_Node_Str",e);
}
}
}
conn.addMavLinkConnectionListener(listenerTag,listener);
if (conn.getConnectionStatus() == MavLinkConnection.MAVLINK_DISCONNECTED) {
conn.connect();
GAUtils.sendEvent(new HitBuilders.EventBuilder().setCategory(GAUtils.Category.MAVLINK_CONNECTION).setAction("String_Node_Str").setLabel(connParams.toString()));
}
}