Program: 184875
Project: 184875
Buggy source:
@Override public void handleMessage(Message msg){
synchronized (BluetoothHandsfree.this) {
switch (msg.what) {
case SCO_ACCEPTED:
      if (msg.arg1 == ScoSocket.STATE_CONNECTED) {
        if (isHeadsetConnected() && (mAudioPossible || allowAudioAnytime()) && mConnectedSco == null) {
          Log.i(TAG,"String_Node_Str");
          mConnectedSco=(ScoSocket)msg.obj;
          mAudioManager.setBluetoothScoOn(true);
          broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_CONNECTED);
        }
 else {
          Log.i(TAG,"String_Node_Str");
          ((ScoSocket)msg.obj).close();
        }
      }
    mIncomingSco=createScoSocket();
  mIncomingSco.accept();
break;
case SCO_CONNECTED:
if (msg.arg1 == ScoSocket.STATE_CONNECTED && isHeadsetConnected() && mConnectedSco == null) {
if (DBG) log("String_Node_Str");
mConnectedSco=(ScoSocket)msg.obj;
mAudioManager.setBluetoothScoOn(true);
broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_CONNECTED);
}
 else if (msg.arg1 == ScoSocket.STATE_CONNECTED) {
if (DBG) log("String_Node_Str");
((ScoSocket)msg.obj).close();
mOutgoingSco.close();
}
mOutgoingSco=null;
break;
case SCO_CLOSED:
if (mConnectedSco == (ScoSocket)msg.obj) {
mConnectedSco=null;
mAudioManager.setBluetoothScoOn(false);
broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED);
}
 else if (mOutgoingSco == (ScoSocket)msg.obj) {
mOutgoingSco=null;
}
 else if (mIncomingSco == (ScoSocket)msg.obj) {
mIncomingSco=null;
}
break;
case CHECK_CALL_STARTED:
if (mWaitingForCallStart) {
mWaitingForCallStart=false;
Log.e(TAG,"String_Node_Str");
sendURC("String_Node_Str");
if (mStartCallWakeLock.isHeld()) {
mStartCallWakeLock.release();
}
}
break;
case CHECK_VOICE_RECOGNITION_STARTED:
if (mWaitingForVoiceRecognition) {
mWaitingForVoiceRecognition=false;
Log.e(TAG,"String_Node_Str");
sendURC("String_Node_Str");
}
break;
}
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
synchronized (BluetoothHandsfree.this) {
switch (msg.what) {
case SCO_ACCEPTED:
      if (msg.arg1 == ScoSocket.STATE_CONNECTED) {
        if (isHeadsetConnected() && (mAudioPossible || allowAudioAnytime()) && mConnectedSco == null) {
          Log.i(TAG,"String_Node_Str");
          mConnectedSco=(ScoSocket)msg.obj;
          mAudioManager.setBluetoothScoOn(true);
          broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_CONNECTED,mHeadset.getAddress());
        }
 else {
          Log.i(TAG,"String_Node_Str");
          ((ScoSocket)msg.obj).close();
        }
      }
    mIncomingSco=createScoSocket();
  mIncomingSco.accept();
break;
case SCO_CONNECTED:
if (msg.arg1 == ScoSocket.STATE_CONNECTED && isHeadsetConnected() && mConnectedSco == null) {
if (DBG) log("String_Node_Str");
mConnectedSco=(ScoSocket)msg.obj;
mAudioManager.setBluetoothScoOn(true);
broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_CONNECTED,mHeadset.getAddress());
}
 else if (msg.arg1 == ScoSocket.STATE_CONNECTED) {
if (DBG) log("String_Node_Str");
((ScoSocket)msg.obj).close();
mOutgoingSco.close();
}
mOutgoingSco=null;
break;
case SCO_CLOSED:
if (mConnectedSco == (ScoSocket)msg.obj) {
mConnectedSco=null;
mAudioManager.setBluetoothScoOn(false);
broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getAddress());
}
 else if (mOutgoingSco == (ScoSocket)msg.obj) {
mOutgoingSco=null;
}
 else if (mIncomingSco == (ScoSocket)msg.obj) {
mIncomingSco=null;
}
break;
case CHECK_CALL_STARTED:
if (mWaitingForCallStart) {
mWaitingForCallStart=false;
Log.e(TAG,"String_Node_Str");
sendURC("String_Node_Str");
if (mStartCallWakeLock.isHeld()) {
mStartCallWakeLock.release();
}
}
break;
case CHECK_VOICE_RECOGNITION_STARTED:
if (mWaitingForVoiceRecognition) {
mWaitingForVoiceRecognition=false;
Log.e(TAG,"String_Node_Str");
sendURC("String_Node_Str");
}
break;
}
}
}