Program: 190985
Project: 190985
Buggy source:
/** 
 * Initialize or update the local profile objects. If a UUID was previously present but has been removed, we print a warning but don't remove the profile object as it might be referenced elsewhere, or the UUID might come back and we don't want multiple copies of the profile objects.
 * @param uuids
 */
void updateLocalProfiles(ParcelUuid[] uuids){
  if (BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.AudioSource)) {
    if (mA2dpProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mA2dpProfile=new A2dpProfile(mContext,mLocalAdapter,mDeviceManager,this);
      addProfile(mA2dpProfile,A2dpProfile.NAME,BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
    }
  }
 else   if (mA2dpProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
  if (BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.AudioSink)) {
    if (mA2dpSinkProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mA2dpSinkProfile=new A2dpSinkProfile(mContext,mLocalAdapter,mDeviceManager,this);
      addProfile(mA2dpSinkProfile,A2dpSinkProfile.NAME,BluetoothA2dpSink.ACTION_CONNECTION_STATE_CHANGED);
    }
  }
 else   if (mA2dpSinkProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
  if (BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.Handsfree_AG) || BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.HSP_AG)) {
    if (mHeadsetProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mHeadsetProfile=new HeadsetProfile(mContext,mLocalAdapter,mDeviceManager,this);
      addProfile(mHeadsetProfile,HeadsetProfile.NAME,BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
    }
  }
 else   if (mHeadsetProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
  if (BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.Handsfree)) {
    if (mHfpClientProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mHfpClientProfile=new HfpClientProfile(mContext,mLocalAdapter,mDeviceManager,this);
      addProfile(mHfpClientProfile,HfpClientProfile.NAME,BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED);
    }
  }
 else   if (mHfpClientProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
 else {
    Log.d(TAG,"String_Node_Str");
  }
  if (BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.ObexObjectPush)) {
    if (mOppProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mOppProfile=new OppProfile();
      mProfileNameMap.put(OppProfile.NAME,mOppProfile);
    }
  }
 else   if (mOppProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
  if (mUsePbapPce) {
    if (mPbapClientProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mPbapClientProfile=new PbapClientProfile(mContext,mLocalAdapter,mDeviceManager,this);
      addProfile(mPbapClientProfile,PbapClientProfile.NAME,BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED);
    }
  }
 else   if (mPbapClientProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
  mEventManager.registerProfileIntentReceiver();
}

Fixed version (ground truth):
/** 
 * Initialize or update the local profile objects. If a UUID was previously present but has been removed, we print a warning but don't remove the profile object as it might be referenced elsewhere, or the UUID might come back and we don't want multiple copies of the profile objects.
 * @param uuids
 */
void updateLocalProfiles(ParcelUuid[] uuids){
  if (BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.AudioSource)) {
    if (mA2dpProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mA2dpProfile=new A2dpProfile(mContext,mLocalAdapter,mDeviceManager,this);
      addProfile(mA2dpProfile,A2dpProfile.NAME,BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
    }
  }
 else   if (mA2dpProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
  if (BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.AudioSink)) {
    if (mA2dpSinkProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mA2dpSinkProfile=new A2dpSinkProfile(mContext,mLocalAdapter,mDeviceManager,this);
      addProfile(mA2dpSinkProfile,A2dpSinkProfile.NAME,BluetoothA2dpSink.ACTION_CONNECTION_STATE_CHANGED);
    }
  }
 else   if (mA2dpSinkProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
  if (BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.Handsfree_AG) || BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.HSP_AG)) {
    if (mHeadsetProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mHeadsetProfile=new HeadsetProfile(mContext,mLocalAdapter,mDeviceManager,this);
      addProfile(mHeadsetProfile,HeadsetProfile.NAME,BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
    }
  }
 else   if (mHeadsetProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
  if (BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.Handsfree)) {
    if (mHfpClientProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mHfpClientProfile=new HfpClientProfile(mContext,mLocalAdapter,mDeviceManager,this);
      addProfile(mHfpClientProfile,HfpClientProfile.NAME,BluetoothHeadsetClient.ACTION_CONNECTION_STATE_CHANGED);
    }
  }
 else   if (mHfpClientProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
 else {
    Log.d(TAG,"String_Node_Str");
  }
  if (BluetoothUuid.isUuidPresent(uuids,BluetoothUuid.ObexObjectPush)) {
    if (mOppProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mOppProfile=new OppProfile();
      mProfileNameMap.put(OppProfile.NAME,mOppProfile);
    }
  }
 else   if (mOppProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
  if (mUsePbapPce) {
    if (mPbapClientProfile == null) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mPbapClientProfile=new PbapClientProfile(mContext,mLocalAdapter,mDeviceManager,this);
      addProfile(mPbapClientProfile,PbapClientProfile.NAME,BluetoothPbapClient.ACTION_CONNECTION_STATE_CHANGED);
    }
  }
 else   if (mPbapClientProfile != null) {
    Log.w(TAG,"String_Node_Str");
  }
  mEventManager.setDefaultReceiverHandler();
}