nus-yam/ex-repair huggingface dataset:
Program: 184747
Project: 184747
Buggy source:
/** 
 * Request to disconnect SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block.
 */
synchronized void audioOff(){
  if (VDBG)   log("String_Node_Str" + mPendingSco + "String_Node_Str"+ mConnectedSco+ "String_Node_Str"+ mOutgoingSco+ "String_Node_Str"+ mA2dpState+ "String_Node_Str"+ mA2dpSuspended);
  if (mA2dpSuspended) {
    if (DBG)     log("String_Node_Str");
    mA2dp.resumeSink(mA2dpDevice);
    mA2dpSuspended=false;
  }
  mPendingSco=false;
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
}

Fixed version (ground truth):
/** 
 * Request to disconnect SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block.
 */
synchronized void audioOff(){
  if (VDBG)   log("String_Node_Str" + mPendingSco + "String_Node_Str"+ mConnectedSco+ "String_Node_Str"+ mOutgoingSco+ "String_Node_Str"+ mA2dpState+ "String_Node_Str"+ mA2dpSuspended);
  if (mA2dpSuspended) {
    if (isA2dpMultiProfile()) {
      if (DBG)       log("String_Node_Str");
      mA2dp.resumeSink(mA2dpDevice);
    }
    mA2dpSuspended=false;
  }
  mPendingSco=false;
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
}
Program: 184748
Project: 184748
Buggy source:
synchronized void onBluetoothDisabled(){
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
  if (mIncomingSco != null) {
    mIncomingSco.close();
    mIncomingSco=null;
  }
}

Fixed version (ground truth):
synchronized void onBluetoothDisabled(){
  audioOff();
  if (mIncomingSco != null) {
    mIncomingSco.close();
    mIncomingSco=null;
  }
}
Program: 184749
Project: 184749
Buggy source:
private synchronized void setState(int state,int result){
  if (state != mState) {
    if (DBG)     log("String_Node_Str" + mState + "String_Node_Str"+ state+ "String_Node_Str"+ result);
    if (mState == BluetoothHeadset.STATE_CONNECTED) {
      mBtHandsfree.audioOff();
      mBtHandsfree.disconnectHeadset();
    }
    Intent intent=new Intent(BluetoothHeadset.ACTION_STATE_CHANGED);
    intent.putExtra(BluetoothHeadset.EXTRA_PREVIOUS_STATE,mState);
    mState=state;
    intent.putExtra(BluetoothHeadset.EXTRA_STATE,mState);
    intent.putExtra(BluetoothDevice.EXTRA_DEVICE,mRemoteDevice);
    sendBroadcast(intent,BLUETOOTH_PERM);
    if (mState == BluetoothHeadset.STATE_DISCONNECTED) {
      mHeadset=null;
      mRemoteDevice=null;
      mHeadsetType=BluetoothHandsfree.TYPE_UNKNOWN;
      if (mAutoConnectQueue != null) {
        doNextAutoConnect();
      }
    }
 else     if (mState == BluetoothHeadset.STATE_CONNECTED) {
      mAutoConnectQueue=null;
      mHeadsetPriority.bump(mRemoteDevice);
    }
  }
}

Fixed version (ground truth):
private synchronized void setState(int state,int result){
  if (state != mState) {
    if (DBG)     log("String_Node_Str" + mState + "String_Node_Str"+ state+ "String_Node_Str"+ result);
    if (mState == BluetoothHeadset.STATE_CONNECTED) {
      mBtHandsfree.disconnectHeadset();
      mBtHandsfree.audioOff();
    }
    Intent intent=new Intent(BluetoothHeadset.ACTION_STATE_CHANGED);
    intent.putExtra(BluetoothHeadset.EXTRA_PREVIOUS_STATE,mState);
    mState=state;
    intent.putExtra(BluetoothHeadset.EXTRA_STATE,mState);
    intent.putExtra(BluetoothDevice.EXTRA_DEVICE,mRemoteDevice);
    sendBroadcast(intent,BLUETOOTH_PERM);
    if (mState == BluetoothHeadset.STATE_DISCONNECTED) {
      mHeadset=null;
      mRemoteDevice=null;
      mHeadsetType=BluetoothHandsfree.TYPE_UNKNOWN;
      if (mAutoConnectQueue != null) {
        doNextAutoConnect();
      }
    }
 else     if (mState == BluetoothHeadset.STATE_CONNECTED) {
      mAutoConnectQueue=null;
      mHeadsetPriority.bump(mRemoteDevice);
    }
  }
}
Program: 184750
Project: 184750
Buggy source:
/** 
 * Request to disconnect SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block.
 */
synchronized void audioOff(){
  if (VDBG)   log("String_Node_Str" + mPendingSco + "String_Node_Str"+ mConnectedSco+ "String_Node_Str"+ mOutgoingSco+ "String_Node_Str"+ mA2dpState+ "String_Node_Str"+ mA2dpSuspended);
  if (mA2dpSuspended) {
    if (DBG)     log("String_Node_Str");
    mA2dp.resumeSink(mA2dpDevice);
    mA2dpSuspended=false;
  }
  mPendingSco=false;
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
}

Fixed version (ground truth):
/** 
 * Request to disconnect SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block.
 */
