Program: 33094
Project: 33094
Buggy source:
/** 
 * Registers receiver for the broadcasted intent when a wired headset is plugged in or unplugged. The received intent will have an extra 'state' value where 0 means unplugged, and 1 means plugged.
 */
private void registerForWiredHeadsetIntentBroadcast(){
  IntentFilter filter=new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  wiredHeadsetReceiver=new BroadcastReceiver(){
    private static final int STATE_UNPLUGGED=0;
    private static final int STATE_PLUGGED=1;
    private static final int HAS_NO_MIC=0;
    private static final int HAS_MIC=1;
    @Override public void onReceive(    Context context,    Intent intent){
      proximitySensor=AppRTCProximitySensor.create(apprtcContext,new Runnable(){
        public void run(){
          onProximitySensorChangedState();
        }
      }
);
      savedAudioMode=audioManager.getMode();
      savedIsSpeakerPhoneOn=audioManager.isSpeakerphoneOn();
      savedIsMicrophoneMute=audioManager.isMicrophoneMute();
      audioManager.requestAudioFocus(null,AudioManager.STREAM_VOICE_CALL,AudioManager.AUDIOFOCUS_GAIN);
      audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
      setMicrophoneMute(false);
      int state=intent.getIntExtra("String_Node_Str",STATE_UNPLUGGED);
      int microphone=intent.getIntExtra("String_Node_Str",HAS_NO_MIC);
      String name=intent.getStringExtra("String_Node_Str");
      RCLogger.d(TAG,"String_Node_Str" + AppRTCUtils.getThreadInfo() + "String_Node_Str"+ "String_Node_Str"+ intent.getAction()+ "String_Node_Str"+ (state == STATE_UNPLUGGED ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ (microphone == HAS_MIC ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ name+ "String_Node_Str"+ isInitialStickyBroadcast());
switch (state) {
case STATE_UNPLUGGED:
        updateAudioDeviceState(false);
      break;
case STATE_PLUGGED:
    if (selectedAudioDevice != AudioDevice.WIRED_HEADSET) {
      updateAudioDeviceState(true);
    }
  break;
default :
RCLogger.e(TAG,"String_Node_Str");
break;
}
callAudioInitialized=true;
}
}
;
apprtcContext.registerReceiver(wiredHeadsetReceiver,filter);
}

Fixed version (ground truth):
/** 
 * Registers receiver for the broadcasted intent when a wired headset is plugged in or unplugged. The received intent will have an extra 'state' value where 0 means unplugged, and 1 means plugged.
 */
private void registerForWiredHeadsetIntentBroadcast(){
  IntentFilter filter=new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  wiredHeadsetReceiver=new BroadcastReceiver(){
    private static final int STATE_UNPLUGGED=0;
    private static final int STATE_PLUGGED=1;
    private static final int HAS_NO_MIC=0;
    private static final int HAS_MIC=1;
    @Override public void onReceive(    Context context,    Intent intent){
      proximitySensor=AppRTCProximitySensor.create(apprtcContext,new Runnable(){
        public void run(){
          onProximitySensorChangedState();
        }
      }
);
      savedAudioMode=audioManager.getMode();
      savedIsSpeakerPhoneOn=audioManager.isSpeakerphoneOn();
      savedIsMicrophoneMute=audioManager.isMicrophoneMute();
      audioManager.requestAudioFocus(null,AudioManager.STREAM_VOICE_CALL,AudioManager.AUDIOFOCUS_GAIN);
      audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
      setMicrophoneMute(false);
      int state=intent.getIntExtra("String_Node_Str",STATE_UNPLUGGED);
      int microphone=intent.getIntExtra("String_Node_Str",HAS_NO_MIC);
      String name=intent.getStringExtra("String_Node_Str");
      RCLogger.d(TAG,"String_Node_Str" + AppRTCUtils.getThreadInfo() + "String_Node_Str"+ "String_Node_Str"+ intent.getAction()+ "String_Node_Str"+ (state == STATE_UNPLUGGED ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ (microphone == HAS_MIC ? "String_Node_Str" : "String_Node_Str")+ "String_Node_Str"+ name+ "String_Node_Str"+ isInitialStickyBroadcast());
switch (state) {
case STATE_UNPLUGGED:
        updateAudioDeviceState(false);
      break;
case STATE_PLUGGED:
    updateAudioDeviceState(true);
  break;
default :
RCLogger.e(TAG,"String_Node_Str");
break;
}
callAudioInitialized=true;
}
}
;
apprtcContext.registerReceiver(wiredHeadsetReceiver,filter);
}