nus-yam/ex-repair huggingface dataset:
Program: 183586
Project: 183586
Buggy source:
@Override public void onBackup(ParcelFileDescriptor oldState,BackupDataOutput data,ParcelFileDescriptor newState){
  LinkedList<File> dirsToScan=new LinkedList<File>();
  ArrayList<String> allFiles=new ArrayList<String>();
  dirsToScan.add(getFilesDir());
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + getFilesDir().getAbsolutePath() + "String_Node_Str");
  while (dirsToScan.size() > 0) {
    File dir=dirsToScan.removeFirst();
    File[] contents=dir.listFiles();
    if (contents != null) {
      for (      File f : contents) {
        if (f.isDirectory()) {
          dirsToScan.add(f);
        }
 else         if (f.isFile()) {
          if (DEBUG)           Log.v(TAG,"String_Node_Str" + f.getAbsolutePath());
          allFiles.add(f.getAbsolutePath());
        }
      }
    }
  }
  FileBackupHelper.performBackup(this,oldState,data,newState,(String[])allFiles.toArray());
}

Fixed version (ground truth):
@Override public void onBackup(ParcelFileDescriptor oldState,BackupDataOutput data,ParcelFileDescriptor newState){
  LinkedList<File> dirsToScan=new LinkedList<File>();
  ArrayList<String> allFiles=new ArrayList<String>();
  dirsToScan.add(getFilesDir());
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + getFilesDir().getAbsolutePath() + "String_Node_Str");
  while (dirsToScan.size() > 0) {
    File dir=dirsToScan.removeFirst();
    File[] contents=dir.listFiles();
    if (contents != null) {
      for (      File f : contents) {
        if (f.isDirectory()) {
          dirsToScan.add(f);
        }
 else         if (f.isFile()) {
          if (DEBUG)           Log.v(TAG,"String_Node_Str" + f.getAbsolutePath());
          allFiles.add(f.getAbsolutePath());
        }
      }
    }
  }
  FileBackupHelper helper=new FileBackupHelper(this);
  helper.performBackup(oldState,data,newState,(String[])allFiles.toArray());
}
Program: 183587
Project: 183587
Buggy source:
/** 
 * Based on oldState, determine which of the files from the application's data directory need to be backed up, write them to the data stream, and fill in newState with the state as it exists now.
 */
public static void performBackup(Context context,ParcelFileDescriptor oldState,BackupDataOutput data,ParcelFileDescriptor newState,String[] files){
  File base=context.getFilesDir();
  final int N=files.length;
  String[] fullPaths=new String[N];
  for (int i=0; i < N; i++) {
    fullPaths[i]=(new File(base,files[i])).getAbsolutePath();
  }
  performBackup_checked(oldState,data,newState,fullPaths,files);
}

Fixed version (ground truth):
/** 
 * Based on oldState, determine which of the files from the application's data directory need to be backed up, write them to the data stream, and fill in newState with the state as it exists now.
 */
public void performBackup(ParcelFileDescriptor oldState,BackupDataOutput data,ParcelFileDescriptor newState,String[] files){
  File base=mContext.getFilesDir();
  final int N=files.length;
  String[] fullPaths=new String[N];
  for (int i=0; i < N; i++) {
    fullPaths[i]=(new File(base,files[i])).getAbsolutePath();
  }
  String[] keys=makeKeys(mKeyPrefix,files);
  performBackup_checked(oldState,data,newState,fullPaths,keys);
}
Program: 183588
Project: 183588
Buggy source:
public static void performBackup(Context context,ParcelFileDescriptor oldSnapshot,ParcelFileDescriptor newSnapshot,BackupDataOutput data,String[] prefGroups){
  final int N=prefGroups.length;
  String[] files=new String[N];
  for (int i=0; i < N; i++) {
    files[i]=context.getSharedPrefsFile(prefGroups[i]).toString();
  }
  FileBackupHelper.performBackup_checked(oldSnapshot,data,newSnapshot,files,prefGroups);
}

Fixed version (ground truth):
public void performBackup(ParcelFileDescriptor oldSnapshot,ParcelFileDescriptor newSnapshot,BackupDataOutput data,String[] prefGroups){
  Context context=mContext;
  final int N=prefGroups.length;
  String[] files=new String[N];
  for (int i=0; i < N; i++) {
    files[i]=context.getSharedPrefsFile(prefGroups[i]).getAbsolutePath();
  }
  String[] keys=FileBackupHelper.makeKeys(mKeyPrefix,prefGroups);
  FileBackupHelper.performBackup_checked(oldSnapshot,data,newSnapshot,files,prefGroups);
}
Program: 183589
Project: 183589
Buggy source:
public final void finishSubActivity(IBinder token,String resultWho,int requestCode){
synchronized (this) {
    int index=indexOfTokenLocked(token,false);
    if (index < 0) {
      return;
    }
    HistoryRecord self=(HistoryRecord)mHistory.get(index);
    final long origId=Binder.clearCallingIdentity();
    int i;
    for (i=mHistory.size() - 1; i >= 0; i--) {
      HistoryRecord r=(HistoryRecord)mHistory.get(i);
      if (r.resultTo == self && r.requestCode == requestCode) {
        if ((r.resultWho == null && resultWho == null) || (r.resultWho != null && r.resultWho.equals(resultWho))) {
          finishActivityLocked(r,i,Activity.RESULT_CANCELED,null,"String_Node_Str");
        }
      }
    }
    Binder.restoreCallingIdentity(origId);
  }
}

Fixed version (ground truth):
public final void finishSubActivity(IBinder token,String resultWho,int requestCode){
synchronized (this) {
    int index=indexOfTokenLocked(token);
    if (index < 0) {
      return;
    }
    HistoryRecord self=(HistoryRecord)mHistory.get(index);
    final long origId=Binder.clearCallingIdentity();
    int i;
    for (i=mHistory.size() - 1; i >= 0; i--) {
      HistoryRecord r=(HistoryRecord)mHistory.get(i);
      if (r.resultTo == self && r.requestCode == requestCode) {
        if ((r.resultWho == null && resultWho == null) || (r.resultWho != null && r.resultWho.equals(resultWho))) {
          finishActivityLocked(r,i,Activity.RESULT_CANCELED,null,"String_Node_Str");
        }
      }
    }
    Binder.restoreCallingIdentity(origId);
  }
}
Program: 183591
Project: 183591
Buggy source:
public final void activityDestroyed(IBinder token){
  if (DEBUG_SWITCH)   Log.v(TAG,"String_Node_Str" + token);
synchronized (this) {
    mHandler.removeMessages(DESTROY_TIMEOUT_MSG,token);
    int index=indexOfTokenLocked(token,false);
    if (index >= 0) {
      HistoryRecord r=(HistoryRecord)mHistory.get(index);
      if (r.state == ActivityState.DESTROYING) {
        final long origId=Binder.clearCallingIdentity();
        removeActivityFromHistoryLocked(r);
        Binder.restoreCallingIdentity(origId);
      }
    }
  }
}

