Program: 195953
Project: 195953
Buggy source:
/** 
 * Updates the set of recent tasks 
 */
void updateRecentsTasks(Intent launchIntent){
  boolean fromSearchHome=launchIntent.getBooleanExtra(AlternateRecentsComponent.EXTRA_FROM_SEARCH_HOME,false);
  int numVisibleTasks=launchIntent.getIntExtra(AlternateRecentsComponent.EXTRA_NUM_VISIBLE_TASKS,0);
  int numVisibleThumbnails=launchIntent.getIntExtra(AlternateRecentsComponent.EXTRA_NUM_VISIBLE_THUMBNAILS,0);
  mConfig.launchedFromHome=fromSearchHome || launchIntent.getBooleanExtra(AlternateRecentsComponent.EXTRA_FROM_HOME,false);
  mConfig.launchedFromAppWithThumbnail=launchIntent.getBooleanExtra(AlternateRecentsComponent.EXTRA_FROM_APP_THUMBNAIL,false);
  mConfig.launchedToTaskId=launchIntent.getIntExtra(AlternateRecentsComponent.EXTRA_FROM_TASK_ID,-1);
  mConfig.launchedWithAltTab=launchIntent.getBooleanExtra(AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB,false);
  mConfig.launchedReuseTaskStackViews=launchIntent.getBooleanExtra(AlternateRecentsComponent.EXTRA_REUSE_TASK_STACK_VIEWS,false);
  RecentsTaskLoader loader=RecentsTaskLoader.getInstance();
  RecentsTaskLoadPlan plan=AlternateRecentsComponent.consumeInstanceLoadPlan();
  if (plan == null) {
    plan=loader.createLoadPlan(this);
    loader.preloadTasks(plan,mConfig.launchedFromHome);
  }
  RecentsTaskLoadPlan.Options loadOpts=new RecentsTaskLoadPlan.Options();
  loadOpts.runningTaskId=mConfig.launchedToTaskId;
  loadOpts.numVisibleTasks=numVisibleTasks;
  loadOpts.numVisibleTaskThumbnails=numVisibleThumbnails;
  loader.loadTasks(this,plan,loadOpts);
  SpaceNode root=plan.getSpaceNode();
  ArrayList<TaskStack> stacks=root.getStacks();
  boolean hasTasks=root.hasTasks();
  if (hasTasks) {
    mRecentsView.setTaskStacks(stacks);
  }
  mConfig.launchedWithNoRecentTasks=!hasTasks;
  Intent homeIntent=new Intent(Intent.ACTION_MAIN,null);
  homeIntent.addCategory(Intent.CATEGORY_HOME);
  homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  mFinishLaunchHomeRunnable=new FinishRecentsRunnable(homeIntent,ActivityOptions.makeCustomAnimation(this,fromSearchHome ? R.anim.recents_to_search_launcher_enter : R.anim.recents_to_launcher_enter,fromSearchHome ? R.anim.recents_to_search_launcher_exit : R.anim.recents_to_launcher_exit));
  int taskStackCount=stacks.size();
  if (mConfig.launchedToTaskId != -1) {
    for (int i=0; i < taskStackCount; i++) {
      TaskStack stack=stacks.get(i);
      ArrayList<Task> tasks=stack.getTasks();
      int taskCount=tasks.size();
      for (int j=0; j < taskCount; j++) {
        Task t=tasks.get(j);
        if (t.key.id == mConfig.launchedToTaskId) {
          t.isLaunchTarget=true;
          break;
        }
      }
    }
  }
  if (mConfig.launchedWithNoRecentTasks) {
    if (mEmptyView == null) {
      mEmptyView=mEmptyViewStub.inflate();
    }
    mEmptyView.setVisibility(View.VISIBLE);
    mRecentsView.setSearchBarVisibility(View.GONE);
  }
 else {
    if (mEmptyView != null) {
      mEmptyView.setVisibility(View.GONE);
    }
    if (mRecentsView.hasSearchBar()) {
      mRecentsView.setSearchBarVisibility(View.VISIBLE);
    }
 else {
      addSearchBarAppWidgetView();
    }
  }
  mScrimViews.prepareEnterRecentsAnimation();
}

Fixed version (ground truth):
/** 
 * Updates the set of recent tasks 
 */