synchronized void audioOff(){
  if (VDBG)   log("String_Node_Str" + mPendingSco + "String_Node_Str"+ mConnectedSco+ "String_Node_Str"+ mOutgoingSco+ "String_Node_Str"+ mA2dpState+ "String_Node_Str"+ mA2dpSuspended);
  if (mA2dpSuspended) {
    if (isA2dpMultiProfile()) {
      if (DBG)       log("String_Node_Str");
      mA2dp.resumeSink(mA2dpDevice);
    }
    mA2dpSuspended=false;
  }
  mPendingSco=false;
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
}
Program: 184751
Project: 184751
Buggy source:
synchronized void onBluetoothDisabled(){
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
  if (mIncomingSco != null) {
    mIncomingSco.close();
    mIncomingSco=null;
  }
}

Fixed version (ground truth):
synchronized void onBluetoothDisabled(){
  audioOff();
  if (mIncomingSco != null) {
    mIncomingSco.close();
    mIncomingSco=null;
  }
}
Program: 184752
Project: 184752
Buggy source:
private synchronized void setState(int state,int result){
  if (state != mState) {
    if (DBG)     log("String_Node_Str" + mState + "String_Node_Str"+ state+ "String_Node_Str"+ result);
    if (mState == BluetoothHeadset.STATE_CONNECTED) {
      mBtHandsfree.audioOff();
      mBtHandsfree.disconnectHeadset();
    }
    Intent intent=new Intent(BluetoothHeadset.ACTION_STATE_CHANGED);
    intent.putExtra(BluetoothHeadset.EXTRA_PREVIOUS_STATE,mState);
    mState=state;
    intent.putExtra(BluetoothHeadset.EXTRA_STATE,mState);
    intent.putExtra(BluetoothDevice.EXTRA_DEVICE,mRemoteDevice);
    sendBroadcast(intent,BLUETOOTH_PERM);
    if (mState == BluetoothHeadset.STATE_DISCONNECTED) {
      mHeadset=null;
      mRemoteDevice=null;
      mHeadsetType=BluetoothHandsfree.TYPE_UNKNOWN;
      if (mAutoConnectQueue != null) {
        doNextAutoConnect();
      }
    }
 else     if (mState == BluetoothHeadset.STATE_CONNECTED) {
      mAutoConnectQueue=null;
      mHeadsetPriority.bump(mRemoteDevice);
    }
  }
}

Fixed version (ground truth):
private synchronized void setState(int state,int result){
  if (state != mState) {
    if (DBG)     log("String_Node_Str" + mState + "String_Node_Str"+ state+ "String_Node_Str"+ result);
    if (mState == BluetoothHeadset.STATE_CONNECTED) {
      mBtHandsfree.disconnectHeadset();
      mBtHandsfree.audioOff();
    }
    Intent intent=new Intent(BluetoothHeadset.ACTION_STATE_CHANGED);
    intent.putExtra(BluetoothHeadset.EXTRA_PREVIOUS_STATE,mState);
    mState=state;
    intent.putExtra(BluetoothHeadset.EXTRA_STATE,mState);
    intent.putExtra(BluetoothDevice.EXTRA_DEVICE,mRemoteDevice);
    sendBroadcast(intent,BLUETOOTH_PERM);
    if (mState == BluetoothHeadset.STATE_DISCONNECTED) {
      mHeadset=null;
      mRemoteDevice=null;
      mHeadsetType=BluetoothHandsfree.TYPE_UNKNOWN;
      if (mAutoConnectQueue != null) {
        doNextAutoConnect();
      }
    }
 else     if (mState == BluetoothHeadset.STATE_CONNECTED) {
      mAutoConnectQueue=null;
      mHeadsetPriority.bump(mRemoteDevice);
    }
  }
}
Program: 184754
Project: 184754
Buggy source:
private void handleSetVMOrFwdMessage(){
  if (DBG) {
    log("String_Node_Str");
  }
  boolean success=true;
  boolean fwdFailure=false;
  String exceptionMessage="String_Node_Str";
  if (mForwardingChangeResults != null) {
    for (int i=0; i < mForwardingChangeResults.length; i++) {
      if (mForwardingChangeResults[i].exception != null) {
        exceptionMessage=mForwardingChangeResults[i].exception.getMessage();
        success=false;
        fwdFailure=true;
        break;
      }
    }
  }
  if (success && mVoicemailChangeResult.exception != null) {
    exceptionMessage=mVoicemailChangeResult.exception.getMessage();
    success=false;
  }
  if (success) {
    if (DBG)     log("String_Node_Str");
    showVMDialog(MSG_VM_OK);
  }
 else {
    if (fwdFailure) {
      log("String_Node_Str" + exceptionMessage);
      showVMDialog(MSG_FW_SET_EXCEPTION);
    }
 else {
      log("String_Node_Str" + exceptionMessage);
      showVMDialog(MSG_VM_EXCEPTION);
    }
  }
  updateVoiceNumberField();
}

Fixed version (ground truth):
private void handleSetVMOrFwdMessage(){
  if (DBG) {
    log("String_Node_Str");
  }
  boolean success=true;
  boolean fwdFailure=false;
  String exceptionMessage="String_Node_Str";
  if (mForwardingChangeResults != null) {
    for (int i=0; i < mForwardingChangeResults.length; i++) {
      if (mForwardingChangeResults[i].exception != null) {
        exceptionMessage=mForwardingChangeResults[i].exception.getMessage();
        success=false;
        fwdFailure=true;
        break;
      }
    }
  }
  if (success && mVoicemailChangeResult.exception != null) {
    exceptionMessage=mVoicemailChangeResult.exception.getMessage();
    success=false;
  }
  if (success) {
    if (DBG)     log("String_Node_Str");
    handleVMAndFwdSetSuccess(MSG_VM_OK);
  }
 else {
    if (fwdFailure) {
      log("String_Node_Str" + exceptionMessage);
      handleVMOrFwdSetError(MSG_FW_SET_EXCEPTION);
    }
 else {
      log("String_Node_Str" + exceptionMessage);
      handleVMOrFwdSetError(MSG_VM_EXCEPTION);
    }
  }
  updateVoiceNumberField();
}
Program: 184755
Project: 184755
Buggy source:
/** 
 * Request to disconnect SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block.
 */