Fixed version (ground truth):
public final void activityDestroyed(IBinder token){
  if (DEBUG_SWITCH)   Log.v(TAG,"String_Node_Str" + token);
synchronized (this) {
    mHandler.removeMessages(DESTROY_TIMEOUT_MSG,token);
    int index=indexOfTokenLocked(token);
    if (index >= 0) {
      HistoryRecord r=(HistoryRecord)mHistory.get(index);
      if (r.state == ActivityState.DESTROYING) {
        final long origId=Binder.clearCallingIdentity();
        removeActivityFromHistoryLocked(r);
        Binder.restoreCallingIdentity(origId);
      }
    }
  }
}
Program: 183594
Project: 183594
Buggy source:
private final int indexOfTokenLocked(IBinder token,boolean required){
  int count=mHistory.size();
  HistoryRecord r=null;
  int index=-1;
  for (int i=count - 1; i >= 0; i--) {
    Object o=mHistory.get(i);
    if (o == token) {
      r=(HistoryRecord)o;
      index=i;
      break;
    }
  }
  if (index < 0 && required) {
    RuntimeInit.crash(TAG,new InvalidTokenException(token));
  }
  return index;
}

Fixed version (ground truth):
private final int indexOfTokenLocked(IBinder token){
  int count=mHistory.size();
  HistoryRecord r=null;
  int index=-1;
  for (int i=count - 1; i >= 0; i--) {
    Object o=mHistory.get(i);
    if (o == token) {
      r=(HistoryRecord)o;
      index=i;
      break;
    }
  }
  return index;
}
Program: 183595
Project: 183595
Buggy source:
public int getRequestedOrientation(IBinder token){
synchronized (this) {
    int index=indexOfTokenLocked(token,false);
    if (index < 0) {
      return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    }
    HistoryRecord r=(HistoryRecord)mHistory.get(index);
    return mWindowManager.getAppOrientation(r);
  }
}

Fixed version (ground truth):
public int getRequestedOrientation(IBinder token){
synchronized (this) {
    int index=indexOfTokenLocked(token);
    if (index < 0) {
      return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
    }
    HistoryRecord r=(HistoryRecord)mHistory.get(index);
    return mWindowManager.getAppOrientation(r);
  }
}
Program: 183596
Project: 183596
Buggy source:
public final void activityStopped(IBinder token,Bitmap thumbnail,CharSequence description){
  if (localLOGV)   Log.v(TAG,"String_Node_Str" + token);
  HistoryRecord r=null;
  final long origId=Binder.clearCallingIdentity();
synchronized (this) {
    int index=indexOfTokenLocked(token,false);
    if (index >= 0) {
      r=(HistoryRecord)mHistory.get(index);
      r.thumbnail=thumbnail;
      r.description=description;
      r.stopped=true;
      r.state=ActivityState.STOPPED;
      if (!r.finishing) {
        if (r.configDestroy) {
          destroyActivityLocked(r,true);
          resumeTopActivityLocked(null);
        }
      }
    }
  }
  if (r != null) {
    sendPendingThumbnail(r,null,null,null,false);
  }
  trimApplications();
  Binder.restoreCallingIdentity(origId);
}

Fixed version (ground truth):
public final void activityStopped(IBinder token,Bitmap thumbnail,CharSequence description){
  if (localLOGV)   Log.v(TAG,"String_Node_Str" + token);
  HistoryRecord r=null;
  final long origId=Binder.clearCallingIdentity();
synchronized (this) {
    int index=indexOfTokenLocked(token);
    if (index >= 0) {
      r=(HistoryRecord)mHistory.get(index);
      r.thumbnail=thumbnail;
      r.description=description;
      r.stopped=true;
      r.state=ActivityState.STOPPED;
      if (!r.finishing) {
        if (r.configDestroy) {
          destroyActivityLocked(r,true);
          resumeTopActivityLocked(null);
        }
      }
    }
  }
  if (r != null) {
    sendPendingThumbnail(r,null,null,null,false);
  }
  trimApplications();
  Binder.restoreCallingIdentity(origId);
}
Program: 183597
Project: 183597
Buggy source:
public void setRequestedOrientation(IBinder token,int requestedOrientation){
synchronized (this) {
    int index=indexOfTokenLocked(token,false);
    if (index < 0) {
      return;
    }
    HistoryRecord r=(HistoryRecord)mHistory.get(index);
    final long origId=Binder.clearCallingIdentity();
    mWindowManager.setAppOrientation(r,requestedOrientation);
    Configuration config=mWindowManager.updateOrientationFromAppTokens(mConfiguration,r.mayFreezeScreenLocked(r.app) ? r : null);
    if (config != null) {
      r.frozenBeforeDestroy=true;
      if (!updateConfigurationLocked(config,r)) {
        resumeTopActivityLocked(null);
      }
    }
    Binder.restoreCallingIdentity(origId);
  }
}

Fixed version (ground truth):
public void setRequestedOrientation(IBinder token,int requestedOrientation){
synchronized (this) {
    int index=indexOfTokenLocked(token);
    if (index < 0) {
      return;
    }
    HistoryRecord r=(HistoryRecord)mHistory.get(index);
    final long origId=Binder.clearCallingIdentity();
    mWindowManager.setAppOrientation(r,requestedOrientation);
    Configuration config=mWindowManager.updateOrientationFromAppTokens(mConfiguration,r.mayFreezeScreenLocked(r.app) ? r : null);
    if (config != null) {
      r.frozenBeforeDestroy=true;
      if (!updateConfigurationLocked(config,r)) {
        resumeTopActivityLocked(null);
      }
    }
    Binder.restoreCallingIdentity(origId);
  }
}
Program: 183598
Project: 183598
Buggy source:
public ComponentName getActivityClassForToken(IBinder token){
synchronized (this) {
    int index=indexOfTokenLocked(token,false);
    if (index >= 0) {
      HistoryRecord r=(HistoryRecord)mHistory.get(index);
      return r.intent.getComponent();
    }
    return null;
  }
}

