Program: 184733
Project: 184733
Buggy source:
private void onPhoneStateChanged(AsyncResult r){
  Phone.State state=mPhone.getState();
  if (VDBG)   log("String_Node_Str" + state);
  NotificationMgr.getDefault().getStatusBarMgr().enableNotificationAlerts(state == Phone.State.IDLE);
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
    if ((mPhone.getForegroundCall().getState() == Call.State.ACTIVE) && ((mPreviousCdmaCallState == Call.State.DIALING) || (mPreviousCdmaCallState == Call.State.ALERTING))) {
      if (mIsCdmaRedialCall) {
        int toneToPlay=InCallTonePlayer.TONE_REDIAL;
        new InCallTonePlayer(toneToPlay).start();
      }
      stopSignalInfoTone();
    }
    mPreviousCdmaCallState=mPhone.getForegroundCall().getState();
  }
  mApplication.updateBluetoothIndication(false);
  mApplication.updatePhoneState(state);
  if (state == Phone.State.OFFHOOK) {
    PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_OFFHOOK);
    if (VDBG)     log("String_Node_Str");
    if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
      AudioManager audioManager=(AudioManager)mPhone.getContext().getSystemService(Context.AUDIO_SERVICE);
      if (audioManager.getMode() != AudioManager.MODE_IN_CALL) {
        PhoneUtils.setAudioMode(mPhone.getContext(),AudioManager.MODE_IN_CALL);
      }
    }
    if (!mApplication.isShowingCallScreen()) {
      mApplication.setScreenTimeout(PhoneApp.ScreenTimeoutDuration.DEFAULT);
      mApplication.requestWakeState(PhoneApp.WakeState.SLEEP);
    }
    if (DBG)     log("String_Node_Str");
    mRinger.stopRing();
    NotificationMgr.getDefault().updateInCallNotification();
  }
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
    Connection c=mPhone.getForegroundCall().getLatestConnection();
    if ((c != null) && (PhoneNumberUtils.isEmergencyNumber(c.getAddress()))) {
      if (VDBG)       log("String_Node_Str");
      Call.State callState=mPhone.getForegroundCall().getState();
      if (mEmergencyTonePlayerVibrator == null) {
        mEmergencyTonePlayerVibrator=new EmergencyTonePlayerVibrator();
      }
      if (callState == Call.State.DIALING || callState == Call.State.ALERTING) {
        mIsEmergencyToneOn=Settings.System.getInt(mPhone.getContext().getContentResolver(),Settings.System.EMERGENCY_TONE,EMERGENCY_TONE_OFF);
        if (mIsEmergencyToneOn != EMERGENCY_TONE_OFF && mCurrentEmergencyToneState == EMERGENCY_TONE_OFF) {
          if (mEmergencyTonePlayerVibrator != null) {
            mEmergencyTonePlayerVibrator.start();
          }
        }
      }
 else       if (callState == Call.State.ACTIVE) {
        if (mCurrentEmergencyToneState != EMERGENCY_TONE_OFF) {
          if (mEmergencyTonePlayerVibrator != null) {
            mEmergencyTonePlayerVibrator.stop();
          }
        }
      }
    }
  }
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_GSM) {
    Call.State callState=mPhone.getForegroundCall().getState();
    if (!callState.isDialing()) {
      if (mInCallRingbackTonePlayer != null && mCurrentRingbackToneState == RINGBACK_TONE_ON) {
        mInCallRingbackTonePlayer.stop();
      }
    }
  }
}

Fixed version (ground truth):
private void onPhoneStateChanged(AsyncResult r){
  Phone.State state=mPhone.getState();
  if (VDBG)   log("String_Node_Str" + state);
  NotificationMgr.getDefault().getStatusBarMgr().enableNotificationAlerts(state == Phone.State.IDLE);
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
    if ((mPhone.getForegroundCall().getState() == Call.State.ACTIVE) && ((mPreviousCdmaCallState == Call.State.DIALING) || (mPreviousCdmaCallState == Call.State.ALERTING))) {
      if (mIsCdmaRedialCall) {
        int toneToPlay=InCallTonePlayer.TONE_REDIAL;
        new InCallTonePlayer(toneToPlay).start();
      }
      stopSignalInfoTone();
    }
    mPreviousCdmaCallState=mPhone.getForegroundCall().getState();
  }
  mApplication.updateBluetoothIndication(false);
  mApplication.updatePhoneState(state);
  if (state == Phone.State.OFFHOOK) {
    if (mCallWaitingTonePlayer != null) {
      mCallWaitingTonePlayer.stopTone();
      mCallWaitingTonePlayer=null;
    }
    PhoneUtils.setAudioControlState(PhoneUtils.AUDIO_OFFHOOK);
    if (VDBG)     log("String_Node_Str");
    if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
      if (mAudioManager.getMode() != AudioManager.MODE_IN_CALL) {
        PhoneUtils.setAudioMode(mPhone.getContext(),AudioManager.MODE_IN_CALL);
      }
    }
    if (!mApplication.isShowingCallScreen()) {
      mApplication.setScreenTimeout(PhoneApp.ScreenTimeoutDuration.DEFAULT);
      mApplication.requestWakeState(PhoneApp.WakeState.SLEEP);
    }
    if (DBG)     log("String_Node_Str");
    mRinger.stopRing();
    NotificationMgr.getDefault().updateInCallNotification();
  }
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_CDMA) {
    Connection c=mPhone.getForegroundCall().getLatestConnection();
    if ((c != null) && (PhoneNumberUtils.isEmergencyNumber(c.getAddress()))) {
      if (VDBG)       log("String_Node_Str");
      Call.State callState=mPhone.getForegroundCall().getState();
      if (mEmergencyTonePlayerVibrator == null) {
        mEmergencyTonePlayerVibrator=new EmergencyTonePlayerVibrator();
      }
      if (callState == Call.State.DIALING || callState == Call.State.ALERTING) {
        mIsEmergencyToneOn=Settings.System.getInt(mPhone.getContext().getContentResolver(),Settings.System.EMERGENCY_TONE,EMERGENCY_TONE_OFF);
        if (mIsEmergencyToneOn != EMERGENCY_TONE_OFF && mCurrentEmergencyToneState == EMERGENCY_TONE_OFF) {
          if (mEmergencyTonePlayerVibrator != null) {
            mEmergencyTonePlayerVibrator.start();
          }
        }
      }
 else       if (callState == Call.State.ACTIVE) {
        if (mCurrentEmergencyToneState != EMERGENCY_TONE_OFF) {
          if (mEmergencyTonePlayerVibrator != null) {
            mEmergencyTonePlayerVibrator.stop();
          }
        }
      }
    }
  }
  if (mPhone.getPhoneType() == Phone.PHONE_TYPE_GSM) {
    Call.State callState=mPhone.getForegroundCall().getState();
    if (!callState.isDialing()) {
      if (mInCallRingbackTonePlayer != null) {
        mInCallRingbackTonePlayer.stopTone();
        mInCallRingbackTonePlayer=null;
      }
    }
  }
}