synchronized void audioOff(){
  if (VDBG)   log("String_Node_Str");
  mPendingSco=false;
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
    if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
      if (DBG)       log("String_Node_Str");
      mA2dp.resumeSink(mA2dpDevice);
    }
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
}

Fixed version (ground truth):
/** 
 * Request to disconnect SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block.
 */
synchronized void audioOff(){
  if (VDBG)   log("String_Node_Str" + mPendingSco + "String_Node_Str"+ mConnectedSco+ "String_Node_Str"+ mOutgoingSco+ "String_Node_Str"+ mA2dpState+ "String_Node_Str"+ mA2dpSuspended);
  if (mA2dpSuspended) {
    if (DBG)     log("String_Node_Str");
    mA2dp.resumeSink(mA2dpDevice);
    mA2dpSuspended=false;
  }
  mPendingSco=false;
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
}
Program: 184757
Project: 184757
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
    updateBatteryState(intent);
  }
 else   if (intent.getAction().equals(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED)) {
    updateSignalState(intent);
  }
 else   if (intent.getAction().equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
    int state=intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    int oldState=intent.getIntExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    BluetoothDevice device=intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
synchronized (BluetoothHandsfree.this) {
      mA2dpState=state;
      mA2dpDevice=device;
      if (isA2dpMultiProfile() && mPendingSco) {
        mHandler.removeMessages(MESSAGE_CHECK_PENDING_SCO);
        if (mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
          if (DBG)           log("String_Node_Str");
          mOutgoingSco=createScoSocket();
          if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
            mOutgoingSco=null;
          }
        }
      }
      mPendingSco=false;
    }
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
    updateBatteryState(intent);
  }
 else   if (intent.getAction().equals(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED)) {
    updateSignalState(intent);
  }
 else   if (intent.getAction().equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
    int state=intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    int oldState=intent.getIntExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    BluetoothDevice device=intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
synchronized (BluetoothHandsfree.this) {
      mA2dpState=state;
      mA2dpDevice=device;
      if (oldState == BluetoothA2dp.STATE_PLAYING && mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
        if (mA2dpSuspended) {
          if (mPendingSco) {
            mHandler.removeMessages(MESSAGE_CHECK_PENDING_SCO);
            if (DBG)             log("String_Node_Str");
            mOutgoingSco=createScoSocket();
            if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
              mOutgoingSco=null;
            }
            mPendingSco=false;
          }
        }
      }
    }
  }
}
Program: 184758
Project: 184758
Buggy source:
/** 
 * Request to establish SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block. Returns false if the user has requested audio off, or if there is some other immediate problem that will prevent BT audio.
 */
synchronized boolean audioOn(){
  if (VDBG)   log("String_Node_Str");
  if (!isHeadsetConnected()) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mHeadsetType == TYPE_HANDSFREE && !mServiceConnectionEstablished) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mConnectedSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (!mUserWantsAudio) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mOutgoingSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (mPendingSco) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_PLAYING) {
    if (DBG)     log("String_Node_Str");
    mPendingSco=mA2dp.suspendSink(mA2dpDevice);
    if (mPendingSco) {
      Message msg=mHandler.obtainMessage(MESSAGE_CHECK_PENDING_SCO);
      mHandler.sendMessageDelayed(msg,2000);
    }
 else {
      Log.w(TAG,"String_Node_Str");
    }
  }
  if (!mPendingSco) {
    mOutgoingSco=createScoSocket();
    if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
      mOutgoingSco=null;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Request to establish SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block. Returns false if the user has requested audio off, or if there is some other immediate problem that will prevent BT audio.
 */
synchronized boolean audioOn(){
  if (VDBG)   log("String_Node_Str");
  if (!isHeadsetConnected()) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mHeadsetType == TYPE_HANDSFREE && !mServiceConnectionEstablished) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mConnectedSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (!mUserWantsAudio) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mOutgoingSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (mPendingSco) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  mA2dpSuspended=false;
  mPendingSco=false;
  if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_PLAYING) {
    if (DBG)     log("String_Node_Str");
    mA2dpSuspended=mA2dp.suspendSink(mA2dpDevice);
    if (mA2dpSuspended) {
      mPendingSco=true;
      Message msg=mHandler.obtainMessage(MESSAGE_CHECK_PENDING_SCO);
      mHandler.sendMessageDelayed(msg,2000);
    }
 else {
      Log.w(TAG,"String_Node_Str");
    }
  }
  if (!mPendingSco) {
    mOutgoingSco=createScoSocket();
    if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
      mOutgoingSco=null;
    }
  }
  return true;
}
Program: 184759
Project: 184759
Buggy source:
/** 
 * Request to disconnect SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block.
 */
synchronized void audioOff(){
  if (VDBG)   log("String_Node_Str");
  mPendingSco=false;
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
    if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
      if (DBG)       log("String_Node_Str");
      mA2dp.resumeSink(mA2dpDevice);
    }
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
  mPendingSco=false;
  if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
    if (DBG)     log("String_Node_Str");
    mA2dp.resumeSink(mA2dpDevice);
  }
}

