Program: 192814
Project: 192814
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 int timerIndicatorDuration){
  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 (timerIndicatorDuration > 0) {
      final TaskView tv=getChildViewForTask(mFocusedTask);
      if (tv != null) {
        tv.getHeaderView().cancelFocusTimerIndicator();
      }
    }
    resetFocusedTask(mFocusedTask);
  }
  boolean willScroll=false;
  mFocusedTask=newFocusedTask;
  if (newFocusedTask != null) {
    if (timerIndicatorDuration > 0) {
      final TaskView tv=getChildViewForTask(mFocusedTask);
      if (tv != null) {
        tv.getHeaderView().startFocusTimerIndicator(timerIndicatorDuration);
      }
 else {
        mStartTimerIndicatorDuration=timerIndicatorDuration;
      }
    }
    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;
}

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 int timerIndicatorDuration){
  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 (timerIndicatorDuration > 0) {
      final TaskView tv=getChildViewForTask(mFocusedTask);
      if (tv != null) {
        tv.getHeaderView().cancelFocusTimerIndicator();
      }
    }
    resetFocusedTask(mFocusedTask);
  }
  boolean willScroll=false;
  mFocusedTask=newFocusedTask;
  if (newFocusedTask != null) {
    if (timerIndicatorDuration > 0) {
      final TaskView tv=getChildViewForTask(mFocusedTask);
      if (tv != null) {
        tv.getHeaderView().startFocusTimerIndicator(timerIndicatorDuration);
      }
 else {
        mStartTimerIndicatorDuration=timerIndicatorDuration;
      }
    }
    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(newScroll,focusTaskRunnable);
        willScroll=true;
      }
 else {
        focusTaskRunnable.run();
      }
      mLayoutAlgorithm.animateFocusState(TaskStackLayoutAlgorithm.STATE_FOCUSED);
    }
 else {
      focusTaskRunnable.run();
    }
  }
  return willScroll;
}