nus-yam/ex-repair huggingface dataset:
Program: 32420
Project: 32420
Buggy source:
/** 
 * Start the ConnectedThread to begin managing a Bluetooth connection
 * @param socket  The BluetoothSocket on which the connection was made
 * @param device  The BluetoothDevice that has been connected
 */
public synchronized void connected(BluetoothSocket socket,BluetoothDevice device){
  if (getBluetoothSerialServerInstance().mConnectThread != null) {
    getBluetoothSerialServerInstance().mConnectThread.cancel();
    getBluetoothSerialServerInstance().mConnectThread=null;
  }
  if (mConnectedThread != null) {
    mConnectedThread.cancel();
    mConnectedThread=null;
  }
  if (mConnectedWriteThread != null) {
    mConnectedWriteThread.cancel();
    mConnectedWriteThread=null;
  }
  if (getBluetoothSerialServerInstance().mSecureAcceptThread != null) {
    getBluetoothSerialServerInstance().mSecureAcceptThread.cancel();
    getBluetoothSerialServerInstance().mSecureAcceptThread=null;
  }
  mConnectedThread=new ConnectedThread(socket);
  mConnectedThread.start();
  mConnectedWriteThread=new ConnectedWriteThread(socket);
  mConnectedWriteThread.start();
  if (device != null && device.getName() != null && device.getName() != "String_Node_Str") {
    currentlyConnectedDevice=device.getName();
  }
  Message msg=mHandler.obtainMessage(SdlRouterService.MESSAGE_DEVICE_NAME);
  Bundle bundle=new Bundle();
  bundle.putString(DEVICE_NAME,device.getName());
  msg.setData(bundle);
  getBluetoothSerialServerInstance().mHandler.sendMessage(msg);
  getBluetoothSerialServerInstance().setState(STATE_CONNECTED);
}

Fixed version (ground truth):
/** 
 * Start the ConnectedThread to begin managing a Bluetooth connection
 * @param socket  The BluetoothSocket on which the connection was made
 * @param device  The BluetoothDevice that has been connected
 */
public synchronized void connected(BluetoothSocket socket,BluetoothDevice device){
  if (getBluetoothSerialServerInstance().mConnectThread != null) {
    getBluetoothSerialServerInstance().mConnectThread.cancel();
    getBluetoothSerialServerInstance().mConnectThread=null;
  }
  if (mConnectedThread != null) {
    mConnectedThread.cancel();
    mConnectedThread=null;
  }
  if (mConnectedWriteThread != null) {
    mConnectedWriteThread.cancel();
    mConnectedWriteThread=null;
  }
  if (!keepSocketAlive && getBluetoothSerialServerInstance().mSecureAcceptThread != null) {
    getBluetoothSerialServerInstance().mSecureAcceptThread.cancel();
    getBluetoothSerialServerInstance().mSecureAcceptThread=null;
  }
  mConnectedThread=new ConnectedThread(socket);
  mConnectedThread.start();
  mConnectedWriteThread=new ConnectedWriteThread(socket);
  mConnectedWriteThread.start();
  if (device != null && device.getName() != null && device.getName() != "String_Node_Str") {
    currentlyConnectedDevice=device.getName();
  }
  Message msg=mHandler.obtainMessage(SdlRouterService.MESSAGE_DEVICE_NAME);
  Bundle bundle=new Bundle();
  bundle.putString(DEVICE_NAME,device.getName());
  msg.setData(bundle);
  getBluetoothSerialServerInstance().mHandler.sendMessage(msg);
  getBluetoothSerialServerInstance().setState(STATE_CONNECTED);
}
Program: 32422
Project: 32422
Buggy source:
protected MessageFrameAssembler getFrameAssemblerForFrame(SdlPacket packet){
  Hashtable<Integer,MessageFrameAssembler> hashSessionID=_assemblerForSessionID.get(packet.getSessionId());
  if (hashSessionID == null) {
    hashSessionID=new Hashtable<Integer,MessageFrameAssembler>();
    _assemblerForSessionID.put((byte)packet.getSessionId(),hashSessionID);
  }
  MessageFrameAssembler ret=(MessageFrameAssembler)_assemblerForMessageID.get(Integer.valueOf(packet.getMessageId()));
  if (ret == null) {
    ret=new MessageFrameAssembler();
    _assemblerForMessageID.put(Integer.valueOf(packet.getMessageId()),ret);
  }
  return ret;
}

Fixed version (ground truth):
protected MessageFrameAssembler getFrameAssemblerForFrame(SdlPacket packet){
  Integer iSessionId=Integer.valueOf(packet.getSessionId());
  Byte bySessionId=iSessionId.byteValue();
  Hashtable<Integer,MessageFrameAssembler> hashSessionID=_assemblerForSessionID.get(bySessionId);
  if (hashSessionID == null) {
    hashSessionID=new Hashtable<Integer,MessageFrameAssembler>();
    _assemblerForSessionID.put(bySessionId,hashSessionID);
  }
  MessageFrameAssembler ret=(MessageFrameAssembler)_assemblerForMessageID.get(Integer.valueOf(packet.getMessageId()));
  if (ret == null) {
    ret=new MessageFrameAssembler();
    _assemblerForMessageID.put(Integer.valueOf(packet.getMessageId()),ret);
  }
  return ret;
}
Program: 32424
Project: 32424
Buggy source:
public void startVersionCheck(){
  registerReceiver(registerAnInstanceOfSerialServer,new IntentFilter(REGISTER_NEWER_SERVER_INSTANCE_ACTION));
  newestServiceCheck(currentContext);
}

Fixed version (ground truth):
public void startVersionCheck(){
  Intent intent=new Intent(START_SERVICE_ACTION);
  List<ResolveInfo> infos=getPackageManager().queryBroadcastReceivers(intent,0);
  sdlMultiList=new HashMap<String,ResolveInfo>();
  for (  ResolveInfo info : infos) {
    if (getPackageName().equals(info.activityInfo.applicationInfo.packageName)) {
      continue;
    }
    sdlMultiList.put(info.activityInfo.packageName,info);
  }
  registerReceiver(registerAnInstanceOfSerialServer,new IntentFilter(REGISTER_NEWER_SERVER_INSTANCE_ACTION));
  newestServiceCheck(currentContext);
}
Program: 32425
Project: 32425
Buggy source:
/** 
 * This method is used to check for the newest version of this class to make sure the latest and greatest is up and running.
 * @param context
 */