Fixed version (ground truth):
/** 
 * Request to disconnect SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block.
 */
synchronized void audioOff(){
  if (VDBG)   log("String_Node_Str" + mPendingSco + "String_Node_Str"+ mConnectedSco+ "String_Node_Str"+ mOutgoingSco+ "String_Node_Str"+ mA2dpState+ "String_Node_Str"+ mA2dpSuspended);
  if (mA2dpSuspended) {
    if (DBG)     log("String_Node_Str");
    mA2dp.resumeSink(mA2dpDevice);
    mA2dpSuspended=false;
  }
  mPendingSco=false;
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
  mPendingSco=false;
  if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
    if (DBG)     log("String_Node_Str");
    mA2dp.resumeSink(mA2dpDevice);
  }
}
Program: 184761
Project: 184761
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
    updateBatteryState(intent);
  }
 else   if (intent.getAction().equals(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED)) {
    updateSignalState(intent);
  }
 else   if (intent.getAction().equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
    int state=intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    int oldState=intent.getIntExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    BluetoothDevice device=intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
synchronized (BluetoothHandsfree.this) {
      mA2dpState=state;
      mA2dpDevice=device;
      if (isA2dpMultiProfile() && mPendingSco) {
        mHandler.removeMessages(MESSAGE_CHECK_PENDING_SCO);
        if (mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
          if (DBG)           log("String_Node_Str");
          mOutgoingSco=createScoSocket();
          if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
            mOutgoingSco=null;
          }
        }
      }
      mPendingSco=false;
    }
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
    updateBatteryState(intent);
  }
 else   if (intent.getAction().equals(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED)) {
    updateSignalState(intent);
  }
 else   if (intent.getAction().equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
    int state=intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    int oldState=intent.getIntExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    BluetoothDevice device=intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
synchronized (BluetoothHandsfree.this) {
      mA2dpState=state;
      mA2dpDevice=device;
      if (oldState == BluetoothA2dp.STATE_PLAYING && mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
        if (mA2dpSuspended) {
          if (mPendingSco) {
            mHandler.removeMessages(MESSAGE_CHECK_PENDING_SCO);
            if (DBG)             log("String_Node_Str");
            mOutgoingSco=createScoSocket();
            if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
              mOutgoingSco=null;
            }
            mPendingSco=false;
          }
        }
      }
    }
  }
}
Program: 184762
Project: 184762
Buggy source:
/** 
 * Request to establish SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block. Returns false if the user has requested audio off, or if there is some other immediate problem that will prevent BT audio.
 */
synchronized boolean audioOn(){
  if (VDBG)   log("String_Node_Str");
  if (!isHeadsetConnected()) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mHeadsetType == TYPE_HANDSFREE && !mServiceConnectionEstablished) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mConnectedSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (!mUserWantsAudio) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mOutgoingSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (mPendingSco) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_PLAYING) {
    if (DBG)     log("String_Node_Str");
    mPendingSco=mA2dp.suspendSink(mA2dpDevice);
    if (mPendingSco) {
      Message msg=mHandler.obtainMessage(MESSAGE_CHECK_PENDING_SCO);
      mHandler.sendMessageDelayed(msg,2000);
    }
 else {
      Log.w(TAG,"String_Node_Str");
    }
  }
  if (!mPendingSco) {
    mOutgoingSco=createScoSocket();
    if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
      mOutgoingSco=null;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Request to establish SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block. Returns false if the user has requested audio off, or if there is some other immediate problem that will prevent BT audio.
 */
synchronized boolean audioOn(){
  if (VDBG)   log("String_Node_Str");
  if (!isHeadsetConnected()) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mHeadsetType == TYPE_HANDSFREE && !mServiceConnectionEstablished) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mConnectedSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (!mUserWantsAudio) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mOutgoingSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (mPendingSco) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  mA2dpSuspended=false;
  mPendingSco=false;
  if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_PLAYING) {
    if (DBG)     log("String_Node_Str");
    mA2dpSuspended=mA2dp.suspendSink(mA2dpDevice);
    if (mA2dpSuspended) {
      mPendingSco=true;
      Message msg=mHandler.obtainMessage(MESSAGE_CHECK_PENDING_SCO);
      mHandler.sendMessageDelayed(msg,2000);
    }
 else {
      Log.w(TAG,"String_Node_Str");
    }
  }
  if (!mPendingSco) {
    mOutgoingSco=createScoSocket();
    if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
      mOutgoingSco=null;
    }
  }
  return true;
}
Program: 184763
Project: 184763
Buggy source:
/** 
 * Request to disconnect SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block.
 */
synchronized void audioOff(){
  if (VDBG)   log("String_Node_Str");
  mPendingSco=false;
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
    if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
      if (DBG)       log("String_Node_Str");
      mA2dp.resumeSink(mA2dpDevice);
    }
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
}

Fixed version (ground truth):
/** 
 * Request to disconnect SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block.
 */
