Program: 192858
Project: 192858
Buggy source:
/** 
 * Sets the focused task to the provided (bounded taskIndex).
 * @return whether or not the stack will scroll as a part of this focus change
 */
private boolean setFocusedTask(int taskIndex,boolean scrollToTask,final boolean requestViewFocus,final boolean showTimerIndicator){
  int newFocusedTaskIndex=mStack.getTaskCount() > 0 ? Math.max(0,Math.min(mStack.getTaskCount() - 1,taskIndex)) : -1;
  final Task newFocusedTask=(newFocusedTaskIndex != -1) ? mStack.getStackTasks().get(newFocusedTaskIndex) : null;
  if (mFocusedTask != null) {
    if (showTimerIndicator) {
      final TaskView tv=getChildViewForTask(mFocusedTask);
      if (tv != null) {
        tv.getHeaderView().cancelFocusTimerIndicator();
      }
    }
    resetFocusedTask(mFocusedTask);
  }
  boolean willScroll=false;
  mFocusedTask=newFocusedTask;
  if (newFocusedTask != null) {
    if (showTimerIndicator) {
      final TaskView tv=getChildViewForTask(mFocusedTask);
      if (tv != null) {
        tv.getHeaderView().startFocusTimerIndicator();
      }
 else {
        mStartTimerIndicator=true;
      }
    }
    Runnable focusTaskRunnable=new Runnable(){
      @Override public void run(){
        final TaskView tv=getChildViewForTask(newFocusedTask);
        if (tv != null) {
          tv.setFocusedState(true,requestViewFocus);
        }
      }
    }
;
    if (scrollToTask) {
      float newScroll=mLayoutAlgorithm.getStackScrollForTask(newFocusedTask);
      if (Float.compare(newScroll,mStackScroller.getStackScroll()) != 0) {
        mStackScroller.animateScroll(mStackScroller.getStackScroll(),newScroll,focusTaskRunnable);
        willScroll=true;
        if (!mEnterAnimationComplete) {
          cancelAllTaskViewAnimations();
        }
      }
 else {
        focusTaskRunnable.run();
      }
      mLayoutAlgorithm.animateFocusState(TaskStackLayoutAlgorithm.STATE_FOCUSED);
    }
 else {
      focusTaskRunnable.run();
    }
  }
  return willScroll;
}

Fixed version (ground truth):
/** 
 * Sets the focused task to the provided (bounded taskIndex).
 * @return whether or not the stack will scroll as a part of this focus change
 */
private boolean setFocusedTask(int taskIndex,boolean scrollToTask,final boolean requestViewFocus,final boolean showTimerIndicator){
  int newFocusedTaskIndex=mStack.getTaskCount() > 0 ? Math.max(0,Math.min(mStack.getTaskCount() - 1,taskIndex)) : -1;
  final Task newFocusedTask=(newFocusedTaskIndex != -1) ? mStack.getStackTasks().get(newFocusedTaskIndex) : null;
  if (mFocusedTask != null) {
    if (showTimerIndicator) {
      final TaskView tv=getChildViewForTask(mFocusedTask);
      if (tv != null) {
        tv.getHeaderView().cancelFocusTimerIndicator();
      }
    }
    resetFocusedTask(mFocusedTask);
  }
  boolean willScroll=false;
  mFocusedTask=newFocusedTask;
  if (newFocusedTask != null) {
    if (showTimerIndicator) {
      final TaskView tv=getChildViewForTask(mFocusedTask);
      if (tv != null) {
        tv.getHeaderView().startFocusTimerIndicator();
      }
 else {
        mStartTimerIndicator=true;
      }
    }
    Runnable focusTaskRunnable=new Runnable(){
      @Override public void run(){
        final TaskView tv=getChildViewForTask(newFocusedTask);
        if (tv != null) {
          tv.setFocusedState(true,requestViewFocus);
        }
      }
    }
;
    if (scrollToTask) {
      if (!mEnterAnimationComplete) {
        cancelAllTaskViewAnimations();
      }
      float newScroll=mLayoutAlgorithm.getStackScrollForTask(newFocusedTask);
      if (Float.compare(newScroll,mStackScroller.getStackScroll()) != 0) {
        mStackScroller.animateScroll(mStackScroller.getStackScroll(),newScroll,focusTaskRunnable);
        willScroll=true;
      }
 else {
        focusTaskRunnable.run();
      }
      mLayoutAlgorithm.animateFocusState(TaskStackLayoutAlgorithm.STATE_FOCUSED);
    }
 else {
      focusTaskRunnable.run();
    }
  }
  return willScroll;
}