nus-yam/ex-repair huggingface dataset:
Program: 183479
Project: 183479
Buggy source:
private void appendSspTo(StringBuilder builder){
  if (authority != null) {
    String encodedAuthority=authority.getEncoded();
    if (encodedAuthority != null) {
      builder.append("String_Node_Str").append(encodedAuthority);
    }
  }
  String encodedPath=path.getEncoded();
  if (encodedPath != null) {
    builder.append(encodedPath);
  }
  if (query != null && !query.isEmpty()) {
    builder.append('?').append(query.getEncoded());
  }
}

Fixed version (ground truth):
private void appendSspTo(StringBuilder builder){
  String encodedAuthority=authority.getEncoded();
  if (encodedAuthority != null) {
    builder.append("String_Node_Str").append(encodedAuthority);
  }
  String encodedPath=path.getEncoded();
  if (encodedPath != null) {
    builder.append(encodedPath);
  }
  if (!query.isEmpty()) {
    builder.append('?').append(query.getEncoded());
  }
}
Program: 183480
Project: 183480
Buggy source:
private HierarchicalUri(String scheme,Part authority,PathPart path,Part query,Part fragment){
  this.scheme=scheme;
  this.authority=authority;
  this.path=path;
  this.query=query;
  this.fragment=fragment;
}

Fixed version (ground truth):
private HierarchicalUri(String scheme,Part authority,PathPart path,Part query,Part fragment){
  this.scheme=scheme;
  this.authority=Part.nonNull(authority);
  this.path=path == null ? PathPart.NULL : path;
  this.query=Part.nonNull(query);
  this.fragment=Part.nonNull(fragment);
}
Program: 183481
Project: 183481
Buggy source:
private void release(){
  if (mMediaPlayer != null) {
    mMediaPlayer.reset();
    mMediaPlayer.release();
    mMediaPlayer=null;
    mCurrentState=STATE_IDLE;
    mTargetState=STATE_IDLE;
  }
}

Fixed version (ground truth):
private void release(boolean cleartargetstate){
  if (mMediaPlayer != null) {
    mMediaPlayer.reset();
    mMediaPlayer.release();
    mMediaPlayer=null;
    mCurrentState=STATE_IDLE;
    if (cleartargetstate) {
      mTargetState=STATE_IDLE;
    }
  }
}
Program: 183482
Project: 183482
Buggy source:
public void surfaceDestroyed(SurfaceHolder holder){
  mSurfaceHolder=null;
  if (mMediaController != null)   mMediaController.hide();
  release();
}

Fixed version (ground truth):
public void surfaceDestroyed(SurfaceHolder holder){
  mSurfaceHolder=null;
  if (mMediaController != null)   mMediaController.hide();
  release(true);
}
Program: 183483
Project: 183483
Buggy source:
private void openVideo(){
  if (mUri == null || mSurfaceHolder == null) {
    return;
  }
  Intent i=new Intent("String_Node_Str");
  i.putExtra("String_Node_Str","String_Node_Str");
  mContext.sendBroadcast(i);
  release();
  try {
    mMediaPlayer=new MediaPlayer();
    mMediaPlayer.setOnPreparedListener(mPreparedListener);
    mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
    mDuration=-1;
    mMediaPlayer.setOnCompletionListener(mCompletionListener);
    mMediaPlayer.setOnErrorListener(mErrorListener);
    mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener);
    mCurrentBufferPercentage=0;
    mMediaPlayer.setDataSource(mContext,mUri);
    mMediaPlayer.setDisplay(mSurfaceHolder);
    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mMediaPlayer.setScreenOnWhilePlaying(true);
    mMediaPlayer.prepareAsync();
    mCurrentState=STATE_PREPARING;
    mTargetState=STATE_PREPARED;
    attachMediaController();
  }
 catch (  IOException ex) {
    Log.w(TAG,"String_Node_Str" + mUri,ex);
    mCurrentState=STATE_ERROR;
    mTargetState=STATE_ERROR;
    return;
  }
catch (  IllegalArgumentException ex) {
    Log.w(TAG,"String_Node_Str" + mUri,ex);
    mCurrentState=STATE_ERROR;
    mTargetState=STATE_ERROR;
    return;
  }
}

Fixed version (ground truth):
private void openVideo(){
  if (mUri == null || mSurfaceHolder == null) {
    return;
  }
  Intent i=new Intent("String_Node_Str");
  i.putExtra("String_Node_Str","String_Node_Str");
  mContext.sendBroadcast(i);
  release(false);
  try {
    mMediaPlayer=new MediaPlayer();
    mMediaPlayer.setOnPreparedListener(mPreparedListener);
    mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
    mDuration=-1;
    mMediaPlayer.setOnCompletionListener(mCompletionListener);
    mMediaPlayer.setOnErrorListener(mErrorListener);
    mMediaPlayer.setOnBufferingUpdateListener(mBufferingUpdateListener);
    mCurrentBufferPercentage=0;
    mMediaPlayer.setDataSource(mContext,mUri);
    mMediaPlayer.setDisplay(mSurfaceHolder);
    mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    mMediaPlayer.setScreenOnWhilePlaying(true);
    mMediaPlayer.prepareAsync();
    mCurrentState=STATE_PREPARING;
    attachMediaController();
  }
 catch (  IOException ex) {
    Log.w(TAG,"String_Node_Str" + mUri,ex);
    mCurrentState=STATE_ERROR;
    mTargetState=STATE_ERROR;
    return;
  }
catch (  IllegalArgumentException ex) {
    Log.w(TAG,"String_Node_Str" + mUri,ex);
    mCurrentState=STATE_ERROR;
    mTargetState=STATE_ERROR;
    return;
  }
}
Program: 183484
Project: 183484
Buggy source:
@Override public void onChange(boolean selfChange){
  super.onChange(selfChange);
  mRingerModeAffectedStreams=Settings.System.getInt(mContentResolver,Settings.System.MODE_RINGER_STREAMS_AFFECTED,0);
  setRingerModeInt(getRingerMode());
}

Fixed version (ground truth):
@Override public void onChange(boolean selfChange){
  super.onChange(selfChange);
  mRingerModeAffectedStreams=Settings.System.getInt(mContentResolver,Settings.System.MODE_RINGER_STREAMS_AFFECTED,0);
  setRingerModeInt(getRingerMode(),false);
}
Program: 183485
Project: 183485
Buggy source:
private void setRingerModeInt(int ringerMode){
  mRingerMode=ringerMode;
  int numStreamTypes=AudioSystem.getNumStreamTypes();
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
      if (!isStreamAffectedByRingerMode(streamType))       continue;
      setStreamVolumeInt(streamType,mStreamStates[streamType].mLastAudibleIndex,false,false);
    }
  }
 else {
    for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
      if (isStreamAffectedByRingerMode(streamType)) {
        setStreamVolumeInt(streamType,0,false,false);
      }
 else {
        setStreamVolumeInt(streamType,mStreamStates[streamType].mLastAudibleIndex,false,false);
      }
    }
  }
  sendMsg(mAudioHandler,MSG_PERSIST_RINGER_MODE,SHARED_MSG,SENDMSG_REPLACE,0,0,null,PERSIST_DELAY);
}