private void newestServiceCheck(final Context context){
  getLocalRouterService();
  versionCheckTimeOutHandler=new Handler();
  versionCheckRunable=new Runnable(){
    public void run(){
      Log.i(TAG,"String_Node_Str");
      LocalRouterService newestServiceReceived=getLocalBluetoothServiceComapre();
      LocalRouterService self=getLocalRouterService();
      if (newestServiceReceived != null && self.isNewer(newestServiceReceived)) {
        Log.d(TAG,"String_Node_Str");
        closing=true;
        closeBluetoothSerialServer();
        Intent serviceIntent=newestServiceReceived.launchIntent;
        if (getLastReceivedStartIntent() != null) {
          serviceIntent.putExtras(getLastReceivedStartIntent());
        }
        if (newestServiceReceived.launchIntent == null) {
          Log.e(TAG,"String_Node_Str");
        }
        context.startService(newestServiceReceived.launchIntent);
        notifyAltTransportOfClose(TransportConstants.ROUTER_SHUTTING_DOWN_REASON_NEWER_SERVICE);
        if (getBaseContext() != null) {
          stopSelf();
        }
 else {
          onDestroy();
        }
      }
 else {
        Log.d(TAG,"String_Node_Str");
        startUpSequence();
      }
    }
  }
;
  versionCheckTimeOutHandler.postDelayed(versionCheckRunable,VERSION_TIMEOUT_RUNNABLE);
}

Fixed version (ground truth):
/** 
 * This method is used to check for the newest version of this class to make sure the latest and greatest is up and running.
 * @param context
 */
private void newestServiceCheck(final Context context){
  getLocalRouterService();
  versionCheckTimeOutHandler=new Handler();
  versionCheckRunable=new Runnable(){
    public void run(){
      Log.i(TAG,"String_Node_Str");
      LocalRouterService newestServiceReceived=getLocalBluetoothServiceComapre();
      LocalRouterService self=getLocalRouterService();
      if (newestServiceReceived != null && self.isNewer(newestServiceReceived)) {
        Log.d(TAG,"String_Node_Str" + newestServiceReceived.version + "String_Node_Str");
        closing=true;
        closeBluetoothSerialServer();
        Intent serviceIntent=newestServiceReceived.launchIntent;
        if (getLastReceivedStartIntent() != null) {
          serviceIntent.putExtras(getLastReceivedStartIntent());
        }
        if (newestServiceReceived.launchIntent == null) {
          Log.e(TAG,"String_Node_Str");
          startUpSequence();
          return;
        }
        context.startService(newestServiceReceived.launchIntent);
        notifyAltTransportOfClose(TransportConstants.ROUTER_SHUTTING_DOWN_REASON_NEWER_SERVICE);
        if (getBaseContext() != null) {
          stopSelf();
        }
 else {
          onDestroy();
        }
      }
 else {
        Log.d(TAG,"String_Node_Str" + ROUTER_SERVICE_VERSION_NUMBER + "String_Node_Str");
        startUpSequence();
      }
    }
  }
;
  versionCheckTimeOutHandler.postDelayed(versionCheckRunable,VERSION_TIMEOUT_RUNNABLE);
}
Program: 32426
Project: 32426
Buggy source:
/** 
 * We need to define this for local copy of the Sdl Bluetooth Service class. It will be the main point of connection for Sdl Connected apps
 * @return Return the local copy of SdlRouterService.class{@inheritDoc}
 */
@SuppressWarnings("String_Node_Str") public abstract Class defineLocalSdlRouterClass();

Fixed version (ground truth):
/** 
 * We need to define this for local copy of the Sdl Router Service class. It will be the main point of connection for Sdl enabled apps
 * @return Return the local copy of SdlRouterService.class{@inheritDoc}
 */