Fixed version (ground truth):
public ComponentName getActivityClassForToken(IBinder token){
synchronized (this) {
    int index=indexOfTokenLocked(token);
    if (index >= 0) {
      HistoryRecord r=(HistoryRecord)mHistory.get(index);
      return r.intent.getComponent();
    }
    return null;
  }
}
Program: 183602
Project: 183602
Buggy source:
/** 
 * @return Returns true if the activity is being finished, false if forsome reason it is being left as-is.
 */
private final boolean requestFinishActivityLocked(IBinder token,int resultCode,Intent resultData,String reason){
  if (DEBUG_RESULTS)   Log.v(TAG,"String_Node_Str" + token + "String_Node_Str"+ resultCode+ "String_Node_Str"+ resultData);
  int index=indexOfTokenLocked(token,false);
  if (index < 0) {
    return false;
  }
  HistoryRecord r=(HistoryRecord)mHistory.get(index);
  boolean lastActivity=true;
  for (int i=mHistory.size() - 1; i >= 0; i--) {
    HistoryRecord p=(HistoryRecord)mHistory.get(i);
    if (!p.finishing && p != r) {
      lastActivity=false;
      break;
    }
  }
  if (lastActivity) {
    if (r.intent.hasCategory(Intent.CATEGORY_HOME)) {
      return false;
    }
  }
  finishActivityLocked(r,index,resultCode,resultData,reason);
  return true;
}

Fixed version (ground truth):
/** 
 * @return Returns true if the activity is being finished, false if forsome reason it is being left as-is.
 */
private final boolean requestFinishActivityLocked(IBinder token,int resultCode,Intent resultData,String reason){
  if (DEBUG_RESULTS)   Log.v(TAG,"String_Node_Str" + token + "String_Node_Str"+ resultCode+ "String_Node_Str"+ resultData);
  int index=indexOfTokenLocked(token);
  if (index < 0) {
    return false;
  }
  HistoryRecord r=(HistoryRecord)mHistory.get(index);
  boolean lastActivity=true;
  for (int i=mHistory.size() - 1; i >= 0; i--) {
    HistoryRecord p=(HistoryRecord)mHistory.get(i);
    if (!p.finishing && p != r) {
      lastActivity=false;
      break;
    }
  }
  if (lastActivity) {
    if (r.intent.hasCategory(Intent.CATEGORY_HOME)) {
      return false;
    }
  }
  finishActivityLocked(r,index,resultCode,resultData,reason);
  return true;
}
Program: 183603
Project: 183603
Buggy source:
private HistoryRecord getCallingRecordLocked(IBinder token){
  int index=indexOfTokenLocked(token,true);
  if (index >= 0) {
    HistoryRecord r=(HistoryRecord)mHistory.get(index);
    if (r != null) {
      return r.resultTo;
    }
  }
  return null;
}

Fixed version (ground truth):
private HistoryRecord getCallingRecordLocked(IBinder token){
  int index=indexOfTokenLocked(token);
  if (index >= 0) {
    HistoryRecord r=(HistoryRecord)mHistory.get(index);
    if (r != null) {
      return r.resultTo;
    }
  }
  return null;
}
Program: 183604
Project: 183604
Buggy source:
public String getPackageForToken(IBinder token){
synchronized (this) {
    int index=indexOfTokenLocked(token,false);
    if (index >= 0) {
      HistoryRecord r=(HistoryRecord)mHistory.get(index);
      return r.packageName;
    }
    return null;
  }
}

Fixed version (ground truth):
public String getPackageForToken(IBinder token){
synchronized (this) {
    int index=indexOfTokenLocked(token);
    if (index >= 0) {
      HistoryRecord r=(HistoryRecord)mHistory.get(index);
      return r.packageName;
    }
    return null;
  }
}
Program: 183606
Project: 183606
Buggy source:
final void sendPendingThumbnail(HistoryRecord r,IBinder token,Bitmap thumbnail,CharSequence description,boolean always){
  TaskRecord task=null;
  ArrayList receivers=null;
synchronized (this) {
    if (r == null) {
      int index=indexOfTokenLocked(token,false);
      if (index < 0) {
        return;
      }
      r=(HistoryRecord)mHistory.get(index);
    }
    if (thumbnail == null) {
      thumbnail=r.thumbnail;
      description=r.description;
    }
    if (thumbnail == null && !always) {
      return;
    }
    task=r.task;
    int N=mPendingThumbnails.size();
    int i=0;
    while (i < N) {
      PendingThumbnailsRecord pr=(PendingThumbnailsRecord)mPendingThumbnails.get(i);
      if (pr.pendingRecords.remove(r)) {
        if (receivers == null) {
          receivers=new ArrayList();
        }
        receivers.add(pr);
        if (pr.pendingRecords.size() == 0) {
          pr.finished=true;
          mPendingThumbnails.remove(i);
          N--;
          continue;
        }
      }
      i++;
    }
  }
  if (receivers != null) {
    final int N=receivers.size();
    for (int i=0; i < N; i++) {
      try {
        PendingThumbnailsRecord pr=(PendingThumbnailsRecord)receivers.get(i);
        pr.receiver.newThumbnail(task != null ? task.taskId : -1,thumbnail,description);
        if (pr.finished) {
          pr.receiver.finished();
        }
      }
 catch (      Exception e) {
        Log.w(TAG,"String_Node_Str",e);
      }
    }
  }
}

