Program: 94959
Project: 94959
Buggy source:
void connectMAVConnection(ConnectionParameter connParams){
  AndroidMavLinkConnection conn=mavConnections.get(connParams);
  if (conn == null) {
    final int connectionType=connParams.getConnectionType();
    final Bundle paramsBundle=connParams.getParamsBundle();
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_UPD_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,conn);
}
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);
  if (conn == null) {
    final int connectionType=connParams.getConnectionType();
    final Bundle paramsBundle=connParams.getParamsBundle();
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_UPD_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,conn);
}
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()));
}
conn.addMavLinkConnectionListener(listenerTag,listener);
}