Program: 193255
Project: 193255
Buggy source:
/** 
 * Preloads the list of recent tasks from the system.  After this call, the TaskStack will have a list of all the recent tasks with their metadata, not including icons or thumbnails which were not cached and have to be loaded. The tasks will be ordered by: - least-recent to most-recent stack tasks - least-recent to most-recent freeform tasks
 */
public synchronized void preloadPlan(RecentsTaskLoader loader,boolean isTopTaskHome){
  if (DEBUG)   Log.d(TAG,"String_Node_Str");
  RecentsConfiguration config=Recents.getConfiguration();
  SystemServicesProxy ssp=Recents.getSystemServices();
  Resources res=mContext.getResources();
  ArrayList<Task> freeformTasks=new ArrayList<>();
  ArrayList<Task> stackTasks=new ArrayList<>();
  if (mRawTasks == null) {
    preloadRawTasks(isTopTaskHome);
  }
  int taskCount=mRawTasks.size();
  for (int i=0; i < taskCount; i++) {
    ActivityManager.RecentTaskInfo t=mRawTasks.get(i);
    Task.TaskKey taskKey=new Task.TaskKey(t.persistentId,t.stackId,t.baseIntent,t.userId,t.firstActiveTime,t.lastActiveTime);
    String activityLabel=loader.getAndUpdateActivityLabel(taskKey,t.taskDescription,ssp);
    String contentDescription=loader.getAndUpdateContentDescription(taskKey,activityLabel,ssp,res);
    Drawable activityIcon=loader.getAndUpdateActivityIcon(taskKey,t.taskDescription,ssp,res,false);
    int activityColor=loader.getActivityPrimaryColor(t.taskDescription);
    Bitmap icon=t.taskDescription != null ? t.taskDescription.getInMemoryIcon() : null;
    String iconFilename=t.taskDescription != null ? t.taskDescription.getIconFilename() : null;
    Task task=new Task(taskKey,(t.id != INVALID_TASK_ID),t.affiliatedTaskId,t.affiliatedTaskColor,activityLabel,contentDescription,activityIcon,activityColor,(i == (taskCount - 1)),config.lockToAppEnabled,icon,iconFilename,t.bounds);
    task.thumbnail=loader.getAndUpdateThumbnail(taskKey,ssp,false);
    if (DEBUG) {
      Log.d(TAG,activityLabel + "String_Node_Str" + t.bounds);
    }
    if (task.isFreeformTask()) {
      freeformTasks.add(task);
    }
 else {
      stackTasks.add(task);
    }
  }
  ArrayList<Task> allTasks=new ArrayList<>();
  allTasks.addAll(stackTasks);
  allTasks.addAll(freeformTasks);
  mStack=new TaskStack();
  mStack.setTasks(allTasks);
  mStack.createAffiliatedGroupings(mContext);
}

Fixed version (ground truth):
/** 
 * Preloads the list of recent tasks from the system.  After this call, the TaskStack will have a list of all the recent tasks with their metadata, not including icons or thumbnails which were not cached and have to be loaded. The tasks will be ordered by: - least-recent to most-recent stack tasks - least-recent to most-recent freeform tasks
 */
public synchronized void preloadPlan(RecentsTaskLoader loader,boolean isTopTaskHome){
  if (DEBUG)   Log.d(TAG,"String_Node_Str");
  RecentsConfiguration config=Recents.getConfiguration();
  SystemServicesProxy ssp=Recents.getSystemServices();
  Resources res=mContext.getResources();
  ArrayList<Task> freeformTasks=new ArrayList<>();
  ArrayList<Task> stackTasks=new ArrayList<>();
  if (mRawTasks == null) {
    preloadRawTasks(isTopTaskHome);
  }
  int taskCount=mRawTasks.size();
  for (int i=0; i < taskCount; i++) {
    ActivityManager.RecentTaskInfo t=mRawTasks.get(i);
    Task.TaskKey taskKey=new Task.TaskKey(t.persistentId,t.stackId,t.baseIntent,t.userId,t.firstActiveTime,t.lastActiveTime);
    String activityLabel=loader.getAndUpdateActivityLabel(taskKey,t.taskDescription,ssp);
    String contentDescription=loader.getAndUpdateContentDescription(taskKey,activityLabel,ssp,res);
    Drawable activityIcon=loader.getAndUpdateActivityIcon(taskKey,t.taskDescription,ssp,res,false);
    int activityColor=loader.getActivityPrimaryColor(t.taskDescription);
    Bitmap icon=t.taskDescription != null ? t.taskDescription.getInMemoryIcon() : null;
    String iconFilename=t.taskDescription != null ? t.taskDescription.getIconFilename() : null;
    Task task=new Task(taskKey,t.affiliatedTaskId,t.affiliatedTaskColor,activityLabel,contentDescription,activityIcon,activityColor,(i == (taskCount - 1)),config.lockToAppEnabled,icon,iconFilename,t.bounds);
    task.thumbnail=loader.getAndUpdateThumbnail(taskKey,ssp,false);
    if (DEBUG) {
      Log.d(TAG,activityLabel + "String_Node_Str" + t.bounds);
    }
    if (task.isFreeformTask()) {
      freeformTasks.add(task);
    }
 else {
      stackTasks.add(task);
    }
  }
  ArrayList<Task> allTasks=new ArrayList<>();
  allTasks.addAll(stackTasks);
  allTasks.addAll(freeformTasks);
  mStack=new TaskStack();
  mStack.setTasks(allTasks);
  mStack.createAffiliatedGroupings(mContext);
}