Fixed version (ground truth):
final void sendPendingThumbnail(HistoryRecord r,IBinder token,Bitmap thumbnail,CharSequence description,boolean always){
  TaskRecord task=null;
  ArrayList receivers=null;
synchronized (this) {
    if (r == null) {
      int index=indexOfTokenLocked(token);
      if (index < 0) {
        return;
      }
      r=(HistoryRecord)mHistory.get(index);
    }
    if (thumbnail == null) {
      thumbnail=r.thumbnail;
      description=r.description;
    }
    if (thumbnail == null && !always) {
      return;
    }
    task=r.task;
    int N=mPendingThumbnails.size();
    int i=0;
    while (i < N) {
      PendingThumbnailsRecord pr=(PendingThumbnailsRecord)mPendingThumbnails.get(i);
      if (pr.pendingRecords.remove(r)) {
        if (receivers == null) {
          receivers=new ArrayList();
        }
        receivers.add(pr);
        if (pr.pendingRecords.size() == 0) {
          pr.finished=true;
          mPendingThumbnails.remove(i);
          N--;
          continue;
        }
      }
      i++;
    }
  }
  if (receivers != null) {
    final int N=receivers.size();
    for (int i=0; i < N; i++) {
      try {
        PendingThumbnailsRecord pr=(PendingThumbnailsRecord)receivers.get(i);
        pr.receiver.newThumbnail(task != null ? task.taskId : -1,thumbnail,description);
        if (pr.finished) {
          pr.receiver.finished();
        }
      }
 catch (      Exception e) {
        Log.w(TAG,"String_Node_Str",e);
      }
    }
  }
}
Program: 183607
Project: 183607
Buggy source:
final void activityPaused(IBinder token,Bundle icicle,boolean timeout){
  if (DEBUG_PAUSE)   Log.v(TAG,"String_Node_Str" + token + "String_Node_Str"+ icicle+ "String_Node_Str"+ timeout);
  HistoryRecord r=null;
synchronized (this) {
    int index=indexOfTokenLocked(token,false);
    if (index >= 0) {
      r=(HistoryRecord)mHistory.get(index);
      if (!timeout) {
        r.icicle=icicle;
        r.haveState=true;
      }
      mHandler.removeMessages(PAUSE_TIMEOUT_MSG,r);
      if (mPausingActivity == r) {
        r.state=ActivityState.PAUSED;
        completePauseLocked();
      }
 else {
        EventLog.writeEvent(LOG_AM_FAILED_TO_PAUSE_ACTIVITY,System.identityHashCode(r),r.shortComponentName,mPausingActivity != null ? mPausingActivity.shortComponentName : "String_Node_Str");
      }
    }
  }
}

Fixed version (ground truth):
final void activityPaused(IBinder token,Bundle icicle,boolean timeout){
  if (DEBUG_PAUSE)   Log.v(TAG,"String_Node_Str" + token + "String_Node_Str"+ icicle+ "String_Node_Str"+ timeout);
  HistoryRecord r=null;
synchronized (this) {
    int index=indexOfTokenLocked(token);
    if (index >= 0) {
      r=(HistoryRecord)mHistory.get(index);
      if (!timeout) {
        r.icicle=icicle;
        r.haveState=true;
      }
      mHandler.removeMessages(PAUSE_TIMEOUT_MSG,r);
      if (mPausingActivity == r) {
        r.state=ActivityState.PAUSED;
        completePauseLocked();
      }
 else {
        EventLog.writeEvent(LOG_AM_FAILED_TO_PAUSE_ACTIVITY,System.identityHashCode(r),r.shortComponentName,mPausingActivity != null ? mPausingActivity.shortComponentName : "String_Node_Str");
      }
    }
  }
}
Program: 183608
Project: 183608
Buggy source:
public boolean isStreamAffectedByRingerMode(int streamType){
  int ringerModeAffectedStreams=Settings.System.getInt(mContentResolver,Settings.System.MODE_RINGER_STREAMS_AFFECTED,0);
  return (ringerModeAffectedStreams & (1 << streamType)) != 0;
}

Fixed version (ground truth):
public boolean isStreamAffectedByRingerMode(int streamType){
  return (mRingerModeAffectedStreams & (1 << streamType)) != 0;
}
Program: 183609
Project: 183609
Buggy source:
/** 
 * Sync the STREAM_RING and STREAM_NOTIFICATION volumes if mandated by the value in Settings.
 * @param streamType Type of the stream
 * @param index Volume index for the stream
 * @param force If true, set the volume even if the current and desiredvolume as same
 */
private void syncRingerAndNotificationStreamVolume(int streamType,int index,boolean force){
  boolean notificationsUseRingVolume=Settings.System.getInt(mContentResolver,Settings.System.NOTIFICATIONS_USE_RING_VOLUME,1) == 1;
  if (notificationsUseRingVolume) {
    if (streamType == AudioManager.STREAM_NOTIFICATION) {
      streamType=AudioManager.STREAM_RING;
    }
    if (streamType == AudioManager.STREAM_RING) {
      setStreamVolumeInt(AudioManager.STREAM_NOTIFICATION,index,force);
    }
  }
}

Fixed version (ground truth):
/** 
 * Sync the STREAM_RING and STREAM_NOTIFICATION volumes if mandated by the value in Settings.
 * @param streamType Type of the stream
 * @param index Volume index for the stream
 * @param force If true, set the volume even if the current and desiredvolume as same
 */