synchronized void audioOff(){
  if (VDBG)   log("String_Node_Str" + mPendingSco + "String_Node_Str"+ mConnectedSco+ "String_Node_Str"+ mOutgoingSco+ "String_Node_Str"+ mA2dpState+ "String_Node_Str"+ mA2dpSuspended);
  if (mA2dpSuspended) {
    if (DBG)     log("String_Node_Str");
    mA2dp.resumeSink(mA2dpDevice);
    mA2dpSuspended=false;
  }
  mPendingSco=false;
  if (mConnectedSco != null) {
    mAudioManager.setBluetoothScoOn(false);
    broadcastAudioStateIntent(BluetoothHeadset.AUDIO_STATE_DISCONNECTED,mHeadset.getRemoteDevice());
    mConnectedSco.close();
    mConnectedSco=null;
  }
  if (mOutgoingSco != null) {
    mOutgoingSco.close();
    mOutgoingSco=null;
  }
}
Program: 184765
Project: 184765
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
    updateBatteryState(intent);
  }
 else   if (intent.getAction().equals(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED)) {
    updateSignalState(intent);
  }
 else   if (intent.getAction().equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
    int state=intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    int oldState=intent.getIntExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    BluetoothDevice device=intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
synchronized (BluetoothHandsfree.this) {
      mA2dpState=state;
      mA2dpDevice=device;
      if (isA2dpMultiProfile() && mPendingSco) {
        mHandler.removeMessages(MESSAGE_CHECK_PENDING_SCO);
        if (mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
          if (DBG)           log("String_Node_Str");
          mOutgoingSco=createScoSocket();
          if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
            mOutgoingSco=null;
          }
        }
      }
      mPendingSco=false;
    }
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
    updateBatteryState(intent);
  }
 else   if (intent.getAction().equals(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED)) {
    updateSignalState(intent);
  }
 else   if (intent.getAction().equals(BluetoothA2dp.ACTION_SINK_STATE_CHANGED)) {
    int state=intent.getIntExtra(BluetoothA2dp.EXTRA_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    int oldState=intent.getIntExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE,BluetoothA2dp.STATE_DISCONNECTED);
    BluetoothDevice device=intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
synchronized (BluetoothHandsfree.this) {
      mA2dpState=state;
      mA2dpDevice=device;
      if (oldState == BluetoothA2dp.STATE_PLAYING && mA2dpState == BluetoothA2dp.STATE_CONNECTED) {
        if (mA2dpSuspended) {
          if (mPendingSco) {
            mHandler.removeMessages(MESSAGE_CHECK_PENDING_SCO);
            if (DBG)             log("String_Node_Str");
            mOutgoingSco=createScoSocket();
            if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
              mOutgoingSco=null;
            }
            mPendingSco=false;
          }
        }
      }
    }
  }
}
Program: 184766
Project: 184766
Buggy source:
/** 
 * Request to establish SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block. Returns false if the user has requested audio off, or if there is some other immediate problem that will prevent BT audio.
 */
