Program: 199055
Project: 199055
Buggy source:
/** 
 * Reload the set of recent tasks 
 */
public SpaceNode reload(Context context,int preloadCount){
  long t1=System.currentTimeMillis();
  if (Console.Enabled) {
    Console.log(Constants.Log.App.TaskDataLoader,"String_Node_Str");
  }
  Resources res=context.getResources();
  ArrayList<Task> tasksToForceLoad=new ArrayList<Task>();
  TaskStack stack=new TaskStack(context);
  SpaceNode root=new SpaceNode(context);
  root.setStack(stack);
  SystemServicesProxy ssp=mSystemServicesProxy;
  List<ActivityManager.RecentTaskInfo> tasks=getRecentTasks();
  t1=System.currentTimeMillis();
  int taskCount=tasks.size();
  for (int i=0; i < taskCount; i++) {
    ActivityManager.RecentTaskInfo t=tasks.get(i);
    ActivityInfo info=ssp.getActivityInfo(t.baseIntent.getComponent(),t.userId);
    if (info == null)     continue;
    ActivityManager.TaskDescription av=t.taskDescription;
    String activityLabel=null;
    BitmapDrawable activityIcon=null;
    int activityColor=0;
    if (av != null) {
      activityLabel=(av.getLabel() != null ? av.getLabel() : ssp.getActivityLabel(info));
      activityIcon=(av.getIcon() != null) ? new BitmapDrawable(res,av.getIcon()) : null;
      activityColor=av.getPrimaryColor();
    }
 else {
      activityLabel=ssp.getActivityLabel(info);
    }
    boolean isForemostTask=(i == (taskCount - 1));
    Task task=new Task(t.persistentId,(t.id > -1),t.baseIntent,activityLabel,activityIcon,activityColor,t.userId,t.lastActiveTime);
    if (i >= (taskCount - preloadCount)) {
      if (Console.Enabled) {
        Console.log(Constants.Log.App.TaskDataLoader,"String_Node_Str","String_Node_Str" + i + "String_Node_Str"+ t.baseIntent.getComponent().getPackageName());
      }
      task.applicationIcon=mApplicationIconCache.getCheckLastActiveTime(task.key);
      if (task.applicationIcon == null) {
        if (isForemostTask) {
          task.applicationIcon=ssp.getActivityIcon(info,task.userId);
          if (task.applicationIcon != null) {
            mApplicationIconCache.put(task.key,task.applicationIcon);
          }
 else {
            task.applicationIcon=mDefaultApplicationIcon;
          }
        }
 else {
          tasksToForceLoad.add(task);
        }
      }
      task.thumbnail=mThumbnailCache.getCheckLastActiveTime(task.key);
      if (task.thumbnail == null) {
        if (Console.Enabled) {
          Console.log(Constants.Log.App.TaskDataLoader,"String_Node_Str");
        }
        if (isForemostTask) {
          task.thumbnail=ssp.getTaskThumbnail(task.key.id);
          if (task.thumbnail != null) {
            task.thumbnail.setHasAlpha(false);
            mThumbnailCache.put(task.key,task.thumbnail);
          }
 else {
            task.thumbnail=mDefaultThumbnail;
          }
        }
 else {
          tasksToForceLoad.add(task);
        }
      }
    }
    if (Console.Enabled) {
      Console.log(Constants.Log.App.TaskDataLoader,"String_Node_Str",t.baseIntent.getComponent().getPackageName());
    }
    stack.addTask(task);
  }
  if (Console.Enabled) {
    Console.log(Constants.Log.App.TimeSystemCalls,"String_Node_Str","String_Node_Str" + (System.currentTimeMillis() - t1) + "String_Node_Str");
  }
  mLoader.start(context);
  for (  Task t : tasksToForceLoad) {
    mLoadQueue.addTask(t,true);
  }
  mPackageMonitor.setTasks(tasks);
  return root;
}

Fixed version (ground truth):
/** 
 * Reload the set of recent tasks 
 */