Fixed version (ground truth):
private void setRingerModeInt(int ringerMode,boolean persist){
  mRingerMode=ringerMode;
  int numStreamTypes=AudioSystem.getNumStreamTypes();
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
      if (!isStreamAffectedByRingerMode(streamType))       continue;
      setStreamVolumeInt(streamType,mStreamStates[streamType].mLastAudibleIndex,false,false);
    }
  }
 else {
    for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
      if (isStreamAffectedByRingerMode(streamType)) {
        setStreamVolumeInt(streamType,0,false,false);
      }
 else {
        setStreamVolumeInt(streamType,mStreamStates[streamType].mLastAudibleIndex,false,false);
      }
    }
  }
  if (persist) {
    sendMsg(mAudioHandler,MSG_PERSIST_RINGER_MODE,SHARED_MSG,SENDMSG_REPLACE,0,0,null,PERSIST_DELAY);
  }
}
Program: 183486
Project: 183486
Buggy source:
/** 
 * @see AudioManager#setRingerMode(int) 
 */
public void setRingerMode(int ringerMode){
  if (ringerMode != mRingerMode) {
    setRingerModeInt(ringerMode);
    broadcastRingerMode();
  }
}

Fixed version (ground truth):
/** 
 * @see AudioManager#setRingerMode(int) 
 */
public void setRingerMode(int ringerMode){
  if (ringerMode != mRingerMode) {
    setRingerModeInt(ringerMode,true);
    broadcastRingerMode();
  }
}
Program: 183488
Project: 183488
Buggy source:
public void onCompletion(MediaPlayer mp){
  if (mMediaController != null) {
    mMediaController.hide();
  }
  if (mOnCompletionListener != null) {
    mOnCompletionListener.onCompletion(mMediaPlayer);
  }
}

Fixed version (ground truth):
public void onCompletion(MediaPlayer mp){
  mIsPlaybackCompleted=true;
  if (mMediaController != null) {
    mMediaController.hide();
  }
  if (mOnCompletionListener != null) {
    mOnCompletionListener.onCompletion(mMediaPlayer);
  }
}
Program: 183489
Project: 183489
Buggy source:
public void surfaceChanged(SurfaceHolder holder,int format,int w,int h){
  mSurfaceWidth=w;
  mSurfaceHeight=h;
  if (mMediaPlayer != null && mIsPrepared && mVideoWidth == w && mVideoHeight == h) {
    if (mSeekWhenPrepared != 0) {
      mMediaPlayer.seekTo(mSeekWhenPrepared);
      mSeekWhenPrepared=0;
    }
    mMediaPlayer.start();
    if (mMediaController != null) {
      mMediaController.show();
    }
  }
}

Fixed version (ground truth):
public void surfaceChanged(SurfaceHolder holder,int format,int w,int h){
  mSurfaceWidth=w;
  mSurfaceHeight=h;
  if (mMediaPlayer != null && mIsPrepared && mVideoWidth == w && mVideoHeight == h) {
    if (mSeekWhenPrepared != 0) {
      mMediaPlayer.seekTo(mSeekWhenPrepared);
      mSeekWhenPrepared=0;
    }
    if (!mIsPlaybackCompleted) {
      start();
    }
    if (mMediaController != null) {
      mMediaController.show();
    }
  }
}
Program: 183490
Project: 183490
Buggy source:
public void start(){
  if (mMediaPlayer != null && mIsPrepared) {
    mMediaPlayer.start();
    mStartWhenPrepared=false;
  }
 else {
    mStartWhenPrepared=true;
  }
}

Fixed version (ground truth):
public void start(){
  mIsPlaybackCompleted=false;
  if (mMediaPlayer != null && mIsPrepared) {
    mMediaPlayer.start();
    mStartWhenPrepared=false;
  }
 else {
    mStartWhenPrepared=true;
  }
}
Program: 183491
Project: 183491
Buggy source:
public void onPrepared(MediaPlayer mp){
  mIsPrepared=true;
  if (mOnPreparedListener != null) {
    mOnPreparedListener.onPrepared(mMediaPlayer);
  }
  if (mMediaController != null) {
    mMediaController.setEnabled(true);
  }
  mVideoWidth=mp.getVideoWidth();
  mVideoHeight=mp.getVideoHeight();
  if (mVideoWidth != 0 && mVideoHeight != 0) {
    getHolder().setFixedSize(mVideoWidth,mVideoHeight);
    if (mSurfaceWidth == mVideoWidth && mSurfaceHeight == mVideoHeight) {
      if (mSeekWhenPrepared != 0) {
        mMediaPlayer.seekTo(mSeekWhenPrepared);
        mSeekWhenPrepared=0;
      }
      if (mStartWhenPrepared) {
        mMediaPlayer.start();
        mStartWhenPrepared=false;
        if (mMediaController != null) {
          mMediaController.show();
        }
      }
 else       if (!isPlaying() && (mSeekWhenPrepared != 0 || getCurrentPosition() > 0)) {
        if (mMediaController != null) {
          mMediaController.show(0);
        }
      }
    }
  }
 else {
    if (mSeekWhenPrepared != 0) {
      mMediaPlayer.seekTo(mSeekWhenPrepared);
      mSeekWhenPrepared=0;
    }
    if (mStartWhenPrepared) {
      mMediaPlayer.start();
      mStartWhenPrepared=false;
    }
  }
}

