nus-yam/ex-repair huggingface dataset:
Program: 43537
Project: 43537
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: 43538
Project: 43538
Buggy source:
public int performBackup(PackageInfo packageInfo,ParcelFileDescriptor data) throws RemoteException {
  File packageDir=new File(mDataDir,packageInfo.packageName);
  File imageFileName=new File(packageDir,DATA_FILE_NAME);
  return -1;
}

Fixed version (ground truth):
public int performBackup(PackageInfo packageInfo,ParcelFileDescriptor data) throws RemoteException {
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + packageInfo.packageName);
  int err=0;
  File packageDir=new File(mDataDir,packageInfo.packageName);
  packageDir.mkdirs();
  BackupDataInput changeSet=new BackupDataInput(data.getFileDescriptor());
  try {
    int bufSize=512;
    byte[] buf=new byte[bufSize];
    while (changeSet.readNextHeader()) {
      String key=changeSet.getKey();
      int dataSize=changeSet.getDataSize();
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + key + "String_Node_Str"+ dataSize);
      if (dataSize > bufSize) {
        bufSize=dataSize;
        buf=new byte[bufSize];
      }
      changeSet.readEntityData(buf,dataSize);
      if (DEBUG)       Log.v(TAG,"String_Node_Str" + dataSize);
      File entityFile=new File(packageDir,key);
      FileOutputStream entity=new FileOutputStream(entityFile);
      try {
        entity.write(buf,0,dataSize);
      }
 catch (      IOException e) {
        Log.e(TAG,"String_Node_Str" + entityFile.getAbsolutePath());
        err=-1;
      }
 finally {
        entity.close();
      }
    }
  }
 catch (  IOException e) {
    Log.v(TAG,"String_Node_Str");
    e.printStackTrace();
    err=-1;
  }
  return err;
}
Program: 43539
Project: 43539
Buggy source:
public int endSession() throws RemoteException {
  return 0;
}

Fixed version (ground truth):
public int endSession() throws RemoteException {
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  return 0;
}
Program: 43540
Project: 43540
Buggy source:
public int startSession() throws RemoteException {
  return 0;
}

Fixed version (ground truth):
public int startSession() throws RemoteException {
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  mDataDir.mkdirs();
  return 0;
}
Program: 43541
Project: 43541
Buggy source:
public int getRestoreData(int token,PackageInfo packageInfo,ParcelFileDescriptor output) throws android.os.RemoteException {
  if (token != 0)   return -1;
  File packageDir=new File(mDataDir,packageInfo.packageName);
  File imageFile=new File(packageDir,DATA_FILE_NAME);
  return copyFileToFD(imageFile,output);
}

Fixed version (ground truth):
public int getRestoreData(int token,PackageInfo packageInfo,ParcelFileDescriptor output) throws android.os.RemoteException {
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + token + "String_Node_Str"+ packageInfo.packageName);
  if (token != 0)   return -1;
  File packageDir=new File(mDataDir,packageInfo.packageName);
  File[] blobs=packageDir.listFiles();
  int err=0;
  if (blobs != null && blobs.length > 0) {
    for (    File f : blobs) {
      err=copyFileToFD(f,output);
      if (err != 0)       break;
    }
  }
  return err;
}
Program: 43542
Project: 43542
Buggy source:
public PackageInfo[] getAppSet(int token) throws android.os.RemoteException {
  File[] packageDirs=mDataDir.listFiles(mDirFileFilter);
  ArrayList<PackageInfo> packages=new ArrayList<PackageInfo>();
  for (  File dir : packageDirs) {
    try {
      PackageInfo pkg=mPackageManager.getPackageInfo(dir.getName(),PackageManager.GET_SIGNATURES);
      if (pkg != null) {
        packages.add(pkg);
      }
    }
 catch (    NameNotFoundException e) {
    }
  }
  Log.v(TAG,"String_Node_Str" + packages.size() + "String_Node_Str");
  for (  PackageInfo p : packages) {
    Log.v(TAG,"String_Node_Str" + p.packageName);
  }
  PackageInfo[] result=new PackageInfo[packages.size()];
  return packages.toArray(result);
}