public SpaceNode reload(Context context,int preloadCount){
  long t1=System.currentTimeMillis();
  if (Console.Enabled) {
    Console.log(Constants.Log.App.TaskDataLoader,"String_Node_Str");
  }
  RecentsConfiguration config=RecentsConfiguration.getInstance();
  Resources res=context.getResources();
  ArrayList<Task> tasksToForceLoad=new ArrayList<Task>();
  TaskStack stack=new TaskStack(context);
  SpaceNode root=new SpaceNode(context);
  root.setStack(stack);
  SystemServicesProxy ssp=mSystemServicesProxy;
  List<ActivityManager.RecentTaskInfo> tasks=getRecentTasks();
  t1=System.currentTimeMillis();
  int taskCount=tasks.size();
  for (int i=0; i < taskCount; i++) {
    ActivityManager.RecentTaskInfo t=tasks.get(i);
    ActivityInfo info=ssp.getActivityInfo(t.baseIntent.getComponent(),t.userId);
    if (info == null)     continue;
    ActivityManager.TaskDescription av=t.taskDescription;
    String activityLabel=null;
    BitmapDrawable activityIcon=null;
    int activityColor=config.taskBarViewDefaultBackgroundColor;
    if (av != null) {
      activityLabel=(av.getLabel() != null ? av.getLabel() : ssp.getActivityLabel(info));
      activityIcon=(av.getIcon() != null) ? new BitmapDrawable(res,av.getIcon()) : null;
      activityColor=av.getPrimaryColor();
    }
 else {
      activityLabel=ssp.getActivityLabel(info);
    }
    boolean isForemostTask=(i == (taskCount - 1));
    Task task=new Task(t.persistentId,(t.id > -1),t.baseIntent,activityLabel,activityIcon,activityColor,t.userId,t.lastActiveTime);
    if (i >= (taskCount - preloadCount)) {
      if (Console.Enabled) {
        Console.log(Constants.Log.App.TaskDataLoader,"String_Node_Str","String_Node_Str" + i + "String_Node_Str"+ t.baseIntent.getComponent().getPackageName());
      }
      task.applicationIcon=mApplicationIconCache.getCheckLastActiveTime(task.key);
      if (task.applicationIcon == null) {
        if (isForemostTask) {
          task.applicationIcon=ssp.getActivityIcon(info,task.userId);
          if (task.applicationIcon != null) {
            mApplicationIconCache.put(task.key,task.applicationIcon);
          }
 else {
            task.applicationIcon=mDefaultApplicationIcon;
          }
        }
 else {
          tasksToForceLoad.add(task);
        }
      }
      task.thumbnail=mThumbnailCache.getCheckLastActiveTime(task.key);
      if (task.thumbnail == null) {
        if (Console.Enabled) {
          Console.log(Constants.Log.App.TaskDataLoader,"String_Node_Str");
        }
        if (isForemostTask) {
          task.thumbnail=ssp.getTaskThumbnail(task.key.id);
          if (task.thumbnail != null) {
            task.thumbnail.setHasAlpha(false);
            mThumbnailCache.put(task.key,task.thumbnail);
          }
 else {
            task.thumbnail=mDefaultThumbnail;
          }
        }
 else {
          tasksToForceLoad.add(task);
        }
      }
    }
    if (Console.Enabled) {
      Console.log(Constants.Log.App.TaskDataLoader,"String_Node_Str",t.baseIntent.getComponent().getPackageName());
    }
    stack.addTask(task);
  }
  if (Console.Enabled) {
    Console.log(Constants.Log.App.TimeSystemCalls,"String_Node_Str","String_Node_Str" + (System.currentTimeMillis() - t1) + "String_Node_Str");
  }
  mLoader.start(context);
  for (  Task t : tasksToForceLoad) {
    mLoadQueue.addTask(t,true);
  }
  mPackageMonitor.setTasks(tasks);
  return root;
}