synchronized boolean audioOn(){
  if (VDBG)   log("String_Node_Str");
  if (!isHeadsetConnected()) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mHeadsetType == TYPE_HANDSFREE && !mServiceConnectionEstablished) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mConnectedSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (!mUserWantsAudio) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mOutgoingSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (mPendingSco) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_PLAYING) {
    if (DBG)     log("String_Node_Str");
    mPendingSco=mA2dp.suspendSink(mA2dpDevice);
    if (mPendingSco) {
      Message msg=mHandler.obtainMessage(MESSAGE_CHECK_PENDING_SCO);
      mHandler.sendMessageDelayed(msg,2000);
    }
 else {
      Log.w(TAG,"String_Node_Str");
    }
  }
  if (!mPendingSco) {
    mOutgoingSco=createScoSocket();
    if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
      mOutgoingSco=null;
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Request to establish SCO (audio) connection to bluetooth headset/handsfree, if one is connected. Does not block. Returns false if the user has requested audio off, or if there is some other immediate problem that will prevent BT audio.
 */
synchronized boolean audioOn(){
  if (VDBG)   log("String_Node_Str");
  if (!isHeadsetConnected()) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mHeadsetType == TYPE_HANDSFREE && !mServiceConnectionEstablished) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mConnectedSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (!mUserWantsAudio) {
    if (DBG)     log("String_Node_Str");
    return false;
  }
  if (mOutgoingSco != null) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  if (mPendingSco) {
    if (DBG)     log("String_Node_Str");
    return true;
  }
  mA2dpSuspended=false;
  mPendingSco=false;
  if (isA2dpMultiProfile() && mA2dpState == BluetoothA2dp.STATE_PLAYING) {
    if (DBG)     log("String_Node_Str");
    mA2dpSuspended=mA2dp.suspendSink(mA2dpDevice);
    if (mA2dpSuspended) {
      mPendingSco=true;
      Message msg=mHandler.obtainMessage(MESSAGE_CHECK_PENDING_SCO);
      mHandler.sendMessageDelayed(msg,2000);
    }
 else {
      Log.w(TAG,"String_Node_Str");
    }
  }
  if (!mPendingSco) {
    mOutgoingSco=createScoSocket();
    if (!mOutgoingSco.connect(mHeadset.getRemoteDevice().getAddress())) {
      mOutgoingSco=null;
    }
  }
  return true;
}
Program: 184768
Project: 184768
Buggy source:
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,Preference preference){
  if (preference == mSubMenuVoicemailSettings) {
    return true;
  }
 else   if (preference == mButtonDTMF) {
    return true;
  }
 else   if (preference == mButtonTTY) {
    return true;
  }
 else   if (preference == mButtonAutoRetry) {
    android.provider.Settings.System.putInt(mPhone.getContext().getContentResolver(),android.provider.Settings.System.CALL_AUTO_RETRY,mButtonAutoRetry.isChecked() ? 1 : 0);
    return true;
  }
 else   if (preference == mButtonHAC) {
    int hac=mButtonHAC.isChecked() ? 1 : 0;
    Settings.System.putInt(mPhone.getContext().getContentResolver(),Settings.System.HEARING_AID,hac);
    mAudioManager.setParameter(HAC_KEY,hac != 0 ? HAC_VAL_ON : HAC_VAL_OFF);
    return true;
  }
 else   if (preference == mVoicemailSettings) {
    if (preference.getIntent() != null) {
      this.startActivityForResult(preference.getIntent(),VOICEMAIL_PROVIDER_CFG_ID);
    }
 else {
      updateVoiceNumberField();
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen,Preference preference){
  if (preference == mSubMenuVoicemailSettings) {
    return true;
  }
 else   if (preference == mButtonDTMF) {
    return true;
  }
 else   if (preference == mButtonTTY) {
    return true;
  }
 else   if (preference == mButtonAutoRetry) {
    android.provider.Settings.System.putInt(mPhone.getContext().getContentResolver(),android.provider.Settings.System.CALL_AUTO_RETRY,mButtonAutoRetry.isChecked() ? 1 : 0);
    return true;
  }
 else   if (preference == mButtonHAC) {
    int hac=mButtonHAC.isChecked() ? 1 : 0;
    Settings.System.putInt(mPhone.getContext().getContentResolver(),Settings.System.HEARING_AID,hac);
    mAudioManager.setParameter(HAC_KEY,hac != 0 ? HAC_VAL_ON : HAC_VAL_OFF);
    return true;
  }
 else   if (preference == mVoicemailSettings) {
    if (preference.getIntent() != null) {
      if (DBG)       log("String_Node_Str" + preference.getIntent().getPackage());
      this.startActivityForResult(preference.getIntent(),VOICEMAIL_PROVIDER_CFG_ID);
    }
 else {
      if (DBG)       log("String_Node_Str");
      updateVoiceNumberField();
      mSubMenuVoicemailSettings.showPhoneNumberDialog();
    }
    return true;
  }
  return false;
}
Program: 184769
Project: 184769
Buggy source:
/** 
 * Implemented to support onPreferenceChangeListener to look for preference changes.
 * @param preference is the preference to be changed
 * @param objValue should be the value of the selection, NOT its localizeddisplay value.
 */
public boolean onPreferenceChange(Preference preference,Object objValue){
  if (preference == mButtonDTMF) {
    int index=mButtonDTMF.findIndexOfValue((String)objValue);
    Settings.System.putInt(mPhone.getContext().getContentResolver(),Settings.System.DTMF_TONE_TYPE_WHEN_DIALING,index);
  }
 else   if (preference == mButtonTTY) {
    handleTTYChange(preference,objValue);
  }
 else   if (preference == mVoicemailProviders) {
    mPreviousVMProviderKey=mVoicemailProviders.getValue();
    final String newProviderKey=(String)objValue;
    if (DBG)     log("String_Node_Str" + newProviderKey + "String_Node_Str"+ mPreviousVMProviderKey);
    updateVMPreferenceWidgets(newProviderKey);
    final VoiceMailProviderSettings newProviderSettings=loadSettingsForVoiceMailProvider(newProviderKey);
    if (newProviderSettings == null) {
      mVMProviderSettingsForced=true;
      simulatePreferenceClick(mVoicemailSettings);
    }
 else {
      saveVoiceMailAndForwardingNumber(newProviderKey,newProviderSettings);
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Implemented to support onPreferenceChangeListener to look for preference changes.
 * @param preference is the preference to be changed
 * @param objValue should be the value of the selection, NOT its localizeddisplay value.
 */
public boolean onPreferenceChange(Preference preference,Object objValue){
  if (preference == mButtonDTMF) {
    int index=mButtonDTMF.findIndexOfValue((String)objValue);
    Settings.System.putInt(mPhone.getContext().getContentResolver(),Settings.System.DTMF_TONE_TYPE_WHEN_DIALING,index);
  }
 else   if (preference == mButtonTTY) {
    handleTTYChange(preference,objValue);
  }
 else   if (preference == mVoicemailProviders) {
    mPreviousVMProviderKey=getCurrentVoicemailProviderKey();
    final String newProviderKey=(String)objValue;
    if (DBG)     log("String_Node_Str" + newProviderKey + "String_Node_Str"+ mPreviousVMProviderKey);
    updateVMPreferenceWidgets(newProviderKey);
    final VoiceMailProviderSettings newProviderSettings=loadSettingsForVoiceMailProvider(newProviderKey);
    if (newProviderSettings == null) {
      if (DBG)       log("String_Node_Str");
      mVMProviderSettingsForced=true;
      simulatePreferenceClick(mVoicemailSettings);
    }
 else {
      if (DBG)       log("String_Node_Str");
      saveVoiceMailAndForwardingNumber(newProviderKey,newProviderSettings);
    }
  }
  return true;
}
Program: 184771
Project: 184771
Buggy source:
private void handleVMBtnClickRequest(){
  saveVoiceMailAndForwardingNumber(mVoicemailProviders.getValue(),new VoiceMailProviderSettings(mSubMenuVoicemailSettings.getPhoneNumber(),FWD_SETTINGS_DONT_TOUCH));
}

Fixed version (ground truth):
private void handleVMBtnClickRequest(){
  saveVoiceMailAndForwardingNumber(getCurrentVoicemailProviderKey(),new VoiceMailProviderSettings(mSubMenuVoicemailSettings.getPhoneNumber(),FWD_SETTINGS_DONT_TOUCH));
}
Program: 184772
Project: 184772
Buggy source:
private int waitForConnect(HeadsetBase headset){
  int result=ETIMEOUT;
  for (int i=0; i < 40 && result == ETIMEOUT; i++) {
    result=headset.waitForAsyncConnect(500,mConnectedStatusHandler);
    if (isInterrupted()) {
      headset.disconnect();
      return EINTERRUPT;
    }
  }
  return result;
}

Fixed version (ground truth):
private int waitForConnect(HeadsetBase headset){
  int result=0;
  for (int i=0; i < 40 && result == 0; i++) {
    result=headset.waitForAsyncConnect(500,mConnectedStatusHandler);
    if (isInterrupted()) {
      headset.disconnect();
      return EINTERRUPT;
    }
  }
  return result;
}
Program: 184773
Project: 184773
Buggy source:
@Override public void run(){
  long timestamp;
  timestamp=System.currentTimeMillis();
  HeadsetBase headset=new HeadsetBase(mPowerManager,mAdapter,device,channel);
  int result=waitForConnect(headset);
  if (result == ECONNREFUSED) {
    Log.i(TAG,"String_Node_Str");
    try {
      sleep(1000);
    }
 catch (    InterruptedException e) {
    }
    result=waitForConnect(headset);
  }
  if (result == EINTERRUPT)   return;
  if (DBG)   log("String_Node_Str" + (System.currentTimeMillis() - timestamp) + "String_Node_Str");
  if (isInterrupted()) {
    headset.disconnect();
    return;
  }
  if (result < 0) {
    Log.w(TAG,"String_Node_Str" + result);
    if (result == ETIMEOUT) {
      Log.w(TAG,"String_Node_Str");
    }
    mConnectingStatusHandler.obtainMessage(RFCOMM_ERROR).sendToTarget();
    return;
  }
 else {
    mConnectingStatusHandler.obtainMessage(RFCOMM_CONNECTED,headset).sendToTarget();
  }
}

Fixed version (ground truth):
@Override public void run(){
  long timestamp;
  timestamp=System.currentTimeMillis();
  HeadsetBase headset=new HeadsetBase(mPowerManager,mAdapter,device,channel);
  int result=waitForConnect(headset);
  if (result == ECONNREFUSED) {
    Log.i(TAG,"String_Node_Str");
    try {
      sleep(1000);
    }
 catch (    InterruptedException e) {
    }
    result=waitForConnect(headset);
  }
  if (result == EINTERRUPT)   return;
  if (DBG)   log("String_Node_Str" + (System.currentTimeMillis() - timestamp) + "String_Node_Str");
  if (isInterrupted()) {
    headset.disconnect();
    return;
  }
  if (result < 0) {
    Log.w(TAG,"String_Node_Str" + result);
    mConnectingStatusHandler.obtainMessage(RFCOMM_ERROR).sendToTarget();
    return;
  }
 else   if (result == 0) {
    mConnectingStatusHandler.obtainMessage(RFCOMM_ERROR).sendToTarget();
    Log.w(TAG,"String_Node_Str" + result + "String_Node_Str");
    return;
  }
 else {
    mConnectingStatusHandler.obtainMessage(RFCOMM_CONNECTED,headset).sendToTarget();
  }
}
Program: 184774
Project: 184774
Buggy source:
/** 
 * Restore the mute setting from the earliest connection of the foreground call.
 */
static Boolean restoreMuteState(Phone phone){
  Connection c=phone.getForegroundCall().getEarliestConnection();
  if (c != null) {
    int phoneType=phone.getPhoneType();
    Boolean shouldMute=null;
    if (phoneType == Phone.PHONE_TYPE_CDMA && PhoneApp.getInstance().cdmaPhoneCallState.getCurrentCallState() == CdmaPhoneCallState.PhoneCallState.THRWAY_ACTIVE) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getLatestConnection());
    }
 else     if (phoneType == Phone.PHONE_TYPE_GSM) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getEarliestConnection());
    }
    if (shouldMute == null) {
      if (DBG)       log("String_Node_Str");
      shouldMute=Boolean.FALSE;
    }
    setMute(phone,shouldMute.booleanValue());
    return shouldMute;
  }
  return Boolean.valueOf(getMute(phone));
}

Fixed version (ground truth):
/** 
 * Restore the mute setting from the earliest connection of the foreground call.
 */
static Boolean restoreMuteState(Phone phone){
  Connection c=phone.getForegroundCall().getEarliestConnection();
  if (c != null) {
    int phoneType=phone.getPhoneType();
    Boolean shouldMute=null;
    if (phoneType == Phone.PHONE_TYPE_CDMA) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getLatestConnection());
    }
 else     if (phoneType == Phone.PHONE_TYPE_GSM) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getEarliestConnection());
    }
    if (shouldMute == null) {
      if (DBG)       log("String_Node_Str");
      shouldMute=Boolean.FALSE;
    }
    setMute(phone,shouldMute.booleanValue());
    return shouldMute;
  }
  return Boolean.valueOf(getMute(phone));
}
Program: 184775
Project: 184775
Buggy source:
/** 
 * Restore the mute setting from the earliest connection of the foreground call.
 */