public abstract Class<? extends SdlRouterService> defineLocalSdlRouterClass();
Program: 32428
Project: 32428
Buggy source:
@Override public void onTransportDisconnected(String info){
  for (  SdlSession session : listenerList) {
    session.onTransportDisconnected(info);
  }
  if (cachedMultiConfig != null) {
    if (cachedMultiConfig.getService() != null) {
synchronized (TRANSPORT_REFERENCE_LOCK) {
        if (_transport != null) {
          if (_transport.getIsConnected()) {
            _transport.disconnect();
          }
          _transport=null;
        }
        _transport=new MultiplexTransport(cachedMultiConfig,SdlConnection.this);
        try {
          startTransport();
        }
 catch (        SdlException e) {
          e.printStackTrace();
        }
        ((MultiplexTransport)_transport).forceHardwareConnectEvent(TransportType.BLUETOOTH);
      }
    }
 else {
      for (      SdlSession session : listenerList) {
        session.checkForOpenMultiplexConnection(SdlConnection.this);
        ;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onTransportDisconnected(String info){
  for (  SdlSession session : listenerList) {
    session.onTransportDisconnected(info);
  }
  if (cachedMultiConfig != null) {
    if (cachedMultiConfig.getService() != null) {
synchronized (TRANSPORT_REFERENCE_LOCK) {
        if (_transport != null) {
          if (_transport.getIsConnected()) {
            _transport.disconnect();
          }
          _transport=null;
        }
        _transport=new MultiplexTransport(cachedMultiConfig,SdlConnection.this);
        try {
          startTransport();
        }
 catch (        SdlException e) {
          e.printStackTrace();
        }
      }
    }
 else {
      for (      SdlSession session : listenerList) {
        session.checkForOpenMultiplexConnection(SdlConnection.this);
        ;
      }
    }
  }
}
Program: 32429
Project: 32429
Buggy source:
@Override public IBinder onBind(Intent intent){
  if (intent != null) {
    if (closing) {
      Log.w(TAG,"String_Node_Str");
      return null;
    }
    String requestType=intent.getAction();
    if (TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT.equals(requestType)) {
      return this.altTransportMessenger.getBinder();
    }
 else     if (TransportConstants.BIND_REQUEST_TYPE_CLIENT.equals(requestType)) {
      return this.routerMessenger.getBinder();
    }
 else {
      Log.w(TAG,"String_Node_Str");
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public IBinder onBind(Intent intent){
  if (intent != null) {
    if (closing) {
      Log.w(TAG,"String_Node_Str");
      return null;
    }
    String requestType=intent.getAction();
    if (TransportConstants.BIND_REQUEST_TYPE_ALT_TRANSPORT.equals(requestType)) {
      return this.altTransportMessenger.getBinder();
    }
 else     if (TransportConstants.BIND_REQUEST_TYPE_CLIENT.equals(requestType)) {
      return this.routerMessenger.getBinder();
    }
 else     if (TransportConstants.BIND_REQUEST_TYPE_STATUS.equals(requestType)) {
      return this.routerStatusMessenger.getBinder();
    }
 else {
      Log.w(TAG,"String_Node_Str");
    }
  }
  return null;
}
Program: 32430
Project: 32430
Buggy source:
public void onTransportDisconnected(TransportType type){
  if (altTransportService != null) {
    return;
  }
  Log.e(TAG,"String_Node_Str");
  isTarnsportConnected=false;
  stopClientPings();
  exitForeground();
  if (packetWriteTaskMaster != null) {
    packetWriteTaskMaster.close();
    packetWriteTaskMaster=null;
  }
  cachedModuleVersion=-1;
  if (registeredApps == null || registeredApps.isEmpty()) {
    Log.w(TAG,"String_Node_Str");
    Intent unregisterIntent=new Intent();
    unregisterIntent.putExtra(HARDWARE_DISCONNECTED,type.name());
    unregisterIntent.putExtra(TransportConstants.ENABLE_LEGACY_MODE_EXTRA,legacyModeEnabled);
    unregisterIntent.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
    sendBroadcast(unregisterIntent);
  }
 else {
    Message message=Message.obtain();
    message.what=TransportConstants.HARDWARE_CONNECTION_EVENT;
    Bundle bundle=new Bundle();
    bundle.putString(HARDWARE_DISCONNECTED,type.name());
    bundle.putBoolean(TransportConstants.ENABLE_LEGACY_MODE_EXTRA,legacyModeEnabled);
    message.setData(bundle);
    notifyClients(message);
  }
synchronized (SESSION_LOCK) {
    this.sessionMap.clear();
    this.sessionHashIdMap.clear();
  }
synchronized (REGISTERED_APPS_LOCK) {
    if (registeredApps == null) {
      return;
    }
    registeredApps.clear();
  }
}

Fixed version (ground truth):
public void onTransportDisconnected(TransportType type){
  if (altTransportService != null) {
    return;
  }
  Log.e(TAG,"String_Node_Str");
  connectedTransportType=null;
  isTransportConnected=false;
  stopClientPings();
  exitForeground();
  if (packetWriteTaskMaster != null) {
    packetWriteTaskMaster.close();
    packetWriteTaskMaster=null;
  }
  cachedModuleVersion=-1;
  if (registeredApps == null || registeredApps.isEmpty()) {
    Log.w(TAG,"String_Node_Str");
    Intent unregisterIntent=new Intent();
    unregisterIntent.putExtra(HARDWARE_DISCONNECTED,type.name());
    unregisterIntent.putExtra(TransportConstants.ENABLE_LEGACY_MODE_EXTRA,legacyModeEnabled);
    unregisterIntent.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
    sendBroadcast(unregisterIntent);
  }
 else {
    Message message=Message.obtain();
    message.what=TransportConstants.HARDWARE_CONNECTION_EVENT;
    Bundle bundle=new Bundle();
    bundle.putString(HARDWARE_DISCONNECTED,type.name());
    bundle.putBoolean(TransportConstants.ENABLE_LEGACY_MODE_EXTRA,legacyModeEnabled);
    message.setData(bundle);
    notifyClients(message);
  }
synchronized (SESSION_LOCK) {
    this.sessionMap.clear();
    this.sessionHashIdMap.clear();
  }
synchronized (REGISTERED_APPS_LOCK) {
    if (registeredApps == null) {
      return;
    }
    registeredApps.clear();
  }
}
Program: 32431
Project: 32431
Buggy source:
/** 
 * This method is needed so that apps that choose not to implement this as a service as defined by Android, but rather just a simple class we have to know how to shut down.
 */
public void closeSelf(){
  closing=true;
  storeConnectedStatus(false);
  if (getBaseContext() != null) {
    stopSelf();
  }
 else {
    onDestroy();
  }
}

Fixed version (ground truth):
/** 
 * This method is needed so that apps that choose not to implement this as a service as defined by Android, but rather just a simple class we have to know how to shut down.
 */
public void closeSelf(){
  closing=true;
  if (getBaseContext() != null) {
    stopSelf();
  }
 else {
    onDestroy();
  }
}
Program: 32432
Project: 32432
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  if (!processCheck()) {
    Log.e(TAG,"String_Node_Str");
    wrongProcess=true;
    stopSelf();
    return;
  }
 else {
    Log.d(TAG,"String_Node_Str");
  }
synchronized (REGISTERED_APPS_LOCK) {
    registeredApps=new HashMap<Long,RegisteredApp>();
  }
  closing=false;
  currentContext=getBaseContext();
  storeConnectedStatus(false);
  startVersionCheck();
  Log.i(TAG,"String_Node_Str");
synchronized (SESSION_LOCK) {
    this.sessionMap=new SparseArray<Long>();
    this.sessionHashIdMap=new SparseArray<Integer>();
  }
  packetExecuter=Executors.newSingleThreadExecutor();
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  if (!processCheck()) {
    Log.e(TAG,"String_Node_Str");
    wrongProcess=true;
    stopSelf();
    return;
  }
 else {
    Log.d(TAG,"String_Node_Str");
  }
synchronized (REGISTERED_APPS_LOCK) {
    registeredApps=new HashMap<Long,RegisteredApp>();
  }
  closing=false;
  currentContext=getBaseContext();
  startVersionCheck();
  Log.i(TAG,"String_Node_Str");
synchronized (SESSION_LOCK) {
    this.sessionMap=new SparseArray<Long>();
    this.sessionHashIdMap=new SparseArray<Integer>();
  }
  packetExecuter=Executors.newSingleThreadExecutor();
}
Program: 32433
Project: 32433
Buggy source:
public void onTransportConnected(final TransportType type){
  isTarnsportConnected=true;
  enterForeground();
  if (packetWriteTaskMaster != null) {
    packetWriteTaskMaster.close();
    packetWriteTaskMaster=null;
  }
  packetWriteTaskMaster=new PacketWriteTaskMaster();
  packetWriteTaskMaster.start();
  Intent startService=new Intent();
  startService.setAction(START_SERVICE_ACTION);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA,true);
  startService.putExtra(TransportConstants.FORCE_TRANSPORT_CONNECTED,true);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE,getBaseContext().getPackageName());
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME,new ComponentName(this,this.getClass()));
  sendBroadcast(startService);
}

Fixed version (ground truth):
public void onTransportConnected(final TransportType type){
  isTransportConnected=true;
  enterForeground();
  if (packetWriteTaskMaster != null) {
    packetWriteTaskMaster.close();
    packetWriteTaskMaster=null;
  }
  packetWriteTaskMaster=new PacketWriteTaskMaster();
  packetWriteTaskMaster.start();
  connectedTransportType=type;
  Intent startService=new Intent();
  startService.setAction(START_SERVICE_ACTION);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA,true);
  startService.putExtra(TransportConstants.FORCE_TRANSPORT_CONNECTED,true);
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE,getBaseContext().getPackageName());
  startService.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME,new ComponentName(this,this.getClass()));
  sendBroadcast(startService);
  if (!(registeredApps == null || registeredApps.isEmpty())) {
    notifyClients(createHardwareConnectedMessage(type));
  }
}
Program: 32434
Project: 32434
Buggy source:
private void startClientPings(){
synchronized (this) {
    if (!isTarnsportConnected) {
      return;
    }
    if (isPingingClients) {
      Log.w(TAG,"String_Node_Str");
synchronized (PING_COUNT_LOCK) {
        pingCount=0;
      }
      return;
    }
    if (clientPingExecutor == null) {
      clientPingExecutor=Executors.newSingleThreadScheduledExecutor();
    }
    isPingingClients=true;
synchronized (PING_COUNT_LOCK) {
      pingCount=0;
    }
    clientPingExecutor.scheduleAtFixedRate(new Runnable(){
      @Override public void run(){
        if (getPingCount() >= 10) {
          Log.d(TAG,"String_Node_Str");
          stopClientPings();
          return;
        }
        if (pingIntent == null) {
          pingIntent=new Intent();
          pingIntent.setAction(START_SERVICE_ACTION);
          pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA,true);
          pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE,getBaseContext().getPackageName());
          pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME,new ComponentName(SdlRouterService.this,SdlRouterService.this.getClass()));
          pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_PING,true);
        }
        getBaseContext().sendBroadcast(pingIntent);
synchronized (PING_COUNT_LOCK) {
          pingCount++;
        }
      }
    }
