Program: 184734
Project: 184734
Buggy source:
private void onDisconnect(AsyncResult r){
  if (VDBG)   log("String_Node_Str" + mPhone.getState());
  mCdmaVoicePrivacyState=false;
  int autoretrySetting=0;
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
    autoretrySetting=android.provider.Settings.System.getInt(mPhone.getContext().getContentResolver(),android.provider.Settings.System.CALL_AUTO_RETRY,0);
  }
  if (mPhone.getState() == Phone.State.IDLE) {
    PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_IDLE);
  }
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
    stopSignalInfoTone();
    mApplication.cdmaPhoneCallState.resetCdmaPhoneCallState();
    removeMessages(CALLWAITING_CALLERINFO_DISPLAY_DONE);
    removeMessages(CALLWAITING_ADDCALL_DISABLE_TIMEOUT);
  }
  Connection c=(Connection)r.result;
  if (DBG && c != null) {
    log("String_Node_Str" + c.getDisconnectCause() + "String_Node_Str"+ c.isIncoming()+ "String_Node_Str"+ c.getCreateTime());
  }
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
    if (mPhone.getRingingCall().getState() == Call.State.INCOMING) {
      if (DBG)       log("String_Node_Str");
      NotificationMgr.getDefault().cancelCallInProgressNotification();
    }
 else {
      if (DBG)       log("String_Node_Str");
      mRinger.stopRing();
    }
  }
 else {
    if (DBG)     log("String_Node_Str");
    mRinger.stopRing();
  }
  int toneToPlay=InCallTonePlayer.TONE_NONE;
  if (c != null) {
    Connection.DisconnectCause cause=c.getDisconnectCause();
    if (cause == Connection.DisconnectCause.BUSY) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_BUSY;
    }
 else     if (cause == Connection.DisconnectCause.CONGESTION) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_CONGESTION;
    }
 else     if (((cause == Connection.DisconnectCause.NORMAL) || (cause == Connection.DisconnectCause.LOCAL)) && (mApplication.isOtaCallInActiveState())) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_OTA_CALL_END;
    }
 else     if (cause == Connection.DisconnectCause.CDMA_REORDER) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_REORDER;
    }
 else     if (cause == Connection.DisconnectCause.CDMA_INTERCEPT) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_INTERCEPT;
    }
 else     if (cause == Connection.DisconnectCause.CDMA_DROP) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_CDMA_DROP;
    }
 else     if (cause == Connection.DisconnectCause.OUT_OF_SERVICE) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_OUT_OF_SERVICE;
    }
 else     if (cause == Connection.DisconnectCause.ERROR_UNSPECIFIED) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_CALL_ENDED;
    }
  }
  if ((toneToPlay == InCallTonePlayer.TONE_NONE) && (mPhone.getState() == Phone.State.IDLE) && (c != null)) {
    Connection.DisconnectCause cause=c.getDisconnectCause();
    if ((cause == Connection.DisconnectCause.NORMAL) || (cause == Connection.DisconnectCause.LOCAL)) {
      if (VDBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_CALL_ENDED;
      mIsCdmaRedialCall=false;
    }
  }
  if (mPhone.getState() == Phone.State.IDLE) {
    if (toneToPlay == InCallTonePlayer.TONE_NONE) {
      resetAudioStateAfterDisconnect();
    }
    NotificationMgr.getDefault().cancelCallInProgressNotification();
    if (!mApplication.isShowingCallScreen()) {
      if (VDBG)       log("String_Node_Str");
      mApplication.dismissCallScreen();
    }
  }
  if (c != null) {
    final String number=c.getAddress();
    final long date=c.getCreateTime();
    final long duration=c.getDurationMillis();
    final Connection.DisconnectCause cause=c.getDisconnectCause();
    final int callLogType;
    if (c.isIncoming()) {
      callLogType=(cause == Connection.DisconnectCause.INCOMING_MISSED ? CallLog.Calls.MISSED_TYPE : CallLog.Calls.INCOMING_TYPE);
    }
 else {
      callLogType=CallLog.Calls.OUTGOING_TYPE;
    }
    if (VDBG)     log("String_Node_Str" + callLogType + "String_Node_Str"+ c.getUserData());
{
      final CallerInfo ci=getCallerInfoFromConnection(c);
      final String logNumber=getLogNumber(c,ci);
      if (DBG)       log("String_Node_Str" + logNumber);
      final int presentation=getPresentation(c,ci);
      if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
        if ((PhoneNumberUtils.isEmergencyNumber(number)) && (mCurrentEmergencyToneState != EMERGENCY_TONE_OFF)) {
          if (mEmergencyTonePlayerVibrator != null) {
            mEmergencyTonePlayerVibrator.stop();
          }
        }
      }
      final boolean shouldNotlogEmergencyNumber=(mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA);
      final boolean isOtaNumber=(mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) && mPhone.isOtaSpNumber(number);
      final boolean isEmergencyNumber=PhoneNumberUtils.isEmergencyNumber(number);
      if (!(isOtaNumber || isEmergencyNumber && shouldNotlogEmergencyNumber)) {
        Thread t=new Thread(){
          public void run(){
            Calls.addCall(ci,mApplication,logNumber,presentation,callLogType,date,(int)duration / 1000);
          }
        }
;
        t.start();
      }
    }
    if (callLogType == CallLog.Calls.MISSED_TYPE) {
      showMissedCallNotification(c,date);
    }
    if (toneToPlay != InCallTonePlayer.TONE_NONE) {
      if (VDBG)       log("String_Node_Str" + toneToPlay + "String_Node_Str");
      new InCallTonePlayer(toneToPlay).start();
    }
    if (mPhone.getState() == Phone.State.IDLE) {
      if (!mApplication.isShowingCallScreen()) {
        if (VDBG)         log("String_Node_Str");
        mApplication.setScreenTimeout(PhoneApp.ScreenTimeoutDuration.DEFAULT);
        mApplication.requestWakeState(PhoneApp.WakeState.SLEEP);
      }
 else {
        if (VDBG)         log("String_Node_Str");
      }
    }
 else {
      if (VDBG)       log("String_Node_Str");
    }
    if (((mPreviousCdmaCallState == Call.State.DIALING) || (mPreviousCdmaCallState == Call.State.ALERTING)) && (!PhoneNumberUtils.isEmergencyNumber(number)) && (cause != Connection.DisconnectCause.INCOMING_MISSED)&& (cause != Connection.DisconnectCause.NORMAL)&& (cause != Connection.DisconnectCause.LOCAL)&& (cause != Connection.DisconnectCause.INCOMING_REJECTED)) {
      if (!mIsCdmaRedialCall) {
        if (autoretrySetting == InCallScreen.AUTO_RETRY_ON) {
          PhoneUtils.placeCall(mPhone,number,null);
          mIsCdmaRedialCall=true;
        }
 else {
          mIsCdmaRedialCall=false;
        }
      }
 else {
        mIsCdmaRedialCall=false;
      }
    }
  }
}

