Program: 36897
Project: 36897
Buggy source:
/** 
 * The call has transitioned to another state. We can now visually update the view with extra info or perform required actions.
 * @param newStatus the new interaction state to which we should act.
 * @see SipConstants for the possible states.
 */
private void onCallStatusUpdate(String newStatus){
  mRemoteLogger.d("String_Node_Str" + newStatus);
switch (newStatus) {
case CALL_CONNECTED_MESSAGE:
    toggleCallStateButtonVisibility(TYPE_CONNECTED_CALL);
  mStateView.setText(R.string.call_connected);
mCallStartTime=System.currentTimeMillis();
mCallHandler.postDelayed(mCallDurationRunnable,0);
mConnected=true;
mHasConnected=true;
mIncomingCallIsRinging=false;
mProximityHelper.updateWakeLock();
mNotificationHelper.updateNotification(getCallerInfo(),this.getString(R.string.callnotification_active_call),NotificationHelper.mCallNotifyId);
if (mOnTransfer && mSipService.getCurrentCall() != null && mSipService.getFirstCall() != null) {
CallTransferFragment callTransferFragment=(CallTransferFragment)getFragmentManager().findFragmentByTag(TAG_CALL_TRANSFER_FRAGMENT);
callTransferFragment.secondCallIsConnected();
}
mCallDurationView.setVisibility(View.VISIBLE);
break;
case CALL_DISCONNECTED_MESSAGE:
if (!mHasConnected && !mSelfHangup) {
mStateView.setText(R.string.call_unreachable);
sendBroadcast(new Intent(BluetoothMediaButtonReceiver.DECLINE_BTN));
}
 else {
mStateView.setText(R.string.call_ended);
}
mCallHandler.removeCallbacks(mCallDurationRunnable);
mConnected=false;
mIncomingCallIsRinging=false;
mMediaManager.stopIncomingCallRinger();
if (mOnTransfer) {
if (mCallIsTransferred) {
toggleVisibilityCallInfo(false);
Map<String,String> map=new HashMap<>();
map.put(MAP_ORIGINAL_CALLER_ID,mSipService.getFirstCall().getCallerId());
map.put(MAP_ORIGINAL_CALLER_PHONE_NUMBER,mSipService.getFirstCall().getPhoneNumber());
map.put(MAP_TRANSFERRED_PHONE_NUMBER,mTransferredNumber);
swapFragment(TAG_CALL_TRANSFER_COMPLETE_FRAGMENT,map);
mOnTransfer=false;
try {
mSipService.getFirstCall().hangup(true);
}
 catch (Exception e) {
e.printStackTrace();
}
}
 else if (mSipService.getCurrentCall() != null) {
String currentCallIdentifier=mSipService.getCurrentCall().getIdentifier();
String initialCallIdentifier=mSipService.getFirstCall().getIdentifier();
mMediaManager.setCallOnSpeaker(false);
mConnected=true;
toggleVisibilityCallInfo(true);
findViewById(R.id.button_transfer).setVisibility(View.VISIBLE);
swapFragment(TAG_CALL_CONNECTED_FRAGMENT,null);
newStatus=mSipService.getCurrentCall().getCurrentCallState();
if (!currentCallIdentifier.equals(initialCallIdentifier)) {
mCurrentCallId=mSipService.getCurrentCall().getIdentifier();
mCallerIdToDisplay=mSipService.getCurrentCall().getCallerId();
mPhoneNumberToDisplay=mSipService.getCurrentCall().getPhoneNumber();
}
 else {
mCurrentCallId=mSipService.getFirstCall().getIdentifier();
newStatus=mSipService.getFirstCall().getCurrentCallState();
mCallerIdToDisplay=mSipService.getFirstCall().getCallerId();
mPhoneNumberToDisplay=mSipService.getFirstCall().getPhoneNumber();
}
displayCallInfo();
mOnHold=mSipService.getCurrentCall().isOnHold();
mOnTransfer=false;
updateCallButton(R.id.button_transfer,true);
updateCallButton(R.id.button_onhold,true);
updateCallButton(R.id.button_keypad,true);
updateCallButton(R.id.button_microphone,true);
onCallStatusUpdate(mSipService.getCurrentCall().getCurrentCallState());
}
 else {
if (mSipService != null && mSipService.getCurrentCall() == null && mSipService.getFirstCall() == null) {
toggleVisibilityCallInfo(true);
swapFragment(TAG_CALL_CONNECTED_FRAGMENT,null);
displayCallInfo();
mOnTransfer=false;
mOnHold=false;
updateCallButton(R.id.button_transfer,false);
updateCallButton(R.id.button_onhold,false);
updateCallButton(R.id.button_keypad,false);
updateCallButton(R.id.button_microphone,false);
updateCallButton(R.id.button_hangup,false);
onCallStatusUpdate(CALL_DISCONNECTED_MESSAGE);
}
}
}
 else {
mMediaManager.callEnded();
finishWithDelay();
}
onCallStatesUpdateButtons(newStatus);
break;
case CALL_PUT_ON_HOLD_ACTION:
mCallHandler.removeCallbacks(mCallDurationRunnable);
mCallDurationView.setVisibility(View.GONE);
mStateView.setText(R.string.call_on_hold);
mNotificationHelper.updateNotification(getCallerInfo(),this.getString(R.string.callnotification_on_hold),NotificationHelper.mCallNotifyId);
break;
case CALL_UNHOLD_ACTION:
mCallHandler.postDelayed(mCallDurationRunnable,0);
mCallDurationView.setVisibility(View.VISIBLE);
mStateView.setText(R.string.call_connected);
mNotificationHelper.updateNotification(getCallerInfo(),this.getString(R.string.callnotification_active_call),NotificationHelper.mCallNotifyId);
break;
case CALL_RINGING_OUT_MESSAGE:
mStateView.setText(R.string.call_outgoing);
findViewById(R.id.button_speaker).setEnabled(false);
findViewById(R.id.button_microphone).setEnabled(false);
break;
case CALL_RINGING_IN_MESSAGE:
mStateView.setText(R.string.call_incoming);
break;
case SERVICE_STOPPED:
mConnected=false;
mIncomingCallIsRinging=false;
finishWithDelay();
break;
}
}