Fixed version (ground truth):
public void onPrepared(MediaPlayer mp){
  mIsPrepared=true;
  if (mOnPreparedListener != null) {
    mOnPreparedListener.onPrepared(mMediaPlayer);
  }
  if (mMediaController != null) {
    mMediaController.setEnabled(true);
  }
  mVideoWidth=mp.getVideoWidth();
  mVideoHeight=mp.getVideoHeight();
  if (mVideoWidth != 0 && mVideoHeight != 0) {
    getHolder().setFixedSize(mVideoWidth,mVideoHeight);
    if (mSurfaceWidth == mVideoWidth && mSurfaceHeight == mVideoHeight) {
      if (mSeekWhenPrepared != 0) {
        mMediaPlayer.seekTo(mSeekWhenPrepared);
        mSeekWhenPrepared=0;
      }
      if (mStartWhenPrepared) {
        start();
        mStartWhenPrepared=false;
        if (mMediaController != null) {
          mMediaController.show();
        }
      }
 else       if (!isPlaying() && (mSeekWhenPrepared != 0 || getCurrentPosition() > 0)) {
        if (mMediaController != null) {
          mMediaController.show(0);
        }
      }
    }
  }
 else {
    if (mSeekWhenPrepared != 0) {
      mMediaPlayer.seekTo(mSeekWhenPrepared);
      mSeekWhenPrepared=0;
    }
    if (mStartWhenPrepared) {
      start();
      mStartWhenPrepared=false;
    }
  }
}
Program: 183492
Project: 183492
Buggy source:
private void refreshBatteryDisplay(){
  if (!mShowingBatteryInfo || !mSimOk) {
    mBatteryInfoGroup.setVisibility(View.GONE);
    mBatteryInfoSpacer.setVisibility(View.GONE);
    return;
  }
  mBatteryInfoGroup.setVisibility(View.VISIBLE);
  mBatteryInfoSpacer.setVisibility(View.VISIBLE);
  if (mPluggedIn) {
    mBatteryInfoIcon.setImageResource(R.drawable.ic_lock_idle_charging);
    mBatteryInfoText.setText(getContext().getString(R.string.lockscreen_plugged_in,mBatteryLevel));
  }
 else {
    mBatteryInfoIcon.setImageResource(R.drawable.ic_lock_idle_low_battery);
    mBatteryInfoText.setText(R.string.lockscreen_low_battery);
  }
}

Fixed version (ground truth):
private void refreshBatteryDisplay(){
  if (!mShowingBatteryInfo || !mSimOk) {
    mBatteryInfoGroup.setVisibility(View.GONE);
    mBatteryInfoSpacer.setVisibility(View.GONE);
    return;
  }
  mBatteryInfoGroup.setVisibility(View.VISIBLE);
  mBatteryInfoSpacer.setVisibility(View.VISIBLE);
  if (mPluggedIn) {
    mBatteryInfoIcon.setImageResource(R.drawable.ic_lock_idle_charging);
    if (mBatteryLevel >= 100) {
      mBatteryInfoText.setText(R.string.lockscreen_charged);
    }
 else {
      mBatteryInfoText.setText(getContext().getString(R.string.lockscreen_plugged_in,mBatteryLevel));
    }
  }
 else {
    mBatteryInfoIcon.setImageResource(R.drawable.ic_lock_idle_low_battery);
    mBatteryInfoText.setText(R.string.lockscreen_low_battery);
  }
}
Program: 183493
Project: 183493
Buggy source:
private void refreshBatteryDisplay(){
  if (!mShowingBatteryInfo || !mSimOk) {
    mBatteryInfoGroup.setVisibility(View.GONE);
    mBatteryInfoSpacer.setVisibility(View.GONE);
    return;
  }
  mBatteryInfoGroup.setVisibility(View.VISIBLE);
  mBatteryInfoSpacer.setVisibility(View.VISIBLE);
  if (mPluggedIn) {
    mBatteryInfoIcon.setImageResource(R.drawable.ic_lock_idle_charging);
    mBatteryInfoText.setText(getContext().getString(R.string.lockscreen_plugged_in,mBatteryLevel));
  }
 else {
    mBatteryInfoIcon.setImageResource(R.drawable.ic_lock_idle_low_battery);
    mBatteryInfoText.setText(R.string.lockscreen_low_battery);
  }
}

Fixed version (ground truth):
private void refreshBatteryDisplay(){
  if (!mShowingBatteryInfo || !mSimOk) {
    mBatteryInfoGroup.setVisibility(View.GONE);
    mBatteryInfoSpacer.setVisibility(View.GONE);
    return;
  }
  mBatteryInfoGroup.setVisibility(View.VISIBLE);
  mBatteryInfoSpacer.setVisibility(View.VISIBLE);
  if (mPluggedIn) {
    mBatteryInfoIcon.setImageResource(R.drawable.ic_lock_idle_charging);
    if (mBatteryLevel >= 100) {
      mBatteryInfoText.setText(R.string.lockscreen_charged);
    }
 else {
      mBatteryInfoText.setText(getContext().getString(R.string.lockscreen_plugged_in,mBatteryLevel));
    }
  }
 else {
    mBatteryInfoIcon.setImageResource(R.drawable.ic_lock_idle_low_battery);
    mBatteryInfoText.setText(R.string.lockscreen_low_battery);
  }
}
Program: 183494
Project: 183494
Buggy source:
private void setDefaultSettings(){
  setLanguage(this.getDefaultLanguage(),getDefaultLanguage(),getDefaultLocVariant());
  setSpeechRate(getDefaultRate());
}

Fixed version (ground truth):
private void setDefaultSettings(){
  setLanguage(this.getDefaultLanguage(),getDefaultCountry(),getDefaultLocVariant());
  setSpeechRate(getDefaultRate());
}
Program: 183495
Project: 183495
Buggy source:
/** 
 * Returns a constant indicating the type of activity on a data connection (cellular).
 * @see #DATA_ACTIVITY_NONE
 * @see #DATA_ACTIVITY_IN
 * @see #DATA_ACTIVITY_OUT
 * @see #DATA_ACTIVITY_INOUT
 * @see #DATA_ACTIVITY_DORMANT
 */
public int getDataActivity(){
  try {
    return getITelephony().getDataActivity();
  }
 catch (  RemoteException ex) {
    return DATA_ACTIVITY_NONE;
  }
}

Fixed version (ground truth):
/** 
 * Returns a constant indicating the type of activity on a data connection (cellular).
 * @see #DATA_ACTIVITY_NONE
 * @see #DATA_ACTIVITY_IN
 * @see #DATA_ACTIVITY_OUT
 * @see #DATA_ACTIVITY_INOUT
 * @see #DATA_ACTIVITY_DORMANT
 */
public int getDataActivity(){
  try {
    return getITelephony().getDataActivity();
  }
 catch (  RemoteException ex) {
    return DATA_ACTIVITY_NONE;
  }
catch (  NullPointerException ex) {
    return DATA_ACTIVITY_NONE;
  }
}
Program: 183496
Project: 183496
Buggy source:
/** 
 * Returns a constant indicating the call state (cellular) on the device.
 */
public int getCallState(){
  try {
    return getITelephony().getCallState();
  }
 catch (  RemoteException ex) {
    return CALL_STATE_IDLE;
  }
}

Fixed version (ground truth):
/** 
 * Returns a constant indicating the call state (cellular) on the device.
 */
public int getCallState(){
  try {
    return getITelephony().getCallState();
  }
 catch (  RemoteException ex) {
    return CALL_STATE_IDLE;
  }
catch (  NullPointerException ex) {
    return CALL_STATE_IDLE;
  }
}
Program: 183497
Project: 183497
Buggy source:
private void setDefaultSettings(){
  setLanguage(this.getDefaultLanguage(),getDefaultLanguage(),getDefaultLocVariant());
  setSpeechRate(getDefaultRate());
}

