Program: 191338
Project: 191338
Buggy source:
/** 
 * Synchronizes the set of children   {@link TaskView}s to match the visible set of tasks in the current   {@link TaskStack}. This call does not continue on to update their position to the computed   {@link TaskViewTransform}s of the visible range, but only ensures that they will be added/removed from the view hierarchy and placed in the correct Z order and initial position (if not currently on screen).
 * @param targetStackScroll If provided, will ensure that the set of visible {@link TaskView}s includes those visible at the current stack scroll, and all at the target stack scroll.
 * @param ignoreTaskOverrides If set, the visible task computation will get the transforms fortasks at their non-overridden task progress
 */
void bindVisibleTaskViews(float targetStackScroll,boolean ignoreTaskOverrides){
  ArrayList<Task> tasks=mStack.getStackTasks();
  int[] visibleTaskRange=computeVisibleTaskTransforms(mCurrentTaskTransforms,tasks,mStackScroller.getStackScroll(),targetStackScroll,mIgnoreTasks,ignoreTaskOverrides);
  mTmpTaskViewMap.clear();
  List<TaskView> taskViews=getTaskViews();
  int lastFocusedTaskIndex=-1;
  int taskViewCount=taskViews.size();
  for (int i=taskViewCount - 1; i >= 0; i--) {
    TaskView tv=taskViews.get(i);
    Task task=tv.getTask();
    if (mIgnoreTasks.contains(task.key)) {
      continue;
    }
    int taskIndex=mStack.indexOfStackTask(task);
    TaskViewTransform transform=null;
    if (taskIndex != -1) {
      transform=mCurrentTaskTransforms.get(taskIndex);
    }
    if (task.isFreeformTask() || (transform != null && transform.visible)) {
      mTmpTaskViewMap.put(task.key,tv);
    }
 else {
      if (mTouchExplorationEnabled) {
        lastFocusedTaskIndex=taskIndex;
        resetFocusedTask(task);
      }
      mViewPool.returnViewToPool(tv);
    }
  }
  for (int i=tasks.size() - 1; i >= 0; i--) {
    Task task=tasks.get(i);
    TaskViewTransform transform=mCurrentTaskTransforms.get(i);
    if (mIgnoreTasks.contains(task.key)) {
      continue;
    }
    if (!task.isFreeformTask() && !transform.visible) {
      continue;
    }
    TaskView tv=mTmpTaskViewMap.get(task.key);
    if (tv == null) {
      tv=mViewPool.pickUpViewFromPool(task,task);
      if (task.isFreeformTask()) {
        updateTaskViewToTransform(tv,transform,AnimationProps.IMMEDIATE);
      }
 else {
        if (transform.rect.top <= mLayoutAlgorithm.mStackRect.top) {
          updateTaskViewToTransform(tv,mLayoutAlgorithm.getBackOfStackTransform(),AnimationProps.IMMEDIATE);
        }
 else {
          updateTaskViewToTransform(tv,mLayoutAlgorithm.getFrontOfStackTransform(),AnimationProps.IMMEDIATE);
        }
      }
    }
 else {
      final int taskIndex=mStack.indexOfStackTask(task);
      final int insertIndex=findTaskViewInsertIndex(task,taskIndex);
      if (insertIndex != getTaskViews().indexOf(tv)) {
        detachViewFromParent(tv);
        attachViewToParent(tv,insertIndex,tv.getLayoutParams());
        updateTaskViewsList();
      }
    }
  }
  if (lastFocusedTaskIndex != -1) {
    if (lastFocusedTaskIndex < visibleTaskRange[1]) {
      setFocusedTask(visibleTaskRange[1],false,true);
    }
 else {
      setFocusedTask(visibleTaskRange[0],false,true);
    }
  }
}

Fixed version (ground truth):
/** 
 * Synchronizes the set of children   {@link TaskView}s to match the visible set of tasks in the current   {@link TaskStack}. This call does not continue on to update their position to the computed   {@link TaskViewTransform}s of the visible range, but only ensures that they will be added/removed from the view hierarchy and placed in the correct Z order and initial position (if not currently on screen).
 * @param targetStackScroll If provided, will ensure that the set of visible {@link TaskView}s includes those visible at the current stack scroll, and all at the target stack scroll.
 * @param ignoreTaskOverrides If set, the visible task computation will get the transforms fortasks at their non-overridden task progress
 */
void bindVisibleTaskViews(float targetStackScroll,boolean ignoreTaskOverrides){
  ArrayList<Task> tasks=mStack.getStackTasks();
  int[] visibleTaskRange=computeVisibleTaskTransforms(mCurrentTaskTransforms,tasks,mStackScroller.getStackScroll(),targetStackScroll,mIgnoreTasks,ignoreTaskOverrides);
  mTmpTaskViewMap.clear();
  List<TaskView> taskViews=getTaskViews();
  int lastFocusedTaskIndex=-1;
  int taskViewCount=taskViews.size();
  for (int i=taskViewCount - 1; i >= 0; i--) {
    TaskView tv=taskViews.get(i);
    Task task=tv.getTask();
    if (mIgnoreTasks.contains(task.key)) {
      continue;
    }
    int taskIndex=mStack.indexOfStackTask(task);
    TaskViewTransform transform=null;
    if (taskIndex != -1) {
      transform=mCurrentTaskTransforms.get(taskIndex);
    }
    if (task.isFreeformTask() || (transform != null && transform.visible)) {
      mTmpTaskViewMap.put(task.key,tv);
    }
 else {
      if (mTouchExplorationEnabled && Utilities.isDescendentAccessibilityFocused(tv)) {
        lastFocusedTaskIndex=taskIndex;
        resetFocusedTask(task);
      }
      mViewPool.returnViewToPool(tv);
    }
  }
  for (int i=tasks.size() - 1; i >= 0; i--) {
    Task task=tasks.get(i);
    TaskViewTransform transform=mCurrentTaskTransforms.get(i);
    if (mIgnoreTasks.contains(task.key)) {
      continue;
    }
    if (!task.isFreeformTask() && !transform.visible) {
      continue;
    }
    TaskView tv=mTmpTaskViewMap.get(task.key);
    if (tv == null) {
      tv=mViewPool.pickUpViewFromPool(task,task);
      if (task.isFreeformTask()) {
        updateTaskViewToTransform(tv,transform,AnimationProps.IMMEDIATE);
      }
 else {
        if (transform.rect.top <= mLayoutAlgorithm.mStackRect.top) {
          updateTaskViewToTransform(tv,mLayoutAlgorithm.getBackOfStackTransform(),AnimationProps.IMMEDIATE);
        }
 else {
          updateTaskViewToTransform(tv,mLayoutAlgorithm.getFrontOfStackTransform(),AnimationProps.IMMEDIATE);
        }
      }
    }
 else {
      final int taskIndex=mStack.indexOfStackTask(task);
      final int insertIndex=findTaskViewInsertIndex(task,taskIndex);
      if (insertIndex != getTaskViews().indexOf(tv)) {
        detachViewFromParent(tv);
        attachViewToParent(tv,insertIndex,tv.getLayoutParams());
        updateTaskViewsList();
      }
    }
  }
  if (lastFocusedTaskIndex != -1) {
    int newFocusedTaskIndex=(lastFocusedTaskIndex < visibleTaskRange[1]) ? visibleTaskRange[1] : visibleTaskRange[0];
    setFocusedTask(newFocusedTaskIndex,false,true);
    TaskView focusedTaskView=getChildViewForTask(mFocusedTask);
    if (focusedTaskView != null) {
      focusedTaskView.requestAccessibilityFocus();
    }
  }
}