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

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

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

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

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

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

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

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

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

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

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

Fixed version (ground truth):
public boolean profileControl(String process,boolean start,String path,ParcelFileDescriptor fd) throws RemoteException {
  try {
synchronized (this) {
      if (checkCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER) != PackageManager.PERMISSION_GRANTED) {
        throw new SecurityException("String_Node_Str" + android.Manifest.permission.SET_ACTIVITY_WATCHER);
      }
      if (start && fd == null) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      ProcessRecord proc=null;
      try {
        int pid=Integer.parseInt(process);
synchronized (mPidsSelfLocked) {
          proc=mPidsSelfLocked.get(pid);
        }
      }
 catch (      NumberFormatException e) {
      }
      if (proc == null) {
        HashMap<String,SparseArray<ProcessRecord>> all=mProcessNames.getMap();
        SparseArray<ProcessRecord> procs=all.get(process);
        if (procs != null && procs.size() > 0) {
          proc=procs.valueAt(0);
        }
      }
      if (proc == null || proc.thread == null) {
        throw new IllegalArgumentException("String_Node_Str" + process);
      }
      boolean isSecure="String_Node_Str".equals(SystemProperties.get(SYSTEM_SECURE,"String_Node_Str"));
      if (isSecure) {
        if ((proc.info.flags & ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
          throw new SecurityException("String_Node_Str" + proc);
        }
      }
      proc.thread.profilerControl(start,path,fd);
      fd=null;
      return true;
    }
  }
 catch (  RemoteException e) {
    throw new IllegalStateException("String_Node_Str");
  }
 finally {
    if (fd != null) {
      try {
        fd.close();
      }
 catch (      IOException e) {
      }
    }
  }
}
Program: 43498
Project: 43498
Buggy source:
public void noteAudioOffLocked(int uid){
  if (mAudioOn) {
    mAudioOn=false;
    mAudioOnTimer.stopRunningLocked(this);
  }
  Uid u=mUidStats.get(uid);
  if (u != null) {
    u.noteAudioTurnedOffLocked();
  }
}

Fixed version (ground truth):
public void noteAudioOffLocked(int uid){
  if (mAudioOn) {
    mAudioOn=false;
    mAudioOnTimer.stopRunningLocked(this);
  }
  getUidStatsLocked(uid).noteAudioTurnedOffLocked();
}
Program: 43499
Project: 43499
Buggy source:
public void noteWifiOffLocked(int uid){
  if (mWifiOn) {
    mWifiOn=false;
    mWifiOnTimer.stopRunningLocked(this);
  }
  if (mWifiOnUid >= 0) {
    Uid u=mUidStats.get(mWifiOnUid);
    if (u != null) {
      u.noteWifiTurnedOffLocked();
    }
    mWifiOnUid=-1;
  }
}

Fixed version (ground truth):
public void noteWifiOffLocked(int uid){
  if (mWifiOn) {
    mWifiOn=false;
    mWifiOnTimer.stopRunningLocked(this);
  }
  if (mWifiOnUid >= 0) {
    getUidStatsLocked(mWifiOnUid).noteWifiTurnedOffLocked();
    mWifiOnUid=-1;
  }
}
Program: 43500
Project: 43500
Buggy source:
public void noteAudioOnLocked(int uid){
  if (!mAudioOn) {
    mAudioOn=true;
    mAudioOnTimer.startRunningLocked(this);
  }
  Uid u=mUidStats.get(uid);
  if (u != null) {
    u.noteAudioTurnedOnLocked();
  }
}

Fixed version (ground truth):
public void noteAudioOnLocked(int uid){
  if (!mAudioOn) {
    mAudioOn=true;
    mAudioOnTimer.startRunningLocked(this);
  }
  getUidStatsLocked(uid).noteAudioTurnedOnLocked();
}
Program: 43501
Project: 43501
Buggy source:
public void noteVideoOffLocked(int uid){
  if (mVideoOn) {
    mVideoOn=false;
    mVideoOnTimer.stopRunningLocked(this);
  }
  Uid u=mUidStats.get(uid);
  if (u != null) {
    u.noteVideoTurnedOffLocked();
  }
}

