nus-yam/ex-repair huggingface dataset:
Program: 24021
Project: 24021
Buggy source:
private void silence(final SpeechItem speechItem){
class SilenceThread implements Runnable {
    public void run(){
      String utteranceId="String_Node_Str";
      if (speechItem.mParams != null) {
        for (int i=0; i < speechItem.mParams.size() - 1; i=i + 2) {
          String param=speechItem.mParams.get(i);
          if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)) {
            utteranceId=speechItem.mParams.get(i + 1);
          }
        }
      }
      try {
        Thread.sleep(speechItem.mDuration);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
 finally {
        if (utteranceId.length() > 0) {
          dispatchUtteranceCompletedCallback(utteranceId,speechItem.mCallingApp);
        }
        mCurrentSpeechItem=null;
        processSpeechQueue();
      }
    }
  }
  Thread slnc=(new Thread(new SilenceThread()));
  slnc.setPriority(Thread.MIN_PRIORITY);
  slnc.start();
}

Fixed version (ground truth):
private void silence(final SpeechItem speechItem){
class SilenceThread implements Runnable {
    public void run(){
      String utteranceId="String_Node_Str";
      if (speechItem.mParams != null) {
        for (int i=0; i < speechItem.mParams.size() - 1; i=i + 2) {
          String param=speechItem.mParams.get(i);
          if (param.equals(TextToSpeech.Engine.TTS_KEY_PARAM_UTTERANCE_ID)) {
            utteranceId=speechItem.mParams.get(i + 1);
          }
        }
      }
      try {
        Thread.sleep(speechItem.mDuration);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
 finally {
        if (utteranceId.length() > 0) {
          dispatchUtteranceCompletedCallback(utteranceId,speechItem.mCallingApp);
        }
        processSpeechQueue();
      }
    }
  }
  Thread slnc=(new Thread(new SilenceThread()));
  slnc.setPriority(Thread.MIN_PRIORITY);
  slnc.start();
}
Program: 24024
Project: 24024
Buggy source:
public void onChanged(NumberPicker picker,int oldVal,int newVal){
  mYear=newVal;
  if (mOnDateChangedListener != null) {
    mOnDateChangedListener.onDateChanged(DatePicker.this,mYear,mMonth,mDay);
  }
}

Fixed version (ground truth):
public void onChanged(NumberPicker picker,int oldVal,int newVal){
  mYear=newVal;
  adjustMaxDay();
  if (mOnDateChangedListener != null) {
    mOnDateChangedListener.onDateChanged(DatePicker.this,mYear,mMonth,mDay);
  }
  updateDaySpinner();
}
Program: 24026
Project: 24026
Buggy source:
private void validateCurrentView(CharSequence str){
  int val=getSelectedPos(str.toString());
  if ((val >= mStart) && (val <= mEnd)) {
    mPrevious=mCurrent;
    mCurrent=val;
    notifyChange();
  }
  updateView();
}

Fixed version (ground truth):
private void validateCurrentView(CharSequence str){
  int val=getSelectedPos(str.toString());
  if ((val >= mStart) && (val <= mEnd)) {
    if (mCurrent != val) {
      mPrevious=mCurrent;
      mCurrent=val;
      notifyChange();
    }
  }
  updateView();
}
Program: 24027
Project: 24027
Buggy source:
private String makeUriString(){
  StringBuilder builder=new StringBuilder();
  if (scheme != null) {
    builder.append(scheme).append(':');
  }
  appendSspTo(builder);
  if (fragment != null && !fragment.isEmpty()) {
    builder.append('#').append(fragment.getEncoded());
  }
  return builder.toString();
}

Fixed version (ground truth):
private String makeUriString(){
  StringBuilder builder=new StringBuilder();
  if (scheme != null) {
    builder.append(scheme).append(':');
  }
  appendSspTo(builder);
  if (!fragment.isEmpty()) {
    builder.append('#').append(fragment.getEncoded());
  }
  return builder.toString();
}
Program: 24028
Project: 24028
Buggy source:
/** 
 * Searches the query string for parameter values with the given key.
 * @param key which will be encoded
 * @throws UnsupportedOperationException if this isn't a hierarchical URI
 * @throws NullPointerException if key is null
 * @return a list of decoded values
 */
public List<String> getQueryParameters(String key){
  if (isOpaque()) {
    throw new UnsupportedOperationException(NOT_HIERARCHICAL);
  }
  String query=getQuery();
  if (query == null) {
    return Collections.emptyList();
  }
  String encodedKey;
  try {
    encodedKey=URLEncoder.encode(key,DEFAULT_ENCODING);
  }
 catch (  UnsupportedEncodingException e) {
    throw new AssertionError(e);
  }
  query="String_Node_Str" + query;
  String prefix="String_Node_Str" + encodedKey + "String_Node_Str";
  ArrayList<String> values=new ArrayList<String>();
  int start=0;
  int length=query.length();
  while (start < length) {
    start=query.indexOf(prefix,start);
    if (start == -1) {
      break;
    }
    start+=prefix.length();
    int end=query.indexOf('&',start);
    if (end == -1) {
      end=query.length();
    }
    String value=query.substring(start,end);
    values.add(decode(value));
    start=end;
  }
  return Collections.unmodifiableList(values);
}

Fixed version (ground truth):
/** 
 * Searches the query string for parameter values with the given key.
 * @param key which will be encoded
 * @throws UnsupportedOperationException if this isn't a hierarchical URI
 * @throws NullPointerException if key is null
 * @return a list of decoded values
 */
public List<String> getQueryParameters(String key){
  if (isOpaque()) {
    throw new UnsupportedOperationException(NOT_HIERARCHICAL);
  }
  String query=getEncodedQuery();
  if (query == null) {
    return Collections.emptyList();
  }
  String encodedKey;
  try {
    encodedKey=URLEncoder.encode(key,DEFAULT_ENCODING);
  }
 catch (  UnsupportedEncodingException e) {
    throw new AssertionError(e);
  }
  query="String_Node_Str" + query;
  String prefix="String_Node_Str" + encodedKey + "String_Node_Str";
  ArrayList<String> values=new ArrayList<String>();
  int start=0;
  int length=query.length();
  while (start < length) {
    start=query.indexOf(prefix,start);
    if (start == -1) {
      break;
    }
    start+=prefix.length();
    int end=query.indexOf('&',start);
    if (end == -1) {
      end=query.length();
    }
    String value=query.substring(start,end);
    values.add(decode(value));
    start=end;
  }
  return Collections.unmodifiableList(values);
}
Program: 24029
Project: 24029
Buggy source:
/** 
 * Searches the query string for the first value with the given key.
 * @param key which will be encoded
 * @throws UnsupportedOperationException if this isn't a hierarchical URI
 * @throws NullPointerException if key is null
 * @return the decoded value or null if no parameter is found
 */
public String getQueryParameter(String key){
  if (isOpaque()) {
    throw new UnsupportedOperationException(NOT_HIERARCHICAL);
  }
  String query=getQuery();
  if (query == null) {
    return null;
  }
  String encodedKey;
  try {
    encodedKey=URLEncoder.encode(key,DEFAULT_ENCODING);
  }
 catch (  UnsupportedEncodingException e) {
    throw new AssertionError(e);
  }
  String prefix=encodedKey + "String_Node_Str";
  if (query.length() < prefix.length()) {
    return null;
  }
  int start;
  if (query.startsWith(prefix)) {
    start=prefix.length();
  }
 else {
    prefix="String_Node_Str" + prefix;
    start=query.indexOf(prefix);
    if (start == -1) {
      return null;
    }
    start+=prefix.length();
  }
  int end=query.indexOf('&',start);
  if (end == -1) {
    end=query.length();
  }
  String value=query.substring(start,end);
  return decode(value);
}

Fixed version (ground truth):
/** 
 * Searches the query string for the first value with the given key.
 * @param key which will be encoded
 * @throws UnsupportedOperationException if this isn't a hierarchical URI
 * @throws NullPointerException if key is null
 * @return the decoded value or null if no parameter is found
 */
public String getQueryParameter(String key){
  if (isOpaque()) {
    throw new UnsupportedOperationException(NOT_HIERARCHICAL);
  }
  String query=getEncodedQuery();
  if (query == null) {
    return null;
  }
  String encodedKey;
  try {
    encodedKey=URLEncoder.encode(key,DEFAULT_ENCODING);
  }
 catch (  UnsupportedEncodingException e) {
    throw new AssertionError(e);
  }
  String prefix=encodedKey + "String_Node_Str";
  if (query.length() < prefix.length()) {
    return null;
  }
  int start;
  if (query.startsWith(prefix)) {
    start=prefix.length();
  }
 else {
    prefix="String_Node_Str" + prefix;
    start=query.indexOf(prefix);
    if (start == -1) {
      return null;
    }
    start+=prefix.length();
  }
  int end=query.indexOf('&',start);
  if (end == -1) {
    end=query.length();
  }
  String value=query.substring(start,end);
  return decode(value);
}
Program: 24030
Project: 24030
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: 24031
Project: 24031
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: 24032
Project: 24032
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: 24033
Project: 24033
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: 24034
Project: 24034
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: 24035
Project: 24035
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: 24036
Project: 24036
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: 24037
Project: 24037
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: 24039
Project: 24039
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: 24040
Project: 24040
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: 24041
Project: 24041
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: 24042
Project: 24042
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: 24043
Project: 24043
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: 24044
Project: 24044
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: 24045
Project: 24045
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: 24046
Project: 24046
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: 24047
Project: 24047
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: 24049
Project: 24049
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: 24050
Project: 24050
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: 24051
Project: 24051
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: 24052
Project: 24052
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: 24053
Project: 24053
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: 24058
Project: 24058
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: 24059
Project: 24059
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: 24060
Project: 24060
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: 24061
Project: 24061
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: 24062
Project: 24062
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: 24063
Project: 24063
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: 24065
Project: 24065
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: 24067
Project: 24067
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: 24068
Project: 24068
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: 24069
Project: 24069
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: 24072
Project: 24072
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: 24073
Project: 24073
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: 24074
Project: 24074
Buggy source:
void profilerControl(boolean start,String path) throws RemoteException ;

Fixed version (ground truth):
void profilerControl(boolean start,String path,ParcelFileDescriptor fd) throws RemoteException ;