void updateRecentsTasks(Intent launchIntent){
  boolean fromSearchHome=launchIntent.getBooleanExtra(AlternateRecentsComponent.EXTRA_FROM_SEARCH_HOME,false);
  int numVisibleTasks=launchIntent.getIntExtra(AlternateRecentsComponent.EXTRA_NUM_VISIBLE_TASKS,0);
  int numVisibleThumbnails=launchIntent.getIntExtra(AlternateRecentsComponent.EXTRA_NUM_VISIBLE_THUMBNAILS,0);
  mConfig.launchedFromHome=fromSearchHome || launchIntent.getBooleanExtra(AlternateRecentsComponent.EXTRA_FROM_HOME,false);
  mConfig.launchedFromAppWithThumbnail=launchIntent.getBooleanExtra(AlternateRecentsComponent.EXTRA_FROM_APP_THUMBNAIL,false);
  mConfig.launchedToTaskId=launchIntent.getIntExtra(AlternateRecentsComponent.EXTRA_FROM_TASK_ID,-1);
  mConfig.launchedWithAltTab=launchIntent.getBooleanExtra(AlternateRecentsComponent.EXTRA_TRIGGERED_FROM_ALT_TAB,false);
  mConfig.launchedReuseTaskStackViews=launchIntent.getBooleanExtra(AlternateRecentsComponent.EXTRA_REUSE_TASK_STACK_VIEWS,false);
  RecentsTaskLoader loader=RecentsTaskLoader.getInstance();
  RecentsTaskLoadPlan plan=AlternateRecentsComponent.consumeInstanceLoadPlan();
  if (plan == null) {
    plan=loader.createLoadPlan(this);
  }
  if (plan.getTaskStack() == null) {
    loader.preloadTasks(plan,mConfig.launchedFromHome);
  }
  RecentsTaskLoadPlan.Options loadOpts=new RecentsTaskLoadPlan.Options();
  loadOpts.runningTaskId=mConfig.launchedToTaskId;
  loadOpts.numVisibleTasks=numVisibleTasks;
  loadOpts.numVisibleTaskThumbnails=numVisibleThumbnails;
  loader.loadTasks(this,plan,loadOpts);
  SpaceNode root=plan.getSpaceNode();
  ArrayList<TaskStack> stacks=root.getStacks();
  boolean hasTasks=root.hasTasks();
  if (hasTasks) {
    mRecentsView.setTaskStacks(stacks);
  }
  mConfig.launchedWithNoRecentTasks=!hasTasks;
  Intent homeIntent=new Intent(Intent.ACTION_MAIN,null);
  homeIntent.addCategory(Intent.CATEGORY_HOME);
  homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
  mFinishLaunchHomeRunnable=new FinishRecentsRunnable(homeIntent,ActivityOptions.makeCustomAnimation(this,fromSearchHome ? R.anim.recents_to_search_launcher_enter : R.anim.recents_to_launcher_enter,fromSearchHome ? R.anim.recents_to_search_launcher_exit : R.anim.recents_to_launcher_exit));
  int taskStackCount=stacks.size();
  if (mConfig.launchedToTaskId != -1) {
    for (int i=0; i < taskStackCount; i++) {
      TaskStack stack=stacks.get(i);
      ArrayList<Task> tasks=stack.getTasks();
      int taskCount=tasks.size();
      for (int j=0; j < taskCount; j++) {
        Task t=tasks.get(j);
        if (t.key.id == mConfig.launchedToTaskId) {
          t.isLaunchTarget=true;
          break;
        }
      }
    }
  }
  if (mConfig.launchedWithNoRecentTasks) {
    if (mEmptyView == null) {
      mEmptyView=mEmptyViewStub.inflate();
    }
    mEmptyView.setVisibility(View.VISIBLE);
    mRecentsView.setSearchBarVisibility(View.GONE);
  }
 else {
    if (mEmptyView != null) {
      mEmptyView.setVisibility(View.GONE);
    }
    if (mRecentsView.hasSearchBar()) {
      mRecentsView.setSearchBarVisibility(View.VISIBLE);
    }
 else {
      addSearchBarAppWidgetView();
    }
  }
  mScrimViews.prepareEnterRecentsAnimation();
}