Fixed version (ground truth):
public void noteVideoOffLocked(int uid){
  if (mVideoOn) {
    mVideoOn=false;
    mVideoOnTimer.stopRunningLocked(this);
  }
  getUidStatsLocked(uid).noteVideoTurnedOffLocked();
}
Program: 43502
Project: 43502
Buggy source:
public void noteWifiOnLocked(int uid){
  if (!mWifiOn) {
    mWifiOn=true;
    mWifiOnTimer.startRunningLocked(this);
  }
  if (mWifiOnUid != uid) {
    if (mWifiOnUid >= 0) {
      Uid u=mUidStats.get(mWifiOnUid);
      if (u != null) {
        u.noteWifiTurnedOffLocked();
      }
    }
    mWifiOnUid=uid;
    Uid u=mUidStats.get(uid);
    if (u != null) {
      u.noteWifiTurnedOnLocked();
    }
  }
}

Fixed version (ground truth):
public void noteWifiOnLocked(int uid){
  if (!mWifiOn) {
    mWifiOn=true;
    mWifiOnTimer.startRunningLocked(this);
  }
  if (mWifiOnUid != uid) {
    if (mWifiOnUid >= 0) {
      getUidStatsLocked(mWifiOnUid).noteWifiTurnedOffLocked();
    }
    mWifiOnUid=uid;
    getUidStatsLocked(uid).noteWifiTurnedOnLocked();
  }
}
Program: 43503
Project: 43503
Buggy source:
public void noteVideoOnLocked(int uid){
  if (!mVideoOn) {
    mVideoOn=true;
    mVideoOnTimer.startRunningLocked(this);
  }
  Uid u=mUidStats.get(uid);
  if (u != null) {
    u.noteVideoTurnedOnLocked();
  }
}

Fixed version (ground truth):
public void noteVideoOnLocked(int uid){
  if (!mVideoOn) {
    mVideoOn=true;
    mVideoOnTimer.startRunningLocked(this);
  }
  getUidStatsLocked(uid).noteVideoTurnedOnLocked();
}
Program: 43504
Project: 43504
Buggy source:
/** 
 * called from native code to update our status
 */
private void reportStatus(int status){
  if (VERBOSE)   Log.v(TAG,"String_Node_Str" + status);
  boolean wasNavigating=mNavigating;
  mNavigating=(status == GPS_STATUS_SESSION_BEGIN);
  if (wasNavigating != mNavigating) {
    if (mNavigating) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mWakeLock.acquire();
    }
synchronized (mListeners) {
      int size=mListeners.size();
      for (int i=0; i < size; i++) {
        Listener listener=mListeners.get(i);
        try {
          if (mNavigating) {
            listener.mListener.onGpsStarted();
          }
 else {
            listener.mListener.onGpsStopped();
          }
        }
 catch (        RemoteException e) {
          Log.w(TAG,"String_Node_Str");
          mListeners.remove(listener);
          size--;
        }
      }
    }
    try {
      for (int i=mClientUids.size() - 1; i >= 0; i--) {
        int uid=mClientUids.keyAt(i);
        if (mNavigating) {
          mBatteryStats.noteStartGps(uid);
        }
 else {
          mBatteryStats.noteStopGps(uid);
        }
      }
    }
 catch (    RemoteException e) {
      Log.w(TAG,"String_Node_Str");
    }
    Intent intent=new Intent(GPS_ENABLED_CHANGE_ACTION);
    intent.putExtra(EXTRA_ENABLED,mNavigating);
    mContext.sendBroadcast(intent);
    if (!mNavigating) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mWakeLock.release();
    }
  }
}

Fixed version (ground truth):
/** 
 * called from native code to update our status
 */
