Program: 192758
Project: 192758
Buggy source:
/** 
 * Computes the maximum number of visible tasks and thumbnails when the scroll is at the initial stack scroll.  Requires that update() is called first.
 */
public VisibilityReport computeStackVisibilityReport(ArrayList<Task> tasks){
  if (tasks.size() <= 1) {
    return new VisibilityReport(1,1);
  }
  if (mNumStackTasks == 0) {
    return new VisibilityReport(Math.max(mNumFreeformTasks,1),Math.max(mNumFreeformTasks,1));
  }
  TaskViewTransform tmpTransform=new TaskViewTransform();
  Range currentRange=getDefaultFocusState() > 0f ? mFocusedRange : mUnfocusedRange;
  currentRange.offset(mInitialScrollP);
  int taskBarHeight=mContext.getResources().getDimensionPixelSize(R.dimen.recents_task_bar_height);
  int numVisibleTasks=Math.max(mNumFreeformTasks,1);
  int numVisibleThumbnails=Math.max(mNumFreeformTasks,1);
  float prevScreenY=Integer.MAX_VALUE;
  for (int i=tasks.size() - 1; i >= 0; i--) {
    Task task=tasks.get(i);
    if (task.isFreeformTask()) {
      continue;
    }
    float taskProgress=getStackScrollForTask(task);
    if (!currentRange.isInRange(taskProgress)) {
      continue;
    }
    boolean isFrontMostTaskInGroup=task.group == null || task.group.isFrontMostTask(task);
    if (isFrontMostTaskInGroup) {
      getStackTransform(taskProgress,mInitialScrollP,tmpTransform,null,false);
      float screenY=tmpTransform.rect.top;
      boolean hasVisibleThumbnail=(prevScreenY - screenY) > taskBarHeight;
      if (hasVisibleThumbnail) {
        numVisibleThumbnails++;
        numVisibleTasks++;
        prevScreenY=screenY;
      }
 else {
        for (int j=i; j >= 0; j--) {
          numVisibleTasks++;
          taskProgress=getStackScrollForTask(tasks.get(j));
          if (!currentRange.isInRange(taskProgress)) {
            continue;
          }
        }
        break;
      }
    }
 else     if (!isFrontMostTaskInGroup) {
      numVisibleTasks++;
    }
  }
  return new VisibilityReport(numVisibleTasks,numVisibleThumbnails);
}

Fixed version (ground truth):
/** 
 * Computes the maximum number of visible tasks and thumbnails when the scroll is at the initial stack scroll.  Requires that update() is called first.
 */
public VisibilityReport computeStackVisibilityReport(ArrayList<Task> tasks){
  if (tasks.size() <= 1) {
    return new VisibilityReport(1,1);
  }
  if (mNumStackTasks == 0) {
    return new VisibilityReport(Math.max(mNumFreeformTasks,1),Math.max(mNumFreeformTasks,1));
  }
  TaskViewTransform tmpTransform=new TaskViewTransform();
  Range currentRange=getDefaultFocusState() > 0f ? mFocusedRange : mUnfocusedRange;
  currentRange.offset(mInitialScrollP);
  int taskBarHeight=mContext.getResources().getDimensionPixelSize(R.dimen.recents_task_bar_height);
  int numVisibleTasks=Math.max(mNumFreeformTasks,1);
  int numVisibleThumbnails=Math.max(mNumFreeformTasks,1);
  float prevScreenY=Integer.MAX_VALUE;
  for (int i=tasks.size() - 1; i >= 0; i--) {
    Task task=tasks.get(i);
    if (task.isFreeformTask()) {
      continue;
    }
    float taskProgress=getStackScrollForTask(task);
    if (!currentRange.isInRange(taskProgress)) {
      continue;
    }
    boolean isFrontMostTaskInGroup=task.group == null || task.group.isFrontMostTask(task);
    if (isFrontMostTaskInGroup) {
      getStackTransform(taskProgress,mInitialScrollP,tmpTransform,null,false,false);
      float screenY=tmpTransform.rect.top;
      boolean hasVisibleThumbnail=(prevScreenY - screenY) > taskBarHeight;
      if (hasVisibleThumbnail) {
        numVisibleThumbnails++;
        numVisibleTasks++;
        prevScreenY=screenY;
      }
 else {
        for (int j=i; j >= 0; j--) {
          numVisibleTasks++;
          taskProgress=getStackScrollForTask(tasks.get(j));
          if (!currentRange.isInRange(taskProgress)) {
            continue;
          }
        }
        break;
      }
    }
 else     if (!isFrontMostTaskInGroup) {
      numVisibleTasks++;
    }
  }
  return new VisibilityReport(numVisibleTasks,numVisibleThumbnails);
}