Fixed version (ground truth):
private void onDisconnect(AsyncResult r){
  if (VDBG)   log("String_Node_Str" + mPhone.getState());
  mCdmaVoicePrivacyState=false;
  int autoretrySetting=0;
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
    autoretrySetting=android.provider.Settings.System.getInt(mPhone.getContext().getContentResolver(),android.provider.Settings.System.CALL_AUTO_RETRY,0);
  }
  if (mPhone.getState() == Phone.State.IDLE) {
    PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_IDLE);
  }
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
    stopSignalInfoTone();
    mApplication.cdmaPhoneCallState.resetCdmaPhoneCallState();
    removeMessages(CALLWAITING_CALLERINFO_DISPLAY_DONE);
    removeMessages(CALLWAITING_ADDCALL_DISABLE_TIMEOUT);
  }
  Connection c=(Connection)r.result;
  if (DBG && c != null) {
    log("String_Node_Str" + c.getDisconnectCause() + "String_Node_Str"+ c.isIncoming()+ "String_Node_Str"+ c.getCreateTime());
  }
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
    if (mPhone.getRingingCall().getState() == Call.State.INCOMING) {
      if (DBG)       log("String_Node_Str");
      NotificationMgr.getDefault().cancelCallInProgressNotification();
    }
 else {
      if (DBG)       log("String_Node_Str");
      mRinger.stopRing();
    }
  }
 else {
    if (DBG)     log("String_Node_Str");
    mRinger.stopRing();
  }
  if (mCallWaitingTonePlayer != null) {
    mCallWaitingTonePlayer.stopTone();
    mCallWaitingTonePlayer=null;
  }
  int toneToPlay=InCallTonePlayer.TONE_NONE;
  if (c != null) {
    Connection.DisconnectCause cause=c.getDisconnectCause();
    if (cause == Connection.DisconnectCause.BUSY) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_BUSY;
    }
 else     if (cause == Connection.DisconnectCause.CONGESTION) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_CONGESTION;
    }
 else     if (((cause == Connection.DisconnectCause.NORMAL) || (cause == Connection.DisconnectCause.LOCAL)) && (mApplication.isOtaCallInActiveState())) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_OTA_CALL_END;
    }
 else     if (cause == Connection.DisconnectCause.CDMA_REORDER) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_REORDER;
    }
 else     if (cause == Connection.DisconnectCause.CDMA_INTERCEPT) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_INTERCEPT;
    }
 else     if (cause == Connection.DisconnectCause.CDMA_DROP) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_CDMA_DROP;
    }
 else     if (cause == Connection.DisconnectCause.OUT_OF_SERVICE) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_OUT_OF_SERVICE;
    }
 else     if (cause == Connection.DisconnectCause.ERROR_UNSPECIFIED) {
      if (DBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_CALL_ENDED;
    }
  }
  if ((toneToPlay == InCallTonePlayer.TONE_NONE) && (mPhone.getState() == Phone.State.IDLE) && (c != null)) {
    Connection.DisconnectCause cause=c.getDisconnectCause();
    if ((cause == Connection.DisconnectCause.NORMAL) || (cause == Connection.DisconnectCause.LOCAL)) {
      if (VDBG)       log("String_Node_Str");
      toneToPlay=InCallTonePlayer.TONE_CALL_ENDED;
      mIsCdmaRedialCall=false;
    }
  }
  if (mPhone.getState() == Phone.State.IDLE) {
    if (toneToPlay == InCallTonePlayer.TONE_NONE) {
      resetAudioStateAfterDisconnect();
    }
    NotificationMgr.getDefault().cancelCallInProgressNotification();
    if (!mApplication.isShowingCallScreen()) {
      if (VDBG)       log("String_Node_Str");
      mApplication.dismissCallScreen();
    }
  }
  if (c != null) {
    final String number=c.getAddress();
    final long date=c.getCreateTime();
    final long duration=c.getDurationMillis();
    final Connection.DisconnectCause cause=c.getDisconnectCause();
    final int callLogType;
    if (c.isIncoming()) {
      callLogType=(cause == Connection.DisconnectCause.INCOMING_MISSED ? CallLog.Calls.MISSED_TYPE : CallLog.Calls.INCOMING_TYPE);
    }
 else {
      callLogType=CallLog.Calls.OUTGOING_TYPE;
    }
    if (VDBG)     log("String_Node_Str" + callLogType + "String_Node_Str"+ c.getUserData());
{
      final CallerInfo ci=getCallerInfoFromConnection(c);
      final String logNumber=getLogNumber(c,ci);
      if (DBG)       log("String_Node_Str" + logNumber);
      final int presentation=getPresentation(c,ci);
      if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
        if ((PhoneNumberUtils.isEmergencyNumber(number)) && (mCurrentEmergencyToneState != EMERGENCY_TONE_OFF)) {
          if (mEmergencyTonePlayerVibrator != null) {
            mEmergencyTonePlayerVibrator.stop();
          }
        }
      }
      final boolean shouldNotlogEmergencyNumber=(mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA);
      final boolean isOtaNumber=(mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) && mPhone.isOtaSpNumber(number);
      final boolean isEmergencyNumber=PhoneNumberUtils.isEmergencyNumber(number);
      if (!(isOtaNumber || isEmergencyNumber && shouldNotlogEmergencyNumber)) {
        Thread t=new Thread(){
          public void run(){
            Calls.addCall(ci,mApplication,logNumber,presentation,callLogType,date,(int)duration / 1000);
          }
        }
;
        t.start();
      }
    }
    if (callLogType == CallLog.Calls.MISSED_TYPE) {
      showMissedCallNotification(c,date);
    }
    if (toneToPlay != InCallTonePlayer.TONE_NONE) {
      if (VDBG)       log("String_Node_Str" + toneToPlay + "String_Node_Str");
      new InCallTonePlayer(toneToPlay).start();
    }
    if (mPhone.getState() == Phone.State.IDLE) {
      if (!mApplication.isShowingCallScreen()) {
        if (VDBG)         log("String_Node_Str");
        mApplication.setScreenTimeout(PhoneApp.ScreenTimeoutDuration.DEFAULT);
        mApplication.requestWakeState(PhoneApp.WakeState.SLEEP);
      }
 else {
        if (VDBG)         log("String_Node_Str");
      }
    }
 else {
      if (VDBG)       log("String_Node_Str");
    }
    if (((mPreviousCdmaCallState == Call.State.DIALING) || (mPreviousCdmaCallState == Call.State.ALERTING)) && (!PhoneNumberUtils.isEmergencyNumber(number)) && (cause != Connection.DisconnectCause.INCOMING_MISSED)&& (cause != Connection.DisconnectCause.NORMAL)&& (cause != Connection.DisconnectCause.LOCAL)&& (cause != Connection.DisconnectCause.INCOMING_REJECTED)) {
      if (!mIsCdmaRedialCall) {
        if (autoretrySetting == InCallScreen.AUTO_RETRY_ON) {
          PhoneUtils.placeCall(mPhone,number,null);
          mIsCdmaRedialCall=true;
        }
 else {
          mIsCdmaRedialCall=false;
        }
      }
 else {
        mIsCdmaRedialCall=false;
      }
    }
  }
}