Fixed version (ground truth):
public PackageInfo[] getAppSet(int token) throws android.os.RemoteException {
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + token);
  File[] packageDirs=mDataDir.listFiles(mDirFileFilter);
  ArrayList<PackageInfo> packages=new ArrayList<PackageInfo>();
  for (  File dir : packageDirs) {
    try {
      PackageInfo pkg=mPackageManager.getPackageInfo(dir.getName(),PackageManager.GET_SIGNATURES);
      if (pkg != null) {
        packages.add(pkg);
      }
    }
 catch (    NameNotFoundException e) {
    }
  }
  if (DEBUG) {
    Log.v(TAG,"String_Node_Str" + packages.size() + "String_Node_Str");
    for (    PackageInfo p : packages) {
      Log.v(TAG,"String_Node_Str" + p.packageName);
    }
  }
  PackageInfo[] result=new PackageInfo[packages.size()];
  return packages.toArray(result);
}
Program: 43543
Project: 43543
Buggy source:
public LocalTransport(Context context){
  mContext=context;
  mPackageManager=context.getPackageManager();
}

Fixed version (ground truth):
public LocalTransport(Context context){
  if (DEBUG)   Log.v(TAG,"String_Node_Str");
  mContext=context;
  mPackageManager=context.getPackageManager();
}
Program: 43544
Project: 43544
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: 43546
Project: 43546
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: 43549
Project: 43549
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: 43550
Project: 43550
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: 43551
Project: 43551
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: 43552
Project: 43552
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: 43553
Project: 43553
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: 43557
Project: 43557
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: 43558
Project: 43558
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: 43559
Project: 43559
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: 43561
Project: 43561
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: 43562
Project: 43562
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: 43563
Project: 43563
Buggy source:
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying DataConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  for (  DataConnection connBase : dataConnectionList) {
    CdmaDataConnection conn=(CdmaDataConnection)connBase;
    if (conn != null) {
      if (tearDown) {
        Message msg=obtainMessage(EVENT_DISCONNECT_DONE,reason);
        conn.disconnect(msg);
      }
 else {
        conn.clearSettings();
      }
    }
  }
  stopNetStatPoll();
  if (!tearDown) {
    setState(State.IDLE);
    phone.notifyDataConnection(reason);
  }
 else   if (state != State.IDLE) {
    setState(State.DISCONNECTING);
  }
}

Fixed version (ground truth):
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying DataConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  setState(State.DISCONNECTING);
  for (  DataConnection connBase : dataConnectionList) {
    CdmaDataConnection conn=(CdmaDataConnection)connBase;
    if (conn != null) {
      if (tearDown) {
        Message msg=obtainMessage(EVENT_DISCONNECT_DONE,reason);
        conn.disconnect(msg);
      }
 else {
        conn.clearSettings();
      }
    }
  }
  stopNetStatPoll();
  if (!tearDown) {
    setState(State.IDLE);
    phone.notifyDataConnection(reason);
  }
}
Program: 43564
Project: 43564
Buggy source:
/** 
 * @override com.android.internal.telephony.DataConnectionTracker
 */
protected void onVoiceCallEnded(){
  if (state == State.CONNECTED) {
    if (!mCdmaPhone.mSST.isConcurrentVoiceAndData()) {
      startNetStatPoll();
      phone.notifyDataConnection(Phone.REASON_VOICE_CALL_ENDED);
    }
 else {
      resetPollStats();
    }
  }
 else {
    trySetupData(Phone.REASON_VOICE_CALL_ENDED);
  }
}

Fixed version (ground truth):
/** 
 * @override com.android.internal.telephony.DataConnectionTracker
 */