,CLIENT_PING_DELAY,CLIENT_PING_DELAY,TimeUnit.MILLISECONDS);
  }
}

Fixed version (ground truth):
private void startClientPings(){
synchronized (this) {
    if (!isTransportConnected) {
      return;
    }
    if (isPingingClients) {
      Log.w(TAG,"String_Node_Str");
synchronized (PING_COUNT_LOCK) {
        pingCount=0;
      }
      return;
    }
    if (clientPingExecutor == null) {
      clientPingExecutor=Executors.newSingleThreadScheduledExecutor();
    }
    isPingingClients=true;
synchronized (PING_COUNT_LOCK) {
      pingCount=0;
    }
    clientPingExecutor.scheduleAtFixedRate(new Runnable(){
      @Override public void run(){
        if (getPingCount() >= 10) {
          Log.d(TAG,"String_Node_Str");
          stopClientPings();
          return;
        }
        if (pingIntent == null) {
          pingIntent=new Intent();
          pingIntent.setAction(START_SERVICE_ACTION);
          pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_EXTRA,true);
          pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_APP_PACKAGE,getBaseContext().getPackageName());
          pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_CMP_NAME,new ComponentName(SdlRouterService.this,SdlRouterService.this.getClass()));
          pingIntent.putExtra(TransportConstants.START_ROUTER_SERVICE_SDL_ENABLED_PING,true);
        }
        getBaseContext().sendBroadcast(pingIntent);
synchronized (PING_COUNT_LOCK) {
          pingCount++;
        }
      }
    }
,CLIENT_PING_DELAY,CLIENT_PING_DELAY,TimeUnit.MILLISECONDS);
  }
}
Program: 32435
Project: 32435
Buggy source:
public void setC(List<TouchCoord> c){
  if (c != null) {
    store.put(KEY_C,c);
  }
 else {
    store.remove(KEY_C);
  }
}

Fixed version (ground truth):
/** 
 * Use setTouchCoordinates
 * @deprecated 4.0.2
 * @return
 */
@Deprecated public void setC(List<TouchCoord> c){
  setTouchCoordinates(c);
}
Program: 32436
Project: 32436
Buggy source:
public void setTs(List<Long> ts){
  if (ts != null) {
    store.put(KEY_TS,ts);
  }
 else {
    store.remove(KEY_TS);
  }
}

Fixed version (ground truth):
/** 
 * Use setTimestamps. 
 * @deprecated 4.0.2
 * @param ts
 */
