nus-yam/ex-repair huggingface dataset:
Program: 196912
Project: 196912
Buggy source:
void serviceTimeout(ProcessRecord proc){
  String anrMessage=null;
synchronized (this) {
    if (proc.executingServices.size() == 0 || proc.thread == null) {
      return;
    }
    long maxTime=SystemClock.uptimeMillis() - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
    ServiceRecord timeout=null;
    long nextTime=0;
    for (int i=proc.executingServices.size() - 1; i >= 0; i--) {
      ServiceRecord sr=proc.executingServices.valueAt(i);
      if (sr.executingStart < maxTime) {
        timeout=sr;
        break;
      }
      if (sr.executingStart > nextTime) {
        nextTime=sr.executingStart;
      }
    }
    if (timeout != null && mAm.mLruProcesses.contains(proc)) {
      Slog.w(TAG,"String_Node_Str" + timeout);
      anrMessage="String_Node_Str" + timeout.shortName;
    }
 else {
      Message msg=mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
      msg.obj=proc;
      mAm.mHandler.sendMessageAtTime(msg,proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
    }
  }
  if (anrMessage != null) {
    mAm.appNotResponding(proc,null,null,false,anrMessage);
  }
}

Fixed version (ground truth):
void serviceTimeout(ProcessRecord proc){
  String anrMessage=null;
synchronized (mAm) {
    if (proc.executingServices.size() == 0 || proc.thread == null) {
      return;
    }
    long maxTime=SystemClock.uptimeMillis() - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
    ServiceRecord timeout=null;
    long nextTime=0;
    for (int i=proc.executingServices.size() - 1; i >= 0; i--) {
      ServiceRecord sr=proc.executingServices.valueAt(i);
      if (sr.executingStart < maxTime) {
        timeout=sr;
        break;
      }
      if (sr.executingStart > nextTime) {
        nextTime=sr.executingStart;
      }
    }
    if (timeout != null && mAm.mLruProcesses.contains(proc)) {
      Slog.w(TAG,"String_Node_Str" + timeout);
      anrMessage="String_Node_Str" + timeout.shortName;
    }
 else {
      Message msg=mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
      msg.obj=proc;
      mAm.mHandler.sendMessageAtTime(msg,proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
    }
  }
  if (anrMessage != null) {
    mAm.appNotResponding(proc,null,null,false,anrMessage);
  }
}
Program: 196913
Project: 196913
Buggy source:
private void ensureGroupStateLoadedLocked(int userId){
  final int[] profileIds=mSecurityPolicy.getEnabledGroupProfileIds(userId);
  int newMemberCount=0;
  final int profileIdCount=profileIds.length;
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (mLoadedUserIds.indexOfKey(profileId) >= 0) {
      profileIds[i]=LOADED_PROFILE_ID;
    }
 else {
      newMemberCount++;
    }
  }
  if (newMemberCount <= 0) {
    return;
  }
  int newMemberIndex=0;
  final int[] newProfileIds=new int[newMemberCount];
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (profileId != LOADED_PROFILE_ID) {
      mLoadedUserIds.put(profileId,profileId);
      newProfileIds[newMemberIndex]=profileId;
      newMemberIndex++;
    }
  }
  loadGroupWidgetProvidersLocked(newProfileIds);
  loadGroupStateLocked(newProfileIds);
}

Fixed version (ground truth):
private void ensureGroupStateLoadedLocked(int userId){
  final int[] profileIds=mSecurityPolicy.getEnabledGroupProfileIds(userId);
  int newMemberCount=0;
  final int profileIdCount=profileIds.length;
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (mLoadedUserIds.indexOfKey(profileId) >= 0) {
      profileIds[i]=LOADED_PROFILE_ID;
    }
 else {
      newMemberCount++;
    }
  }
  if (newMemberCount <= 0) {
    return;
  }
  int newMemberIndex=0;
  final int[] newProfileIds=new int[newMemberCount];
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (profileId != LOADED_PROFILE_ID) {
      mLoadedUserIds.put(profileId,profileId);
      newProfileIds[newMemberIndex]=profileId;
      newMemberIndex++;
    }
  }
  clearProvidersAndHostsTagsLocked();
  loadGroupWidgetProvidersLocked(newProfileIds);
  loadGroupStateLocked(newProfileIds);
}
Program: 196914
Project: 196914
Buggy source:
/** 
 * Invokes IApplicationThread.dumpService() on the thread of the specified service if there is a thread associated with the service.
 */
