Program: 197522
Project: 197522
Buggy source:
final void appNotResponding(ProcessRecord app,ActivityRecord activity,ActivityRecord parent,boolean aboveSystem,final String annotation){
  ArrayList<Integer> firstPids=new ArrayList<Integer>(5);
  SparseArray<Boolean> lastPids=new SparseArray<Boolean>(20);
  if (mController != null) {
    try {
      int res=mController.appEarlyNotResponding(app.processName,app.pid,annotation);
      if (res < 0 && app.pid != MY_PID) {
        app.kill("String_Node_Str",true);
      }
    }
 catch (    RemoteException e) {
      mController=null;
      Watchdog.getInstance().setActivityController(null);
    }
  }
  long anrTime=SystemClock.uptimeMillis();
  if (MONITOR_CPU_USAGE) {
    updateCpuStatsNow();
  }
synchronized (this) {
    if (mShuttingDown) {
      Slog.i(TAG,"String_Node_Str" + app + "String_Node_Str"+ annotation);
      return;
    }
 else     if (app.notResponding) {
      Slog.i(TAG,"String_Node_Str" + app + "String_Node_Str"+ annotation);
      return;
    }
 else     if (app.crashing) {
      Slog.i(TAG,"String_Node_Str" + app + "String_Node_Str"+ annotation);
      return;
    }
    app.notResponding=true;
    EventLog.writeEvent(EventLogTags.AM_ANR,app.userId,app.pid,app.processName,app.info.flags,annotation);
    firstPids.add(app.pid);
    int parentPid=app.pid;
    if (parent != null && parent.app != null && parent.app.pid > 0)     parentPid=parent.app.pid;
    if (parentPid != app.pid)     firstPids.add(parentPid);
    if (MY_PID != app.pid && MY_PID != parentPid)     firstPids.add(MY_PID);
    for (int i=mLruProcesses.size() - 1; i >= 0; i--) {
      ProcessRecord r=mLruProcesses.get(i);
      if (r != null && r.thread != null) {
        int pid=r.pid;
        if (pid > 0 && pid != app.pid && pid != parentPid && pid != MY_PID) {
          if (r.persistent) {
            firstPids.add(pid);
          }
 else {
            lastPids.put(pid,Boolean.TRUE);
          }
        }
      }
    }
  }
  StringBuilder info=new StringBuilder();
  info.setLength(0);
  info.append("String_Node_Str").append(app.processName);
  if (activity != null && activity.shortComponentName != null) {
    info.append("String_Node_Str").append(activity.shortComponentName).append("String_Node_Str");
  }
  info.append("String_Node_Str");
  info.append("String_Node_Str").append(app.pid).append("String_Node_Str");
  if (annotation != null) {
    info.append("String_Node_Str").append(annotation).append("String_Node_Str");
  }
  if (parent != null && parent != activity) {
    info.append("String_Node_Str").append(parent.shortComponentName).append("String_Node_Str");
  }
  final ProcessCpuTracker processCpuTracker=new ProcessCpuTracker(true);
  File tracesFile=dumpStackTraces(true,firstPids,processCpuTracker,lastPids,NATIVE_STACKS_OF_INTEREST);
  String cpuInfo=null;
  if (MONITOR_CPU_USAGE) {
    updateCpuStatsNow();
synchronized (mProcessCpuThread) {
      cpuInfo=mProcessCpuTracker.printCurrentState(anrTime);
    }
    info.append(processCpuTracker.printCurrentLoad());
    info.append(cpuInfo);
  }
  info.append(processCpuTracker.printCurrentState(anrTime));
  Slog.e(TAG,info.toString());
  if (tracesFile == null) {
    Process.sendSignal(app.pid,Process.SIGNAL_QUIT);
  }
  addErrorToDropBox("String_Node_Str",app,app.processName,activity,parent,annotation,cpuInfo,tracesFile,null);
  if (mController != null) {
    try {
      int res=mController.appNotResponding(app.processName,app.pid,info.toString());
      if (res != 0) {
        if (res < 0 && app.pid != MY_PID) {
          app.kill("String_Node_Str",true);
        }
 else {
synchronized (this) {
            mServices.scheduleServiceTimeoutLocked(app);
          }
        }
        return;
      }
    }
 catch (    RemoteException e) {
      mController=null;
      Watchdog.getInstance().setActivityController(null);
    }
  }
  boolean showBackground=Settings.Secure.getInt(mContext.getContentResolver(),Settings.Secure.ANR_SHOW_BACKGROUND,0) != 0;
synchronized (this) {
    if (!showBackground && !app.isInterestingToUserLocked() && app.pid != MY_PID) {
      app.kill("String_Node_Str",true);
      return;
    }
    makeAppNotRespondingLocked(app,activity != null ? activity.shortComponentName : null,annotation != null ? "String_Node_Str" + annotation : "String_Node_Str",info.toString());
    Message msg=Message.obtain();
    HashMap<String,Object> map=new HashMap<String,Object>();
    msg.what=SHOW_NOT_RESPONDING_MSG;
    msg.obj=map;
    msg.arg1=aboveSystem ? 1 : 0;
    map.put("String_Node_Str",app);
    if (activity != null) {
      map.put("String_Node_Str",activity);
    }
    mHandler.sendMessage(msg);
  }
}

