Program: 193260
Project: 193260
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,true);
  TaskStack focusedStack=plan.getTaskStack();
  if (focusedStack == null || focusedStack.getTaskCount() == 0)   return;
  ActivityManager.RunningTaskInfo runningTask=ssp.getTopMostTask();
  if (runningTask == null)   return;
  if (SystemServicesProxy.isHomeStack(runningTask.stackId))   return;
  ArrayList<Task> tasks=focusedStack.getTasks();
  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);
  if (toTask.isActive) {
    ssp.moveTaskToFront(toTask.key.id,launchOpts);
  }
 else {
    ssp.startActivityFromRecents(mContext,toTask.key.id,toTask.activityLabel,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,true);
  TaskStack focusedStack=plan.getTaskStack();
  if (focusedStack == null || focusedStack.getTaskCount() == 0)   return;
  ActivityManager.RunningTaskInfo runningTask=ssp.getTopMostTask();
  if (runningTask == null)   return;
  if (SystemServicesProxy.isHomeStack(runningTask.stackId))   return;
  ArrayList<Task> tasks=focusedStack.getTasks();
  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.id,toTask.activityLabel,launchOpts);
}