Program: 195741
Project: 195741
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.
 */
synchronized void preloadPlan(RecentsTaskLoader loader,boolean isTopTaskHome){
  if (DEBUG)   Log.d(TAG,"String_Node_Str");
  mActivityInfoCache.clear();
  mStack=new TaskStack();
  Resources res=mContext.getResources();
  ArrayList<Task> loadedTasks=new ArrayList<Task>();
  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.baseIntent,t.userId,t.firstActiveTime,t.lastActiveTime);
    Task.ComponentNameKey cnKey=taskKey.getComponentNameKey();
    ActivityInfoHandle infoHandle;
    boolean hadCachedActivityInfo=false;
    if (mActivityInfoCache.containsKey(cnKey)) {
      infoHandle=mActivityInfoCache.get(cnKey);
      hadCachedActivityInfo=true;
    }
 else {
      infoHandle=new ActivityInfoHandle();
    }
    String activityLabel=loader.getAndUpdateActivityLabel(taskKey,t.taskDescription,mSystemServicesProxy,infoHandle);
    Drawable activityIcon=loader.getAndUpdateActivityIcon(taskKey,t.taskDescription,mSystemServicesProxy,res,infoHandle,false);
    int activityColor=loader.getActivityPrimaryColor(t.taskDescription,mConfig);
    if (!hadCachedActivityInfo && infoHandle.info != null) {
      mActivityInfoCache.put(cnKey,infoHandle);
    }
    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 != RecentsTaskLoader.INVALID_TASK_ID),t.affiliatedTaskId,t.affiliatedTaskColor,activityLabel,activityIcon,activityColor,(i == (taskCount - 1)),mConfig.lockToAppEnabled,icon,iconFilename);
    task.thumbnail=loader.getAndUpdateThumbnail(taskKey,mSystemServicesProxy,false);
    loadedTasks.add(task);
  }
  mStack.setTasks(loadedTasks);
  mStack.createAffiliatedGroupings(mConfig);
  if (mStack.getTaskCount() != mRawTasks.size()) {
    throw new RuntimeException("String_Node_Str");
  }
}

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.
 */
synchronized void preloadPlan(RecentsTaskLoader loader,boolean isTopTaskHome){
  if (DEBUG)   Log.d(TAG,"String_Node_Str");
  mActivityInfoCache.clear();
  mStack=new TaskStack();
  Resources res=mContext.getResources();
  ArrayList<Task> loadedTasks=new ArrayList<Task>();
  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.baseIntent,t.userId,t.firstActiveTime,t.lastActiveTime);
    Task.ComponentNameKey cnKey=taskKey.getComponentNameKey();
    ActivityInfoHandle infoHandle;
    boolean hadCachedActivityInfo=false;
    if (mActivityInfoCache.containsKey(cnKey)) {
      infoHandle=mActivityInfoCache.get(cnKey);
      hadCachedActivityInfo=true;
    }
 else {
      infoHandle=new ActivityInfoHandle();
    }
    String activityLabel=loader.getAndUpdateActivityLabel(taskKey,t.taskDescription,mSystemServicesProxy,infoHandle);
    Drawable activityIcon=loader.getAndUpdateActivityIcon(taskKey,t.taskDescription,mSystemServicesProxy,res,infoHandle,false);
    int activityColor=loader.getActivityPrimaryColor(t.taskDescription,mConfig);
    if (!hadCachedActivityInfo && infoHandle.info != null) {
      mActivityInfoCache.put(cnKey,infoHandle);
    }
    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 != RecentsTaskLoader.INVALID_TASK_ID),t.affiliatedTaskId,t.affiliatedTaskColor,activityLabel,activityIcon,activityColor,(i == (taskCount - 1)),mConfig.lockToAppEnabled,icon,iconFilename);
    task.thumbnail=loader.getAndUpdateThumbnail(taskKey,mSystemServicesProxy,false);
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + taskKey + "String_Node_Str"+ task.thumbnail);
    loadedTasks.add(task);
  }
  mStack.setTasks(loadedTasks);
  mStack.createAffiliatedGroupings(mConfig);
  if (mStack.getTaskCount() != mRawTasks.size()) {
    throw new RuntimeException("String_Node_Str");
  }
}