nus-yam/ex-repair huggingface dataset:
Program: 36899
Project: 36899
Buggy source:
@Override protected void onResume(){
  super.onResume();
  if (mIncomingCallIsRinging && mPausedRinging) {
    mMediaManager.startIncomingCallRinger();
  }
  mPausedRinging=false;
  mRemoteLogger.d("String_Node_Str");
  if (!mSipServiceBound && mSipService == null) {
    mRemoteLogger.e("String_Node_Str");
    bindService(new Intent(this,SipService.class),mSipServiceConnection,Context.BIND_AUTO_CREATE);
  }
  if (!mOnTransfer && mSipService != null && mSipService.getCurrentCall() != null) {
    if (mSipService.getCurrentCall().isOnHold()) {
      mRemoteLogger.d("String_Node_Str");
      if (!mOnHold) {
        mRemoteLogger.i("String_Node_Str");
        mOnHold=true;
        updateCallButton(R.id.button_onhold,true);
        onCallStatusUpdate(CALL_PUT_ON_HOLD_ACTION);
      }
 else       if (!findViewById(R.id.button_onhold).isActivated()) {
        mRemoteLogger.i("String_Node_Str");
        updateCallButton(R.id.button_onhold,true);
      }
    }
  }
  new Handler().postDelayed(new Runnable(){
    @Override public void run(){
      if (!mSipServiceBound) {
        finishWithDelay();
      }
 else       if (mSipService.getCurrentCall() == null) {
        mRemoteLogger.d("String_Node_Str");
        onCallStatusUpdate(CALL_DISCONNECTED_MESSAGE);
      }
    }
  }
,500);
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  if (mIncomingCallIsRinging && mPausedRinging) {
    mMediaManager.startIncomingCallRinger();
  }
  mPausedRinging=false;
  mRemoteLogger.d("String_Node_Str");
  if (!mSipServiceBound && mSipService == null) {
    mRemoteLogger.i("String_Node_Str");
    bindService(new Intent(this,SipService.class),mSipServiceConnection,Context.BIND_AUTO_CREATE);
  }
  if (!mOnTransfer && mSipService != null && mSipService.getCurrentCall() != null) {
    if (mSipService.getCurrentCall().isOnHold()) {
      mRemoteLogger.d("String_Node_Str");
      if (!mOnHold) {
        mRemoteLogger.i("String_Node_Str");
        mOnHold=true;
        updateCallButton(R.id.button_onhold,true);
        onCallStatusUpdate(CALL_PUT_ON_HOLD_ACTION);
      }
 else       if (!findViewById(R.id.button_onhold).isActivated()) {
        mRemoteLogger.i("String_Node_Str");
        updateCallButton(R.id.button_onhold,true);
      }
    }
  }
  new Handler().postDelayed(new Runnable(){
    @Override public void run(){
      if (!mSipServiceBound) {
        finishWithDelay();
      }
 else       if (mSipService.getCurrentCall() == null) {
        mRemoteLogger.d("String_Node_Str");
        onCallStatusUpdate(CALL_DISCONNECTED_MESSAGE);
      }
    }
  }
,500);
}
Program: 36900
Project: 36900
Buggy source:
@Override protected void onPause(){
  super.onPause();
  unregisterReceivers();
}

Fixed version (ground truth):
@Override protected void onPause(){
  super.onPause();
  mReachabilityReceiver.stopListening();
}
Program: 36901
Project: 36901
Buggy source:
@Override protected void onResume(){
  askForPermissions(requestCounter);
  registerReceivers();
  super.onResume();
}

Fixed version (ground truth):
@Override protected void onResume(){
  askForPermissions(requestCounter);
  mReachabilityReceiver.startListening();
  super.onResume();
}
Program: 36902
Project: 36902
Buggy source:
private void askForPermissions(int requestNr){
switch (requestNr) {
case 0:
    int storagePermissionState=ReadExternalStoragePermission.getPermissionStatus(this,ReadExternalStoragePermission.mPermissionToCheck);
  if (storagePermissionState != ReadExternalStoragePermission.BLOCKED || ReadExternalStoragePermission.firstRequest) {
    if (!ReadExternalStoragePermission.hasPermission(this)) {
      ReadExternalStoragePermission.askForPermission(this);
      requestCounter++;
      return;
    }
  }
case 1:
if (!PhonePermission.hasPermission(this)) {
  PhonePermission.askForPermission(this);
  requestCounter++;
  return;
}
case 2:
if (!ContactsPermission.hasPermission(this)) {
if (mAskForPermission) {
  mAskForPermission=false;
  ContactsPermission.askForPermission(this);
  requestCounter++;
  return;
}
}
}
}

Fixed version (ground truth):
private void askForPermissions(int requestNr){
switch (requestNr) {
case 0:
    int storagePermissionState=ReadExternalStoragePermission.getPermissionStatus(this,ReadExternalStoragePermission.mPermissionToCheck);
  if (storagePermissionState != ReadExternalStoragePermission.BLOCKED || ReadExternalStoragePermission.firstRequest) {
    if (!ReadExternalStoragePermission.hasPermission(this)) {
      ReadExternalStoragePermission.askForPermission(this);
      requestCounter++;
      return;
    }
  }
case 1:
if (!PhonePermission.hasPermission(this)) {
  PhonePermission.askForPermission(this);
  requestCounter++;
  return;
}
case 2:
if (!ContactsPermission.hasPermission(this)) {
if (mAskForPermission) {
  mAskForPermission=false;
  ContactsPermission.askForPermission(this);
  requestCounter++;
}
}
}
}
Program: 36903
Project: 36903
Buggy source:
/** 
 * Use the deprecated version of the onAttach method for api levels < 23 The old android 4.1.2 API level 16 calls this method. If don't use this function no callback will be set.
 * @param activity Activity the attached activity/
 */