Fixed version (ground truth):
private void setDefaultSettings(){
  setLanguage(this.getDefaultLanguage(),getDefaultCountry(),getDefaultLocVariant());
  setSpeechRate(getDefaultRate());
}
Program: 183498
Project: 183498
Buggy source:
public void onChildViewRemoved(View p,View child){
  if (child == this) {
    if (inEditingMode()) {
      clearTextEntry();
    }
  }
}

Fixed version (ground truth):
public void onChildViewRemoved(View p,View child){
  if (child == this) {
    clearTextEntry();
  }
}
Program: 183499
Project: 183499
Buggy source:
@Override public boolean performLongClick(){
  if (inEditingMode()) {
    return mWebTextView.performLongClick();
  }
 else {
    return super.performLongClick();
  }
}

Fixed version (ground truth):
@Override public boolean performLongClick(){
  if (mNativeClass != 0 && nativeCursorIsTextInput()) {
    mWebViewCore.sendMessage(EventHub.CLICK,nativeCursorFramePointer(),nativeCursorNodePointer());
    rebuildWebTextView();
  }
  if (inEditingMode()) {
    return mWebTextView.performLongClick();
  }
 else {
    return super.performLongClick();
  }
}
Program: 183501
Project: 183501
Buggy source:
private static byte[] numberToCalledPartyBCDHelper(byte[] ret,int offset,String number){
  if (hasPlus(number)) {
    number=number.replaceAll("String_Node_Str","String_Node_Str");
    ret[offset]=(byte)TOA_International;
  }
 else {
    ret[offset]=(byte)TOA_Unknown;
  }
  int size=number.length();
  int curChar=0;
  int countFullBytes=ret.length - offset - 1- ((size - curChar) & 1);
  for (int i=1; i < 1 + countFullBytes; i++) {
    ret[offset + i]=(byte)((charToBCD(number.charAt(curChar++))) | (charToBCD(number.charAt(curChar++))) << 4);
  }
  if (countFullBytes + offset < ret.length - 1) {
    ret[ret.length - 1]=(byte)(charToBCD(number.charAt(curChar)) | (0xf << 4));
  }
  return ret;
}

Fixed version (ground truth):
/** 
 * If includeLength is true, prepend a one-byte length value to the return array.
 */
private static byte[] numberToCalledPartyBCDHelper(String number,boolean includeLength){
  int numberLenReal=number.length();
  int numberLenEffective=numberLenReal;
  boolean hasPlus=number.indexOf('+') != -1;
  if (hasPlus)   numberLenEffective--;
  if (numberLenEffective == 0)   return null;
  int resultLen=(numberLenEffective + 1) / 2;
  int extraBytes=1;
  if (includeLength)   extraBytes++;
  resultLen+=extraBytes;
  byte[] result=new byte[resultLen];
  int digitCount=0;
  for (int i=0; i < numberLenReal; i++) {
    char c=number.charAt(i);
    if (c == '+')     continue;
    int shift=((digitCount & 0x01) == 1) ? 4 : 0;
    result[extraBytes + (digitCount >> 1)]|=(byte)((charToBCD(c) & 0x0F) << shift);
    digitCount++;
  }
  if ((digitCount & 0x01) == 1)   result[extraBytes + (digitCount >> 1)]|=0xF0;
  int offset=0;
  if (includeLength)   result[offset++]=(byte)(resultLen - 1);
  result[offset]=(byte)(hasPlus ? TOA_International : TOA_Unknown);
  return result;
}
Program: 183502
Project: 183502
Buggy source:
/** 
 * Note: calls extractNetworkPortion(), so do not use for SIM EF[ADN] style records Exceptions thrown if extractNetworkPortion(s).length() == 0
 */
public static byte[] networkPortionToCalledPartyBCD(String s){
  return numberToCalledPartyBCD(extractNetworkPortion(s));
}

Fixed version (ground truth):
/** 
 * Note: calls extractNetworkPortion(), so do not use for SIM EF[ADN] style records Returns null if network portion is empty.
 */
public static byte[] networkPortionToCalledPartyBCD(String s){
  String networkPortion=extractNetworkPortion(s);
  return numberToCalledPartyBCDHelper(networkPortion,false);
}
Program: 183503
Project: 183503
Buggy source:
/** 
 * Convert a dialing number to BCD byte array
 * @param number dialing number stringif the dialing number starts with '+', set to internationl TOA
 * @return BCD byte array
 */
public static byte[] numberToCalledPartyBCD(String number){
  int size=(hasPlus(number) ? number.length() - 1 : number.length());
  byte[] ret=new byte[(size + 1) / 2 + 1];
  return numberToCalledPartyBCDHelper(ret,0,number);
}

Fixed version (ground truth):
/** 
 * Convert a dialing number to BCD byte array
 * @param number dialing number stringif the dialing number starts with '+', set to internationl TOA
 * @return BCD byte array
 */
public static byte[] numberToCalledPartyBCD(String number){
  return numberToCalledPartyBCDHelper(number,false);
}
Program: 183504
Project: 183504
Buggy source:
/** 
 * Same as   {@link #networkPortionToCalledPartyBCD}, but includes a one-byte length prefix.
 */
public static byte[] networkPortionToCalledPartyBCDWithLength(String s){
  return numberToCalledPartyBCDWithLength(extractNetworkPortion(s));
}

Fixed version (ground truth):
/** 
 * Same as   {@link #networkPortionToCalledPartyBCD}, but includes a one-byte length prefix.
 */
public static byte[] networkPortionToCalledPartyBCDWithLength(String s){
  String networkPortion=extractNetworkPortion(s);
  return numberToCalledPartyBCDHelper(networkPortion,true);
}
Program: 183506
Project: 183506
Buggy source:
/** 
 * Inject a pointer (touch) event into the UI.
 * @param ev A motion event describing the pointer (touch) action.  (As noted in{@link MotionEvent#obtain(long,long,int,float,float,int)}, be sure to use  {@link SystemClock#uptimeMillis()} as the timebase.)
 * @param sync If true, wait for the event to be completed before returning to the caller.
 * @return Returns true if event was dispatched, false if it was dropped for any reason
 */
public boolean injectPointerEvent(MotionEvent ev,boolean sync){
  int result=dispatchPointer(null,ev,Binder.getCallingPid(),Binder.getCallingUid());
  if (sync) {
    mKeyWaiter.waitForNextEventTarget(null,null,null,false,true);
  }
switch (result) {
case INJECT_NO_PERMISSION:
    throw new SecurityException("String_Node_Str");
case INJECT_SUCCEEDED:
  return true;
}
return false;
}

Fixed version (ground truth):
/** 
 * Inject a pointer (touch) event into the UI.
 * @param ev A motion event describing the pointer (touch) action.  (As noted in{@link MotionEvent#obtain(long,long,int,float,float,int)}, be sure to use  {@link SystemClock#uptimeMillis()} as the timebase.)
 * @param sync If true, wait for the event to be completed before returning to the caller.
 * @return Returns true if event was dispatched, false if it was dropped for any reason
 */