static Boolean restoreMuteState(Phone phone){
  Connection c=phone.getForegroundCall().getEarliestConnection();
  if (c != null) {
    int phoneType=phone.getPhoneType();
    Boolean shouldMute=null;
    if (phoneType == Phone.PHONE_TYPE_CDMA && PhoneApp.getInstance().cdmaPhoneCallState.getCurrentCallState() == CdmaPhoneCallState.PhoneCallState.THRWAY_ACTIVE) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getLatestConnection());
    }
 else     if (phoneType == Phone.PHONE_TYPE_GSM) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getEarliestConnection());
    }
    if (shouldMute == null) {
      if (DBG)       log("String_Node_Str");
      shouldMute=Boolean.FALSE;
    }
    setMute(phone,shouldMute.booleanValue());
    return shouldMute;
  }
  return Boolean.valueOf(getMute(phone));
}

Fixed version (ground truth):
/** 
 * Restore the mute setting from the earliest connection of the foreground call.
 */
static Boolean restoreMuteState(Phone phone){
  Connection c=phone.getForegroundCall().getEarliestConnection();
  if (c != null) {
    int phoneType=phone.getPhoneType();
    Boolean shouldMute=null;
    if (phoneType == Phone.PHONE_TYPE_CDMA) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getLatestConnection());
    }
 else     if (phoneType == Phone.PHONE_TYPE_GSM) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getEarliestConnection());
    }
    if (shouldMute == null) {
      if (DBG)       log("String_Node_Str");
      shouldMute=Boolean.FALSE;
    }
    setMute(phone,shouldMute.booleanValue());
    return shouldMute;
  }
  return Boolean.valueOf(getMute(phone));
}
Program: 184776
Project: 184776
Buggy source:
/** 
 * Restore the mute setting from the earliest connection of the foreground call.
 */