@Override public void onAttach(Activity activity){
  super.onAttach(activity);
  try {
    mCallback=(CallKeyPadFragmentListener)activity;
  }
 catch (  ClassCastException e) {
    throw new ClassCastException(activity.toString() + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Use the deprecated version of the onAttach method for api levels < 23 The old android 4.1.2 API level 16 calls this method. If don't use this function no callback will be set.
 * @param activity Activity the attached activity.
 */
@Override public void onAttach(Activity activity){
  super.onAttach(activity);
  try {
    mCallback=(CallKeyPadFragmentListener)activity;
  }
 catch (  ClassCastException e) {
    throw new ClassCastException(activity.toString() + "String_Node_Str");
  }
}
Program: 36904
Project: 36904
Buggy source:
@Override public void onAttach(Context context){
  super.onAttach(context);
  try {
    mCallback=(CallTransferFragmentListener)context;
  }
 catch (  ClassCastException e) {
    throw new ClassCastException(context.toString() + "String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * Use the deprecated version of the onAttach method for api levels < 23 The old android 4.1.2 API level 16 calls this method. If don't use this function no callback will be set.
 * @param activity Activity the attached activity/
 */
@Override public void onAttach(Activity activity){
  super.onAttach(activity);
  try {
    mCallback=(CallTransferFragmentListener)activity;
  }
 catch (  ClassCastException e) {
    throw new ClassCastException(activity.toString() + "String_Node_Str");
  }
}
Program: 36905
Project: 36905
Buggy source:
@Override public void onAttach(Context context){
  super.onAttach(context);
  if (context instanceof Activity) {
    Activity activity=(Activity)context;
    try {
      mListener=(OnFragmentInteractionListener)activity;
    }
 catch (    ClassCastException e) {
      throw new ClassCastException(activity.toString() + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
@Override public void onAttach(Activity activity){
  super.onAttach(activity);
  try {
    mListener=(OnFragmentInteractionListener)activity;
  }
 catch (  ClassCastException e) {
    throw new ClassCastException(activity.toString() + "String_Node_Str");
  }
}
Program: 36907
Project: 36907
Buggy source:
private void unregisterForWiredHeadsetIntentBroadcast(){
  mRemoteLogger.v("String_Node_Str");
  mContext.unregisterReceiver(mWiredHeadsetReceiver);
  mWiredHeadsetReceiver=null;
}

Fixed version (ground truth):
private void unregisterForWiredHeadsetIntentBroadcast(){
  mRemoteLogger.v("String_Node_Str");
  try {
    mContext.unregisterReceiver(mWiredHeadsetReceiver);
  }
 catch (  IllegalArgumentException e) {
    mRemoteLogger.w("String_Node_Str");
  }
  mWiredHeadsetReceiver=null;
}
Program: 36908
Project: 36908
Buggy source:
private void unregisterForBluetoothScoIntentBroadcast(){
  mRemoteLogger.v("String_Node_Str");
  mContext.unregisterReceiver(mBluetoothScoReceiver);
  mBluetoothScoReceiver=null;
}

Fixed version (ground truth):
private void unregisterForBluetoothScoIntentBroadcast(){
  mRemoteLogger.v("String_Node_Str");
  try {
    mContext.unregisterReceiver(mBluetoothScoReceiver);
  }
 catch (  IllegalArgumentException e) {
    mRemoteLogger.w("String_Node_Str");
  }
  mBluetoothScoReceiver=null;
}
Program: 36909
Project: 36909
Buggy source:
private void unregisterForBluetoothHeadsetIntentBroadcast(){
  mRemoteLogger.v("String_Node_Str");
  mContext.unregisterReceiver(mBluetoothHeadsetReceiver);
  mBluetoothHeadsetReceiver=null;
}

Fixed version (ground truth):
private void unregisterForBluetoothHeadsetIntentBroadcast(){
  mRemoteLogger.v("String_Node_Str");
  try {
    mContext.unregisterReceiver(mBluetoothHeadsetReceiver);
  }
 catch (  IllegalArgumentException e) {
    mRemoteLogger.w("String_Node_Str");
  }
  mBluetoothHeadsetReceiver=null;
}
Program: 36910
Project: 36910
Buggy source:
/** 
 * Function for the call activity when a call has been answered
 */
public void callAnswered(){
  mRemoteLogger.v("String_Node_Str");
  mAudioRouter.onAnsweredCall();
  BluetoothMediaButtonReceiver.setCallAnswered();
}

Fixed version (ground truth):
/** 
 * Function for the call activity when a call has been answered
 */
public void callAnswered(){
  mRemoteLogger.v("String_Node_Str");
  if (mAudioRouter == null) {
    mAudioRouter=new AudioRouter(mContext,this,mAudioManager);
    mAudioRouter.onAnsweredCall();
  }
 else {
    mAudioRouter.onAnsweredCall();
  }
  BluetoothMediaButtonReceiver.setCallAnswered();
}
Program: 36911
Project: 36911
Buggy source:
public ReachabilityReceiver(Context context){
  mContext=context;
}

Fixed version (ground truth):
public ReachabilityReceiver(Context context){
  mContext=context;
  mRemoteLogger=new RemoteLogger(context,ReachabilityReceiver.class,1);
}
Program: 36912
Project: 36912
Buggy source:
public void stopListening(){
  mContext.unregisterReceiver(this);
}

Fixed version (ground truth):
public void stopListening(){
  try {
    mContext.unregisterReceiver(this);
  }
 catch (  IllegalArgumentException e) {
    mRemoteLogger.w("String_Node_Str");
  }
}
Program: 36913
Project: 36913
Buggy source:
private void stopNetworkingListener(){
  mSipService.unregisterReceiver(mNetworkStateReceiver);
}

Fixed version (ground truth):
private void stopNetworkingListener(){
  try {
    mSipService.unregisterReceiver(mNetworkStateReceiver);
  }
 catch (  IllegalArgumentException e) {
    mRemoteLogger.w("String_Node_Str");
  }
}
Program: 36914
Project: 36914
Buggy source:
/** 
 * This will calculate the current MOS value of the call. Credits to: https://www.pingman.com/kb/article/how-is-mos-calculated-in-pingplotter-pro-50.html
 */
private float getR(){
  float r=0;
  try {
    StreamStat mStreamStat=this.getStreamStat(0);
    RtcpStat rtcpStat=mStreamStat.getRtcp();
    RtcpStreamStat rtcpStreamStat=rtcpStat.getRxStat();
    float rxJitter=(float)rtcpStreamStat.getJitterUsec().getMean() / 1000;
    float averageRoundTripTime=(float)rtcpStat.getRttUsec().getMean() / 1000;
    if (averageRoundTripTime == 0) {
      averageRoundTripTime=20;
    }
    float effectiveLatency=averageRoundTripTime + rxJitter * 2 + 10;
    if (effectiveLatency < 160) {
      r=93.2f - (effectiveLatency / 40);
    }
 else {
      r=93.2f - (effectiveLatency - 120) / 10;
    }
    float rxPackets=rtcpStreamStat.getPkt();
    float rxLoss=rtcpStreamStat.getLoss();
    float rxPacketLoss;
    if (rxPackets == 0) {
      rxPacketLoss=100f;
    }
 else {
      rxPacketLoss=(rxLoss / (rxPackets + rxLoss)) * 100f;
    }
    r=r - (rxPacketLoss * 2.5f);
    Log.e(TAG,"String_Node_Str");
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return r;
}

Fixed version (ground truth):
/** 
 * This will calculate the current MOS value of the call. Credits to: https://www.pingman.com/kb/article/how-is-mos-calculated-in-pingplotter-pro-50.html
 */
private float getR(){
  float r=0;
  try {
    StreamStat mStreamStat=this.getStreamStat(0);
    RtcpStat rtcpStat=mStreamStat.getRtcp();
    RtcpStreamStat rtcpStreamStat=rtcpStat.getRxStat();
    float rxJitter=(float)rtcpStreamStat.getJitterUsec().getMean() / 1000;
    float averageRoundTripTime=(float)rtcpStat.getRttUsec().getMean() / 1000;
    if (averageRoundTripTime == 0) {
      averageRoundTripTime=20;
    }
    float effectiveLatency=averageRoundTripTime + rxJitter * 2 + 10;
    if (effectiveLatency < 160) {
      r=93.2f - (effectiveLatency / 40);
    }
 else {
      r=93.2f - (effectiveLatency - 120) / 10;
    }
    float rxPackets=rtcpStreamStat.getPkt();
    float rxLoss=rtcpStreamStat.getLoss();
    float rxPacketLoss;
    if (rxPackets == 0) {
      rxPacketLoss=100f;
    }
 else {
      rxPacketLoss=(rxLoss / (rxPackets + rxLoss)) * 100f;
    }
    r=r - (rxPacketLoss * 2.5f);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  return r;
}
Program: 36915
Project: 36915
Buggy source:
private void stopNetworkingListener(){
  mSipService.unregisterReceiver(mNetworkStateReceiver);
}

Fixed version (ground truth):
private void stopNetworkingListener(){
  try {
    mSipService.unregisterReceiver(mNetworkStateReceiver);
  }
 catch (  IllegalArgumentException e) {
    mRemoteLogger.w("String_Node_Str");
  }
}
Program: 36916
Project: 36916
Buggy source:
/** 
 * Add text to the number input field
 * @param text
 */
public void add(CharSequence text){
  Editable inputText=mEditText.getText();
  Integer startCursorPosition=mEditText.getSelectionStart();
  Integer endCursorPosition=mEditText.getSelectionEnd();
  removeTextFromInput(startCursorPosition,endCursorPosition);
  inputText.insert(startCursorPosition,text);
}

Fixed version (ground truth):
/** 
 * Add text to the number input field
 * @param text
 */
public void add(CharSequence text){
  Editable inputText=mNumberInputEditText.getText();
  Integer startCursorPosition=mNumberInputEditText.getSelectionStart();
  Integer endCursorPosition=mNumberInputEditText.getSelectionEnd();
  removeTextFromInput(startCursorPosition,endCursorPosition);
  inputText.insert(startCursorPosition,text);
}
Program: 36917
Project: 36917
Buggy source:
private void init(){
  LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  inflater.inflate(R.layout.view_number_input,this);
  mEditText=(EditText)findViewById(R.id.edit_text);
  mEditText.addTextChangedListener(this);
  mEditText.setOnClickListener(this);
  mEditText.setOnLongClickListener(this);
  mRemoveButton=(ImageButton)findViewById(R.id.remove_button);
  mRemoveButton.setOnClickListener(this);
  mRemoveButton.setOnLongClickListener(this);
  mEditText.setTextSize(TypedValue.COMPLEX_UNIT_SP,getResources().getDimension(R.dimen.dialpad_number_input_text_size));
  mDefaultTextsize=mEditText.getTextSize();
}

Fixed version (ground truth):
private void init(){
  LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  inflater.inflate(R.layout.view_number_input,this);
  mNumberInputEditText=(EditText)findViewById(R.id.edit_text);
  mNumberInputEditText.addTextChangedListener(this);
  mNumberInputEditText.setOnClickListener(this);
  mNumberInputEditText.setOnLongClickListener(this);
  mRemoveButton=(ImageButton)findViewById(R.id.remove_button);
  mRemoveButton.setOnClickListener(this);
  mRemoveButton.setOnLongClickListener(this);
  mNumberInputEditText.setTextSize(TypedValue.COMPLEX_UNIT_SP,getResources().getDimension(R.dimen.dialpad_number_input_text_size));
}
Program: 36918
Project: 36918
Buggy source:
@Override public void onClick(View view){
switch (view.getId()) {
case R.id.remove_button:
    remove();
  break;
case R.id.edit_text:
if (!isEmpty()) {
  mEditText.setCursorVisible(true);
}
break;
}
}

Fixed version (ground truth):
@Override public void onClick(View view){
switch (view.getId()) {
case R.id.remove_button:
    remove();
  break;
case R.id.edit_text:
if (!isEmpty()) {
  mNumberInputEditText.setCursorVisible(true);
}
break;
}
}
Program: 36919
Project: 36919
Buggy source:
public void setCorrectFontSize(){
  int charCount=mEditText.getText().length();
  float charSize=mDefaultTextsize;
  if (charCount > mNormalPhoneNumberLengthMax) {
    for (int i=charCount; i > mNormalPhoneNumberLengthMax; i--) {
      charSize=charSize / 1.03f;
    }
  }
  mEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX,charSize);
}

Fixed version (ground truth):
public void setCorrectFontSize(){
  int charCount=mNumberInputEditText.getText().length();
  float charSize=getTextSize();
  int inputMaxScalingLength=getResources().getInteger(R.integer.dialpad_number_input_max_scaling_length);
  int maxLengthNormalPhoneNumber=getResources().getInteger(R.integer.dialpad_normal_phonenumber_length_max);
  if (charCount > maxLengthNormalPhoneNumber && charCount < inputMaxScalingLength) {
    charSize=charSize / 1.04f;
  }
  mNumberInputEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP,charSize);
}
Program: 36920
Project: 36920
Buggy source:
/** 
 * Clear the number input field
 */
public void clear(){
  mEditText.setCursorVisible(false);
  mEditText.getText().clear();
}

Fixed version (ground truth):
/** 
 * Clear the number input field
 */
public void clear(){
  mNumberInputEditText.setCursorVisible(false);
  mNumberInputEditText.getText().clear();
}
Program: 36921
Project: 36921
Buggy source:
public boolean isEmpty(){
  return mEditText.length() == 0;
}

Fixed version (ground truth):
public boolean isEmpty(){
  return mNumberInputEditText.length() == 0;
}
Program: 36922
Project: 36922
Buggy source:
/** 
 * Remove character from input field
 */
public void remove(){
  if (mEditText.length() > 0) {
    mRemoveButton.animate();
    Integer startCursorPosition=mEditText.getSelectionStart();
    Integer endCursorPosition=mEditText.getSelectionEnd();
    if (startCursorPosition == 0 && endCursorPosition == 0) {
      return;
    }
    if ((endCursorPosition - startCursorPosition) > 0) {
      removeTextFromInput(startCursorPosition,endCursorPosition);
    }
 else {
      removeTextFromInput(startCursorPosition - 1,endCursorPosition);
    }
  }
  setCorrectFontSize();
}

Fixed version (ground truth):
/** 
 * Remove character from input field
 */
public void remove(){
  if (mNumberInputEditText.length() > 0) {
    mRemoveButton.animate();
    Integer startCursorPosition=mNumberInputEditText.getSelectionStart();
    Integer endCursorPosition=mNumberInputEditText.getSelectionEnd();
    if (startCursorPosition == 0 && endCursorPosition == 0) {
      return;
    }
    if ((endCursorPosition - startCursorPosition) > 0) {
      removeTextFromInput(startCursorPosition,endCursorPosition);
    }
 else {
      removeTextFromInput(startCursorPosition - 1,endCursorPosition);
    }
  }
  setCorrectFontSize();
}
Program: 36923
Project: 36923
Buggy source:
public void setNumber(String number){
  mEditText.setText(number);
  mEditText.setSelection(number.length());
}

Fixed version (ground truth):
public void setNumber(String number){
  mNumberInputEditText.setText(number);
  mNumberInputEditText.setSelection(number.length());
}
Program: 36924
Project: 36924
Buggy source:
/** 
 * Return the number input as String
 * @return
 */
public String getNumber(){
  return mEditText.getText().toString();
}

Fixed version (ground truth):
/** 
 * Return the number input as String
 * @return String representation of the number
 */
public String getNumber(){
  return mNumberInputEditText.getText().toString();
}
Program: 36925
Project: 36925
Buggy source:
@Override public boolean onLongClick(View view){
switch (view.getId()) {
case R.id.remove_button:
    clear();
  return true;
case R.id.edit_text:
mEditText.setCursorVisible(true);
return false;
}
return false;
}

Fixed version (ground truth):
@Override public boolean onLongClick(View view){
switch (view.getId()) {
case R.id.remove_button:
    clear();
  return true;
case R.id.edit_text:
mNumberInputEditText.setCursorVisible(true);
return false;
}
return false;
}
Program: 36926
Project: 36926
Buggy source:
private void removeTextFromInput(Integer startCursorPosition,Integer endCursorPosition){
  if ((endCursorPosition - startCursorPosition) > 0) {
    mEditText.getText().delete(startCursorPosition,endCursorPosition);
  }
  if (startCursorPosition == mEditText.length()) {
    mEditText.setCursorVisible(false);
  }
 else {
    mEditText.setCursorVisible(true);
  }
}

Fixed version (ground truth):
private void removeTextFromInput(Integer startCursorPosition,Integer endCursorPosition){
  if ((endCursorPosition - startCursorPosition) > 0) {
    mNumberInputEditText.getText().delete(startCursorPosition,endCursorPosition);
  }
  if (startCursorPosition == mNumberInputEditText.length()) {
    mNumberInputEditText.setCursorVisible(false);
  }
 else {
    mNumberInputEditText.setCursorVisible(true);
  }
}
Program: 36927
Project: 36927
Buggy source:
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
  if (mPreferences.hasSipEnabled() == isChecked) {
    return;
  }
  mPreferences.setSipEnabled(isChecked);
  if (!isChecked) {
    MiddlewareHelper.executeUnregisterTask(this);
    mSipIdEditText.setVisibility(View.GONE);
  }
 else {
    enableProgressBar(true);
    new AsyncTask<Void,Void,PhoneAccount>(){
      @Override protected PhoneAccount doInBackground(      Void... params){
        return mPhoneAccountHelper.getLinkedPhoneAccount();
      }
      @Override protected void onPostExecute(      PhoneAccount phoneAccount){
        super.onPostExecute(phoneAccount);
        if (phoneAccount != null) {
          mPhoneAccountHelper.savePhoneAccountAndRegister(phoneAccount);
          updateAndPopulate();
        }
 else {
          setVoipAccount();
        }
      }
    }
.execute();
  }
}

Fixed version (ground truth):
@Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked){
  if (mPreferences.hasSipEnabled() == isChecked) {
    return;
  }
  mPreferences.setSipEnabled(isChecked);
  if (!isChecked) {
    MiddlewareHelper.executeUnregisterTask(this);
    stopService(new Intent(this,SipService.class));
    mSipIdEditText.setVisibility(View.GONE);
  }
 else {
    enableProgressBar(true);
    new AsyncTask<Void,Void,PhoneAccount>(){
      @Override protected PhoneAccount doInBackground(      Void... params){
        return mPhoneAccountHelper.getLinkedPhoneAccount();
      }
      @Override protected void onPostExecute(      PhoneAccount phoneAccount){
        super.onPostExecute(phoneAccount);
        if (phoneAccount != null) {
          mPhoneAccountHelper.savePhoneAccountAndRegister(phoneAccount);
          updateAndPopulate();
        }
 else {
          setVoipAccount();
        }
      }
    }
.execute();
  }
}
Program: 36928
Project: 36928
Buggy source:
@Override public void run(){
  mToneGenerator.startTone(ToneGenerator.TONE_SUP_DIAL,1000);
  mHandler.postDelayed(mRingbackRunnable,4000);
}

Fixed version (ground truth):
@Override public void run(){
  checkServiceBeingUsed();
}
Program: 36929
Project: 36929
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  mHandler=new Handler();
  mToneGenerator=new ToneGenerator(AudioManager.STREAM_VOICE_CALL,SipConstants.RINGING_VOLUME);
  mSipBroadcaster=new SipBroadcaster(this);
  mPreferences=new Preferences(this);
  mRemoteLogger=new RemoteLogger(this);
  mRemoteLogger.d(TAG + "String_Node_Str");
  IntentFilter filter=new IntentFilter();
  filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
  registerReceiver(phoneStateReceiver,filter);
  PhoneAccount phoneAccount=new JsonStorage<PhoneAccount>(this).get(PhoneAccount.class);
  if (phoneAccount != null) {
    mSipConfig=new SipConfig(this,phoneAccount);
    try {
      mSipConfig.initLibrary();
    }
 catch (    SipConfig.LibraryInitFailedException e) {
      stopSelf();
    }
  }
 else {
    mRemoteLogger.w("String_Node_Str");
    stopSelf();
  }
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  mHandler=new Handler();
  mToneGenerator=new ToneGenerator(AudioManager.STREAM_VOICE_CALL,SipConstants.RINGING_VOLUME);
  mSipBroadcaster=new SipBroadcaster(this);
  mPreferences=new Preferences(this);
  mRemoteLogger=new RemoteLogger(this);
  mRemoteLogger.d(TAG + "String_Node_Str");
  IntentFilter filter=new IntentFilter();
  filter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
  registerReceiver(phoneStateReceiver,filter);
  PhoneAccount phoneAccount=new JsonStorage<PhoneAccount>(this).get(PhoneAccount.class);
  if (phoneAccount != null) {
    mSipConfig=new SipConfig(this,phoneAccount);
    try {
      mSipConfig.initLibrary();
    }
 catch (    SipConfig.LibraryInitFailedException e) {
      stopSelf();
    }
  }
 else {
    mRemoteLogger.w("String_Node_Str");
    stopSelf();
  }
  new Handler().postDelayed(new Runnable(){
    @Override public void run(){
      checkServiceBeingUsed();
    }
  }
,5000);
}
Program: 36930
Project: 36930
Buggy source:
@Override public void onServiceConnected(ComponentName className,IBinder service){
  SipService.SipServiceBinder binder=(SipService.SipServiceBinder)service;
  mSipService=binder.getService();
  mServiceBound=true;
  if (mSipService.getFirstCall() != null) {
    mCurrentCallId=mSipService.getFirstCall().getIdentifier();
  }
  if (mIsIncomingCall) {
    new Handler().postDelayed(new Runnable(){
      @Override public void run(){
        mSipService.getFirstCall().setCallerId(mCallerIdToDisplay);
        mSipService.getFirstCall().setPhoneNumber(mPhoneNumberToDisplay);
      }
    }
,1000);
  }
}

Fixed version (ground truth):
@Override public void onServiceConnected(ComponentName className,IBinder service){
  SipService.SipServiceBinder binder=(SipService.SipServiceBinder)service;
  mSipService=binder.getService();
  mServiceBound=true;
  if (mSipService.getFirstCall() != null) {
    mCurrentCallId=mSipService.getFirstCall().getIdentifier();
  }
  if (mIsIncomingCall) {
    new Handler().postDelayed(new Runnable(){
      @Override public void run(){
        SipCall firstCall=mSipService.getFirstCall();
        if (firstCall != null) {
          firstCall.setCallerId(mCallerIdToDisplay);
          firstCall.setPhoneNumber(mPhoneNumberToDisplay);
        }
      }
    }
,1000);
  }
}
Program: 36931
Project: 36931
Buggy source:
public void stopSensor(){
  if (mProximitySensor != null) {
    mSensorManager.unregisterListener(this);
  }
  if (mWakeLock.isHeld()) {
    mWakeLock.release();
  }
}

Fixed version (ground truth):
public void stopSensor(){
  if (mProximitySensor != null) {
    mSensorManager.unregisterListener(this);
  }
  if (mWakeLock != null) {
    if (mWakeLock.isHeld()) {
      mWakeLock.release();
    }
  }
}
Program: 36932
Project: 36932
Buggy source:
@Override public void onResponse(Call call,Response response){
  if (response.body() instanceof SystemUser) {
    SystemUser systemUser=((SystemUser)response.body());
    mJsonStorage.save(systemUser);
    mSystemUser=systemUser;
    String phoneAccountId=mSystemUser.getPhoneAccountId();
    if (phoneAccountId != null) {
      Call<PhoneAccount> apicall=mApi.phoneAccount(phoneAccountId);
      apicall.enqueue(this);
    }
 else {
      mJsonStorage.remove(PhoneAccount.class);
    }
  }
 else   if (response.body() instanceof PhoneAccount) {
    mJsonStorage.save(response.body());
    mListener.onFinish(this);
  }
}

Fixed version (ground truth):
@Override public void onResponse(Call call,Response response){
  if (response.body() instanceof SystemUser) {
    SystemUser systemUser=((SystemUser)response.body());
    SystemUser currentSystemuser=mSystemUser;
    currentSystemuser.setOutgoingCli(systemUser.getOutgoingCli());
    currentSystemuser.setMobileNumber(systemUser.getMobileNumber());
    currentSystemuser.setClient(systemUser.getClient());
    currentSystemuser.setAppAccountUri(systemUser.getAppAccountUri());
    mJsonStorage.save(currentSystemuser);
    mSystemUser=currentSystemuser;
    String phoneAccountId=mSystemUser.getPhoneAccountId();
    if (phoneAccountId != null) {
      Call<PhoneAccount> apicall=mApi.phoneAccount(phoneAccountId);
      apicall.enqueue(this);
    }
 else {
      mJsonStorage.remove(PhoneAccount.class);
    }
  }
 else   if (response.body() instanceof PhoneAccount) {
    mJsonStorage.save(response.body());
    mListener.onFinish(this);
  }
}
Program: 36933
Project: 36933
Buggy source:
/** 
 * Function to update the systemuser information.
 */
private void updateSystemUser(SystemUser systemUser){
  SystemUser currentSystemuser=(SystemUser)mJsonStorage.get(SystemUser.class);
  currentSystemuser.setOutgoingCli(systemUser.getOutgoingCli());
  currentSystemuser.setMobileNumber(systemUser.getMobileNumber());
  currentSystemuser.setClient(systemUser.getClient());
  mJsonStorage.save(currentSystemuser);
}

Fixed version (ground truth):
/** 
 * Function to update the systemuser information.
 */
private void updateSystemUser(SystemUser systemUser){
  SystemUser currentSystemuser=(SystemUser)mJsonStorage.get(SystemUser.class);
  currentSystemuser.setOutgoingCli(systemUser.getOutgoingCli());
  currentSystemuser.setMobileNumber(systemUser.getMobileNumber());
  currentSystemuser.setClient(systemUser.getClient());
  currentSystemuser.setAppAccountUri(systemUser.getAppAccountUri());
  mJsonStorage.save(currentSystemuser);
}
Program: 36934
Project: 36934
Buggy source:
private void hangup(Integer viewId){
  if (mServiceBound) {
    updateCallButton(viewId,false);
    mSipService.hangUp(mSipService.getCurrentCall(),true);
    mStateView.setText(R.string.call_hangup);
    finishWithDelay();
  }
}

Fixed version (ground truth):
private void hangup(Integer viewId){
  if (mServiceBound) {
    updateCallButton(viewId,false);
    mSipService.hangUp(mSipService.getCurrentCall(),true);
    mSelfHangup=true;
    mStateView.setText(R.string.call_hangup);
    finishWithDelay();
  }
}
Program: 36936
Project: 36936
Buggy source:
/** 
 * Create a SyncContactNumber object from the give number cursor.
 * @param numberCursor Cursor containing phone numbers.
 * @return Populated SyncContact object or null.
 */
private SyncContactNumber createSyncContactNumberFromCursor(Cursor numberCursor){
  long dataId=numberCursor.getLong(numberCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone._ID));
  String number=numberCursor.getString(numberCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
  int type=numberCursor.getInt(numberCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
  String label=numberCursor.getString(numberCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL));
  number=number.replace("String_Node_Str","String_Node_Str");
  if (number == null || number.length() < 1) {
    return null;
  }
  return new SyncContactNumber(dataId,number,type,label);
}

Fixed version (ground truth):
/** 
 * Create a SyncContactNumber object from the give number cursor.
 * @param numberCursor Cursor containing phone numbers.
 * @return Populated SyncContact object or null.
 */
private SyncContactNumber createSyncContactNumberFromCursor(Cursor numberCursor){
  long dataId=numberCursor.getLong(numberCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone._ID));
  String number=numberCursor.getString(numberCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
  int type=numberCursor.getInt(numberCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
  String label=numberCursor.getString(numberCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.LABEL));
  if (number == null) {
    return null;
  }
  number=number.replace("String_Node_Str","String_Node_Str");
  if (number.length() < 1) {
    return null;
  }
  return new SyncContactNumber(dataId,number,type,label);
}
Program: 36937
Project: 36937
Buggy source:
@Override public void onResponse(Call call,Response response){
  if (response.body() instanceof SystemUser) {
    SystemUser systemUser=((SystemUser)response.body());
    mJsonStorage.save(systemUser);
    mSystemUser=systemUser;
    String phoneAccountId=mSystemUser.getPhoneAccountId();
    if (phoneAccountId != null) {
      Call<PhoneAccount> apicall=mApi.phoneAccount(phoneAccountId);
      apicall.enqueue(this);
    }
 else {
      mJsonStorage.remove(PhoneAccount.class);
    }
  }
 else   if (response.body() instanceof PhoneAccount) {
    mJsonStorage.save(response.body());
    mListener.onFinish(this);
  }
}

Fixed version (ground truth):
@Override public void onResponse(Call call,Response response){
  if (response.body() instanceof SystemUser) {
    SystemUser systemUser=((SystemUser)response.body());
    SystemUser currentSystemuser=mSystemUser;
    currentSystemuser.setOutgoingCli(systemUser.getOutgoingCli());
    currentSystemuser.setMobileNumber(systemUser.getMobileNumber());
    currentSystemuser.setClient(systemUser.getClient());
    currentSystemuser.setAppAccountUri(systemUser.getAppAccountUri());
    mJsonStorage.save(currentSystemuser);
    mSystemUser=currentSystemuser;
    String phoneAccountId=mSystemUser.getPhoneAccountId();
    if (phoneAccountId != null) {
      Call<PhoneAccount> apicall=mApi.phoneAccount(phoneAccountId);
      apicall.enqueue(this);
    }
 else {
      mJsonStorage.remove(PhoneAccount.class);
    }
  }
 else   if (response.body() instanceof PhoneAccount) {
    mJsonStorage.save(response.body());
    mListener.onFinish(this);
  }
}
Program: 36938
Project: 36938
Buggy source:
/** 
 * Function to update the systemuser information.
 */
private void updateSystemUser(SystemUser systemUser){
  SystemUser currentSystemuser=(SystemUser)mJsonStorage.get(SystemUser.class);
  currentSystemuser.setOutgoingCli(systemUser.getOutgoingCli());
  currentSystemuser.setMobileNumber(systemUser.getMobileNumber());
  currentSystemuser.setClient(systemUser.getClient());
  mJsonStorage.save(currentSystemuser);
}

Fixed version (ground truth):
/** 
 * Function to update the systemuser information.
 */
private void updateSystemUser(SystemUser systemUser){
  SystemUser currentSystemuser=(SystemUser)mJsonStorage.get(SystemUser.class);
  currentSystemuser.setOutgoingCli(systemUser.getOutgoingCli());
  currentSystemuser.setMobileNumber(systemUser.getMobileNumber());
  currentSystemuser.setClient(systemUser.getClient());
  currentSystemuser.setAppAccountUri(systemUser.getAppAccountUri());
  mJsonStorage.save(currentSystemuser);
}
Program: 36939
Project: 36939
Buggy source:
private void onCallStatesUpdateButtons(String callState){
  Integer speakerButtonId=R.id.button_speaker;
  Integer microphoneButtonId=R.id.button_microphone;
  Integer keypadButtonId=R.id.button_keypad;
  Integer onHoldButtonId=R.id.button_onhold;
  View declineButton=findViewById(R.id.button_reject);
  View acceptButton=findViewById(R.id.button_pickup);
switch (callState) {
case CALL_CONNECTED_MESSAGE:
    updateCallButton(speakerButtonId,true);
  updateCallButton(microphoneButtonId,true);
updateCallButton(keypadButtonId,true);
updateCallButton(onHoldButtonId,true);
break;
case CALL_DISCONNECTED_MESSAGE:
if (mIsIncomingCall) {
if (declineButton != null && declineButton.getVisibility() == View.VISIBLE) {
declineButton.setEnabled(false);
declineButton.setClickable(false);
declineButton.setAlpha(0.5f);
}
if (acceptButton != null && acceptButton.getVisibility() == View.VISIBLE) {
acceptButton.setEnabled(false);
acceptButton.setClickable(false);
acceptButton.setAlpha(0.5f);
}
}
 else {
updateCallButton(R.id.button_hangup,false);
}
updateCallButton(speakerButtonId,false);
updateCallButton(microphoneButtonId,false);
updateCallButton(keypadButtonId,false);
updateCallButton(onHoldButtonId,false);
if (mKeyPadVisible) {
toggleDialPad();
updateCallButton(keypadButtonId,false);
}
break;
case SERVICE_STOPPED:
updateCallButton(microphoneButtonId,false);
updateCallButton(keypadButtonId,false);
updateCallButton(onHoldButtonId,false);
break;
}
}

Fixed version (ground truth):
private void onCallStatesUpdateButtons(String callState){
  Integer speakerButtonId=R.id.button_speaker;
  Integer microphoneButtonId=R.id.button_microphone;
  Integer keypadButtonId=R.id.button_keypad;
  Integer onHoldButtonId=R.id.button_onhold;
  View declineButton=findViewById(R.id.button_reject);
  View acceptButton=findViewById(R.id.button_pickup);
switch (callState) {
case CALL_CONNECTED_MESSAGE:
    updateCallButton(speakerButtonId,true);
  updateCallButton(microphoneButtonId,true);
updateCallButton(keypadButtonId,true);
updateCallButton(onHoldButtonId,true);
break;
case CALL_DISCONNECTED_MESSAGE:
if (mIsIncomingCall) {
if (declineButton != null && declineButton.getVisibility() == View.VISIBLE) {
declineButton.setEnabled(false);
declineButton.setClickable(false);
declineButton.setAlpha(0.5f);
}
if (acceptButton != null && acceptButton.getVisibility() == View.VISIBLE) {
acceptButton.setEnabled(false);
acceptButton.setClickable(false);
acceptButton.setAlpha(0.5f);
}
}
updateCallButton(R.id.button_hangup,false);
updateCallButton(speakerButtonId,false);
updateCallButton(microphoneButtonId,false);
updateCallButton(keypadButtonId,false);
updateCallButton(onHoldButtonId,false);
if (mKeyPadVisible) {
toggleDialPad();
updateCallButton(keypadButtonId,false);
}
break;
case SERVICE_STOPPED:
updateCallButton(microphoneButtonId,false);
updateCallButton(keypadButtonId,false);
updateCallButton(onHoldButtonId,false);
break;
}
}
Program: 36940
Project: 36940
Buggy source:
@Override public void onStop(){
  super.onStop();
  mRemoteLogger.d(TAG + "String_Node_Str");
  mBroadcastManager.unregisterReceiver(mCallStatusReceiver);
  mBroadcastManager.unregisterReceiver(mDTMFButtonPressed);
  if (mServiceBound) {
    unbindService(mConnection);
    mServiceBound=false;
  }
}

Fixed version (ground truth):
@Override public void onStop(){
  super.onStop();
  mRemoteLogger.d(TAG + "String_Node_Str");
  mBroadcastManager.unregisterReceiver(mCallStatusReceiver);
  mBroadcastManager.unregisterReceiver(mDTMFButtonPressed);
  if (mServiceBound && (mSipService != null && mSipService.getCurrentCall() == null)) {
    unbindService(mConnection);
    mServiceBound=false;
  }
}
Program: 36941
Project: 36941
Buggy source:
@Override public void onStart(){
  super.onStart();
  IntentFilter intentFilter=new IntentFilter(ACTION_BROADCAST_CALL_STATUS);
  mBroadcastManager.registerReceiver(mCallStatusReceiver,intentFilter);
  mProximityHelper.startSensor();
}

Fixed version (ground truth):
@Override public void onStart(){
  super.onStart();
  IntentFilter intentFilter=new IntentFilter(ACTION_BROADCAST_CALL_STATUS);
  mBroadcastManager.registerReceiver(mCallStatusReceiver,intentFilter);
}
Program: 36942
Project: 36942
Buggy source:
@Override public void onStop(){
  super.onStop();
  mBroadcastManager.unregisterReceiver(mCallStatusReceiver);
  mProximityHelper.stopSensor();
  if (mServiceBound) {
    unbindService(mConnection);
    mServiceBound=false;
  }
}

Fixed version (ground truth):
@Override public void onStop(){
  super.onStop();
  mBroadcastManager.unregisterReceiver(mCallStatusReceiver);
  if (mServiceBound) {
    unbindService(mConnection);
    mServiceBound=false;
  }
}
Program: 36944
Project: 36944
Buggy source:
@Override protected void onDestroy(){
  super.onDestroy();
  mAudioManager.abandonAudioFocus(this);
}

Fixed version (ground truth):
@Override protected void onDestroy(){
  super.onDestroy();
  mAudioManager.abandonAudioFocus(this);
  mProximityHelper.stopSensor();
}
Program: 36945
Project: 36945
Buggy source:
@Override public void onTextChanged(CharSequence s,int start,int before,int count){
  mRemoveButton.setVisibility(s.length() == 0 ? View.INVISIBLE : View.VISIBLE);
  if (s.length() > 0) {
    mListener.onInputChanged(s.toString());
  }
}

Fixed version (ground truth):
@Override public void onTextChanged(CharSequence s,int start,int before,int count){
  mRemoveButton.setVisibility(s.length() == 0 ? View.INVISIBLE : View.VISIBLE);
  if (s.length() >= 0) {
    mListener.onInputChanged(s.toString());
  }
}
Program: 36946
Project: 36946
Buggy source:
@Override public void onClick(View view){
}

Fixed version (ground truth):
@Override public void onClick(View view){
  Integer viewId=view.getId();
switch (viewId) {
case R.id.button_speaker:
    toggleSpeaker();
  updateCallButton(viewId,true);
break;
case R.id.button_microphone:
if (mConnected) {
toggleMute();
updateCallButton(viewId,true);
}
break;
case R.id.button_keypad:
if (mConnected) {
toggleDialPad();
updateCallButton(viewId,true);
}
break;
case R.id.button_onhold:
if (mConnected) {
toggleOnHold();
updateCallButton(viewId,true);
}
break;
case R.id.button_hangup:
if (mServiceBound) {
mSipService.hangUp(mSipService.getCurrentCall());
mStateView.setText(R.string.call_hangup);
finishWithDelay();
}
break;
case R.id.button_reject:
if (mServiceBound) {
mSipService.decline(mSipService.getCurrentCall());
mAnalyticsHelper.sendEvent(getString(R.string.analytics_event_category_call),getString(R.string.analytics_event_action_inbound),getString(R.string.analytics_event_label_declined));
finishWithDelay();
}
break;
case R.id.button_pickup:
if (mServiceBound) {
mSipService.answer(mSipService.getCurrentCall());
mAnalyticsHelper.sendEvent(getString(R.string.analytics_event_category_call),getString(R.string.analytics_event_action_inbound),getString(R.string.analytics_event_label_accepted));
}
break;
}
}
Program: 36947
Project: 36947
Buggy source:
@Override public void onCallDisconnected(final Call call){
  try {
    mSipAccount.setRegistration(false);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (!mUserHangupCall && mCallIsConnected) {
    mToneGenerator.startTone(ToneGenerator.TONE_CDMA_NETWORK_BUSY,1500);
  }
  setCurrentCall(null);
  if (PhonePermission.hasPermission(getApplicationContext())) {
    unregisterReceiver(mGsmCallListener);
  }
  broadcast(SipConstants.CALL_DISCONNECTED_MESSAGE);
  stopSelf();
}

Fixed version (ground truth):
@Override public void onCallDisconnected(final Call call){
  try {
    mSipAccount.setRegistration(false);
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  if (!mUserHangupCall && mCallIsConnected) {
    mToneGenerator.startTone(ToneGenerator.TONE_CDMA_NETWORK_BUSY,1500);
  }
  setCurrentCall(null);
  if (PhonePermission.hasPermission(getApplicationContext()) && mCallIsConnected) {
    unregisterReceiver(mGsmCallListener);
  }
  broadcast(SipConstants.CALL_DISCONNECTED_MESSAGE);
  stopSelf();
}
Program: 36948
Project: 36948
Buggy source:
/** 
 * Translate the callback to the interface, which is currently implemented by the SipService.
 * @see CallStatus
 * @param onCallStateParam parameters containing the state of an active call.
 */
@Override public void onCallState(OnCallStateParam onCallStateParam){
  try {
    CallInfo info=getInfo();
    pjsip_inv_state callState=info.getState();
    if (callState == pjsip_inv_state.PJSIP_INV_STATE_CALLING) {
      mOutgoingCall=true;
    }
 else     if (callState == pjsip_inv_state.PJSIP_INV_STATE_CONNECTING || callState == pjsip_inv_state.PJSIP_INV_STATE_EARLY) {
      if (callState == pjsip_inv_state.PJSIP_INV_STATE_EARLY) {
        if (!hasMedia() && mOutgoingCall) {
          mCallStatus.onCallStartRingback();
        }
      }
      pjsip_status_code lastStatusCode=info.getLastStatusCode();
      if (hasMedia() && (lastStatusCode == pjsip_status_code.PJSIP_SC_PROGRESS || lastStatusCode == pjsip_status_code.PJSIP_SC_OK)) {
        mCallStatus.onCallStopRingback();
      }
    }
 else     if (callState == pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED) {
      mCallStatus.onCallStopRingback();
      mCallStatus.onCallConnected(this);
    }
 else     if (callState == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) {
      mCallStatus.onCallDisconnected(this);
      mCallStatus.onCallStopRingback();
      this.delete();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    mCallStatus.onCallInvalidState(this,e);
  }
}

Fixed version (ground truth):
/** 
 * Translate the callback to the interface, which is currently implemented by the SipService.
 * @see CallStatus
 * @param onCallStateParam parameters containing the state of an active call.
 */
@Override public void onCallState(OnCallStateParam onCallStateParam){
  try {
    CallInfo info=getInfo();
    pjsip_inv_state callState=info.getState();
    if (callState == pjsip_inv_state.PJSIP_INV_STATE_CALLING) {
      mOutgoingCall=true;
    }
 else     if (callState == pjsip_inv_state.PJSIP_INV_STATE_CONNECTING || callState == pjsip_inv_state.PJSIP_INV_STATE_EARLY) {
      if (callState == pjsip_inv_state.PJSIP_INV_STATE_EARLY) {
        if (!hasMedia() && mOutgoingCall) {
          mCallStatus.onCallStartRingback();
        }
      }
      pjsip_status_code lastStatusCode=info.getLastStatusCode();
      if (hasMedia() && (lastStatusCode == pjsip_status_code.PJSIP_SC_PROGRESS || lastStatusCode == pjsip_status_code.PJSIP_SC_OK)) {
        mCallStatus.onCallStopRingback();
      }
    }
 else     if (callState == pjsip_inv_state.PJSIP_INV_STATE_CONFIRMED) {
      mCallStatus.onCallStopRingback();
      mCallStatus.onCallConnected(this);
    }
 else     if (callState == pjsip_inv_state.PJSIP_INV_STATE_DISCONNECTED) {
      mCallStatus.onCallStopRingback();
      mCallStatus.onCallDisconnected(this);
      this.delete();
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    mCallStatus.onCallInvalidState(this,e);
  }
}
Program: 36949
Project: 36949
Buggy source:
/** 
 * @param phoneNumber the number that tried call in.
 * @param callerId pretty name of the phonenumber that tied to call in.
 * @param messageStartTime message roundtrip throughput timestamp handled as String for loggingpurposes.
 */
private void startSipService(String phoneNumber,String callerId,String url,String token,String messageStartTime){
  Intent intent=new Intent(this,SipService.class);
  intent.setAction(SipConstants.ACTION_VIALER_INCOMING);
  intent.setData(SipUri.build(this,phoneNumber));
  intent.putExtra(SipConstants.EXTRA_RESPONSE_URL,url);
  intent.putExtra(SipConstants.EXTRA_REQUEST_TOKEN,token);
  intent.putExtra(SipConstants.EXTRA_PHONE_NUMBER,phoneNumber);
  intent.putExtra(SipConstants.EXTRA_CONTACT_NAME,callerId);
  intent.putExtra(VialerGcmListenerService.MESSAGE_START_TIME,messageStartTime);
  startService(intent);
}

Fixed version (ground truth):
/** 
 * @param phoneNumber the number that tried call in.
 * @param callerId pretty name of the phonenumber that tied to call in.
 * @param messageStartTime message roundtrip throughput timestamp handled as String for loggingpurposes.
 */
private void startSipService(String phoneNumber,String callerId,String url,String token,String messageStartTime){
  Intent intent=new Intent(this,SipService.class);
  intent.setAction(SipConstants.ACTION_VIALER_INCOMING);
  Uri sipAddressUri=SipUri.sipAddressUri(this,PhoneNumberUtils.format(phoneNumber));
  intent.setData(sipAddressUri);
  intent.putExtra(SipConstants.EXTRA_RESPONSE_URL,url);
  intent.putExtra(SipConstants.EXTRA_REQUEST_TOKEN,token);
  intent.putExtra(SipConstants.EXTRA_PHONE_NUMBER,phoneNumber);
  intent.putExtra(SipConstants.EXTRA_CONTACT_NAME,callerId);
  intent.putExtra(VialerGcmListenerService.MESSAGE_START_TIME,messageStartTime);
  startService(intent);
}