public boolean injectPointerEvent(MotionEvent ev,boolean sync){
  final int pid=Binder.getCallingPid();
  final int uid=Binder.getCallingUid();
  final long ident=Binder.clearCallingIdentity();
  final int result=dispatchPointer(null,ev,pid,uid);
  if (sync) {
    mKeyWaiter.waitForNextEventTarget(null,null,null,false,true,pid,uid);
  }
  Binder.restoreCallingIdentity(ident);
switch (result) {
case INJECT_NO_PERMISSION:
    throw new SecurityException("String_Node_Str");
case INJECT_SUCCEEDED:
  return true;
}
return false;
}
Program: 183507
Project: 183507
Buggy source:
/** 
 * @return Returns true if event was dispatched, false if it was dropped for any reason
 */
private int dispatchKey(KeyEvent event,int pid,int uid){
  if (DEBUG_INPUT)   Log.v(TAG,"String_Node_Str" + event);
  Object focusObj=mKeyWaiter.waitForNextEventTarget(event,null,null,false,false);
  if (focusObj == null) {
    Log.w(TAG,"String_Node_Str" + event);
    return INJECT_FAILED;
  }
  if (focusObj == mKeyWaiter.CONSUMED_EVENT_TOKEN) {
    return INJECT_SUCCEEDED;
  }
  WindowState focus=(WindowState)focusObj;
  if (DEBUG_INPUT)   Log.v(TAG,"String_Node_Str" + focus + "String_Node_Str"+ event);
  if (uid != 0 && uid != focus.mSession.mUid) {
    if (mContext.checkPermission(android.Manifest.permission.INJECT_EVENTS,pid,uid) != PackageManager.PERMISSION_GRANTED) {
      Log.w(TAG,"String_Node_Str" + pid + "String_Node_Str"+ uid+ "String_Node_Str"+ focus+ "String_Node_Str"+ focus.mSession.mUid);
      return INJECT_NO_PERMISSION;
    }
  }
synchronized (mWindowMap) {
    mKeyWaiter.bindTargetWindowLocked(focus);
  }
  mKeyWaiter.recordDispatchState(event,focus);
  try {
    if (DEBUG_INPUT || DEBUG_FOCUS) {
      Log.v(TAG,"String_Node_Str" + event.getKeyCode() + "String_Node_Str"+ focus);
    }
    focus.mClient.dispatchKey(event);
    return INJECT_SUCCEEDED;
  }
 catch (  android.os.RemoteException e) {
    Log.i(TAG,"String_Node_Str" + focus);
    try {
      removeWindow(focus.mSession,focus.mClient);
    }
 catch (    java.util.NoSuchElementException ex) {
    }
  }
  return INJECT_FAILED;
}

Fixed version (ground truth):
/** 
 * @return Returns true if event was dispatched, false if it was dropped for any reason
 */
private int dispatchKey(KeyEvent event,int pid,int uid){
  if (DEBUG_INPUT)   Log.v(TAG,"String_Node_Str" + event);
  Object focusObj=mKeyWaiter.waitForNextEventTarget(event,null,null,false,false,pid,uid);
  if (focusObj == null) {
    Log.w(TAG,"String_Node_Str" + event);
    return INJECT_FAILED;
  }
  if (focusObj == mKeyWaiter.CONSUMED_EVENT_TOKEN) {
    return INJECT_SUCCEEDED;
  }
  WindowState focus=(WindowState)focusObj;
  if (DEBUG_INPUT)   Log.v(TAG,"String_Node_Str" + focus + "String_Node_Str"+ event);
  if (uid != 0 && uid != focus.mSession.mUid) {
    if (mContext.checkPermission(android.Manifest.permission.INJECT_EVENTS,pid,uid) != PackageManager.PERMISSION_GRANTED) {
      Log.w(TAG,"String_Node_Str" + pid + "String_Node_Str"+ uid+ "String_Node_Str"+ focus+ "String_Node_Str"+ focus.mSession.mUid);
      return INJECT_NO_PERMISSION;
    }
  }
synchronized (mWindowMap) {
    mKeyWaiter.bindTargetWindowLocked(focus);
  }
  mKeyWaiter.recordDispatchState(event,focus);
  try {
    if (DEBUG_INPUT || DEBUG_FOCUS) {
      Log.v(TAG,"String_Node_Str" + event.getKeyCode() + "String_Node_Str"+ focus);
    }
    focus.mClient.dispatchKey(event);
    return INJECT_SUCCEEDED;
  }
 catch (  android.os.RemoteException e) {
    Log.i(TAG,"String_Node_Str" + focus);
    try {
      removeWindow(focus.mSession,focus.mClient);
    }
 catch (    java.util.NoSuchElementException ex) {
    }
  }
  return INJECT_FAILED;
}
Program: 183512
Project: 183512
Buggy source:
/** 
 * Inject a trackball (navigation device) event into the UI.
 * @param ev A motion event describing the trackball action.  (As noted in{@link MotionEvent#obtain(long,long,int,float,float,int)}, be sure to use  {@link SystemClock#uptimeMillis()} as the timebase.)
 * @param sync If true, wait for the event to be completed before returning to the caller.
 * @return Returns true if event was dispatched, false if it was dropped for any reason
 */
public boolean injectTrackballEvent(MotionEvent ev,boolean sync){
  int result=dispatchTrackball(null,ev,Binder.getCallingPid(),Binder.getCallingUid());
  if (sync) {
    mKeyWaiter.waitForNextEventTarget(null,null,null,false,true);
  }
switch (result) {
case INJECT_NO_PERMISSION:
    throw new SecurityException("String_Node_Str");
case INJECT_SUCCEEDED:
  return true;
}
return false;
}

Fixed version (ground truth):
/** 
 * Inject a trackball (navigation device) event into the UI.
 * @param ev A motion event describing the trackball action.  (As noted in{@link MotionEvent#obtain(long,long,int,float,float,int)}, be sure to use  {@link SystemClock#uptimeMillis()} as the timebase.)
 * @param sync If true, wait for the event to be completed before returning to the caller.
 * @return Returns true if event was dispatched, false if it was dropped for any reason
 */
public boolean injectTrackballEvent(MotionEvent ev,boolean sync){
  final int pid=Binder.getCallingPid();
  final int uid=Binder.getCallingUid();
  final long ident=Binder.clearCallingIdentity();
  final int result=dispatchTrackball(null,ev,pid,uid);
  if (sync) {
    mKeyWaiter.waitForNextEventTarget(null,null,null,false,true,pid,uid);
  }
  Binder.restoreCallingIdentity(ident);
switch (result) {
case INJECT_NO_PERMISSION:
    throw new SecurityException("String_Node_Str");
case INJECT_SUCCEEDED:
  return true;
}
return false;
}
Program: 183513
Project: 183513
Buggy source:
/** 
 * Injects a keystroke event into the UI.
 * @param ev A motion event describing the keystroke action.  (Be sure to use{@link SystemClock#uptimeMillis()} as the timebase.)
 * @param sync If true, wait for the event to be completed before returning to the caller.
 * @return Returns true if event was dispatched, false if it was dropped for any reason
 */