Fixed version (ground truth):
/** 
 * The call has transitioned to another state. We can now visually update the view with extra info or perform required actions.
 * @param newStatus the new interaction state to which we should act.
 * @see SipConstants for the possible states.
 */
private void onCallStatusUpdate(String newStatus){
  mRemoteLogger.d("String_Node_Str" + newStatus);
switch (newStatus) {
case CALL_CONNECTED_MESSAGE:
    toggleCallStateButtonVisibility(TYPE_CONNECTED_CALL);
  mStateView.setText(R.string.call_connected);
mCallStartTime=System.currentTimeMillis();
mCallHandler.postDelayed(mCallDurationRunnable,0);
mConnected=true;
mHasConnected=true;
mIncomingCallIsRinging=false;
mProximityHelper.updateWakeLock();
mNotificationHelper.updateNotification(getCallerInfo(),this.getString(R.string.callnotification_active_call),NotificationHelper.mCallNotifyId);
if (mOnTransfer && mSipService.getCurrentCall() != null && mSipService.getFirstCall() != null) {
CallTransferFragment callTransferFragment=(CallTransferFragment)getFragmentManager().findFragmentByTag(TAG_CALL_TRANSFER_FRAGMENT);
callTransferFragment.secondCallIsConnected();
}
mCallDurationView.setVisibility(View.VISIBLE);
break;
case CALL_DISCONNECTED_MESSAGE:
if (!mHasConnected && !mSelfHangup) {
mStateView.setText(R.string.call_unreachable);
sendBroadcast(new Intent(BluetoothMediaButtonReceiver.DECLINE_BTN));
}
 else {
mStateView.setText(R.string.call_ended);
}
mCallHandler.removeCallbacks(mCallDurationRunnable);
mConnected=false;
mIncomingCallIsRinging=false;
mMediaManager.stopIncomingCallRinger();
if (mOnTransfer) {
if (mCallIsTransferred) {
toggleVisibilityCallInfo(false);
Map<String,String> map=new HashMap<>();
map.put(MAP_ORIGINAL_CALLER_ID,mSipService.getFirstCall().getCallerId());
map.put(MAP_ORIGINAL_CALLER_PHONE_NUMBER,mSipService.getFirstCall().getPhoneNumber());
map.put(MAP_TRANSFERRED_PHONE_NUMBER,mTransferredNumber);
swapFragment(TAG_CALL_TRANSFER_COMPLETE_FRAGMENT,map);
mOnTransfer=false;
try {
mSipService.getFirstCall().hangup(true);
}
 catch (Exception e) {
e.printStackTrace();
}
}
 else if (mSipService.getCurrentCall() != null) {
String currentCallIdentifier=mSipService.getCurrentCall().getIdentifier();
String initialCallIdentifier=mSipService.getFirstCall().getIdentifier();
mMediaManager.setCallOnSpeaker(false);
mConnected=true;
toggleVisibilityCallInfo(true);
findViewById(R.id.button_transfer).setVisibility(View.VISIBLE);
swapFragment(TAG_CALL_CONNECTED_FRAGMENT,null);
newStatus=mSipService.getCurrentCall().getCurrentCallState();
if (!currentCallIdentifier.equals(initialCallIdentifier)) {
mCurrentCallId=mSipService.getCurrentCall().getIdentifier();
mCallerIdToDisplay=mSipService.getCurrentCall().getCallerId();
mPhoneNumberToDisplay=mSipService.getCurrentCall().getPhoneNumber();
}
 else {
mCurrentCallId=mSipService.getFirstCall().getIdentifier();
newStatus=mSipService.getFirstCall().getCurrentCallState();
mCallerIdToDisplay=mSipService.getFirstCall().getCallerId();
mPhoneNumberToDisplay=mSipService.getFirstCall().getPhoneNumber();
}
displayCallInfo();
mOnHold=mSipService.getCurrentCall().isOnHold();
mOnTransfer=false;
updateCallButton(R.id.button_transfer,true);
updateCallButton(R.id.button_onhold,true);
updateCallButton(R.id.button_keypad,true);
updateCallButton(R.id.button_microphone,true);
onCallStatusUpdate(mSipService.getCurrentCall().getCurrentCallState());
}
 else {
if (mSipService != null && mSipService.getCurrentCall() == null && mSipService.getFirstCall() == null) {
toggleVisibilityCallInfo(true);
swapFragment(TAG_CALL_CONNECTED_FRAGMENT,null);
displayCallInfo();
mOnTransfer=false;
mOnHold=false;
updateCallButton(R.id.button_transfer,false);
updateCallButton(R.id.button_onhold,false);
updateCallButton(R.id.button_keypad,false);
updateCallButton(R.id.button_microphone,false);
updateCallButton(R.id.button_hangup,false);
onCallStatusUpdate(CALL_DISCONNECTED_MESSAGE);
}
}
}
 else {
mMediaManager.callEnded();
finishWithDelay();
}
onCallStatesUpdateButtons(newStatus);
break;
case CALL_PUT_ON_HOLD_ACTION:
mOnHold=true;
mCallHandler.removeCallbacks(mCallDurationRunnable);
mCallDurationView.setVisibility(View.GONE);
mStateView.setText(R.string.call_on_hold);
updateCallButton(R.id.button_onhold,true);
mNotificationHelper.updateNotification(getCallerInfo(),this.getString(R.string.callnotification_on_hold),NotificationHelper.mCallNotifyId);
break;
case CALL_UNHOLD_ACTION:
mOnHold=false;
mCallHandler.postDelayed(mCallDurationRunnable,0);
mCallDurationView.setVisibility(View.VISIBLE);
mStateView.setText(R.string.call_connected);
updateCallButton(R.id.button_onhold,true);
mNotificationHelper.updateNotification(getCallerInfo(),this.getString(R.string.callnotification_active_call),NotificationHelper.mCallNotifyId);
break;
case CALL_RINGING_OUT_MESSAGE:
mStateView.setText(R.string.call_outgoing);
findViewById(R.id.button_speaker).setEnabled(false);
findViewById(R.id.button_microphone).setEnabled(false);
break;
case CALL_RINGING_IN_MESSAGE:
mStateView.setText(R.string.call_incoming);
break;
case SERVICE_STOPPED:
mConnected=false;
mIncomingCallIsRinging=false;
finishWithDelay();
break;
}
}