Program: 191557
Project: 191557
Buggy source:
/** 
 * Transitions to the next affiliated task.
 */
public void showRelativeAffiliatedTask(boolean showNextTask){
  SystemServicesProxy ssp=Recents.getSystemServices();
  RecentsTaskLoader loader=Recents.getTaskLoader();
  RecentsTaskLoadPlan plan=loader.createLoadPlan(mContext);
  loader.preloadTasks(plan,-1,true);
  TaskStack focusedStack=plan.getTaskStack();
  if (focusedStack == null || focusedStack.getTaskCount() == 0)   return;
  ActivityManager.RunningTaskInfo runningTask=ssp.getRunningTask();
  if (runningTask == null)   return;
  if (SystemServicesProxy.isHomeStack(runningTask.stackId))   return;
  ArrayList<Task> tasks=focusedStack.getStackTasks();
  Task toTask=null;
  ActivityOptions launchOpts=null;
  int taskCount=tasks.size();
  int numAffiliatedTasks=0;
  for (int i=0; i < taskCount; i++) {
    Task task=tasks.get(i);
    if (task.key.id == runningTask.id) {
      TaskGrouping group=task.group;
      Task.TaskKey toTaskKey;
      if (showNextTask) {
        toTaskKey=group.getNextTaskInGroup(task);
        launchOpts=ActivityOptions.makeCustomAnimation(mContext,R.anim.recents_launch_next_affiliated_task_target,R.anim.recents_launch_next_affiliated_task_source);
      }
 else {
        toTaskKey=group.getPrevTaskInGroup(task);
        launchOpts=ActivityOptions.makeCustomAnimation(mContext,R.anim.recents_launch_prev_affiliated_task_target,R.anim.recents_launch_prev_affiliated_task_source);
      }
      if (toTaskKey != null) {
        toTask=focusedStack.findTaskWithId(toTaskKey.id);
      }
      numAffiliatedTasks=group.getTaskCount();
      break;
    }
  }
  if (toTask == null) {
    if (numAffiliatedTasks > 1) {
      if (showNextTask) {
        ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext,R.anim.recents_launch_next_affiliated_task_bounce));
      }
 else {
        ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext,R.anim.recents_launch_prev_affiliated_task_bounce));
      }
    }
    return;
  }
  MetricsLogger.count(mContext,"String_Node_Str",1);
  ssp.startActivityFromRecents(mContext,toTask.key,toTask.title,launchOpts);
}

Fixed version (ground truth):
/** 
 * Transitions to the next affiliated task.
 */
public void showRelativeAffiliatedTask(boolean showNextTask){
  SystemServicesProxy ssp=Recents.getSystemServices();
  RecentsTaskLoader loader=Recents.getTaskLoader();
  RecentsTaskLoadPlan plan=loader.createLoadPlan(mContext);
  loader.preloadTasks(plan,-1,false);
  TaskStack focusedStack=plan.getTaskStack();
  if (focusedStack == null || focusedStack.getTaskCount() == 0)   return;
  ActivityManager.RunningTaskInfo runningTask=ssp.getRunningTask();
  if (runningTask == null)   return;
  if (SystemServicesProxy.isHomeStack(runningTask.stackId))   return;
  ArrayList<Task> tasks=focusedStack.getStackTasks();
  Task toTask=null;
  ActivityOptions launchOpts=null;
  int taskCount=tasks.size();
  int numAffiliatedTasks=0;
  for (int i=0; i < taskCount; i++) {
    Task task=tasks.get(i);
    if (task.key.id == runningTask.id) {
      TaskGrouping group=task.group;
      Task.TaskKey toTaskKey;
      if (showNextTask) {
        toTaskKey=group.getNextTaskInGroup(task);
        launchOpts=ActivityOptions.makeCustomAnimation(mContext,R.anim.recents_launch_next_affiliated_task_target,R.anim.recents_launch_next_affiliated_task_source);
      }
 else {
        toTaskKey=group.getPrevTaskInGroup(task);
        launchOpts=ActivityOptions.makeCustomAnimation(mContext,R.anim.recents_launch_prev_affiliated_task_target,R.anim.recents_launch_prev_affiliated_task_source);
      }
      if (toTaskKey != null) {
        toTask=focusedStack.findTaskWithId(toTaskKey.id);
      }
      numAffiliatedTasks=group.getTaskCount();
      break;
    }
  }
  if (toTask == null) {
    if (numAffiliatedTasks > 1) {
      if (showNextTask) {
        ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext,R.anim.recents_launch_next_affiliated_task_bounce));
      }
 else {
        ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext,R.anim.recents_launch_prev_affiliated_task_bounce));
      }
    }
    return;
  }
  MetricsLogger.count(mContext,"String_Node_Str",1);
  ssp.startActivityFromRecents(mContext,toTask.key,toTask.title,launchOpts);
}