public boolean injectKeyEvent(KeyEvent ev,boolean sync){
  long downTime=ev.getDownTime();
  long eventTime=ev.getEventTime();
  int action=ev.getAction();
  int code=ev.getKeyCode();
  int repeatCount=ev.getRepeatCount();
  int metaState=ev.getMetaState();
  int deviceId=ev.getDeviceId();
  int scancode=ev.getScanCode();
  if (eventTime == 0)   eventTime=SystemClock.uptimeMillis();
  if (downTime == 0)   downTime=eventTime;
  KeyEvent newEvent=new KeyEvent(downTime,eventTime,action,code,repeatCount,metaState,deviceId,scancode,KeyEvent.FLAG_FROM_SYSTEM);
  int result=dispatchKey(newEvent,Binder.getCallingPid(),Binder.getCallingUid());
  if (sync) {
    mKeyWaiter.waitForNextEventTarget(null,null,null,false,true);
  }
switch (result) {
case INJECT_NO_PERMISSION:
    throw new SecurityException("String_Node_Str");
case INJECT_SUCCEEDED:
  return true;
}
return false;
}

Fixed version (ground truth):
/** 
 * Injects a keystroke event into the UI.
 * @param ev A motion event describing the keystroke action.  (Be sure to use{@link SystemClock#uptimeMillis()} as the timebase.)
 * @param sync If true, wait for the event to be completed before returning to the caller.
 * @return Returns true if event was dispatched, false if it was dropped for any reason
 */
public boolean injectKeyEvent(KeyEvent ev,boolean sync){
  long downTime=ev.getDownTime();
  long eventTime=ev.getEventTime();
  int action=ev.getAction();
  int code=ev.getKeyCode();
  int repeatCount=ev.getRepeatCount();
  int metaState=ev.getMetaState();
  int deviceId=ev.getDeviceId();
  int scancode=ev.getScanCode();
  if (eventTime == 0)   eventTime=SystemClock.uptimeMillis();
  if (downTime == 0)   downTime=eventTime;
  KeyEvent newEvent=new KeyEvent(downTime,eventTime,action,code,repeatCount,metaState,deviceId,scancode,KeyEvent.FLAG_FROM_SYSTEM);
  final int pid=Binder.getCallingPid();
  final int uid=Binder.getCallingUid();
  final long ident=Binder.clearCallingIdentity();
  final int result=dispatchKey(newEvent,pid,uid);
  if (sync) {
    mKeyWaiter.waitForNextEventTarget(null,null,null,false,true,pid,uid);
  }
  Binder.restoreCallingIdentity(ident);
switch (result) {
case INJECT_NO_PERMISSION:
    throw new SecurityException("String_Node_Str");
case INJECT_SUCCEEDED:
  return true;
}
return false;
}
Program: 183514
Project: 183514
Buggy source:
private void runProfile(){
  String profileFile=null;
  boolean start=false;
  String process=nextArg();
  if (process == null) {
    System.err.println("String_Node_Str");
    showUsage();
    return;
  }
  String cmd=nextArg();
  if ("String_Node_Str".equals(cmd)) {
    start=true;
    profileFile=nextArg();
    if (profileFile == null) {
      System.err.println("String_Node_Str");
      showUsage();
      return;
    }
  }
 else   if (!"String_Node_Str".equals(cmd)) {
    System.err.println("String_Node_Str" + cmd + "String_Node_Str");
    showUsage();
    return;
  }
  try {
    if (!mAm.profileControl(process,start,profileFile)) {
      System.out.println("String_Node_Str" + process);
      return;
    }
  }
 catch (  IllegalArgumentException e) {
    System.out.println("String_Node_Str" + e.getMessage());
    return;
  }
catch (  IllegalStateException e) {
    System.out.println("String_Node_Str" + e.getMessage());
    return;
  }
catch (  RemoteException e) {
    System.out.println("String_Node_Str");
    return;
  }
}

Fixed version (ground truth):
private void runProfile(){
  String profileFile=null;
  boolean start=false;
  String process=nextArg();
  if (process == null) {
    System.err.println("String_Node_Str");
    showUsage();
    return;
  }
  ParcelFileDescriptor fd=null;
  String cmd=nextArg();
  if ("String_Node_Str".equals(cmd)) {
    start=true;
    profileFile=nextArg();
    if (profileFile == null) {
      System.err.println("String_Node_Str");
      showUsage();
      return;
    }
    try {
      fd=ParcelFileDescriptor.open(new File(profileFile),ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE | ParcelFileDescriptor.MODE_READ_WRITE);
    }
 catch (    FileNotFoundException e) {
      System.err.println("String_Node_Str" + profileFile);
      return;
    }
  }
 else   if (!"String_Node_Str".equals(cmd)) {
    System.err.println("String_Node_Str" + cmd + "String_Node_Str");
    showUsage();
    return;
  }
  try {
    if (!mAm.profileControl(process,start,profileFile,fd)) {
      System.err.println("String_Node_Str" + process);
      return;
    }
  }
 catch (  IllegalArgumentException e) {
    System.out.println("String_Node_Str" + e.getMessage());
    return;
  }
catch (  IllegalStateException e) {
    System.out.println("String_Node_Str" + e.getMessage());
    return;
  }
catch (  RemoteException e) {
    System.out.println("String_Node_Str");
    return;
  }
}
Program: 183516
Project: 183516
Buggy source:
public boolean profileControl(String process,boolean start,String path) throws RemoteException {
  Parcel data=Parcel.obtain();
  Parcel reply=Parcel.obtain();
  data.writeInterfaceToken(IActivityManager.descriptor);
  data.writeString(process);
  data.writeInt(start ? 1 : 0);
  data.writeString(path);
  mRemote.transact(PROFILE_CONTROL_TRANSACTION,data,reply,0);
  reply.readException();
  boolean res=reply.readInt() != 0;
  reply.recycle();
  data.recycle();
  return res;
}