Fixed version (ground truth):
final void appNotResponding(ProcessRecord app,ActivityRecord activity,ActivityRecord parent,boolean aboveSystem,final String annotation){
  ArrayList<Integer> firstPids=new ArrayList<Integer>(5);
  SparseArray<Boolean> lastPids=new SparseArray<Boolean>(20);
  if (mController != null) {
    try {
      int res=mController.appEarlyNotResponding(app.processName,app.pid,annotation);
      if (res < 0 && app.pid != MY_PID) {
        app.kill("String_Node_Str",true);
      }
    }
 catch (    RemoteException e) {
      mController=null;
      Watchdog.getInstance().setActivityController(null);
    }
  }
  long anrTime=SystemClock.uptimeMillis();
  if (MONITOR_CPU_USAGE) {
    updateCpuStatsNow();
  }
synchronized (this) {
    if (mShuttingDown) {
      Slog.i(TAG,"String_Node_Str" + app + "String_Node_Str"+ annotation);
      return;
    }
 else     if (app.notResponding) {
      Slog.i(TAG,"String_Node_Str" + app + "String_Node_Str"+ annotation);
      return;
    }
 else     if (app.crashing) {
      Slog.i(TAG,"String_Node_Str" + app + "String_Node_Str"+ annotation);
      return;
    }
    app.notResponding=true;
    EventLog.writeEvent(EventLogTags.AM_ANR,app.userId,app.pid,app.processName,app.info.flags,annotation);
    firstPids.add(app.pid);
    int parentPid=app.pid;
    if (parent != null && parent.app != null && parent.app.pid > 0)     parentPid=parent.app.pid;
    if (parentPid != app.pid)     firstPids.add(parentPid);
    if (MY_PID != app.pid && MY_PID != parentPid)     firstPids.add(MY_PID);
    for (int i=mLruProcesses.size() - 1; i >= 0; i--) {
      ProcessRecord r=mLruProcesses.get(i);
      if (r != null && r.thread != null) {
        int pid=r.pid;
        if (pid > 0 && pid != app.pid && pid != parentPid && pid != MY_PID) {
          if (r.persistent) {
            firstPids.add(pid);
          }
 else {
            lastPids.put(pid,Boolean.TRUE);
          }
        }
      }
    }
  }
  StringBuilder info=new StringBuilder();
  info.setLength(0);
  info.append("String_Node_Str").append(app.processName);
  if (activity != null && activity.shortComponentName != null) {
    info.append("String_Node_Str").append(activity.shortComponentName).append("String_Node_Str");
  }
  info.append("String_Node_Str");
  info.append("String_Node_Str").append(app.pid).append("String_Node_Str");
  if (annotation != null) {
    info.append("String_Node_Str").append(annotation).append("String_Node_Str");
  }
  if (parent != null && parent != activity) {
    info.append("String_Node_Str").append(parent.shortComponentName).append("String_Node_Str");
  }
  final ProcessCpuTracker processCpuTracker=new ProcessCpuTracker(true);
  File tracesFile=dumpStackTraces(true,firstPids,processCpuTracker,lastPids,NATIVE_STACKS_OF_INTEREST);
  String cpuInfo=null;
  if (MONITOR_CPU_USAGE) {
    updateCpuStatsNow();
synchronized (mProcessCpuTracker) {
      cpuInfo=mProcessCpuTracker.printCurrentState(anrTime);
    }
    info.append(processCpuTracker.printCurrentLoad());
    info.append(cpuInfo);
  }
  info.append(processCpuTracker.printCurrentState(anrTime));
  Slog.e(TAG,info.toString());
  if (tracesFile == null) {
    Process.sendSignal(app.pid,Process.SIGNAL_QUIT);
  }
  addErrorToDropBox("String_Node_Str",app,app.processName,activity,parent,annotation,cpuInfo,tracesFile,null);
  if (mController != null) {
    try {
      int res=mController.appNotResponding(app.processName,app.pid,info.toString());
      if (res != 0) {
        if (res < 0 && app.pid != MY_PID) {
          app.kill("String_Node_Str",true);
        }
 else {
synchronized (this) {
            mServices.scheduleServiceTimeoutLocked(app);
          }
        }
        return;
      }
    }
 catch (    RemoteException e) {
      mController=null;
      Watchdog.getInstance().setActivityController(null);
    }
  }
  boolean showBackground=Settings.Secure.getInt(mContext.getContentResolver(),Settings.Secure.ANR_SHOW_BACKGROUND,0) != 0;
synchronized (this) {
    if (!showBackground && !app.isInterestingToUserLocked() && app.pid != MY_PID) {
      app.kill("String_Node_Str",true);
      return;
    }
    makeAppNotRespondingLocked(app,activity != null ? activity.shortComponentName : null,annotation != null ? "String_Node_Str" + annotation : "String_Node_Str",info.toString());
    Message msg=Message.obtain();
    HashMap<String,Object> map=new HashMap<String,Object>();
    msg.what=SHOW_NOT_RESPONDING_MSG;
    msg.obj=map;
    msg.arg1=aboveSystem ? 1 : 0;
    map.put("String_Node_Str",app);
    if (activity != null) {
      map.put("String_Node_Str",activity);
    }
    mHandler.sendMessage(msg);
  }
}