private void syncRingerAndNotificationStreamVolume(int streamType,int index,boolean force){
  boolean notificationsUseRingVolume=Settings.System.getInt(mContentResolver,Settings.System.NOTIFICATIONS_USE_RING_VOLUME,1) == 1;
  if (notificationsUseRingVolume) {
    if (streamType == AudioManager.STREAM_NOTIFICATION) {
      streamType=AudioManager.STREAM_RING;
    }
    if (streamType == AudioManager.STREAM_RING) {
      setStreamVolumeInt(AudioManager.STREAM_NOTIFICATION,index,force,true);
    }
  }
}
Program: 183610
Project: 183610
Buggy source:
@Override public void onChange(boolean selfChange){
  super.onChange(selfChange);
  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());
}
Program: 183611
Project: 183611
Buggy source:
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 */
private void setStreamVolumeInt(int streamType,int index,boolean force){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.setIndex(index) || force) {
    if (streamState.muteCount() == 0) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.setIndex(index,lastAudible) || force) {
    if (streamState.muteCount() == 0) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
    }
  }
}
Program: 183612
Project: 183612
Buggy source:
public void mute(boolean state){
synchronized (mDeathHandlers) {
    if (state) {
      if (mMuteCount == 0) {
        try {
          mICallback.linkToDeath(this,0);
          mDeathHandlers.add(this);
          if (muteCount() == 0) {
            setIndex(0);
            sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
          }
        }
 catch (        RemoteException e) {
          binderDied();
          mDeathHandlers.notify();
          return;
        }
      }
 else {
        Log.w(TAG,"String_Node_Str" + mStreamType + "String_Node_Str");
      }
      mMuteCount++;
    }
 else {
      if (mMuteCount == 0) {
        Log.e(TAG,"String_Node_Str" + mStreamType);
      }
 else {
        mMuteCount--;
        if (mMuteCount == 0) {
          mDeathHandlers.remove(this);
          mICallback.unlinkToDeath(this,0);
          if (muteCount() == 0) {
            if (!isStreamAffectedByRingerMode(mStreamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
              setIndex(mLastAudibleIndex);
              sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
            }
          }
        }
      }
    }
    mDeathHandlers.notify();
  }
}

Fixed version (ground truth):
public void mute(boolean state){
synchronized (mDeathHandlers) {
    if (state) {
      if (mMuteCount == 0) {
        try {
          mICallback.linkToDeath(this,0);
          mDeathHandlers.add(this);
          if (muteCount() == 0) {
            setIndex(0,false);
            sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
          }
        }
 catch (        RemoteException e) {
          binderDied();
          mDeathHandlers.notify();
          return;
        }
      }
 else {
        Log.w(TAG,"String_Node_Str" + mStreamType + "String_Node_Str");
      }
      mMuteCount++;
    }
 else {
      if (mMuteCount == 0) {
        Log.e(TAG,"String_Node_Str" + mStreamType);
      }
 else {
        mMuteCount--;
        if (mMuteCount == 0) {
          mDeathHandlers.remove(this);
          mICallback.unlinkToDeath(this,0);
          if (muteCount() == 0) {
            if (!isStreamAffectedByRingerMode(mStreamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
              setIndex(mLastAudibleIndex,false);
              sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
            }
          }
        }
      }
    }
    mDeathHandlers.notify();
  }
}
Program: 183613
Project: 183613
Buggy source:
public boolean adjustIndex(int deltaIndex){
  return setIndex(mIndex + deltaIndex);
}

Fixed version (ground truth):
public boolean adjustIndex(int deltaIndex){
  return setIndex(mIndex + deltaIndex,true);
}
Program: 183614
Project: 183614
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);
    }
  }
 else {
    for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
      if (!isStreamAffectedByRingerMode(streamType))       continue;
      setStreamVolumeInt(streamType,0,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){
  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);
}
Program: 183615
Project: 183615
Buggy source:
public boolean setIndex(int index){
  int oldIndex=mIndex;
  mIndex=getValidIndex(index);
  if (oldIndex != mIndex) {
    if (mIndex > 0) {
      mLastAudibleIndex=mIndex;
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public boolean setIndex(int index,boolean lastAudible){
  int oldIndex=mIndex;
  mIndex=getValidIndex(index);
  if (oldIndex != mIndex) {
    if (lastAudible) {
      mLastAudibleIndex=mIndex;
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 183617
Project: 183617
Buggy source:
/** 
 * @see AudioManager#setMode(int) 
 */
public void setMode(int mode){
  if (!checkAudioSettingsPermission("String_Node_Str")) {
    return;
  }
synchronized (mSettingsLock) {
    if (mode != mMode) {
      if (AudioSystem.setMode(mode) == AudioSystem.AUDIO_STATUS_OK) {
        mMode=mode;
      }
    }
    int streamType=getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE);
    int index=mStreamStates[streamType].mIndex;
    syncRingerAndNotificationStreamVolume(streamType,index,true);
    setStreamVolumeInt(streamType,index,true);
  }
}

Fixed version (ground truth):
/** 
 * @see AudioManager#setMode(int) 
 */
public void setMode(int mode){
  if (!checkAudioSettingsPermission("String_Node_Str")) {
    return;
  }
synchronized (mSettingsLock) {
    if (mode != mMode) {
      if (AudioSystem.setMode(mode) == AudioSystem.AUDIO_STATUS_OK) {
        mMode=mode;
      }
    }
    int streamType=getActiveStreamType(AudioManager.USE_DEFAULT_STREAM_TYPE);
    int index=mStreamStates[streamType].mIndex;
    syncRingerAndNotificationStreamVolume(streamType,index,true);
    setStreamVolumeInt(streamType,index,true,true);
  }
}
Program: 183618
Project: 183618
Buggy source:
private void readPersistedSettings(){
  final ContentResolver cr=mContentResolver;
  mRingerMode=System.getInt(cr,System.MODE_RINGER,AudioManager.RINGER_MODE_NORMAL);
  mVibrateSetting=System.getInt(cr,System.VIBRATE_ON,0);
  mMuteAffectedStreams=System.getInt(cr,System.MUTE_STREAMS_AFFECTED,((1 << AudioSystem.STREAM_MUSIC) | (1 << AudioSystem.STREAM_RING) | (1 << AudioSystem.STREAM_SYSTEM)));
  broadcastRingerMode();
  broadcastVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
  broadcastVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION);
}

Fixed version (ground truth):
private void readPersistedSettings(){
  final ContentResolver cr=mContentResolver;
  mRingerMode=System.getInt(cr,System.MODE_RINGER,AudioManager.RINGER_MODE_NORMAL);
  mVibrateSetting=System.getInt(cr,System.VIBRATE_ON,0);
  mRingerModeAffectedStreams=Settings.System.getInt(cr,Settings.System.MODE_RINGER_STREAMS_AFFECTED,((1 << AudioManager.STREAM_RING) | (1 << AudioManager.STREAM_NOTIFICATION) | (1 << AudioManager.STREAM_SYSTEM)));
  mMuteAffectedStreams=System.getInt(cr,System.MUTE_STREAMS_AFFECTED,((1 << AudioSystem.STREAM_MUSIC) | (1 << AudioSystem.STREAM_RING) | (1 << AudioSystem.STREAM_SYSTEM)));
  broadcastRingerMode();
  broadcastVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
  broadcastVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION);
}
Program: 183619
Project: 183619
Buggy source:
/** 
 * @see AudioManager#setStreamVolume(int,int,int) 
 */
public void setStreamVolume(int streamType,int index,int flags){
  ensureValidStreamType(streamType);
  syncRingerAndNotificationStreamVolume(streamType,index,false);
  setStreamVolumeInt(streamType,index,false);
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType);
}

Fixed version (ground truth):
/** 
 * @see AudioManager#setStreamVolume(int,int,int) 
 */
public void setStreamVolume(int streamType,int index,int flags){
  ensureValidStreamType(streamType);
  syncRingerAndNotificationStreamVolume(streamType,index,false);
  setStreamVolumeInt(streamType,index,false,true);
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType);
}
Program: 183620
Project: 183620
Buggy source:
private void updateProviderListenersLocked(String provider,boolean enabled){
  int listeners=0;
  LocationProviderProxy p=mProvidersByName.get(provider);
  if (p == null) {
    return;
  }
  ArrayList<Receiver> deadReceivers=null;
  ArrayList<UpdateRecord> records=mRecordsByProvider.get(provider);
  if (records != null) {
    final int N=records.size();
    for (int i=0; i < N; i++) {
      UpdateRecord record=records.get(i);
      if (!record.mReceiver.callProviderEnabledLocked(provider,enabled)) {
        if (deadReceivers == null) {
          deadReceivers=new ArrayList<Receiver>();
          deadReceivers.add(record.mReceiver);
        }
      }
      listeners++;
    }
  }
  if (deadReceivers != null) {
    for (int i=deadReceivers.size() - 1; i >= 0; i--) {
      removeUpdatesLocked(deadReceivers.get(i));
    }
  }
  if (enabled) {
    p.enable();
    if (listeners > 0) {
      p.setMinTime(getMinTimeLocked(provider));
      p.enableLocationTracking(true);
    }
  }
 else {
    p.enableLocationTracking(false);
    p.disable();
  }
}

Fixed version (ground truth):
private void updateProviderListenersLocked(String provider,boolean enabled){
  int listeners=0;
  LocationProviderProxy p=mProvidersByName.get(provider);
  if (p == null) {
    return;
  }
  ArrayList<Receiver> deadReceivers=null;
  ArrayList<UpdateRecord> records=mRecordsByProvider.get(provider);
  if (records != null) {
    final int N=records.size();
    for (int i=0; i < N; i++) {
      UpdateRecord record=records.get(i);
      if (!record.mReceiver.callProviderEnabledLocked(provider,enabled)) {
        if (deadReceivers == null) {
          deadReceivers=new ArrayList<Receiver>();
        }
        deadReceivers.add(record.mReceiver);
      }
      listeners++;
    }
  }
  if (deadReceivers != null) {
    for (int i=deadReceivers.size() - 1; i >= 0; i--) {
      removeUpdatesLocked(deadReceivers.get(i));
    }
  }
  if (enabled) {
    p.enable();
    if (listeners > 0) {
      p.setMinTime(getMinTimeLocked(provider));
      p.enableLocationTracking(true);
    }
  }
 else {
    p.enableLocationTracking(false);
    p.disable();
  }
}
Program: 183622
Project: 183622
Buggy source:
public void save(OutputStream stream,boolean closeStream) throws IOException {
  if (!mChanged) {
    return;
  }
  DataOutputStream out=null;
  try {
    long start;
    if (PROFILE_LOADING_SAVING) {
      start=SystemClock.elapsedRealtime();
    }
    final HashMap<String,ArrayList<Gesture>> maps=mNamedGestures;
    out=new DataOutputStream((stream instanceof BufferedOutputStream) ? out : new BufferedOutputStream(out,GestureConstants.IO_BUFFER_SIZE));
    out.writeShort(FILE_FORMAT_VERSION);
    out.writeInt(maps.size());
    for (    Map.Entry<String,ArrayList<Gesture>> entry : maps.entrySet()) {
      final String key=entry.getKey();
      final ArrayList<Gesture> examples=entry.getValue();
      final int count=examples.size();
      out.writeUTF(key);
      out.writeInt(count);
      for (int i=0; i < count; i++) {
        examples.get(i).serialize(out);
      }
    }
    out.flush();
    if (PROFILE_LOADING_SAVING) {
      long end=SystemClock.elapsedRealtime();
      Log.d(LOG_TAG,"String_Node_Str" + (end - start) + "String_Node_Str");
    }
    mChanged=false;
  }
  finally {
    if (closeStream)     GestureUtilities.closeStream(out);
  }
}

Fixed version (ground truth):
public void save(OutputStream stream,boolean closeStream) throws IOException {
  if (!mChanged) {
    return;
  }
  DataOutputStream out=null;
  try {
    long start;
    if (PROFILE_LOADING_SAVING) {
      start=SystemClock.elapsedRealtime();
    }
    final HashMap<String,ArrayList<Gesture>> maps=mNamedGestures;
    out=new DataOutputStream((stream instanceof BufferedOutputStream) ? stream : new BufferedOutputStream(stream,GestureConstants.IO_BUFFER_SIZE));
    out.writeShort(FILE_FORMAT_VERSION);
    out.writeInt(maps.size());
    for (    Map.Entry<String,ArrayList<Gesture>> entry : maps.entrySet()) {
      final String key=entry.getKey();
      final ArrayList<Gesture> examples=entry.getValue();
      final int count=examples.size();
      out.writeUTF(key);
      out.writeInt(count);
      for (int i=0; i < count; i++) {
        examples.get(i).serialize(out);
      }
    }
    out.flush();
    if (PROFILE_LOADING_SAVING) {
      long end=SystemClock.elapsedRealtime();
      Log.d(LOG_TAG,"String_Node_Str" + (end - start) + "String_Node_Str");
    }
    mChanged=false;
  }
  finally {
    if (closeStream)     GestureUtilities.closeStream(out);
  }
}
Program: 183623
Project: 183623
Buggy source:
@Override protected void runTest() throws Throwable {
  ReliabilityTestActivity activity=getActivity();
  LayoutTestsAutoRunner runner=(LayoutTestsAutoRunner)getInstrumentation();
  File testListFile=new File(TEST_LIST_FILE);
  if (!testListFile.exists())   throw new FileNotFoundException("String_Node_Str");
  BufferedReader listReader=new BufferedReader(new FileReader(testListFile));
  String lastUrl=readTestStatus();
  if (lastUrl != null && !TEST_DONE.equals(lastUrl))   fastForward(listReader,lastUrl);
  String url=null;
  Handler handler=null;
  boolean timeoutFlag=false;
  long start, elapsed;
  while ((url=listReader.readLine()) != null) {
    start=System.currentTimeMillis();
    Log.v(LOGTAG,"String_Node_Str" + url);
    updateTestStatus(url);
    activity.reset();
    handler=activity.getHandler();
    handler.sendMessage(handler.obtainMessage(ReliabilityTestActivity.MSG_NAVIGATE,runner.mTimeoutInMillis,0,url));
    timeoutFlag=activity.waitUntilDone();
    elapsed=System.currentTimeMillis() - start;
    if (elapsed < 1000) {
      Log.w(LOGTAG,"String_Node_Str" + elapsed + "String_Node_Str");
    }
 else {
      Log.v(LOGTAG,"String_Node_Str" + elapsed + "String_Node_Str");
    }
    if (timeoutFlag) {
      writeTimeoutFile(url);
    }
    System.runFinalization();
    System.gc();
    System.gc();
  }
  activity.finish();
  listReader.close();
}

Fixed version (ground truth):
@Override protected void runTest() throws Throwable {
  ReliabilityTestActivity activity=getActivity();
  LayoutTestsAutoRunner runner=(LayoutTestsAutoRunner)getInstrumentation();
  File testListFile=new File(TEST_LIST_FILE);
  if (!testListFile.exists())   throw new FileNotFoundException("String_Node_Str");
  BufferedReader listReader=new BufferedReader(new FileReader(testListFile));
  String lastUrl=readTestStatus();
  if (lastUrl != null && !TEST_DONE.equals(lastUrl))   fastForward(listReader,lastUrl);
  String url=null;
  Handler handler=null;
  boolean timeoutFlag=false;
  long start, elapsed;
  while ((url=listReader.readLine()) != null) {
    start=System.currentTimeMillis();
    Log.v(LOGTAG,"String_Node_Str" + url);
    updateTestStatus(url);
    activity.reset();
    handler=activity.getHandler();
    handler.sendMessage(handler.obtainMessage(ReliabilityTestActivity.MSG_NAVIGATE,runner.mTimeoutInMillis,0,url));
    timeoutFlag=activity.waitUntilDone();
    elapsed=System.currentTimeMillis() - start;
    if (elapsed < 1000) {
      Log.w(LOGTAG,"String_Node_Str" + elapsed + "String_Node_Str");
    }
 else {
      Log.v(LOGTAG,"String_Node_Str" + elapsed + "String_Node_Str");
    }
    if (timeoutFlag) {
      writeTimeoutFile(url);
    }
    System.runFinalization();
    System.gc();
    System.gc();
  }
  updateTestStatus(TEST_DONE);
  activity.finish();
  listReader.close();
}
Program: 183624
Project: 183624
Buggy source:
private void readFormatV1(DataInputStream in) throws IOException {
  final Learner classifier=mClassifier;
  final HashMap<String,ArrayList<Gesture>> namedGestures=mNamedGestures;
  namedGestures.clear();
  final int entriesCount=in.readInt();
  for (int i=0; i < entriesCount; i++) {
    final String name=in.readUTF();
    final int gestureCount=in.readInt();
    final ArrayList<Gesture> gestures=new ArrayList<Gesture>(gestureCount);
    for (int j=0; j < gestureCount; j++) {
      final Gesture gesture=Gesture.deserialize(in);
      gestures.add(gesture);
      classifier.addInstance(Instance.createInstance(mSequenceType,gesture,name));
    }
    namedGestures.put(name,gestures);
  }
}

Fixed version (ground truth):
private void readFormatV1(DataInputStream in) throws IOException {
  final Learner classifier=mClassifier;
  final HashMap<String,ArrayList<Gesture>> namedGestures=mNamedGestures;
  namedGestures.clear();
  final int entriesCount=in.readInt();
  for (int i=0; i < entriesCount; i++) {
    final String name=in.readUTF();
    final int gestureCount=in.readInt();
    final ArrayList<Gesture> gestures=new ArrayList<Gesture>(gestureCount);
    for (int j=0; j < gestureCount; j++) {
      final Gesture gesture=Gesture.deserialize(in);
      gestures.add(gesture);
      classifier.addInstance(Instance.createInstance(mSequenceType,mOrientationStyle,gesture,name));
    }
    namedGestures.put(name,gestures);
  }
}
Program: 183625
Project: 183625
Buggy source:
/** 
 * Add a gesture for the entry
 * @param entryName entry name
 * @param gesture
 */
public void addGesture(String entryName,Gesture gesture){
  if (entryName == null || entryName.length() == 0) {
    return;
  }
  ArrayList<Gesture> gestures=mNamedGestures.get(entryName);
  if (gestures == null) {
    gestures=new ArrayList<Gesture>();
    mNamedGestures.put(entryName,gestures);
  }
  gestures.add(gesture);
  mClassifier.addInstance(Instance.createInstance(mSequenceType,gesture,entryName));
  mChanged=true;
}

Fixed version (ground truth):
/** 
 * Add a gesture for the entry
 * @param entryName entry name
 * @param gesture
 */
public void addGesture(String entryName,Gesture gesture){
  if (entryName == null || entryName.length() == 0) {
    return;
  }
  ArrayList<Gesture> gestures=mNamedGestures.get(entryName);
  if (gestures == null) {
    gestures=new ArrayList<Gesture>();
    mNamedGestures.put(entryName,gestures);
  }
  gestures.add(gesture);
  mClassifier.addInstance(Instance.createInstance(mSequenceType,mOrientationStyle,gesture,entryName));
  mChanged=true;
}
Program: 183626
Project: 183626
Buggy source:
/** 
 * Recognize a gesture
 * @param gesture the query
 * @return a list of predictions of possible entries for a given gesture
 */
public ArrayList<Prediction> recognize(Gesture gesture){
  Instance instance=Instance.createInstance(mSequenceType,gesture,null);
  return mClassifier.classify(mSequenceType,instance.vector);
}

Fixed version (ground truth):
/** 
 * Recognize a gesture
 * @param gesture the query
 * @return a list of predictions of possible entries for a given gesture
 */
public ArrayList<Prediction> recognize(Gesture gesture){
  Instance instance=Instance.createInstance(mSequenceType,mOrientationStyle,gesture,null);
  return mClassifier.classify(mSequenceType,instance.vector);
}
Program: 183627
Project: 183627
Buggy source:
/** 
 * Convert the stroke to a Path based on the number of points
 * @param width the width of the bounding box of the target path
 * @param height the height of the bounding box of the target path
 * @param numSample the number of points needed
 * @return the path
 */
public Path toPath(float width,float height,int numSample){
  final float[] pts=GestureUtilities.temporalSampling(this,numSample);
  final RectF rect=boundingBox;
  final Matrix matrix=new Matrix();
  matrix.setTranslate(-rect.left,-rect.top);
  matrix.postScale(width / rect.width(),height / rect.height());
  matrix.mapPoints(pts);
  float mX=0;
  float mY=0;
  Path path=null;
  final int count=pts.length;
  for (int i=0; i < count; i+=2) {
    float x=pts[i];
    float y=pts[i + 1];
    if (path == null) {
      path=new Path();
      path.moveTo(x,y);
      mX=x;
      mY=y;
    }
 else {
      float dx=Math.abs(x - mX);
      float dy=Math.abs(y - mY);
      if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        path.quadTo(mX,mY,(x + mX) / 2,(y + mY) / 2);
        mX=x;
        mY=y;
      }
    }
  }
  return path;
}

