nus-yam/ex-repair huggingface dataset:
Program: 24075
Project: 24075
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: 24076
Project: 24076
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: 24077
Project: 24077
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: 24079
Project: 24079
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: 24080
Project: 24080
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: 24081
Project: 24081
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: 24084
Project: 24084
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: 24085
Project: 24085
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: 24086
Project: 24086
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: 24087
Project: 24087
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: 24088
Project: 24088
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: 24089
Project: 24089
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: 24090
Project: 24090
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: 24091
Project: 24091
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: 24092
Project: 24092
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: 24093
Project: 24093
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: 24094
Project: 24094
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: 24095
Project: 24095
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: 24096
Project: 24096
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: 24097
Project: 24097
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: 24098
Project: 24098
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: 24099
Project: 24099
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: 24100
Project: 24100
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: 24101
Project: 24101
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: 24102
Project: 24102
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: 24103
Project: 24103
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: 24104
Project: 24104
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: 24105
Project: 24105
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: 24106
Project: 24106
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: 24107
Project: 24107
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: 24108
Project: 24108
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: 24110
Project: 24110
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: 24112
Project: 24112
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: 24113
Project: 24113
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: 24115
Project: 24115
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: 24116
Project: 24116
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: 24118
Project: 24118
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: 24119
Project: 24119
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: 24120
Project: 24120
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: 24121
Project: 24121
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: 24123
Project: 24123
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: 24124
Project: 24124
Buggy source:
void updateResume(){
  mLaunchCount++;
  mResumedTime=SystemClock.elapsedRealtime();
}

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