Fixed version (ground truth):
public boolean profileControl(String process,boolean start,String path,ParcelFileDescriptor fd) throws RemoteException {
  Parcel data=Parcel.obtain();
  Parcel reply=Parcel.obtain();
  data.writeInterfaceToken(IActivityManager.descriptor);
  data.writeString(process);
  data.writeInt(start ? 1 : 0);
  data.writeString(path);
  if (fd != null) {
    data.writeInt(1);
    fd.writeToParcel(data,Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
  }
 else {
    data.writeInt(0);
  }
  mRemote.transact(PROFILE_CONTROL_TRANSACTION,data,reply,0);
  reply.readException();
  boolean res=reply.readInt() != 0;
  reply.recycle();
  data.recycle();
  return res;
}
Program: 183517
Project: 183517
Buggy source:
final void handleProfilerControl(boolean start,String path){
  if (start) {
    File file=new File(path);
    file.getParentFile().mkdirs();
    try {
      Debug.startMethodTracing(file.toString(),8 * 1024 * 1024);
    }
 catch (    RuntimeException e) {
      Log.w(TAG,"String_Node_Str" + path + "String_Node_Str");
    }
  }
 else {
    Debug.stopMethodTracing();
  }
}

Fixed version (ground truth):
final void handleProfilerControl(boolean start,ProfilerControlData pcd){
  if (start) {
    try {
      Debug.startMethodTracing(pcd.path,pcd.fd.getFileDescriptor(),8 * 1024 * 1024,0);
    }
 catch (    RuntimeException e) {
      Log.w(TAG,"String_Node_Str" + pcd.path + "String_Node_Str");
    }
 finally {
      try {
        pcd.fd.close();
      }
 catch (      IOException e) {
        Log.w(TAG,"String_Node_Str",e);
      }
    }
  }
 else {
    Debug.stopMethodTracing();
  }
}
Program: 183518
Project: 183518
Buggy source:
public void profilerControl(boolean start,String path){
  queueOrSendMessage(H.PROFILER_CONTROL,path,start ? 1 : 0);
}

Fixed version (ground truth):
public void profilerControl(boolean start,String path,ParcelFileDescriptor fd){
  ProfilerControlData pcd=new ProfilerControlData();
  pcd.path=path;
  pcd.fd=fd;
  queueOrSendMessage(H.PROFILER_CONTROL,pcd,start ? 1 : 0);
}
Program: 183521
Project: 183521
Buggy source:
public void profilerControl(boolean start,String path) throws RemoteException {
  Parcel data=Parcel.obtain();
  data.writeInterfaceToken(IApplicationThread.descriptor);
  data.writeInt(start ? 1 : 0);
  data.writeString(path);
  mRemote.transact(PROFILER_CONTROL_TRANSACTION,data,null,IBinder.FLAG_ONEWAY);
  data.recycle();
}

Fixed version (ground truth):
public void profilerControl(boolean start,String path,ParcelFileDescriptor fd) throws RemoteException {
  Parcel data=Parcel.obtain();
  data.writeInterfaceToken(IApplicationThread.descriptor);
  data.writeInt(start ? 1 : 0);
  data.writeString(path);
  if (fd != null) {
    data.writeInt(1);
    fd.writeToParcel(data,Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
  }
 else {
    data.writeInt(0);
  }
  mRemote.transact(PROFILER_CONTROL_TRANSACTION,data,null,IBinder.FLAG_ONEWAY);
  data.recycle();
}
Program: 183522
Project: 183522
Buggy source:
public boolean profileControl(String process,boolean start,String path) throws RemoteException ;

Fixed version (ground truth):
public boolean profileControl(String process,boolean start,String path,ParcelFileDescriptor fd) throws RemoteException ;
Program: 183523
Project: 183523
Buggy source:
void profilerControl(boolean start,String path) throws RemoteException ;

Fixed version (ground truth):
void profilerControl(boolean start,String path,ParcelFileDescriptor fd) throws RemoteException ;
Program: 183524
Project: 183524
Buggy source:
/** 
 * Start method tracing, specifying the trace log file name and the buffer size. The trace files will be put under "/sdcard" unless an absolute path is given. See <a href="  {@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Log Viewer</a> for information about reading trace files. <p> When method tracing is enabled, the VM will run more slowly than usual, so the timings from the trace files should only be considered in relative terms (e.g. was run #1 faster than run #2).  The times for native methods will not change, so don't try to use this to compare the performance of interpreted and native implementations of the same method.  As an alternative, consider using "native" tracing in the emulator via   {@link #startNativeTracing()}. </p>
 * @param traceName    Name for the trace log file to create.If no name argument is given, this value defaults to "/sdcard/dmtrace.trace". If the files already exist, they will be truncated. If the trace file given does not end in ".trace", it will be appended for you.
 * @param bufferSize    The maximum amount of trace data we gather. If not given, it defaults to 8MB.
 */
public static void startMethodTracing(String traceName,int bufferSize,int flags){
  String pathName=traceName;
  if (pathName.charAt(0) != '/')   pathName=DEFAULT_TRACE_PATH_PREFIX + pathName;
  if (!pathName.endsWith(DEFAULT_TRACE_EXTENSION))   pathName=pathName + DEFAULT_TRACE_EXTENSION;
  VMDebug.startMethodTracing(pathName,bufferSize,flags);
}

Fixed version (ground truth):
/** 
 * Like startMethodTracing(String, int, int), but taking an already-opened FileDescriptor in which the trace is written.  The file name is also supplied simply for logging.  Makes a dup of the file descriptor. Not exposed in the SDK unless we are really comfortable with supporting this and find it would be useful.
 * @hide
 */
public static void startMethodTracing(String traceName,FileDescriptor fd,int bufferSize,int flags){
  VMDebug.startMethodTracing(traceName,fd,bufferSize,flags);
}
Program: 183525
Project: 183525
Buggy source:
public boolean profileControl(String process,boolean start,String path) throws RemoteException {
synchronized (this) {
    if (checkCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER) != PackageManager.PERMISSION_GRANTED) {
      throw new SecurityException("String_Node_Str" + android.Manifest.permission.SET_ACTIVITY_WATCHER);
    }
    ProcessRecord proc=null;
    try {
      int pid=Integer.parseInt(process);
synchronized (mPidsSelfLocked) {
        proc=mPidsSelfLocked.get(pid);
      }
    }
 catch (    NumberFormatException e) {
    }
    if (proc == null) {
      HashMap<String,SparseArray<ProcessRecord>> all=mProcessNames.getMap();
      SparseArray<ProcessRecord> procs=all.get(process);
      if (procs != null && procs.size() > 0) {
        proc=procs.valueAt(0);
      }
    }
    if (proc == null || proc.thread == null) {
      throw new IllegalArgumentException("String_Node_Str" + process);
    }
    boolean isSecure="String_Node_Str".equals(SystemProperties.get(SYSTEM_SECURE,"String_Node_Str"));
    if (isSecure) {
      if ((proc.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
        throw new SecurityException("String_Node_Str" + proc);
      }
    }
    try {
      proc.thread.profilerControl(start,path);
      return true;
    }
 catch (    RemoteException e) {
      throw new IllegalStateException("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public boolean profileControl(String process,boolean start,String path,ParcelFileDescriptor fd) throws RemoteException {
  try {
synchronized (this) {
      if (checkCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER) != PackageManager.PERMISSION_GRANTED) {
        throw new SecurityException("String_Node_Str" + android.Manifest.permission.SET_ACTIVITY_WATCHER);
      }
      if (start && fd == null) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      ProcessRecord proc=null;
      try {
        int pid=Integer.parseInt(process);
synchronized (mPidsSelfLocked) {
          proc=mPidsSelfLocked.get(pid);
        }
      }
 catch (      NumberFormatException e) {
      }
      if (proc == null) {
        HashMap<String,SparseArray<ProcessRecord>> all=mProcessNames.getMap();
        SparseArray<ProcessRecord> procs=all.get(process);
        if (procs != null && procs.size() > 0) {
          proc=procs.valueAt(0);
        }
      }
      if (proc == null || proc.thread == null) {
        throw new IllegalArgumentException("String_Node_Str" + process);
      }
      boolean isSecure="String_Node_Str".equals(SystemProperties.get(SYSTEM_SECURE,"String_Node_Str"));
      if (isSecure) {
        if ((proc.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
          throw new SecurityException("String_Node_Str" + proc);
        }
      }
      proc.thread.profilerControl(start,path,fd);
      fd=null;
      return true;
    }
  }
 catch (  RemoteException e) {
    throw new IllegalStateException("String_Node_Str");
  }
 finally {
    if (fd != null) {
      try {
        fd.close();
      }
 catch (      IOException e) {
      }
    }
  }
}
Program: 183526
Project: 183526
Buggy source:
private void runProfile(){
  String profileFile=null;
  boolean start=false;
  String process=nextArg();
  if (process == null) {
    System.err.println("String_Node_Str");
    showUsage();
    return;
  }
  String cmd=nextArg();
  if ("String_Node_Str".equals(cmd)) {
    start=true;
    profileFile=nextArg();
    if (profileFile == null) {
      System.err.println("String_Node_Str");
      showUsage();
      return;
    }
  }
 else   if (!"String_Node_Str".equals(cmd)) {
    System.err.println("String_Node_Str" + cmd + "String_Node_Str");
    showUsage();
    return;
  }
  try {
    if (!mAm.profileControl(process,start,profileFile)) {
      System.out.println("String_Node_Str" + process);
      return;
    }
  }
 catch (  IllegalArgumentException e) {
    System.out.println("String_Node_Str" + e.getMessage());
    return;
  }
catch (  IllegalStateException e) {
    System.out.println("String_Node_Str" + e.getMessage());
    return;
  }
catch (  RemoteException e) {
    System.out.println("String_Node_Str");
    return;
  }
}

Fixed version (ground truth):
private void runProfile(){
  String profileFile=null;
  boolean start=false;
  String process=nextArg();
  if (process == null) {
    System.err.println("String_Node_Str");
    showUsage();
    return;
  }
  ParcelFileDescriptor fd=null;
  String cmd=nextArg();
  if ("String_Node_Str".equals(cmd)) {
    start=true;
    profileFile=nextArg();
    if (profileFile == null) {
      System.err.println("String_Node_Str");
      showUsage();
      return;
    }
    try {
      fd=ParcelFileDescriptor.open(new File(profileFile),ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_TRUNCATE | ParcelFileDescriptor.MODE_READ_WRITE);
    }
 catch (    FileNotFoundException e) {
      System.err.println("String_Node_Str" + profileFile);
      return;
    }
  }
 else   if (!"String_Node_Str".equals(cmd)) {
    System.err.println("String_Node_Str" + cmd + "String_Node_Str");
    showUsage();
    return;
  }
  try {
    if (!mAm.profileControl(process,start,profileFile,fd)) {
      System.err.println("String_Node_Str" + process);
      return;
    }
  }
 catch (  IllegalArgumentException e) {
    System.out.println("String_Node_Str" + e.getMessage());
    return;
  }
catch (  IllegalStateException e) {
    System.out.println("String_Node_Str" + e.getMessage());
    return;
  }
catch (  RemoteException e) {
    System.out.println("String_Node_Str");
    return;
  }
}
Program: 183528
Project: 183528
Buggy source:
public boolean profileControl(String process,boolean start,String path) throws RemoteException {
  Parcel data=Parcel.obtain();
  Parcel reply=Parcel.obtain();
  data.writeInterfaceToken(IActivityManager.descriptor);
  data.writeString(process);
  data.writeInt(start ? 1 : 0);
  data.writeString(path);
  mRemote.transact(PROFILE_CONTROL_TRANSACTION,data,reply,0);
  reply.readException();
  boolean res=reply.readInt() != 0;
  reply.recycle();
  data.recycle();
  return res;
}

Fixed version (ground truth):
public boolean profileControl(String process,boolean start,String path,ParcelFileDescriptor fd) throws RemoteException {
  Parcel data=Parcel.obtain();
  Parcel reply=Parcel.obtain();
  data.writeInterfaceToken(IActivityManager.descriptor);
  data.writeString(process);
  data.writeInt(start ? 1 : 0);
  data.writeString(path);
  if (fd != null) {
    data.writeInt(1);
    fd.writeToParcel(data,Parcelable.PARCELABLE_WRITE_RETURN_VALUE);
  }
 else {
    data.writeInt(0);
  }
  mRemote.transact(PROFILE_CONTROL_TRANSACTION,data,reply,0);
  reply.readException();
  boolean res=reply.readInt() != 0;
  reply.recycle();
  data.recycle();
  return res;
}
Program: 183529
Project: 183529
Buggy source:
final void handleProfilerControl(boolean start,String path){
  if (start) {
    File file=new File(path);
    file.getParentFile().mkdirs();
    try {
      Debug.startMethodTracing(file.toString(),8 * 1024 * 1024);
    }
 catch (    RuntimeException e) {
      Log.w(TAG,"String_Node_Str" + path + "String_Node_Str");
    }
  }
 else {
    Debug.stopMethodTracing();
  }
}

Fixed version (ground truth):
final void handleProfilerControl(boolean start,ProfilerControlData pcd){
  if (start) {
    try {
      Debug.startMethodTracing(pcd.path,pcd.fd.getFileDescriptor(),8 * 1024 * 1024,0);
    }
 catch (    RuntimeException e) {
      Log.w(TAG,"String_Node_Str" + pcd.path + "String_Node_Str");
    }
 finally {
      try {
        pcd.fd.close();
      }
 catch (      IOException e) {
        Log.w(TAG,"String_Node_Str",e);
      }
    }
  }
 else {
    Debug.stopMethodTracing();
  }
}
Program: 183530
Project: 183530
Buggy source:
public void profilerControl(boolean start,String path){
  queueOrSendMessage(H.PROFILER_CONTROL,path,start ? 1 : 0);
}

Fixed version (ground truth):
public void profilerControl(boolean start,String path,ParcelFileDescriptor fd){
  ProfilerControlData pcd=new ProfilerControlData();
  pcd.path=path;
  pcd.fd=fd;
  queueOrSendMessage(H.PROFILER_CONTROL,pcd,start ? 1 : 0);
}