@Deprecated public void setTs(List<Long> ts){
  setTimestamps(ts);
}
Program: 32437
Project: 32437
Buggy source:
@SuppressWarnings("String_Node_Str") public List<TouchCoord> getC(){
  if (store.get(KEY_C) instanceof List<?>) {
    List<?> list=(List<?>)store.get(KEY_C);
    if (list != null && list.size() > 0) {
      Object obj=list.get(0);
      if (obj instanceof TouchCoord) {
        return (List<TouchCoord>)list;
      }
 else       if (obj instanceof Hashtable) {
        List<TouchCoord> newList=new ArrayList<TouchCoord>();
        for (        Object hashObj : list) {
          newList.add(new TouchCoord((Hashtable<String,Object>)hashObj));
        }
        return newList;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Use getTouchCoordinates
 * @deprecated 4.0.2
 * @return
 */
@Deprecated public List<TouchCoord> getC(){
  return getTouchCoordinates();
}
Program: 32438
Project: 32438
Buggy source:
@SuppressWarnings("String_Node_Str") public List<Long> getTs(){
  if (store.get(KEY_TS) instanceof List<?>) {
    List<?> list=(List<?>)store.get(KEY_TS);
    if (list != null && list.size() > 0) {
      Object obj=list.get(0);
      if (obj instanceof Integer) {
        int size=list.size();
        List<Integer> listOfInt=(List<Integer>)list;
        List<Long> listofLongs=new ArrayList<Long>(size);
        for (int i=0; i < size; i++) {
          listofLongs.add(listOfInt.get(i).longValue());
        }
        return listofLongs;
      }
 else       if (obj instanceof Long) {
        return (List<Long>)list;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Use getTimestamps
 * @deprecated 4.0.2
 * @return
 */
@Deprecated public List<Long> getTs(){
  return getTimestamps();
}
Program: 32439
Project: 32439
Buggy source:
/** 
 * Determines if an instance of the Router Service is currently running on the device. 
 * @param context A context to access Android system services through.
 * @param pingService Set this to true if you want to make sure the service is up and listening to bluetooth
 * @return True if a SDL Router Service is currently running, false otherwise.
 */
private static boolean isRouterServiceRunning(Context context,boolean pingService){
  if (context == null) {
    Log.e(TAG,"String_Node_Str");
    return false;
  }
  Log.d(TAG,"String_Node_Str" + SDL_ROUTER_SERVICE_CLASS_NAME);
  ActivityManager manager=(ActivityManager)context.getSystemService("String_Node_Str");
  for (  RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
    if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SDL_ROUTER_SERVICE_CLASS_NAME)) {
      runningBluetoothServicePackage=service.service;
      if (pingService) {
        Intent intent=new Intent();
        intent.setClassName(service.service.getPackageName(),service.service.getClassName());
        intent.putExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA,pingService);
        context.startService(intent);
      }
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Determines if an instance of the Router Service is currently running on the device. 
 * @param context A context to access Android system services through.
 * @param pingService Set this to true if you want to make sure the service is up and listening to bluetooth
 * @return True if a SDL Router Service is currently running, false otherwise.
 */
private static boolean isRouterServiceRunning(Context context,boolean pingService){
  if (context == null) {
    Log.e(TAG,"String_Node_Str");
    return false;
  }
  Log.d(TAG,"String_Node_Str" + SDL_ROUTER_SERVICE_CLASS_NAME);
  ActivityManager manager=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
  for (  RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
    if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SDL_ROUTER_SERVICE_CLASS_NAME)) {
      runningBluetoothServicePackage=service.service;
      if (pingService) {
        Intent intent=new Intent();
        intent.setClassName(service.service.getPackageName(),service.service.getClassName());
        intent.putExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA,pingService);
        context.startService(intent);
      }
      return true;
    }
  }
  return false;
}
Program: 32440
Project: 32440
Buggy source:
/** 
 * We want to check to see if the Router service is already up and running
 * @param context
 * @return
 */
private boolean isRouterServiceRunning(Context context){
  Log.d(TAG,whereToReply + "String_Node_Str");
  if (context == null) {
    return false;
  }
  ActivityManager manager=(ActivityManager)context.getSystemService("String_Node_Str");
  for (  RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
    if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SdlBroadcastReceiver.SDL_ROUTER_SERVICE_CLASS_NAME)) {
      this.routerClassName=service.service.getClassName();
      this.routerPackage=service.service.getPackageName();
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * We want to check to see if the Router service is already up and running
 * @param context
 * @return
 */
private boolean isRouterServiceRunning(Context context){
  Log.d(TAG,whereToReply + "String_Node_Str");
  if (context == null) {
    return false;
  }
  ActivityManager manager=(ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
  for (  RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
    if ((service.service.getClassName()).toLowerCase(Locale.US).contains(SdlBroadcastReceiver.SDL_ROUTER_SERVICE_CLASS_NAME)) {
      this.routerClassName=service.service.getClassName();
      this.routerPackage=service.service.getPackageName();
      return true;
    }
  }
  return false;
}
Program: 32441
Project: 32441
Buggy source:
/** 
 * If a Router Service is running, this method determines if that service is connected to a device over some form of transport.
 * @param context A context to access Android system services through.
 * @return True if a transport connection is established, false otherwise.
 */
public static boolean isTransportConnected(Context context){
  Log.d(TAG,"String_Node_Str");
  if (isRouterServiceRunning(context,false)) {
    Context con;
    try {
      con=context.createPackageContext(runningBluetoothServicePackage.getPackageName(),0);
      if (con == null) {
        Log.w(TAG,"String_Node_Str" + runningBluetoothServicePackage);
        return false;
      }
      SharedPreferences pref=con.getSharedPreferences(con.getPackageName() + TRANSPORT_GLOBAL_PREFS,4);
      boolean connected=pref.getBoolean(IS_TRANSPORT_CONNECTED,false);
      return connected;
    }
 catch (    NameNotFoundException e) {
      e.printStackTrace();
      return false;
    }
  }
 else {
    Log.w(TAG,"String_Node_Str");
    if (BluetoothAdapter.getDefaultAdapter() != null && BluetoothAdapter.getDefaultAdapter().isEnabled()) {
      Intent serviceIntent=new Intent();
      serviceIntent.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
      serviceIntent.putExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA,true);
      context.sendBroadcast(serviceIntent);
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * If a Router Service is running, this method determines if that service is connected to a device over some form of transport.
 * @param context A context to access Android system services through. If null is passed, this will always return false
 * @return True if a transport connection is established, false otherwise.
 */
public static boolean isTransportConnected(Context context){
  Log.d(TAG,"String_Node_Str");
  if (context == null) {
    return false;
  }
  if (isRouterServiceRunning(context,false)) {
    Context con;
    try {
      con=context.createPackageContext(runningBluetoothServicePackage.getPackageName(),0);
      if (con == null) {
        Log.w(TAG,"String_Node_Str" + runningBluetoothServicePackage);
        return false;
      }
      SharedPreferences pref=con.getSharedPreferences(con.getPackageName() + TRANSPORT_GLOBAL_PREFS,4);
      boolean connected=pref.getBoolean(IS_TRANSPORT_CONNECTED,false);
      return connected;
    }
 catch (    NameNotFoundException e) {
      e.printStackTrace();
      return false;
    }
  }
 else {
    Log.w(TAG,"String_Node_Str");
    if (BluetoothAdapter.getDefaultAdapter() != null && BluetoothAdapter.getDefaultAdapter().isEnabled()) {
      Intent serviceIntent=new Intent();
      serviceIntent.setAction(TransportConstants.START_ROUTER_SERVICE_ACTION);
      serviceIntent.putExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA,true);
      context.sendBroadcast(serviceIntent);
    }
  }
  return false;
}
Program: 32446
Project: 32446
Buggy source:
@Override public void onTransportDisconnected(String info){
  for (  SdlSession session : listenerList) {
    session.onTransportDisconnected(info);
  }
  if (cachedMultiConfig != null && cachedMultiConfig.getService() != null) {
    Log.i(TAG,"String_Node_Str");
synchronized (TRANSPORT_REFERENCE_LOCK) {
      if (_transport != null) {
        if (_transport.getIsConnected()) {
          _transport.disconnect();
        }
        _transport=null;
      }
      _transport=new MultiplexTransport(cachedMultiConfig,SdlConnection.this);
      cachedMultiConfig=null;
      try {
        startTransport();
      }
 catch (      SdlException e) {
        e.printStackTrace();
      }
      ((MultiplexTransport)_transport).forceHardwareConnectEvent(TransportType.BLUETOOTH);
    }
  }
}

Fixed version (ground truth):
@Override public void onTransportDisconnected(String info){
  for (  SdlSession session : listenerList) {
    session.onTransportDisconnected(info);
  }
  if (cachedMultiConfig != null) {
    if (cachedMultiConfig.getService() != null) {
synchronized (TRANSPORT_REFERENCE_LOCK) {
        if (_transport != null) {
          if (_transport.getIsConnected()) {
            _transport.disconnect();
          }
          _transport=null;
        }
        _transport=new MultiplexTransport(cachedMultiConfig,SdlConnection.this);
        try {
          startTransport();
        }
 catch (        SdlException e) {
          e.printStackTrace();
        }
        ((MultiplexTransport)_transport).forceHardwareConnectEvent(TransportType.BLUETOOTH);
      }
    }
 else {
      for (      SdlSession session : listenerList) {
        session.checkForOpenMultiplexConnection(SdlConnection.this);
        ;
      }
    }
  }
}
Program: 32447
Project: 32447
Buggy source:
public void unregisterSession(SdlSession registerListener){
  boolean didRemove=listenerList.remove(registerListener);
  closeConnection(listenerList.size() == 0,registerListener.getSessionId());
  if (didRemove && _transport != null && _transport.getTransportType() == TransportType.MULTIPLEX) {
    ((MultiplexTransport)_transport).removeSession(registerListener.getSessionId());
  }
}

Fixed version (ground truth):
public void unregisterSession(SdlSession registerListener){
  boolean didRemove=listenerList.remove(registerListener);
  if (didRemove && _transport != null && _transport.getTransportType() == TransportType.MULTIPLEX) {
    ((MultiplexTransport)_transport).removeSession(registerListener.getSessionId());
  }
  closeConnection(listenerList.size() == 0,registerListener.getSessionId());
}
Program: 32448
Project: 32448
Buggy source:
@Override public void onProtocolSessionStarted(SessionType sessionType,byte sessionID,byte version,String correlationID){
  Log.d(TAG,"String_Node_Str");
  for (  SdlSession session : listenerList) {
    if (session.getSessionId() == 0) {
      Log.d(TAG,"String_Node_Str");
      session.onProtocolSessionStarted(sessionType,sessionID,version,correlationID);
      break;
    }
  }
  if (sessionType.equals(SessionType.NAV) || sessionType.equals(SessionType.PCM)) {
    SdlSession session=findSessionById(sessionID);
    if (session != null) {
      session.onProtocolSessionStarted(sessionType,sessionID,version,correlationID);
    }
  }
}

Fixed version (ground truth):
@Override public void onProtocolSessionStarted(SessionType sessionType,byte sessionID,byte version,String correlationID){
  for (  SdlSession session : listenerList) {
    if (session.getSessionId() == 0) {
      session.onProtocolSessionStarted(sessionType,sessionID,version,correlationID);
      break;
    }
  }
  if (sessionType.equals(SessionType.NAV) || sessionType.equals(SessionType.PCM)) {
    SdlSession session=findSessionById(sessionID);
    if (session != null) {
      session.onProtocolSessionStarted(sessionType,sessionID,version,correlationID);
    }
  }
}
Program: 32449
Project: 32449
Buggy source:
@Override public void onTransportError(String info,Exception e){
  SdlSession.removeConnection(SdlConnection.this);
  if (isLegacyModeEnabled() && TransportType.MULTIPLEX.equals(_transport.getTransportType())) {
    MultiplexTransport multi=((MultiplexTransport)_transport);
    cachedMultiConfig=multi.getConfig();
  }
  for (  SdlSession session : listenerList) {
    session.onTransportError(info,e);
  }
}

Fixed version (ground truth):
@Override public void onTransportError(String info,Exception e){
  SdlSession.removeConnection(SdlConnection.this);
  if (isLegacyModeEnabled() && TransportType.MULTIPLEX.equals(_transport.getTransportType())) {
    MultiplexTransport multi=((MultiplexTransport)_transport);
    cachedMultiConfig=multi.getConfig();
    cachedMultiConfig.setService(null);
  }
 else {
    cachedMultiConfig=null;
  }
  for (  SdlSession session : listenerList) {
    session.onTransportError(info,e);
  }
}
Program: 32450
Project: 32450
Buggy source:
public void forceHardwareConnectEvent(TransportType type){
  if (_transport != null && _transport.getTransportType() == TransportType.MULTIPLEX) {
    ((MultiplexTransport)_transport).forceHardwareConnectEvent(TransportType.BLUETOOTH);
  }
}

Fixed version (ground truth):
public void forceHardwareConnectEvent(TransportType type){
  if (_transport != null && _transport.getTransportType() == TransportType.MULTIPLEX) {
    MultiplexTransport multi=((MultiplexTransport)_transport);
    boolean forced=multi.forceHardwareConnectEvent(TransportType.BLUETOOTH);
    if (!forced && multi.isDisconnecting()) {
      MultiplexTransportConfig config=multi.getConfig();
      _transport=new MultiplexTransport(config,this);
    }
  }
}
Program: 32451
Project: 32451
Buggy source:
public void initTransportBroker(){
  broker=new TransportBroker(context,appId,service){
    @Override public boolean onHardwareConnected(    TransportType type){
      if (super.onHardwareConnected(type)) {
        Log.d(TAG,"String_Node_Str");
        if (!connected) {
          connected=true;
          Log.d(TAG,"String_Node_Str");
          handleTransportConnected();
        }
 else {
          Log.d(TAG,"String_Node_Str");
        }
        return true;
      }
 else {
        this.start();
      }
      return false;
    }
    @Override public void onHardwareDisconnected(    TransportType type){
      super.onHardwareDisconnected(type);
      if (connected) {
        Log.d(TAG,"String_Node_Str");
        connected=false;
        SdlConnection.enableLegacyMode(isLegacyModeEnabled(),TransportType.BLUETOOTH);
        if (isLegacyModeEnabled()) {
          Log.d(TAG,"String_Node_Str");
          this.stop();
          handleTransportDisconnected("String_Node_Str");
        }
 else {
          Log.d(TAG,"String_Node_Str");
          handleTransportError("String_Node_Str",null);
        }
      }
    }
    @Override public void onPacketReceived(    Parcelable packet){
      if (packet != null) {
        SdlPacket sdlPacket=(SdlPacket)packet;
        handleReceivedPacket(sdlPacket);
      }
    }
  }
;
}

Fixed version (ground truth):
public void initTransportBroker(){
  broker=new TransportBroker(context,appId,service){
    @Override public boolean onHardwareConnected(    TransportType type){
      if (super.onHardwareConnected(type)) {
        Log.d(TAG,"String_Node_Str");
        if (!connected) {
          connected=true;
          Log.d(TAG,"String_Node_Str");
          handleTransportConnected();
        }
 else {
          Log.d(TAG,"String_Node_Str");
        }
        return true;
      }
 else {
        this.start();
      }
      return false;
    }
    @Override public void onHardwareDisconnected(    TransportType type){
      super.onHardwareDisconnected(type);
      if (connected) {
        Log.d(TAG,"String_Node_Str");
        connected=false;
        SdlConnection.enableLegacyMode(isLegacyModeEnabled(),TransportType.BLUETOOTH);
        if (isLegacyModeEnabled()) {
          Log.d(TAG,"String_Node_Str");
          this.stop();
          isDisconnecting=true;
          handleTransportDisconnected("String_Node_Str");
        }
 else {
          Log.d(TAG,"String_Node_Str");
          isDisconnecting=true;
          handleTransportError("String_Node_Str",null);
        }
      }
    }
    @Override public void onPacketReceived(    Parcelable packet){
      if (packet != null) {
        SdlPacket sdlPacket=(SdlPacket)packet;
        handleReceivedPacket(sdlPacket);
      }
    }
  }
;
}
Program: 32452
Project: 32452
Buggy source:
public MultiplexTransport(MultiplexTransportConfig transportConfig,final ITransportListener transportListener){
  super(transportListener);
  brokerThread=new TransportBrokerThread(transportConfig.context,transportConfig.appId,transportConfig.service);
  brokerThread.start();
}

Fixed version (ground truth):
public MultiplexTransport(MultiplexTransportConfig transportConfig,final ITransportListener transportListener){
  super(transportListener);
  this.transportConfig=transportConfig;
  brokerThread=new TransportBrokerThread(transportConfig.context,transportConfig.appId,transportConfig.service);
  brokerThread.start();
  isDisconnecting=false;
}
Program: 32453
Project: 32453
Buggy source:
public boolean forceHardwareConnectEvent(TransportType type){
  if (brokerThread != null) {
    brokerThread.onHardwareConnected(type);
    return true;
  }
  Log.w(TAG,"String_Node_Str");
  return false;
}

Fixed version (ground truth):
public boolean forceHardwareConnectEvent(TransportType type){
  if (brokerThread != null) {
    brokerThread.onHardwareConnected(type);
    return true;
  }
  Log.w(TAG,"String_Node_Str" + isDisconnecting);
  return false;
}
Program: 32454
Project: 32454
Buggy source:
@Override public void onHardwareDisconnected(TransportType type){
  super.onHardwareDisconnected(type);
  if (connected) {
    Log.d(TAG,"String_Node_Str");
    connected=false;
    SdlConnection.enableLegacyMode(isLegacyModeEnabled(),TransportType.BLUETOOTH);
    if (isLegacyModeEnabled()) {
      Log.d(TAG,"String_Node_Str");
      this.stop();
      handleTransportDisconnected("String_Node_Str");
    }
 else {
      Log.d(TAG,"String_Node_Str");
      handleTransportError("String_Node_Str",null);
    }
  }
}

Fixed version (ground truth):
@Override public void onHardwareDisconnected(TransportType type){
  super.onHardwareDisconnected(type);
  if (connected) {
    Log.d(TAG,"String_Node_Str");
    connected=false;
    SdlConnection.enableLegacyMode(isLegacyModeEnabled(),TransportType.BLUETOOTH);
    if (isLegacyModeEnabled()) {
      Log.d(TAG,"String_Node_Str");
      this.stop();
      isDisconnecting=true;
      handleTransportDisconnected("String_Node_Str");
    }
 else {
      Log.d(TAG,"String_Node_Str");
      isDisconnecting=true;
      handleTransportError("String_Node_Str",null);
    }
  }
}
Program: 32455
Project: 32455
Buggy source:
@Override public void onTransportDisconnected(String info){
  for (  SdlSession session : listenerList) {
    session.onTransportDisconnected(info);
  }
  if (isLegacyModeEnabled()) {
synchronized (TRANSPORT_REFERENCE_LOCK) {
      if (_transport != null) {
        if (_transport.getIsConnected()) {
          _transport.disconnect();
        }
        _transport=null;
      }
      _transport=new BTTransport(SdlConnection.this);
      try {
        startTransport();
      }
 catch (      SdlException e) {
        e.printStackTrace();
      }
    }
  }
 else   if (cachedMultiConfig != null && cachedMultiConfig.getService() != null) {
    Log.i(TAG,"String_Node_Str");
synchronized (TRANSPORT_REFERENCE_LOCK) {
      if (_transport != null) {
        if (_transport.getIsConnected()) {
          _transport.disconnect();
        }
        _transport=null;
      }
      _transport=new MultiplexTransport(cachedMultiConfig,SdlConnection.this);
      cachedMultiConfig=null;
      try {
        startTransport();
      }
 catch (      SdlException e) {
        e.printStackTrace();
      }
      ((MultiplexTransport)_transport).forceHardwareConnectEvent(TransportType.BLUETOOTH);
    }
  }
}

Fixed version (ground truth):
@Override public void onTransportDisconnected(String info){
  for (  SdlSession session : listenerList) {
    session.onTransportDisconnected(info);
  }
  if (isLegacyModeEnabled()) {
synchronized (TRANSPORT_REFERENCE_LOCK) {
      if (_transport != null) {
        if (_transport.getIsConnected()) {
          _transport.disconnect();
        }
        _transport=null;
      }
      _transport=new BTTransport(SdlConnection.this);
      try {
        startTransport();
      }
 catch (      SdlException e) {
        e.printStackTrace();
      }
    }
  }
  if (cachedMultiConfig != null && cachedMultiConfig.getService() != null) {
    Log.i(TAG,"String_Node_Str");
synchronized (TRANSPORT_REFERENCE_LOCK) {
      if (_transport != null) {
        if (_transport.getIsConnected()) {
          _transport.disconnect();
        }
        _transport=null;
      }
      _transport=new MultiplexTransport(cachedMultiConfig,SdlConnection.this);
      cachedMultiConfig=null;
      try {
        startTransport();
      }
 catch (      SdlException e) {
        e.printStackTrace();
      }
      ((MultiplexTransport)_transport).forceHardwareConnectEvent(TransportType.BLUETOOTH);
    }
  }
}
Program: 32456
Project: 32456
Buggy source:
@Override public void onTransportError(String info,Exception e){
  for (  SdlSession session : listenerList) {
    session.onTransportError(info,e);
  }
  SdlSession.removeConnection(SdlConnection.this);
}

Fixed version (ground truth):
@Override public void onTransportError(String info,Exception e){
  SdlSession.removeConnection(SdlConnection.this);
  for (  SdlSession session : listenerList) {
    session.clearConnection();
    session.onTransportError(info,e);
  }
}
Program: 32457
Project: 32457
Buggy source:
@Override public void onTransportError(String info,Exception e){
  DebugTool.logError("String_Node_Str" + info,e);
  notifyPutFileStreamError(e,info);
  if (_advancedLifecycleManagementEnabled) {
    cycleProxy(SdlDisconnectedReason.TRANSPORT_ERROR);
  }
 else {
    notifyProxyClosed(info,e,SdlDisconnectedReason.TRANSPORT_ERROR);
  }
}

Fixed version (ground truth):
@Override public void onTransportError(String info,Exception e){
  DebugTool.logError("String_Node_Str" + info,e);
  notifyPutFileStreamError(e,info);
  if (_advancedLifecycleManagementEnabled) {
    if (SdlConnection.isLegacyModeEnabled()) {
      cycleProxy(SdlDisconnectedReason.LEGACY_BLUETOOTH_MODE_ENABLED);
    }
 else {
      cycleProxy(SdlDisconnectedReason.TRANSPORT_ERROR);
    }
  }
 else {
    notifyProxyClosed(info,e,SdlDisconnectedReason.TRANSPORT_ERROR);
  }
}
Program: 32459
Project: 32459
Buggy source:
@Override public void onHardwareDisconnected(TransportType type){
  super.onHardwareDisconnected(type);
  if (connected) {
    Log.d(TAG,"String_Node_Str");
    connected=false;
    SdlConnection.enableLegacyMode(isLegacyModeEnabled(),TransportType.BLUETOOTH);
    if (isLegacyModeEnabled()) {
      Log.d(TAG,"String_Node_Str");
      this.stop();
      isDisconnecting=true;
      handleTransportDisconnected("String_Node_Str");
    }
 else {
      Log.d(TAG,"String_Node_Str");
      isDisconnecting=true;
      handleTransportError("String_Node_Str",null);
    }
  }
}

Fixed version (ground truth):
@Override public void onHardwareDisconnected(TransportType type){
  super.onHardwareDisconnected(type);
  if (connected) {
    Log.d(TAG,"String_Node_Str");
    connected=false;
    SdlConnection.enableLegacyMode(isLegacyModeEnabled(),TransportType.BLUETOOTH);
    if (isLegacyModeEnabled()) {
      Log.d(TAG,"String_Node_Str");
      this.stop();
      isDisconnecting=true;
      handleTransportError("String_Node_Str",null);
    }
 else {
      Log.d(TAG,"String_Node_Str");
      isDisconnecting=true;
      handleTransportError("String_Node_Str",null);
    }
  }
}
Program: 32462
Project: 32462
Buggy source:
private Long getAppIDForSession(int sessionId){
synchronized (SESSION_LOCK) {
    Log.d(TAG,"String_Node_Str" + sessionId);
    Long appId=sessionMap.get(sessionId);
    if (appId == null) {
      int pos;
      for (      RegisteredApp app : registeredApps.values()) {
        pos=app.containsSessionId(-1);
        if (pos != -1) {
          app.setSessionId(pos,sessionId);
          appId=app.getAppId();
          sessionMap.put(sessionId,appId);
          break;
        }
      }
    }
    Log.d(TAG,"String_Node_Str" + appId);
    return appId;
  }
}

Fixed version (ground truth):
private Long getAppIDForSession(int sessionId){
synchronized (SESSION_LOCK) {
    Log.d(TAG,"String_Node_Str" + sessionId);
    if (sessionMap == null) {
      sessionMap=new SparseArray<Long>();
    }
    Long appId=sessionMap.get(sessionId);
    if (appId == null) {
      int pos;
      for (      RegisteredApp app : registeredApps.values()) {
        pos=app.containsSessionId(-1);
        if (pos != -1) {
          app.setSessionId(pos,sessionId);
          appId=app.getAppId();
          sessionMap.put(sessionId,appId);
          break;
        }
      }
    }
    Log.d(TAG,"String_Node_Str" + appId);
    return appId;
  }
}