private void dumpService(String prefix,FileDescriptor fd,PrintWriter pw,final ServiceRecord r,String[] args,boolean dumpAll){
  String innerPrefix=prefix + "String_Node_Str";
synchronized (this) {
    pw.print(prefix);
    pw.print("String_Node_Str");
    pw.print(r.shortName);
    pw.print("String_Node_Str");
    pw.print(Integer.toHexString(System.identityHashCode(r)));
    pw.print("String_Node_Str");
    if (r.app != null)     pw.println(r.app.pid);
 else     pw.println("String_Node_Str");
    if (dumpAll) {
      r.dump(pw,innerPrefix);
    }
  }
  if (r.app != null && r.app.thread != null) {
    pw.print(prefix);
    pw.println("String_Node_Str");
    pw.flush();
    try {
      TransferPipe tp=new TransferPipe();
      try {
        r.app.thread.dumpService(tp.getWriteFd().getFileDescriptor(),r,args);
        tp.setBufferPrefix(prefix + "String_Node_Str");
        tp.go(fd);
      }
  finally {
        tp.kill();
      }
    }
 catch (    IOException e) {
      pw.println(prefix + "String_Node_Str" + e);
    }
catch (    RemoteException e) {
      pw.println(prefix + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Invokes IApplicationThread.dumpService() on the thread of the specified service if there is a thread associated with the service.
 */
private void dumpService(String prefix,FileDescriptor fd,PrintWriter pw,final ServiceRecord r,String[] args,boolean dumpAll){
  String innerPrefix=prefix + "String_Node_Str";
synchronized (mAm) {
    pw.print(prefix);
    pw.print("String_Node_Str");
    pw.print(r.shortName);
    pw.print("String_Node_Str");
    pw.print(Integer.toHexString(System.identityHashCode(r)));
    pw.print("String_Node_Str");
    if (r.app != null)     pw.println(r.app.pid);
 else     pw.println("String_Node_Str");
    if (dumpAll) {
      r.dump(pw,innerPrefix);
    }
  }
  if (r.app != null && r.app.thread != null) {
    pw.print(prefix);
    pw.println("String_Node_Str");
    pw.flush();
    try {
      TransferPipe tp=new TransferPipe();
      try {
        r.app.thread.dumpService(tp.getWriteFd().getFileDescriptor(),r,args);
        tp.setBufferPrefix(prefix + "String_Node_Str");
        tp.go(fd);
      }
  finally {
        tp.kill();
      }
    }
 catch (    IOException e) {
      pw.println(prefix + "String_Node_Str" + e);
    }
catch (    RemoteException e) {
      pw.println(prefix + "String_Node_Str");
    }
  }
}
Program: 196915
Project: 196915
Buggy source:
void serviceTimeout(ProcessRecord proc){
  String anrMessage=null;
synchronized (this) {
    if (proc.executingServices.size() == 0 || proc.thread == null) {
      return;
    }
    long maxTime=SystemClock.uptimeMillis() - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
    ServiceRecord timeout=null;
    long nextTime=0;
    for (int i=proc.executingServices.size() - 1; i >= 0; i--) {
      ServiceRecord sr=proc.executingServices.valueAt(i);
      if (sr.executingStart < maxTime) {
        timeout=sr;
        break;
      }
      if (sr.executingStart > nextTime) {
        nextTime=sr.executingStart;
      }
    }
    if (timeout != null && mAm.mLruProcesses.contains(proc)) {
      Slog.w(TAG,"String_Node_Str" + timeout);
      anrMessage="String_Node_Str" + timeout.shortName;
    }
 else {
      Message msg=mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
      msg.obj=proc;
      mAm.mHandler.sendMessageAtTime(msg,proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
    }
  }
  if (anrMessage != null) {
    mAm.appNotResponding(proc,null,null,false,anrMessage);
  }
}

Fixed version (ground truth):
void serviceTimeout(ProcessRecord proc){
  String anrMessage=null;
synchronized (mAm) {
    if (proc.executingServices.size() == 0 || proc.thread == null) {
      return;
    }
    long maxTime=SystemClock.uptimeMillis() - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
    ServiceRecord timeout=null;
    long nextTime=0;
    for (int i=proc.executingServices.size() - 1; i >= 0; i--) {
      ServiceRecord sr=proc.executingServices.valueAt(i);
      if (sr.executingStart < maxTime) {
        timeout=sr;
        break;
      }
      if (sr.executingStart > nextTime) {
        nextTime=sr.executingStart;
      }
    }
    if (timeout != null && mAm.mLruProcesses.contains(proc)) {
      Slog.w(TAG,"String_Node_Str" + timeout);
      anrMessage="String_Node_Str" + timeout.shortName;
    }
 else {
      Message msg=mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
      msg.obj=proc;
      mAm.mHandler.sendMessageAtTime(msg,proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
    }
  }
  if (anrMessage != null) {
    mAm.appNotResponding(proc,null,null,false,anrMessage);
  }
}
Program: 196916
Project: 196916
Buggy source:
private void ensureGroupStateLoadedLocked(int userId){
  final int[] profileIds=mSecurityPolicy.getEnabledGroupProfileIds(userId);
  int newMemberCount=0;
  final int profileIdCount=profileIds.length;
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (mLoadedUserIds.indexOfKey(profileId) >= 0) {
      profileIds[i]=LOADED_PROFILE_ID;
    }
 else {
      newMemberCount++;
    }
  }
  if (newMemberCount <= 0) {
    return;
  }
  int newMemberIndex=0;
  final int[] newProfileIds=new int[newMemberCount];
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (profileId != LOADED_PROFILE_ID) {
      mLoadedUserIds.put(profileId,profileId);
      newProfileIds[newMemberIndex]=profileId;
      newMemberIndex++;
    }
  }
  loadGroupWidgetProvidersLocked(newProfileIds);
  loadGroupStateLocked(newProfileIds);
}

Fixed version (ground truth):
private void ensureGroupStateLoadedLocked(int userId){
  final int[] profileIds=mSecurityPolicy.getEnabledGroupProfileIds(userId);
  int newMemberCount=0;
  final int profileIdCount=profileIds.length;
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (mLoadedUserIds.indexOfKey(profileId) >= 0) {
      profileIds[i]=LOADED_PROFILE_ID;
    }
 else {
      newMemberCount++;
    }
  }
  if (newMemberCount <= 0) {
    return;
  }
  int newMemberIndex=0;
  final int[] newProfileIds=new int[newMemberCount];
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (profileId != LOADED_PROFILE_ID) {
      mLoadedUserIds.put(profileId,profileId);
      newProfileIds[newMemberIndex]=profileId;
      newMemberIndex++;
    }
  }
  clearProvidersAndHostsTagsLocked();
  loadGroupWidgetProvidersLocked(newProfileIds);
  loadGroupStateLocked(newProfileIds);
}
Program: 196917
Project: 196917
Buggy source:
private void ensureGroupStateLoadedLocked(int userId){
  final int[] profileIds=mSecurityPolicy.getEnabledGroupProfileIds(userId);
  int newMemberCount=0;
  final int profileIdCount=profileIds.length;
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (mLoadedUserIds.indexOfKey(profileId) >= 0) {
      profileIds[i]=LOADED_PROFILE_ID;
    }
 else {
      newMemberCount++;
    }
  }
  if (newMemberCount <= 0) {
    return;
  }
  int newMemberIndex=0;
  final int[] newProfileIds=new int[newMemberCount];
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (profileId != LOADED_PROFILE_ID) {
      mLoadedUserIds.put(profileId,profileId);
      newProfileIds[newMemberIndex]=profileId;
      newMemberIndex++;
    }
  }
  loadGroupWidgetProvidersLocked(newProfileIds);
  loadGroupStateLocked(newProfileIds);
}