static Boolean restoreMuteState(Phone phone){
  Connection c=phone.getForegroundCall().getEarliestConnection();
  if (c != null) {
    int phoneType=phone.getPhoneType();
    Boolean shouldMute=null;
    if (phoneType == Phone.PHONE_TYPE_CDMA && PhoneApp.getInstance().cdmaPhoneCallState.getCurrentCallState() == CdmaPhoneCallState.PhoneCallState.THRWAY_ACTIVE) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getLatestConnection());
    }
 else     if (phoneType == Phone.PHONE_TYPE_GSM) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getEarliestConnection());
    }
    if (shouldMute == null) {
      if (DBG)       log("String_Node_Str");
      shouldMute=Boolean.FALSE;
    }
    setMute(phone,shouldMute.booleanValue());
    return shouldMute;
  }
  return Boolean.valueOf(getMute(phone));
}

Fixed version (ground truth):
/** 
 * Restore the mute setting from the earliest connection of the foreground call.
 */
static Boolean restoreMuteState(Phone phone){
  Connection c=phone.getForegroundCall().getEarliestConnection();
  if (c != null) {
    int phoneType=phone.getPhoneType();
    Boolean shouldMute=null;
    if (phoneType == Phone.PHONE_TYPE_CDMA) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getLatestConnection());
    }
 else     if (phoneType == Phone.PHONE_TYPE_GSM) {
      shouldMute=sConnectionMuteTable.get(phone.getForegroundCall().getEarliestConnection());
    }
    if (shouldMute == null) {
      if (DBG)       log("String_Node_Str");
      shouldMute=Boolean.FALSE;
    }
    setMute(phone,shouldMute.booleanValue());
    return shouldMute;
  }
  return Boolean.valueOf(getMute(phone));
}
Program: 184777
Project: 184777
Buggy source:
/** 
 * Resets the audio mode and speaker state when a call ends.
 */
private void resetAudioStateAfterDisconnect(){
  if (VDBG)   log("String_Node_Str");
  if (mBluetoothHandsfree != null) {
    mBluetoothHandsfree.audioOff();
  }
  if (PhoneUtils.isSpeakerOn(mPhone.getContext())) {
    PhoneUtils.turnOnSpeaker(mPhone.getContext(),false,true);
  }
  PhoneUtils.setAudioMode(mPhone.getContext(),AudioManager.MODE_NORMAL);
}

Fixed version (ground truth):
/** 
 * Resets the audio mode and speaker state when a call ends.
 */
private void resetAudioStateAfterDisconnect(){
  if (VDBG)   log("String_Node_Str");
  if (mBluetoothHandsfree != null) {
    mBluetoothHandsfree.audioOff();
  }
  PhoneUtils.turnOnSpeaker(mPhone.getContext(),false,true);
  PhoneUtils.setAudioMode(mPhone.getContext(),AudioManager.MODE_NORMAL);
}
Program: 184778
Project: 184778
Buggy source:
/** 
 * Resets the audio mode and speaker state when a call ends.
 */
private void resetAudioStateAfterDisconnect(){
  if (VDBG)   log("String_Node_Str");
  if (mBluetoothHandsfree != null) {
    mBluetoothHandsfree.audioOff();
  }
  if (PhoneUtils.isSpeakerOn(mPhone.getContext())) {
    PhoneUtils.turnOnSpeaker(mPhone.getContext(),false,true);
  }
  PhoneUtils.setAudioMode(mPhone.getContext(),AudioManager.MODE_NORMAL);
}

Fixed version (ground truth):
/** 
 * Resets the audio mode and speaker state when a call ends.
 */
private void resetAudioStateAfterDisconnect(){
  if (VDBG)   log("String_Node_Str");
  if (mBluetoothHandsfree != null) {
    mBluetoothHandsfree.audioOff();
  }
  PhoneUtils.turnOnSpeaker(mPhone.getContext(),false,true);
  PhoneUtils.setAudioMode(mPhone.getContext(),AudioManager.MODE_NORMAL);
}