Fixed version (ground truth):
/** 
 * Convert the stroke to a Path based on the number of points
 * @param width the width of the bounding box of the target path
 * @param height the height of the bounding box of the target path
 * @param numSample the number of points needed
 * @return the path
 */
public Path toPath(float width,float height,int numSample){
  final float[] pts=GestureUtilities.temporalSampling(this,numSample);
  final RectF rect=boundingBox;
  GestureUtilities.translate(pts,-rect.left,-rect.top);
  float sx=width / rect.width();
  float sy=height / rect.height();
  float scale=sx > sy ? sy : sx;
  GestureUtilities.scale(pts,scale,scale);
  float mX=0;
  float mY=0;
  Path path=null;
  final int count=pts.length;
  for (int i=0; i < count; i+=2) {
    float x=pts[i];
    float y=pts[i + 1];
    if (path == null) {
      path=new Path();
      path.moveTo(x,y);
      mX=x;
      mY=y;
    }
 else {
      float dx=Math.abs(x - mX);
      float dy=Math.abs(y - mY);
      if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        path.quadTo(mX,mY,(x + mX) / 2,(y + mY) / 2);
        mX=x;
        mY=y;
      }
    }
  }
  return path;
}
Program: 183628
Project: 183628
Buggy source:
static OrientedBoundingBox computeOrientedBoundingBox(float[] points,float[] centroid){
  Matrix tr=new Matrix();
  tr.setTranslate(-centroid[0],-centroid[1]);
  tr.mapPoints(points);
  double[][] array=computeCoVariance(points);
  double[] targetVector=computeOrientation(array);
  float angle;
  if (targetVector[0] == 0 && targetVector[1] == 0) {
    angle=-90;
  }
 else {
    angle=(float)Math.atan2(targetVector[1],targetVector[0]);
    angle=(float)(180 * angle / Math.PI);
    Matrix trans=new Matrix();
    trans.setRotate(-angle);
    trans.mapPoints(points);
  }
  float minx=Float.MAX_VALUE;
  float miny=Float.MAX_VALUE;
  float maxx=Float.MIN_VALUE;
  float maxy=Float.MIN_VALUE;
  int count=points.length;
  for (int i=0; i < count; i++) {
    if (points[i] < minx) {
      minx=points[i];
    }
    if (points[i] > maxx) {
      maxx=points[i];
    }
    i++;
    if (points[i] < miny) {
      miny=points[i];
    }
    if (points[i] > maxy) {
      maxy=points[i];
    }
  }
  return new OrientedBoundingBox(angle,centroid[0],centroid[1],maxx - minx,maxy - miny);
}