protected void onVoiceCallEnded(){
  if (state == State.CONNECTED) {
    if (!mCdmaPhone.mSST.isConcurrentVoiceAndData()) {
      startNetStatPoll();
      phone.notifyDataConnection(Phone.REASON_VOICE_CALL_ENDED);
    }
 else {
      resetPollStats();
    }
  }
 else {
    nextReconnectDelay=RECONNECT_DELAY_INITIAL_MILLIS;
    trySetupData(Phone.REASON_VOICE_CALL_ENDED);
  }
}
Program: 43565
Project: 43565
Buggy source:
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying PdpConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  for (  DataConnection conn : pdpList) {
    PdpConnection pdp=(PdpConnection)conn;
    if (tearDown) {
      Message msg=obtainMessage(EVENT_DISCONNECT_DONE,reason);
      pdp.disconnect(msg);
    }
 else {
      pdp.clearSettings();
    }
  }
  stopNetStatPoll();
  if (!tearDown) {
    setState(State.IDLE);
    phone.notifyDataConnection(reason);
    mActiveApn=null;
  }
 else   if (state != State.IDLE) {
    setState(State.DISCONNECTING);
  }
}

Fixed version (ground truth):
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying PdpConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  setState(State.DISCONNECTING);
  for (  DataConnection conn : pdpList) {
    PdpConnection pdp=(PdpConnection)conn;
    if (tearDown) {
      Message msg=obtainMessage(EVENT_DISCONNECT_DONE,reason);
      pdp.disconnect(msg);
    }
 else {
      pdp.clearSettings();
    }
  }
  stopNetStatPoll();
  if (!tearDown) {
    setState(State.IDLE);
    phone.notifyDataConnection(reason);
    mActiveApn=null;
  }
}
Program: 43566
Project: 43566
Buggy source:
/** 
 * Handles changes to the APN database.
 */
private void onApnChanged(){
  boolean isConnected;
  isConnected=(state != State.IDLE && state != State.FAILED);
  ((GSMPhone)phone).updateCurrentCarrierInProvider();
  createAllApnList();
  if (state != State.DISCONNECTING) {
    cleanUpConnection(isConnected,Phone.REASON_APN_CHANGED);
    if (!isConnected) {
      trySetupData(Phone.REASON_APN_CHANGED);
    }
  }
}

Fixed version (ground truth):
/** 
 * Handles changes to the APN database.
 */
private void onApnChanged(){
  boolean isConnected;
  isConnected=(state != State.IDLE && state != State.FAILED);
  ((GSMPhone)phone).updateCurrentCarrierInProvider();
  createAllApnList();
  if (state != State.DISCONNECTING) {
    cleanUpConnection(isConnected,Phone.REASON_APN_CHANGED);
    if (!isConnected) {
      nextReconnectDelay=RECONNECT_DELAY_INITIAL_MILLIS;
      trySetupData(Phone.REASON_APN_CHANGED);
    }
  }
}
Program: 43567
Project: 43567
Buggy source:
protected void onVoiceCallEnded(){
  if (state == State.CONNECTED) {
    if (!((GSMPhone)phone).mSST.isConcurrentVoiceAndData()) {
      startNetStatPoll();
      phone.notifyDataConnection(Phone.REASON_VOICE_CALL_ENDED);
    }
 else {
      resetPollStats();
    }
  }
 else {
    trySetupData(Phone.REASON_VOICE_CALL_ENDED);
  }
}

Fixed version (ground truth):
protected void onVoiceCallEnded(){
  if (state == State.CONNECTED) {
    if (!((GSMPhone)phone).mSST.isConcurrentVoiceAndData()) {
      startNetStatPoll();
      phone.notifyDataConnection(Phone.REASON_VOICE_CALL_ENDED);
    }
 else {
      resetPollStats();
    }
  }
 else {
    nextReconnectDelay=RECONNECT_DELAY_INITIAL_MILLIS;
    trySetupData(Phone.REASON_VOICE_CALL_ENDED);
  }
}
Program: 43568
Project: 43568
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: 43569
Project: 43569
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: 43570
Project: 43570
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: 43571
Project: 43571
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: 43572
Project: 43572
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: 43573
Project: 43573
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: 43574
Project: 43574
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: 43575
Project: 43575
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: 43577
Project: 43577
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: 43578
Project: 43578
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: 43579
Project: 43579
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: 43580
Project: 43580
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: 43582
Project: 43582
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: 43583
Project: 43583
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();
}