private void reportStatus(int status){
  if (VERBOSE)   Log.v(TAG,"String_Node_Str" + status);
synchronized (mListeners) {
    boolean wasNavigating=mNavigating;
    mNavigating=(status == GPS_STATUS_SESSION_BEGIN);
    if (wasNavigating == mNavigating) {
      return;
    }
    if (mNavigating) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mWakeLock.acquire();
    }
    int size=mListeners.size();
    for (int i=0; i < size; i++) {
      Listener listener=mListeners.get(i);
      try {
        if (mNavigating) {
          listener.mListener.onGpsStarted();
        }
 else {
          listener.mListener.onGpsStopped();
        }
      }
 catch (      RemoteException e) {
        Log.w(TAG,"String_Node_Str");
        mListeners.remove(listener);
        size--;
      }
    }
    try {
      for (int i=mClientUids.size() - 1; i >= 0; i--) {
        int uid=mClientUids.keyAt(i);
        if (mNavigating) {
          mBatteryStats.noteStartGps(uid);
        }
 else {
          mBatteryStats.noteStopGps(uid);
        }
      }
    }
 catch (    RemoteException e) {
      Log.w(TAG,"String_Node_Str");
    }
    Intent intent=new Intent(GPS_ENABLED_CHANGE_ACTION);
    intent.putExtra(EXTRA_ENABLED,mNavigating);
    mContext.sendBroadcast(intent);
    if (!mNavigating) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mWakeLock.release();
    }
  }
}
Program: 43505
Project: 43505
Buggy source:
public void addListener(int uid){
  mClientUids.put(uid,0);
  if (mNavigating) {
    try {
      mBatteryStats.noteStartGps(uid);
    }
 catch (    RemoteException e) {
      Log.w(TAG,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void addListener(int uid){
synchronized (mListeners) {
    if (mClientUids.indexOfKey(uid) >= 0) {
      Log.w(TAG,"String_Node_Str" + uid);
      return;
    }
    mClientUids.put(uid,0);
    if (mNavigating) {
      try {
        mBatteryStats.noteStartGps(uid);
      }
 catch (      RemoteException e) {
        Log.w(TAG,"String_Node_Str");
      }
    }
  }
}
Program: 43506
Project: 43506
Buggy source:
public void removeListener(int uid){
  mClientUids.delete(uid);
  if (mNavigating) {
    try {
      mBatteryStats.noteStopGps(uid);
    }
 catch (    RemoteException e) {
      Log.w(TAG,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void removeListener(int uid){
synchronized (mListeners) {
    if (mClientUids.indexOfKey(uid) < 0) {
      Log.w(TAG,"String_Node_Str" + uid);
      return;
    }
    mClientUids.delete(uid);
    if (mNavigating) {
      try {
        mBatteryStats.noteStopGps(uid);
      }
 catch (      RemoteException e) {
        Log.w(TAG,"String_Node_Str");
      }
    }
  }
}
Program: 43507
Project: 43507
Buggy source:
public void noteAudioOffLocked(int uid){
  if (mAudioOn) {
    mAudioOn=false;
    mAudioOnTimer.stopRunningLocked(this);
  }
  Uid u=mUidStats.get(uid);
  if (u != null) {
    u.noteAudioTurnedOffLocked();
  }
}

Fixed version (ground truth):
public void noteAudioOffLocked(int uid){
  if (mAudioOn) {
    mAudioOn=false;
    mAudioOnTimer.stopRunningLocked(this);
  }
  getUidStatsLocked(uid).noteAudioTurnedOffLocked();
}
Program: 43508
Project: 43508
Buggy source:
public void noteWifiOffLocked(int uid){
  if (mWifiOn) {
    mWifiOn=false;
    mWifiOnTimer.stopRunningLocked(this);
  }
  if (mWifiOnUid >= 0) {
    Uid u=mUidStats.get(mWifiOnUid);
    if (u != null) {
      u.noteWifiTurnedOffLocked();
    }
    mWifiOnUid=-1;
  }
}

Fixed version (ground truth):
public void noteWifiOffLocked(int uid){
  if (mWifiOn) {
    mWifiOn=false;
    mWifiOnTimer.stopRunningLocked(this);
  }
  if (mWifiOnUid >= 0) {
    getUidStatsLocked(mWifiOnUid).noteWifiTurnedOffLocked();
    mWifiOnUid=-1;
  }
}
Program: 43509
Project: 43509
Buggy source:
public void noteAudioOnLocked(int uid){
  if (!mAudioOn) {
    mAudioOn=true;
    mAudioOnTimer.startRunningLocked(this);
  }
  Uid u=mUidStats.get(uid);
  if (u != null) {
    u.noteAudioTurnedOnLocked();
  }
}

Fixed version (ground truth):
public void noteAudioOnLocked(int uid){
  if (!mAudioOn) {
    mAudioOn=true;
    mAudioOnTimer.startRunningLocked(this);
  }
  getUidStatsLocked(uid).noteAudioTurnedOnLocked();
}
Program: 43510
Project: 43510
Buggy source:
public void noteVideoOffLocked(int uid){
  if (mVideoOn) {
    mVideoOn=false;
    mVideoOnTimer.stopRunningLocked(this);
  }
  Uid u=mUidStats.get(uid);
  if (u != null) {
    u.noteVideoTurnedOffLocked();
  }
}

Fixed version (ground truth):
public void noteVideoOffLocked(int uid){
  if (mVideoOn) {
    mVideoOn=false;
    mVideoOnTimer.stopRunningLocked(this);
  }
  getUidStatsLocked(uid).noteVideoTurnedOffLocked();
}
Program: 43511
Project: 43511
Buggy source:
public void noteWifiOnLocked(int uid){
  if (!mWifiOn) {
    mWifiOn=true;
    mWifiOnTimer.startRunningLocked(this);
  }
  if (mWifiOnUid != uid) {
    if (mWifiOnUid >= 0) {
      Uid u=mUidStats.get(mWifiOnUid);
      if (u != null) {
        u.noteWifiTurnedOffLocked();
      }
    }
    mWifiOnUid=uid;
    Uid u=mUidStats.get(uid);
    if (u != null) {
      u.noteWifiTurnedOnLocked();
    }
  }
}

Fixed version (ground truth):
public void noteWifiOnLocked(int uid){
  if (!mWifiOn) {
    mWifiOn=true;
    mWifiOnTimer.startRunningLocked(this);
  }
  if (mWifiOnUid != uid) {
    if (mWifiOnUid >= 0) {
      getUidStatsLocked(mWifiOnUid).noteWifiTurnedOffLocked();
    }
    mWifiOnUid=uid;
    getUidStatsLocked(uid).noteWifiTurnedOnLocked();
  }
}
Program: 43512
Project: 43512
Buggy source:
public void noteVideoOnLocked(int uid){
  if (!mVideoOn) {
    mVideoOn=true;
    mVideoOnTimer.startRunningLocked(this);
  }
  Uid u=mUidStats.get(uid);
  if (u != null) {
    u.noteVideoTurnedOnLocked();
  }
}

Fixed version (ground truth):
public void noteVideoOnLocked(int uid){
  if (!mVideoOn) {
    mVideoOn=true;
    mVideoOnTimer.startRunningLocked(this);
  }
  getUidStatsLocked(uid).noteVideoTurnedOnLocked();
}
Program: 43513
Project: 43513
Buggy source:
/** 
 * called from native code to update our status
 */
private void reportStatus(int status){
  if (VERBOSE)   Log.v(TAG,"String_Node_Str" + status);
  boolean wasNavigating=mNavigating;
  mNavigating=(status == GPS_STATUS_SESSION_BEGIN);
  if (wasNavigating != mNavigating) {
    if (mNavigating) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mWakeLock.acquire();
    }
synchronized (mListeners) {
      int size=mListeners.size();
      for (int i=0; i < size; i++) {
        Listener listener=mListeners.get(i);
        try {
          if (mNavigating) {
            listener.mListener.onGpsStarted();
          }
 else {
            listener.mListener.onGpsStopped();
          }
        }
 catch (        RemoteException e) {
          Log.w(TAG,"String_Node_Str");
          mListeners.remove(listener);
          size--;
        }
      }
    }
    try {
      for (int i=mClientUids.size() - 1; i >= 0; i--) {
        int uid=mClientUids.keyAt(i);
        if (mNavigating) {
          mBatteryStats.noteStartGps(uid);
        }
 else {
          mBatteryStats.noteStopGps(uid);
        }
      }
    }
 catch (    RemoteException e) {
      Log.w(TAG,"String_Node_Str");
    }
    Intent intent=new Intent(GPS_ENABLED_CHANGE_ACTION);
    intent.putExtra(EXTRA_ENABLED,mNavigating);
    mContext.sendBroadcast(intent);
    if (!mNavigating) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mWakeLock.release();
    }
  }
}

Fixed version (ground truth):
/** 
 * called from native code to update our status
 */
private void reportStatus(int status){
  if (VERBOSE)   Log.v(TAG,"String_Node_Str" + status);
synchronized (mListeners) {
    boolean wasNavigating=mNavigating;
    mNavigating=(status == GPS_STATUS_SESSION_BEGIN);
    if (wasNavigating == mNavigating) {
      return;
    }
    if (mNavigating) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mWakeLock.acquire();
    }
    int size=mListeners.size();
    for (int i=0; i < size; i++) {
      Listener listener=mListeners.get(i);
      try {
        if (mNavigating) {
          listener.mListener.onGpsStarted();
        }
 else {
          listener.mListener.onGpsStopped();
        }
      }
 catch (      RemoteException e) {
        Log.w(TAG,"String_Node_Str");
        mListeners.remove(listener);
        size--;
      }
    }
    try {
      for (int i=mClientUids.size() - 1; i >= 0; i--) {
        int uid=mClientUids.keyAt(i);
        if (mNavigating) {
          mBatteryStats.noteStartGps(uid);
        }
 else {
          mBatteryStats.noteStopGps(uid);
        }
      }
    }
 catch (    RemoteException e) {
      Log.w(TAG,"String_Node_Str");
    }
    Intent intent=new Intent(GPS_ENABLED_CHANGE_ACTION);
    intent.putExtra(EXTRA_ENABLED,mNavigating);
    mContext.sendBroadcast(intent);
    if (!mNavigating) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      mWakeLock.release();
    }
  }
}
Program: 43514
Project: 43514
Buggy source:
public void addListener(int uid){
  mClientUids.put(uid,0);
  if (mNavigating) {
    try {
      mBatteryStats.noteStartGps(uid);
    }
 catch (    RemoteException e) {
      Log.w(TAG,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void addListener(int uid){
synchronized (mListeners) {
    if (mClientUids.indexOfKey(uid) >= 0) {
      Log.w(TAG,"String_Node_Str" + uid);
      return;
    }
    mClientUids.put(uid,0);
    if (mNavigating) {
      try {
        mBatteryStats.noteStartGps(uid);
      }
 catch (      RemoteException e) {
        Log.w(TAG,"String_Node_Str");
      }
    }
  }
}
Program: 43515
Project: 43515
Buggy source:
public void removeListener(int uid){
  mClientUids.delete(uid);
  if (mNavigating) {
    try {
      mBatteryStats.noteStopGps(uid);
    }
 catch (    RemoteException e) {
      Log.w(TAG,"String_Node_Str");
    }
  }
}

Fixed version (ground truth):
public void removeListener(int uid){
synchronized (mListeners) {
    if (mClientUids.indexOfKey(uid) < 0) {
      Log.w(TAG,"String_Node_Str" + uid);
      return;
    }
    mClientUids.delete(uid);
    if (mNavigating) {
      try {
        mBatteryStats.noteStopGps(uid);
      }
 catch (      RemoteException e) {
        Log.w(TAG,"String_Node_Str");
      }
    }
  }
}
Program: 43516
Project: 43516
Buggy source:
@Override public final void setBackgroundDrawable(Drawable drawable){
  if (drawable != mBackgroundDrawable) {
    mBackgroundResource=0;
    mBackgroundDrawable=drawable;
    if (mDecor != null) {
      mDecor.setWindowBackground(drawable);
    }
  }
}

Fixed version (ground truth):
@Override public final void setBackgroundDrawable(Drawable drawable){
  if (drawable != mBackgroundDrawable || mBackgroundResource != 0) {
    mBackgroundResource=0;
    mBackgroundDrawable=drawable;
    if (mDecor != null) {
      mDecor.setWindowBackground(drawable);
    }
  }
}
Program: 43517
Project: 43517
Buggy source:
@Override public final void setBackgroundDrawable(Drawable drawable){
  if (drawable != mBackgroundDrawable) {
    mBackgroundResource=0;
    mBackgroundDrawable=drawable;
    if (mDecor != null) {
      mDecor.setWindowBackground(drawable);
    }
  }
}

Fixed version (ground truth):
@Override public final void setBackgroundDrawable(Drawable drawable){
  if (drawable != mBackgroundDrawable || mBackgroundResource != 0) {
    mBackgroundResource=0;
    mBackgroundDrawable=drawable;
    if (mDecor != null) {
      mDecor.setWindowBackground(drawable);
    }
  }
}
Program: 43519
Project: 43519
Buggy source:
/** 
 * The default implementation returns the given amount of text from the current cursor position in the buffer.
 */
public CharSequence getTextBeforeCursor(int length,int flags){
  final Editable content=getEditable();
  if (content == null)   return null;
  int a=Selection.getSelectionStart(content);
  int b=Selection.getSelectionEnd(content);
  if (a > b) {
    int tmp=a;
    a=b;
    b=tmp;
  }
  if (length > a) {
    length=a;
  }
  if ((flags & GET_TEXT_WITH_STYLES) != 0) {
    return content.subSequence(a - length,a);
  }
  return TextUtils.substring(content,a - length,a);
}

Fixed version (ground truth):
/** 
 * The default implementation returns the given amount of text from the current cursor position in the buffer.
 */
public CharSequence getTextBeforeCursor(int length,int flags){
  final Editable content=getEditable();
  if (content == null)   return null;
  int a=Selection.getSelectionStart(content);
  int b=Selection.getSelectionEnd(content);
  if (a > b) {
    int tmp=a;
    a=b;
    b=tmp;
  }
  if (a <= 0) {
    return "String_Node_Str";
  }
  if (length > a) {
    length=a;
  }
  if ((flags & GET_TEXT_WITH_STYLES) != 0) {
    return content.subSequence(a - length,a);
  }
  return TextUtils.substring(content,a - length,a);
}
Program: 43521
Project: 43521
Buggy source:
protected void onReceiveResult(int resultCode,Bundle resultData){
  if (resultCode != InputMethodManager.RESULT_SHOWN) {
    Selection.setSelection((Spannable)mText,mNewStart,mNewEnd);
  }
}

Fixed version (ground truth):
protected void onReceiveResult(int resultCode,Bundle resultData){
  if (resultCode != InputMethodManager.RESULT_SHOWN) {
    final int len=mText.length();
    if (mNewStart > len) {
      mNewStart=len;
    }
    if (mNewEnd > len) {
      mNewEnd=len;
    }
    Selection.setSelection((Spannable)mText,mNewStart,mNewEnd);
  }
}
Program: 43522
Project: 43522
Buggy source:
private Rect sendOurVisibleRect(){
  Rect rect=new Rect();
  calcOurContentVisibleRect(rect);
  if (mFindIsUp) {
    rect.bottom-=viewToContent(FIND_HEIGHT);
  }
  if (!rect.equals(mLastVisibleRectSent)) {
    Point pos=new Point(rect.left,rect.top);
    mWebViewCore.sendMessage(EventHub.SET_SCROLL_OFFSET,nativeMoveGeneration(),0,pos);
    mLastVisibleRectSent=rect;
  }
  Rect globalRect=new Rect();
  if (getGlobalVisibleRect(globalRect) && !globalRect.equals(mLastGlobalRect)) {
    mWebViewCore.sendMessage(EventHub.SET_GLOBAL_BOUNDS,globalRect);
    mLastGlobalRect=globalRect;
  }
  return rect;
}

Fixed version (ground truth):
private Rect sendOurVisibleRect(){
  Rect rect=new Rect();
  calcOurContentVisibleRect(rect);
  if (!rect.equals(mLastVisibleRectSent)) {
    Point pos=new Point(rect.left,rect.top);
    mWebViewCore.sendMessage(EventHub.SET_SCROLL_OFFSET,nativeMoveGeneration(),0,pos);
    mLastVisibleRectSent=rect;
  }
  Rect globalRect=new Rect();
  if (getGlobalVisibleRect(globalRect) && !globalRect.equals(mLastGlobalRect)) {
    if (DebugFlags.WEB_VIEW) {
      Log.v(LOGTAG,"String_Node_Str" + globalRect.left + "String_Node_Str"+ globalRect.top+ "String_Node_Str"+ globalRect.right+ "String_Node_Str"+ globalRect.bottom);
    }
    mWebViewCore.sendMessage(EventHub.SET_GLOBAL_BOUNDS,globalRect);
    mLastGlobalRect=globalRect;
  }
  return rect;
}
Program: 43524
Project: 43524
Buggy source:
private void calcOurVisibleRect(Rect r){
  Point p=new Point();
  getGlobalVisibleRect(r,p);
  r.offset(-p.x,-p.y);
}

Fixed version (ground truth):
private void calcOurVisibleRect(Rect r){
  Point p=new Point();
  getGlobalVisibleRect(r,p);
  r.offset(-p.x,-p.y);
  if (mFindIsUp) {
    r.bottom-=FIND_HEIGHT;
  }
}
Program: 43525
Project: 43525
Buggy source:
private void updateSharedUserPerms(PackageSetting deletedPs){
  if ((deletedPs == null) || (deletedPs.pkg == null)) {
    Log.i(TAG,"String_Node_Str");
    return;
  }
  if (deletedPs.sharedUser == null) {
    return;
  }
  SharedUserSetting sus=deletedPs.sharedUser;
  for (  String eachPerm : deletedPs.pkg.requestedPermissions) {
    boolean used=false;
    if (!sus.grantedPermissions.contains(eachPerm)) {
      continue;
    }
    for (    PackageSetting pkg : sus.packages) {
      if (pkg.grantedPermissions.contains(eachPerm)) {
        used=true;
        break;
      }
    }
    if (!used) {
      sus.grantedPermissions.remove(eachPerm);
      sus.loadedPermissions.remove(eachPerm);
    }
  }
  int newGids[]=null;
  for (  PackageSetting pkg : sus.packages) {
    newGids=appendInts(newGids,pkg.gids);
  }
  sus.gids=newGids;
}

Fixed version (ground truth):
private void updateSharedUserPerms(PackageSetting deletedPs){
  if ((deletedPs == null) || (deletedPs.pkg == null)) {
    Log.i(TAG,"String_Node_Str");
    return;
  }
  if (deletedPs.sharedUser == null) {
    return;
  }
  SharedUserSetting sus=deletedPs.sharedUser;
  for (  String eachPerm : deletedPs.pkg.requestedPermissions) {
    boolean used=false;
    if (!sus.grantedPermissions.contains(eachPerm)) {
      continue;
    }
    for (    PackageSetting pkg : sus.packages) {
      if (pkg.pkg.requestedPermissions.contains(eachPerm)) {
        used=true;
        break;
      }
    }
    if (!used) {
      sus.grantedPermissions.remove(eachPerm);
      sus.loadedPermissions.remove(eachPerm);
    }
  }
  int newGids[]=null;
  for (  PackageSetting pkg : sus.packages) {
    newGids=appendInts(newGids,pkg.gids);
  }
  sus.gids=newGids;
}
Program: 43527
Project: 43527
Buggy source:
/** 
 * Sends a series of key events through instrumentation and waits for idle. For instance: sendKeys(KEYCODE_DPAD_LEFT, KEYCODE_DPAD_CENTER).
 * @param keys The series of key codes to send through instrumentation.
 */
public void sendKeys(int... keys){
  final int count=keys.length;
  final Instrumentation instrumentation=getInstrumentation();
  for (int i=0; i < count; i++) {
    instrumentation.sendKeyDownUpSync(keys[i]);
  }
  instrumentation.waitForIdleSync();
}

Fixed version (ground truth):
/** 
 * Sends a series of key events through instrumentation and waits for idle. For instance: sendKeys(KEYCODE_DPAD_LEFT, KEYCODE_DPAD_CENTER).
 * @param keys The series of key codes to send through instrumentation.
 */
public void sendKeys(int... keys){
  final int count=keys.length;
  final Instrumentation instrumentation=getInstrumentation();
  for (int i=0; i < count; i++) {
    try {
      instrumentation.sendKeyDownUpSync(keys[i]);
    }
 catch (    SecurityException e) {
    }
  }
  instrumentation.waitForIdleSync();
}
Program: 43528
Project: 43528
Buggy source:
/** 
 * Sends a series of key events through instrumentation and waits for idle. Each key code must be preceded by the number of times the key code must be sent. For instance: sendRepeatedKeys(1, KEYCODE_DPAD_CENTER, 2, KEYCODE_DPAD_LEFT).
 * @param keys The series of key repeats and codes to send through instrumentation.
 */
public void sendRepeatedKeys(int... keys){
  final int count=keys.length;
  if ((count & 0x1) == 0x1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  final Instrumentation instrumentation=getInstrumentation();
  for (int i=0; i < count; i+=2) {
    final int keyCount=keys[i];
    final int keyCode=keys[i + 1];
    for (int j=0; j < keyCount; j++) {
      instrumentation.sendKeyDownUpSync(keyCode);
    }
  }
  instrumentation.waitForIdleSync();
}

Fixed version (ground truth):
/** 
 * Sends a series of key events through instrumentation and waits for idle. Each key code must be preceded by the number of times the key code must be sent. For instance: sendRepeatedKeys(1, KEYCODE_DPAD_CENTER, 2, KEYCODE_DPAD_LEFT).
 * @param keys The series of key repeats and codes to send through instrumentation.
 */
public void sendRepeatedKeys(int... keys){
  final int count=keys.length;
  if ((count & 0x1) == 0x1) {
    throw new IllegalArgumentException("String_Node_Str" + "String_Node_Str");
  }
  final Instrumentation instrumentation=getInstrumentation();
  for (int i=0; i < count; i+=2) {
    final int keyCount=keys[i];
    final int keyCode=keys[i + 1];
    for (int j=0; j < keyCount; j++) {
      try {
        instrumentation.sendKeyDownUpSync(keyCode);
      }
 catch (      SecurityException e) {
      }
    }
  }
  instrumentation.waitForIdleSync();
}
Program: 43529
Project: 43529
Buggy source:
TimeStats(Parcel in){
  final int[] localTimes=times;
  for (int i=0; i < NUM_LAUNCH_TIME_BINS; i++) {
    localTimes[i]=in.readInt();
  }
}

Fixed version (ground truth):
TimeStats(Parcel in){
  count=in.readInt();
  final int[] localTimes=times;
  for (int i=0; i < NUM_LAUNCH_TIME_BINS; i++) {
    localTimes[i]=in.readInt();
  }
}
Program: 43530
Project: 43530
Buggy source:
public void noteResumeComponent(ComponentName componentName){
  enforceCallingPermission();
  String pkgName;
  if ((componentName == null) || ((pkgName=componentName.getPackageName()) == null)) {
    return;
  }
  if ((mResumedPkg != null) && (mResumedPkg.equalsIgnoreCase(pkgName))) {
    return;
  }
  if (localLOGV)   Log.i(TAG,"String_Node_Str" + pkgName);
synchronized (mStatsLock) {
    PkgUsageStatsExtended pus=mStats.get(pkgName);
    if (pus == null) {
      pus=new PkgUsageStatsExtended();
      mStats.put(pkgName,pus);
    }
    pus.updateResume();
  }
  mResumedPkg=pkgName;
}

Fixed version (ground truth):
public void noteResumeComponent(ComponentName componentName){
  enforceCallingPermission();
  String pkgName;
synchronized (mStatsLock) {
    if ((componentName == null) || ((pkgName=componentName.getPackageName()) == null)) {
      return;
    }
    final boolean samePackage=pkgName.equals(mLastResumedPkg);
    if (mIsResumed) {
      if (samePackage) {
        Log.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str");
        return;
      }
      if (mLastResumedPkg != null) {
        Log.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str"+ mLastResumedPkg);
        PkgUsageStatsExtended pus=mStats.get(mLastResumedPkg);
        if (pus != null) {
          pus.updatePause();
        }
      }
    }
    final boolean sameComp=samePackage && componentName.getClassName().equals(mLastResumedComp);
    mIsResumed=true;
    mLastResumedPkg=pkgName;
    mLastResumedComp=componentName.getClassName();
    if (localLOGV)     Log.i(TAG,"String_Node_Str" + pkgName);
    PkgUsageStatsExtended pus=mStats.get(pkgName);
    if (pus == null) {
      pus=new PkgUsageStatsExtended();
      mStats.put(pkgName,pus);
    }
    pus.updateResume(!samePackage);
    if (!sameComp) {
      pus.addLaunchCount(mLastResumedComp);
    }
  }
}
Program: 43532
Project: 43532
Buggy source:
public void notePauseComponent(ComponentName componentName){
  enforceCallingPermission();
  String pkgName;
  if ((componentName == null) || ((pkgName=componentName.getPackageName()) == null)) {
    return;
  }
  if ((mResumedPkg == null) || (!pkgName.equalsIgnoreCase(mResumedPkg))) {
    Log.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str");
    return;
  }
  if (localLOGV)   Log.i(TAG,"String_Node_Str" + pkgName);
  writeStatsToFile(false);
synchronized (mStatsLock) {
    PkgUsageStatsExtended pus=mStats.get(pkgName);
    if (pus == null) {
      Log.w(TAG,"String_Node_Str" + pkgName);
      return;
    }
    pus.updatePause();
  }
}

Fixed version (ground truth):
public void notePauseComponent(ComponentName componentName){
  enforceCallingPermission();
synchronized (mStatsLock) {
    String pkgName;
    if ((componentName == null) || ((pkgName=componentName.getPackageName()) == null)) {
      return;
    }
    if (!mIsResumed) {
      Log.w(TAG,"String_Node_Str" + pkgName + "String_Node_Str");
      return;
    }
    mIsResumed=false;
    if (localLOGV)     Log.i(TAG,"String_Node_Str" + pkgName);
    PkgUsageStatsExtended pus=mStats.get(pkgName);
    if (pus == null) {
      Log.w(TAG,"String_Node_Str" + pkgName);
      return;
    }
    pus.updatePause();
  }
  writeStatsToFile(false);
}
Program: 43533
Project: 43533
Buggy source:
void updateResume(){
  mLaunchCount++;
  mResumedTime=SystemClock.elapsedRealtime();
}

Fixed version (ground truth):
void updateResume(boolean launched){
  if (launched) {
    mLaunchCount++;
  }
  mResumedTime=SystemClock.elapsedRealtime();
}
Program: 43535
Project: 43535
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: 43536
Project: 43536
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);
}