Fixed version (ground truth):
static OrientedBoundingBox computeOrientedBoundingBox(float[] points,float[] centroid){
  translate(points,-centroid[0],-centroid[1]);
  double[][] array=computeCoVariance(points);
  double[] targetVector=computeOrientation(array);
  float angle;
  if (targetVector[0] == 0 && targetVector[1] == 0) {
    angle=(float)-Math.PI / 2;
  }
 else {
    angle=(float)Math.atan2(targetVector[1],targetVector[0]);
    rotate(points,-angle);
  }
  float minx=Float.MAX_VALUE;
  float miny=Float.MAX_VALUE;
  float maxx=Float.MIN_VALUE;
  float maxy=Float.MIN_VALUE;
  int count=points.length;
  for (int i=0; i < count; i++) {
    if (points[i] < minx) {
      minx=points[i];
    }
    if (points[i] > maxx) {
      maxx=points[i];
    }
    i++;
    if (points[i] < miny) {
      miny=points[i];
    }
    if (points[i] > maxy) {
      maxy=points[i];
    }
  }
  return new OrientedBoundingBox(angle,centroid[0],centroid[1],maxx - minx,maxy - miny);
}
Program: 183629
Project: 183629
Buggy source:
/** 
 * create a learning instance for a single stroke gesture
 * @param gesture
 * @param label
 * @return the instance
 */
static Instance createInstance(int samplingType,Gesture gesture,String label){
  float[] pts;
  Instance instance;
  if (samplingType == GestureLibrary.SEQUENCE_SENSITIVE) {
    pts=temporalSampler(samplingType,gesture);
    instance=new Instance(gesture.getID(),pts,label);
    instance.normalize();
  }
 else {
    pts=spatialSampler(gesture);
    instance=new Instance(gesture.getID(),pts,label);
  }
  return instance;
}

Fixed version (ground truth):
/** 
 * create a learning instance for a single stroke gesture
 * @param gesture
 * @param label
 * @return the instance
 */
static Instance createInstance(int sequenceType,int orientationType,Gesture gesture,String label){
  float[] pts;
  Instance instance;
  if (sequenceType == GestureLibrary.SEQUENCE_SENSITIVE) {
    pts=temporalSampler(orientationType,gesture);
    instance=new Instance(gesture.getID(),pts,label);
    instance.normalize();
  }
 else {
    pts=spatialSampler(gesture);
    instance=new Instance(gesture.getID(),pts,label);
  }
  return instance;
}