Program: 198932
Project: 198932
Buggy source:
/** 
 * TaskStackView.TaskStackCallbacks Implementation 
 */
@Override public void onTaskViewClicked(final TaskStackView stackView,final TaskView tv,final TaskStack stack,final Task task,final boolean lockToTask){
  if (mCb != null) {
    mCb.onTaskViewClicked();
  }
  TaskViewTransform transform=new TaskViewTransform();
  View sourceView=tv;
  int offsetX=0;
  int offsetY=0;
  int stackScroll=stackView.getStackScroll();
  if (tv == null) {
    sourceView=stackView;
    transform=stackView.getStackAlgorithm().getStackTransform(task,stackScroll,transform);
    offsetX=transform.rect.left;
    offsetY=Math.min(transform.rect.top,mConfig.displayRect.height());
  }
 else {
    transform=stackView.getStackAlgorithm().getStackTransform(task,stackScroll,transform);
  }
  final SystemServicesProxy ssp=RecentsTaskLoader.getInstance().getSystemServicesProxy();
  ActivityOptions opts=null;
  int thumbnailWidth=transform.rect.width();
  int thumbnailHeight=transform.rect.height();
  if (task.thumbnail != null && thumbnailWidth > 0 && thumbnailHeight > 0 && task.thumbnail.getWidth() > 0 && task.thumbnail.getHeight() > 0) {
    Bitmap b=Bitmap.createBitmap(thumbnailWidth,thumbnailHeight,Bitmap.Config.ARGB_8888);
    Canvas c=new Canvas(b);
    c.drawBitmap(task.thumbnail,new Rect(0,0,task.thumbnail.getWidth(),task.thumbnail.getHeight()),new Rect(0,0,thumbnailWidth,thumbnailHeight),null);
    c.setBitmap(null);
    ActivityOptions.OnAnimationStartedListener animStartedListener=null;
    if (lockToTask) {
      animStartedListener=new ActivityOptions.OnAnimationStartedListener(){
        boolean mTriggered=false;
        @Override public void onAnimationStarted(){
          if (!mTriggered) {
            postDelayed(new Runnable(){
              @Override public void run(){
                ssp.lockCurrentTask();
              }
            }
,350);
            mTriggered=true;
          }
        }
      }
;
    }
    opts=ActivityOptions.makeThumbnailScaleUpAnimation(sourceView,b,offsetX,offsetY,animStartedListener);
  }
  final ActivityOptions launchOpts=opts;
  final Runnable launchRunnable=new Runnable(){
    @Override public void run(){
      if (task.isActive) {
        RecentsTaskLoader.getInstance().getSystemServicesProxy().moveTaskToFront(task.key.id,launchOpts);
      }
 else {
        Intent i=new Intent(task.key.baseIntent);
        i.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
        if ((i.getFlags() & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) == 0) {
          i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
        try {
          UserHandle taskUser=new UserHandle(task.userId);
          if (launchOpts != null) {
            getContext().startActivityAsUser(i,launchOpts.toBundle(),taskUser);
          }
 else {
            getContext().startActivityAsUser(i,taskUser);
            if (lockToTask) {
              ssp.lockCurrentTask();
            }
          }
        }
 catch (        ActivityNotFoundException anfe) {
          Console.logError(getContext(),"String_Node_Str");
        }
        onTaskViewDismissed(task);
      }
    }
  }
;
  if (tv == null) {
    post(launchRunnable);
  }
 else {
    stackView.animateOnLaunchingTask(tv,launchRunnable);
  }
}

Fixed version (ground truth):
/** 
 * TaskStackView.TaskStackCallbacks Implementation 
 */
@Override public void onTaskViewClicked(final TaskStackView stackView,final TaskView tv,final TaskStack stack,final Task task,final boolean lockToTask){
  if (mCb != null) {
    mCb.onTaskViewClicked();
  }
  TaskViewTransform transform=new TaskViewTransform();
  View sourceView=tv;
  int offsetX=0;
  int offsetY=0;
  int stackScroll=stackView.getStackScroll();
  if (tv == null) {
    sourceView=stackView;
    transform=stackView.getStackAlgorithm().getStackTransform(task,stackScroll,transform);
    offsetX=transform.rect.left;
    offsetY=Math.min(transform.rect.top,mConfig.displayRect.height());
  }
 else {
    transform=stackView.getStackAlgorithm().getStackTransform(task,stackScroll,transform);
  }
  final SystemServicesProxy ssp=RecentsTaskLoader.getInstance().getSystemServicesProxy();
  ActivityOptions opts=null;
  int thumbnailWidth=transform.rect.width();
  int thumbnailHeight=transform.rect.height();
  if (task.thumbnail != null && thumbnailWidth > 0 && thumbnailHeight > 0 && task.thumbnail.getWidth() > 0 && task.thumbnail.getHeight() > 0) {
    Bitmap b=Bitmap.createBitmap(thumbnailWidth,thumbnailHeight,Bitmap.Config.ARGB_8888);
    Canvas c=new Canvas(b);
    c.drawBitmap(task.thumbnail,new Rect(0,0,task.thumbnail.getWidth(),task.thumbnail.getHeight()),new Rect(0,0,thumbnailWidth,thumbnailHeight),null);
    c.setBitmap(null);
    ActivityOptions.OnAnimationStartedListener animStartedListener=null;
    if (lockToTask) {
      animStartedListener=new ActivityOptions.OnAnimationStartedListener(){
        boolean mTriggered=false;
        @Override public void onAnimationStarted(){
          if (!mTriggered) {
            postDelayed(new Runnable(){
              @Override public void run(){
                ssp.lockCurrentTask();
              }
            }
,350);
            mTriggered=true;
          }
        }
      }
;
    }
    opts=ActivityOptions.makeThumbnailScaleUpAnimation(sourceView,b,offsetX,offsetY,animStartedListener);
  }
  final ActivityOptions launchOpts=opts;
  final Runnable launchRunnable=new Runnable(){
    @Override public void run(){
      if (task.isActive) {
        RecentsTaskLoader.getInstance().getSystemServicesProxy().moveTaskToFront(task.key.id,launchOpts);
      }
 else {
        Intent i=new Intent(task.key.baseIntent);
        i.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY | Intent.FLAG_ACTIVITY_TASK_ON_HOME);
        if (!Utilities.isDocument(i)) {
          i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
        try {
          UserHandle taskUser=new UserHandle(task.userId);
          if (launchOpts != null) {
            getContext().startActivityAsUser(i,launchOpts.toBundle(),taskUser);
          }
 else {
            getContext().startActivityAsUser(i,taskUser);
            if (lockToTask) {
              ssp.lockCurrentTask();
            }
          }
        }
 catch (        ActivityNotFoundException anfe) {
          Console.logError(getContext(),"String_Node_Str");
        }
        onTaskViewDismissed(task);
      }
    }
  }
;
  if (tv == null) {
    post(launchRunnable);
  }
 else {
    stackView.animateOnLaunchingTask(tv,launchRunnable);
  }
}