Fixed version (ground truth):
private void ensureGroupStateLoadedLocked(int userId){
  final int[] profileIds=mSecurityPolicy.getEnabledGroupProfileIds(userId);
  int newMemberCount=0;
  final int profileIdCount=profileIds.length;
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (mLoadedUserIds.indexOfKey(profileId) >= 0) {
      profileIds[i]=LOADED_PROFILE_ID;
    }
 else {
      newMemberCount++;
    }
  }
  if (newMemberCount <= 0) {
    return;
  }
  int newMemberIndex=0;
  final int[] newProfileIds=new int[newMemberCount];
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (profileId != LOADED_PROFILE_ID) {
      mLoadedUserIds.put(profileId,profileId);
      newProfileIds[newMemberIndex]=profileId;
      newMemberIndex++;
    }
  }
  clearProvidersAndHostsTagsLocked();
  loadGroupWidgetProvidersLocked(newProfileIds);
  loadGroupStateLocked(newProfileIds);
}
Program: 196918
Project: 196918
Buggy source:
/** 
 * Invokes IApplicationThread.dumpService() on the thread of the specified service if there is a thread associated with the service.
 */
private void dumpService(String prefix,FileDescriptor fd,PrintWriter pw,final ServiceRecord r,String[] args,boolean dumpAll){
  String innerPrefix=prefix + "String_Node_Str";
synchronized (this) {
    pw.print(prefix);
    pw.print("String_Node_Str");
    pw.print(r.shortName);
    pw.print("String_Node_Str");
    pw.print(Integer.toHexString(System.identityHashCode(r)));
    pw.print("String_Node_Str");
    if (r.app != null)     pw.println(r.app.pid);
 else     pw.println("String_Node_Str");
    if (dumpAll) {
      r.dump(pw,innerPrefix);
    }
  }
  if (r.app != null && r.app.thread != null) {
    pw.print(prefix);
    pw.println("String_Node_Str");
    pw.flush();
    try {
      TransferPipe tp=new TransferPipe();
      try {
        r.app.thread.dumpService(tp.getWriteFd().getFileDescriptor(),r,args);
        tp.setBufferPrefix(prefix + "String_Node_Str");
        tp.go(fd);
      }
  finally {
        tp.kill();
      }
    }
 catch (    IOException e) {
      pw.println(prefix + "String_Node_Str" + e);
    }
catch (    RemoteException e) {
      pw.println(prefix + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Invokes IApplicationThread.dumpService() on the thread of the specified service if there is a thread associated with the service.
 */
private void dumpService(String prefix,FileDescriptor fd,PrintWriter pw,final ServiceRecord r,String[] args,boolean dumpAll){
  String innerPrefix=prefix + "String_Node_Str";
synchronized (mAm) {
    pw.print(prefix);
    pw.print("String_Node_Str");
    pw.print(r.shortName);
    pw.print("String_Node_Str");
    pw.print(Integer.toHexString(System.identityHashCode(r)));
    pw.print("String_Node_Str");
    if (r.app != null)     pw.println(r.app.pid);
 else     pw.println("String_Node_Str");
    if (dumpAll) {
      r.dump(pw,innerPrefix);
    }
  }
  if (r.app != null && r.app.thread != null) {
    pw.print(prefix);
    pw.println("String_Node_Str");
    pw.flush();
    try {
      TransferPipe tp=new TransferPipe();
      try {
        r.app.thread.dumpService(tp.getWriteFd().getFileDescriptor(),r,args);
        tp.setBufferPrefix(prefix + "String_Node_Str");
        tp.go(fd);
      }
  finally {
        tp.kill();
      }
    }
 catch (    IOException e) {
      pw.println(prefix + "String_Node_Str" + e);
    }
catch (    RemoteException e) {
      pw.println(prefix + "String_Node_Str");
    }
  }
}
Program: 196919
Project: 196919
Buggy source:
void serviceTimeout(ProcessRecord proc){
  String anrMessage=null;
synchronized (this) {
    if (proc.executingServices.size() == 0 || proc.thread == null) {
      return;
    }
    long maxTime=SystemClock.uptimeMillis() - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
    ServiceRecord timeout=null;
    long nextTime=0;
    for (int i=proc.executingServices.size() - 1; i >= 0; i--) {
      ServiceRecord sr=proc.executingServices.valueAt(i);
      if (sr.executingStart < maxTime) {
        timeout=sr;
        break;
      }
      if (sr.executingStart > nextTime) {
        nextTime=sr.executingStart;
      }
    }
    if (timeout != null && mAm.mLruProcesses.contains(proc)) {
      Slog.w(TAG,"String_Node_Str" + timeout);
      anrMessage="String_Node_Str" + timeout.shortName;
    }
 else {
      Message msg=mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
      msg.obj=proc;
      mAm.mHandler.sendMessageAtTime(msg,proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
    }
  }
  if (anrMessage != null) {
    mAm.appNotResponding(proc,null,null,false,anrMessage);
  }
}

Fixed version (ground truth):
void serviceTimeout(ProcessRecord proc){
  String anrMessage=null;
synchronized (mAm) {
    if (proc.executingServices.size() == 0 || proc.thread == null) {
      return;
    }
    long maxTime=SystemClock.uptimeMillis() - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
    ServiceRecord timeout=null;
    long nextTime=0;
    for (int i=proc.executingServices.size() - 1; i >= 0; i--) {
      ServiceRecord sr=proc.executingServices.valueAt(i);
      if (sr.executingStart < maxTime) {
        timeout=sr;
        break;
      }
      if (sr.executingStart > nextTime) {
        nextTime=sr.executingStart;
      }
    }
    if (timeout != null && mAm.mLruProcesses.contains(proc)) {
      Slog.w(TAG,"String_Node_Str" + timeout);
      anrMessage="String_Node_Str" + timeout.shortName;
    }
 else {
      Message msg=mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
      msg.obj=proc;
      mAm.mHandler.sendMessageAtTime(msg,proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
    }
  }
  if (anrMessage != null) {
    mAm.appNotResponding(proc,null,null,false,anrMessage);
  }
}
Program: 196920
Project: 196920
Buggy source:
/** 
 * Invokes IApplicationThread.dumpService() on the thread of the specified service if there is a thread associated with the service.
 */
private void dumpService(String prefix,FileDescriptor fd,PrintWriter pw,final ServiceRecord r,String[] args,boolean dumpAll){
  String innerPrefix=prefix + "String_Node_Str";
synchronized (this) {
    pw.print(prefix);
    pw.print("String_Node_Str");
    pw.print(r.shortName);
    pw.print("String_Node_Str");
    pw.print(Integer.toHexString(System.identityHashCode(r)));
    pw.print("String_Node_Str");
    if (r.app != null)     pw.println(r.app.pid);
 else     pw.println("String_Node_Str");
    if (dumpAll) {
      r.dump(pw,innerPrefix);
    }
  }
  if (r.app != null && r.app.thread != null) {
    pw.print(prefix);
    pw.println("String_Node_Str");
    pw.flush();
    try {
      TransferPipe tp=new TransferPipe();
      try {
        r.app.thread.dumpService(tp.getWriteFd().getFileDescriptor(),r,args);
        tp.setBufferPrefix(prefix + "String_Node_Str");
        tp.go(fd);
      }
  finally {
        tp.kill();
      }
    }
 catch (    IOException e) {
      pw.println(prefix + "String_Node_Str" + e);
    }
catch (    RemoteException e) {
      pw.println(prefix + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Invokes IApplicationThread.dumpService() on the thread of the specified service if there is a thread associated with the service.
 */
private void dumpService(String prefix,FileDescriptor fd,PrintWriter pw,final ServiceRecord r,String[] args,boolean dumpAll){
  String innerPrefix=prefix + "String_Node_Str";
synchronized (mAm) {
    pw.print(prefix);
    pw.print("String_Node_Str");
    pw.print(r.shortName);
    pw.print("String_Node_Str");
    pw.print(Integer.toHexString(System.identityHashCode(r)));
    pw.print("String_Node_Str");
    if (r.app != null)     pw.println(r.app.pid);
 else     pw.println("String_Node_Str");
    if (dumpAll) {
      r.dump(pw,innerPrefix);
    }
  }
  if (r.app != null && r.app.thread != null) {
    pw.print(prefix);
    pw.println("String_Node_Str");
    pw.flush();
    try {
      TransferPipe tp=new TransferPipe();
      try {
        r.app.thread.dumpService(tp.getWriteFd().getFileDescriptor(),r,args);
        tp.setBufferPrefix(prefix + "String_Node_Str");
        tp.go(fd);
      }
  finally {
        tp.kill();
      }
    }
 catch (    IOException e) {
      pw.println(prefix + "String_Node_Str" + e);
    }
catch (    RemoteException e) {
      pw.println(prefix + "String_Node_Str");
    }
  }
}
Program: 196921
Project: 196921
Buggy source:
void serviceTimeout(ProcessRecord proc){
  String anrMessage=null;
synchronized (this) {
    if (proc.executingServices.size() == 0 || proc.thread == null) {
      return;
    }
    long maxTime=SystemClock.uptimeMillis() - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
    ServiceRecord timeout=null;
    long nextTime=0;
    for (int i=proc.executingServices.size() - 1; i >= 0; i--) {
      ServiceRecord sr=proc.executingServices.valueAt(i);
      if (sr.executingStart < maxTime) {
        timeout=sr;
        break;
      }
      if (sr.executingStart > nextTime) {
        nextTime=sr.executingStart;
      }
    }
    if (timeout != null && mAm.mLruProcesses.contains(proc)) {
      Slog.w(TAG,"String_Node_Str" + timeout);
      anrMessage="String_Node_Str" + timeout.shortName;
    }
 else {
      Message msg=mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
      msg.obj=proc;
      mAm.mHandler.sendMessageAtTime(msg,proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
    }
  }
  if (anrMessage != null) {
    mAm.appNotResponding(proc,null,null,false,anrMessage);
  }
}

Fixed version (ground truth):
void serviceTimeout(ProcessRecord proc){
  String anrMessage=null;
synchronized (mAm) {
    if (proc.executingServices.size() == 0 || proc.thread == null) {
      return;
    }
    long maxTime=SystemClock.uptimeMillis() - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
    ServiceRecord timeout=null;
    long nextTime=0;
    for (int i=proc.executingServices.size() - 1; i >= 0; i--) {
      ServiceRecord sr=proc.executingServices.valueAt(i);
      if (sr.executingStart < maxTime) {
        timeout=sr;
        break;
      }
      if (sr.executingStart > nextTime) {
        nextTime=sr.executingStart;
      }
    }
    if (timeout != null && mAm.mLruProcesses.contains(proc)) {
      Slog.w(TAG,"String_Node_Str" + timeout);
      anrMessage="String_Node_Str" + timeout.shortName;
    }
 else {
      Message msg=mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
      msg.obj=proc;
      mAm.mHandler.sendMessageAtTime(msg,proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
    }
  }
  if (anrMessage != null) {
    mAm.appNotResponding(proc,null,null,false,anrMessage);
  }
}
Program: 196922
Project: 196922
Buggy source:
/** 
 * Invokes IApplicationThread.dumpService() on the thread of the specified service if there is a thread associated with the service.
 */
private void dumpService(String prefix,FileDescriptor fd,PrintWriter pw,final ServiceRecord r,String[] args,boolean dumpAll){
  String innerPrefix=prefix + "String_Node_Str";
synchronized (this) {
    pw.print(prefix);
    pw.print("String_Node_Str");
    pw.print(r.shortName);
    pw.print("String_Node_Str");
    pw.print(Integer.toHexString(System.identityHashCode(r)));
    pw.print("String_Node_Str");
    if (r.app != null)     pw.println(r.app.pid);
 else     pw.println("String_Node_Str");
    if (dumpAll) {
      r.dump(pw,innerPrefix);
    }
  }
  if (r.app != null && r.app.thread != null) {
    pw.print(prefix);
    pw.println("String_Node_Str");
    pw.flush();
    try {
      TransferPipe tp=new TransferPipe();
      try {
        r.app.thread.dumpService(tp.getWriteFd().getFileDescriptor(),r,args);
        tp.setBufferPrefix(prefix + "String_Node_Str");
        tp.go(fd);
      }
  finally {
        tp.kill();
      }
    }
 catch (    IOException e) {
      pw.println(prefix + "String_Node_Str" + e);
    }
catch (    RemoteException e) {
      pw.println(prefix + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Invokes IApplicationThread.dumpService() on the thread of the specified service if there is a thread associated with the service.
 */
private void dumpService(String prefix,FileDescriptor fd,PrintWriter pw,final ServiceRecord r,String[] args,boolean dumpAll){
  String innerPrefix=prefix + "String_Node_Str";
synchronized (mAm) {
    pw.print(prefix);
    pw.print("String_Node_Str");
    pw.print(r.shortName);
    pw.print("String_Node_Str");
    pw.print(Integer.toHexString(System.identityHashCode(r)));
    pw.print("String_Node_Str");
    if (r.app != null)     pw.println(r.app.pid);
 else     pw.println("String_Node_Str");
    if (dumpAll) {
      r.dump(pw,innerPrefix);
    }
  }
  if (r.app != null && r.app.thread != null) {
    pw.print(prefix);
    pw.println("String_Node_Str");
    pw.flush();
    try {
      TransferPipe tp=new TransferPipe();
      try {
        r.app.thread.dumpService(tp.getWriteFd().getFileDescriptor(),r,args);
        tp.setBufferPrefix(prefix + "String_Node_Str");
        tp.go(fd);
      }
  finally {
        tp.kill();
      }
    }
 catch (    IOException e) {
      pw.println(prefix + "String_Node_Str" + e);
    }
catch (    RemoteException e) {
      pw.println(prefix + "String_Node_Str");
    }
  }
}
Program: 196923
Project: 196923
Buggy source:
void serviceTimeout(ProcessRecord proc){
  String anrMessage=null;
synchronized (this) {
    if (proc.executingServices.size() == 0 || proc.thread == null) {
      return;
    }
    long maxTime=SystemClock.uptimeMillis() - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
    ServiceRecord timeout=null;
    long nextTime=0;
    for (int i=proc.executingServices.size() - 1; i >= 0; i--) {
      ServiceRecord sr=proc.executingServices.valueAt(i);
      if (sr.executingStart < maxTime) {
        timeout=sr;
        break;
      }
      if (sr.executingStart > nextTime) {
        nextTime=sr.executingStart;
      }
    }
    if (timeout != null && mAm.mLruProcesses.contains(proc)) {
      Slog.w(TAG,"String_Node_Str" + timeout);
      anrMessage="String_Node_Str" + timeout.shortName;
    }
 else {
      Message msg=mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
      msg.obj=proc;
      mAm.mHandler.sendMessageAtTime(msg,proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
    }
  }
  if (anrMessage != null) {
    mAm.appNotResponding(proc,null,null,false,anrMessage);
  }
}

Fixed version (ground truth):
void serviceTimeout(ProcessRecord proc){
  String anrMessage=null;
synchronized (mAm) {
    if (proc.executingServices.size() == 0 || proc.thread == null) {
      return;
    }
    long maxTime=SystemClock.uptimeMillis() - (proc.execServicesFg ? SERVICE_TIMEOUT : SERVICE_BACKGROUND_TIMEOUT);
    ServiceRecord timeout=null;
    long nextTime=0;
    for (int i=proc.executingServices.size() - 1; i >= 0; i--) {
      ServiceRecord sr=proc.executingServices.valueAt(i);
      if (sr.executingStart < maxTime) {
        timeout=sr;
        break;
      }
      if (sr.executingStart > nextTime) {
        nextTime=sr.executingStart;
      }
    }
    if (timeout != null && mAm.mLruProcesses.contains(proc)) {
      Slog.w(TAG,"String_Node_Str" + timeout);
      anrMessage="String_Node_Str" + timeout.shortName;
    }
 else {
      Message msg=mAm.mHandler.obtainMessage(ActivityManagerService.SERVICE_TIMEOUT_MSG);
      msg.obj=proc;
      mAm.mHandler.sendMessageAtTime(msg,proc.execServicesFg ? (nextTime + SERVICE_TIMEOUT) : (nextTime + SERVICE_BACKGROUND_TIMEOUT));
    }
  }
  if (anrMessage != null) {
    mAm.appNotResponding(proc,null,null,false,anrMessage);
  }
}
Program: 196924
Project: 196924
Buggy source:
private void ensureGroupStateLoadedLocked(int userId){
  final int[] profileIds=mSecurityPolicy.getEnabledGroupProfileIds(userId);
  int newMemberCount=0;
  final int profileIdCount=profileIds.length;
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (mLoadedUserIds.indexOfKey(profileId) >= 0) {
      profileIds[i]=LOADED_PROFILE_ID;
    }
 else {
      newMemberCount++;
    }
  }
  if (newMemberCount <= 0) {
    return;
  }
  int newMemberIndex=0;
  final int[] newProfileIds=new int[newMemberCount];
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (profileId != LOADED_PROFILE_ID) {
      mLoadedUserIds.put(profileId,profileId);
      newProfileIds[newMemberIndex]=profileId;
      newMemberIndex++;
    }
  }
  loadGroupWidgetProvidersLocked(newProfileIds);
  loadGroupStateLocked(newProfileIds);
}

Fixed version (ground truth):
private void ensureGroupStateLoadedLocked(int userId){
  final int[] profileIds=mSecurityPolicy.getEnabledGroupProfileIds(userId);
  int newMemberCount=0;
  final int profileIdCount=profileIds.length;
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (mLoadedUserIds.indexOfKey(profileId) >= 0) {
      profileIds[i]=LOADED_PROFILE_ID;
    }
 else {
      newMemberCount++;
    }
  }
  if (newMemberCount <= 0) {
    return;
  }
  int newMemberIndex=0;
  final int[] newProfileIds=new int[newMemberCount];
  for (int i=0; i < profileIdCount; i++) {
    final int profileId=profileIds[i];
    if (profileId != LOADED_PROFILE_ID) {
      mLoadedUserIds.put(profileId,profileId);
      newProfileIds[newMemberIndex]=profileId;
      newMemberIndex++;
    }
  }
  clearProvidersAndHostsTagsLocked();
  loadGroupWidgetProvidersLocked(newProfileIds);
  loadGroupStateLocked(newProfileIds);
}
Program: 196925
Project: 196925
Buggy source:
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null && srec.task.getBaseIntent() != null && srec.task.getBaseIntent().isDocument()) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}
Program: 196926
Project: 196926
Buggy source:
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null && srec.task.getBaseIntent() != null && srec.task.getBaseIntent().isDocument()) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}
Program: 196927
Project: 196927
Buggy source:
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null && srec.task.getBaseIntent() != null && srec.task.getBaseIntent().isDocument()) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}
Program: 196928
Project: 196928
Buggy source:
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null && srec.task.getBaseIntent() != null && srec.task.getBaseIntent().isDocument()) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}
Program: 196929
Project: 196929
Buggy source:
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null && srec.task.getBaseIntent() != null && srec.task.getBaseIntent().isDocument()) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}
Program: 196930
Project: 196930
Buggy source:
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null && srec.task.getBaseIntent() != null && srec.task.getBaseIntent().isDocument()) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}
Program: 196931
Project: 196931
Buggy source:
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null && srec.task.getBaseIntent() != null && srec.task.getBaseIntent().isDocument()) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}
Program: 196933
Project: 196933
Buggy source:
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
final boolean shouldUpRecreateTaskLocked(ActivityRecord srec,String destAffinity){
  if (srec == null || srec.task.affinity == null || !srec.task.affinity.equals(destAffinity)) {
    return true;
  }
  if (srec.frontOfTask && srec.task != null && srec.task.getBaseIntent() != null && srec.task.getBaseIntent().isDocument()) {
    if (srec.task.getTaskToReturnTo() != ActivityRecord.APPLICATION_ACTIVITY_TYPE) {
      return true;
    }
    int taskIdx=mTaskHistory.indexOf(srec.task);
    if (taskIdx <= 0) {
      Slog.w(TAG,"String_Node_Str" + srec);
      return false;
    }
    if (taskIdx == 0) {
      return true;
    }
    TaskRecord prevTask=mTaskHistory.get(taskIdx);
    if (!srec.task.affinity.equals(prevTask.affinity)) {
      return true;
    }
  }
  return false;
}
Program: 196949
Project: 196949
Buggy source:
@Override public void enableSystemApp(ComponentName who,String packageName){
synchronized (this) {
    if (who == null) {
      throw new NullPointerException("String_Node_Str");
    }
    getActiveAdminForCallerLocked(who,DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
    int userId=UserHandle.getCallingUserId();
    long id=Binder.clearCallingIdentity();
    try {
      UserManager um=UserManager.get(mContext);
      if (!um.getUserInfo(userId).isManagedProfile()) {
        throw new IllegalStateException("String_Node_Str");
      }
      UserInfo primaryUser=um.getProfileParent(userId);
      if (DBG) {
        Slog.v(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ userId);
      }
      IPackageManager pm=AppGlobals.getPackageManager();
      if (!isSystemApp(pm,packageName,primaryUser.id)) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      pm.installExistingPackageAsUser(packageName,userId);
    }
 catch (    RemoteException re) {
      Slog.wtf(LOG_TAG,"String_Node_Str" + packageName,re);
    }
 finally {
      restoreCallingIdentity(id);
    }
  }
}

Fixed version (ground truth):
@Override public void enableSystemApp(ComponentName who,String packageName){
synchronized (this) {
    if (who == null) {
      throw new NullPointerException("String_Node_Str");
    }
    getActiveAdminForCallerLocked(who,DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
    int userId=UserHandle.getCallingUserId();
    long id=Binder.clearCallingIdentity();
    try {
      if (DBG) {
        Slog.v(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ userId);
      }
      UserManager um=UserManager.get(mContext);
      UserInfo primaryUser=um.getProfileParent(userId);
      if (primaryUser == null) {
        primaryUser=um.getUserInfo(userId);
      }
      IPackageManager pm=AppGlobals.getPackageManager();
      if (!isSystemApp(pm,packageName,primaryUser.id)) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      pm.installExistingPackageAsUser(packageName,userId);
    }
 catch (    RemoteException re) {
      Slog.wtf(LOG_TAG,"String_Node_Str" + packageName,re);
    }
 finally {
      restoreCallingIdentity(id);
    }
  }
}
Program: 196951
Project: 196951
Buggy source:
private boolean isSystemApp(IPackageManager pm,String packageName,int userId) throws RemoteException {
  ApplicationInfo appInfo=pm.getApplicationInfo(packageName,0,userId);
  return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0;
}

Fixed version (ground truth):
private boolean isSystemApp(IPackageManager pm,String packageName,int userId) throws RemoteException {
  ApplicationInfo appInfo=pm.getApplicationInfo(packageName,GET_UNINSTALLED_PACKAGES,userId);
  return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0;
}
Program: 196952
Project: 196952
Buggy source:
@Override public void enableSystemApp(ComponentName who,String packageName){
synchronized (this) {
    if (who == null) {
      throw new NullPointerException("String_Node_Str");
    }
    getActiveAdminForCallerLocked(who,DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
    int userId=UserHandle.getCallingUserId();
    long id=Binder.clearCallingIdentity();
    try {
      UserManager um=UserManager.get(mContext);
      if (!um.getUserInfo(userId).isManagedProfile()) {
        throw new IllegalStateException("String_Node_Str");
      }
      UserInfo primaryUser=um.getProfileParent(userId);
      if (DBG) {
        Slog.v(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ userId);
      }
      IPackageManager pm=AppGlobals.getPackageManager();
      if (!isSystemApp(pm,packageName,primaryUser.id)) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      pm.installExistingPackageAsUser(packageName,userId);
    }
 catch (    RemoteException re) {
      Slog.wtf(LOG_TAG,"String_Node_Str" + packageName,re);
    }
 finally {
      restoreCallingIdentity(id);
    }
  }
}

Fixed version (ground truth):
@Override public void enableSystemApp(ComponentName who,String packageName){
synchronized (this) {
    if (who == null) {
      throw new NullPointerException("String_Node_Str");
    }
    getActiveAdminForCallerLocked(who,DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
    int userId=UserHandle.getCallingUserId();
    long id=Binder.clearCallingIdentity();
    try {
      if (DBG) {
        Slog.v(LOG_TAG,"String_Node_Str" + packageName + "String_Node_Str"+ userId);
      }
      UserManager um=UserManager.get(mContext);
      UserInfo primaryUser=um.getProfileParent(userId);
      if (primaryUser == null) {
        primaryUser=um.getUserInfo(userId);
      }
      IPackageManager pm=AppGlobals.getPackageManager();
      if (!isSystemApp(pm,packageName,primaryUser.id)) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      pm.installExistingPackageAsUser(packageName,userId);
    }
 catch (    RemoteException re) {
      Slog.wtf(LOG_TAG,"String_Node_Str" + packageName,re);
    }
 finally {
      restoreCallingIdentity(id);
    }
  }
}
Program: 196954
Project: 196954
Buggy source:
private boolean isSystemApp(IPackageManager pm,String packageName,int userId) throws RemoteException {
  ApplicationInfo appInfo=pm.getApplicationInfo(packageName,0,userId);
  return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0;
}

Fixed version (ground truth):
private boolean isSystemApp(IPackageManager pm,String packageName,int userId) throws RemoteException {
  ApplicationInfo appInfo=pm.getApplicationInfo(packageName,GET_UNINSTALLED_PACKAGES,userId);
  return (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) > 0;
}