Program: 198395
Project: 198395
Buggy source:
@Override public boolean onTouchEvent(MotionEvent event){
  if (mInstantExpanding) {
    return false;
  }
  int pointerIndex=event.findPointerIndex(mTrackingPointer);
  if (pointerIndex < 0) {
    pointerIndex=0;
    mTrackingPointer=event.getPointerId(pointerIndex);
  }
  final float y=event.getY(pointerIndex);
  final float x=event.getX(pointerIndex);
  if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
    mGestureWaitForTouchSlop=mExpandedHeight == 0f;
  }
  boolean waitForTouchSlop=hasConflictingGestures() || mGestureWaitForTouchSlop;
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
    mInitialTouchY=y;
  mInitialTouchX=x;
mInitialOffsetOnTouch=mExpandedHeight;
mTouchSlopExceeded=false;
mJustPeeked=false;
if (mVelocityTracker == null) {
initVelocityTracker();
}
trackMovement(event);
if (!waitForTouchSlop || (mHeightAnimator != null && !mHintAnimationRunning) || mPeekPending|| mPeekAnimator != null) {
if (mHeightAnimator != null) {
mHeightAnimator.cancel();
}
cancelPeek();
mTouchSlopExceeded=(mHeightAnimator != null && !mHintAnimationRunning) || mPeekPending || mPeekAnimator != null;
onTrackingStarted();
}
if (mExpandedHeight == 0) {
schedulePeek();
}
break;
case MotionEvent.ACTION_POINTER_UP:
final int upPointer=event.getPointerId(event.getActionIndex());
if (mTrackingPointer == upPointer) {
final int newIndex=event.getPointerId(0) != upPointer ? 0 : 1;
final float newY=event.getY(newIndex);
final float newX=event.getX(newIndex);
mTrackingPointer=event.getPointerId(newIndex);
mInitialOffsetOnTouch=mExpandedHeight;
mInitialTouchY=newY;
mInitialTouchX=newX;
}
break;
case MotionEvent.ACTION_MOVE:
float h=y - mInitialTouchY;
if (Math.abs(h) > mTouchSlop && (Math.abs(h) > Math.abs(x - mInitialTouchX) || mInitialOffsetOnTouch == 0f)) {
mTouchSlopExceeded=true;
if (waitForTouchSlop && !mTracking) {
if (!mJustPeeked) {
mInitialOffsetOnTouch=mExpandedHeight;
mInitialTouchX=x;
mInitialTouchY=y;
h=0;
}
if (mHeightAnimator != null) {
mHeightAnimator.cancel();
}
removeCallbacks(mPeekRunnable);
mPeekPending=false;
onTrackingStarted();
}
}
final float newHeight=Math.max(0,h + mInitialOffsetOnTouch);
if (newHeight > mPeekHeight) {
if (mPeekAnimator != null) {
mPeekAnimator.cancel();
}
mJustPeeked=false;
}
if (!mJustPeeked && (!waitForTouchSlop || mTracking) && !isTrackingBlocked()) {
setExpandedHeightInternal(newHeight);
}
trackMovement(event);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mTrackingPointer=-1;
trackMovement(event);
if ((mTracking && mTouchSlopExceeded) || Math.abs(x - mInitialTouchX) > mTouchSlop || Math.abs(y - mInitialTouchY) > mTouchSlop || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
float vel=0f;
float vectorVel=0f;
if (mVelocityTracker != null) {
mVelocityTracker.computeCurrentVelocity(1000);
vel=mVelocityTracker.getYVelocity();
vectorVel=(float)Math.hypot(mVelocityTracker.getXVelocity(),mVelocityTracker.getYVelocity());
}
boolean expand=flingExpands(vel,vectorVel);
onTrackingStopped(expand);
fling(vel,expand);
}
 else {
boolean expands=onEmptySpaceClick(mInitialTouchX);
onTrackingStopped(expands);
}
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker=null;
}
break;
}
return !waitForTouchSlop || mTracking;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent event){
  if (mInstantExpanding) {
    return false;
  }
  int pointerIndex=event.findPointerIndex(mTrackingPointer);
  if (pointerIndex < 0) {
    pointerIndex=0;
    mTrackingPointer=event.getPointerId(pointerIndex);
  }
  final float y=event.getY(pointerIndex);
  final float x=event.getX(pointerIndex);
  if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
    mGestureWaitForTouchSlop=mExpandedHeight == 0f;
  }
  boolean waitForTouchSlop=hasConflictingGestures() || mGestureWaitForTouchSlop;
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
    mInitialTouchY=y;
  mInitialTouchX=x;
mInitialOffsetOnTouch=mExpandedHeight;
mTouchSlopExceeded=false;
mJustPeeked=false;
mPanelClosedOnDown=mExpandedHeight == 0.0f;
mHasLayoutedSinceDown=false;
mUpdateFlingOnLayout=false;
mTouching=true;
if (mVelocityTracker == null) {
initVelocityTracker();
}
trackMovement(event);
if (!waitForTouchSlop || (mHeightAnimator != null && !mHintAnimationRunning) || mPeekPending|| mPeekAnimator != null) {
if (mHeightAnimator != null) {
mHeightAnimator.cancel();
}
cancelPeek();
mTouchSlopExceeded=(mHeightAnimator != null && !mHintAnimationRunning) || mPeekPending || mPeekAnimator != null;
onTrackingStarted();
}
if (mExpandedHeight == 0) {
schedulePeek();
}
break;
case MotionEvent.ACTION_POINTER_UP:
final int upPointer=event.getPointerId(event.getActionIndex());
if (mTrackingPointer == upPointer) {
final int newIndex=event.getPointerId(0) != upPointer ? 0 : 1;
final float newY=event.getY(newIndex);
final float newX=event.getX(newIndex);
mTrackingPointer=event.getPointerId(newIndex);
mInitialOffsetOnTouch=mExpandedHeight;
mInitialTouchY=newY;
mInitialTouchX=newX;
}
break;
case MotionEvent.ACTION_MOVE:
float h=y - mInitialTouchY;
if (Math.abs(h) > mTouchSlop && (Math.abs(h) > Math.abs(x - mInitialTouchX) || mInitialOffsetOnTouch == 0f)) {
mTouchSlopExceeded=true;
if (waitForTouchSlop && !mTracking) {
if (!mJustPeeked) {
mInitialOffsetOnTouch=mExpandedHeight;
mInitialTouchX=x;
mInitialTouchY=y;
h=0;
}
if (mHeightAnimator != null) {
mHeightAnimator.cancel();
}
removeCallbacks(mPeekRunnable);
mPeekPending=false;
onTrackingStarted();
}
}
final float newHeight=Math.max(0,h + mInitialOffsetOnTouch);
if (newHeight > mPeekHeight) {
if (mPeekAnimator != null) {
mPeekAnimator.cancel();
}
mJustPeeked=false;
}
if (!mJustPeeked && (!waitForTouchSlop || mTracking) && !isTrackingBlocked()) {
setExpandedHeightInternal(newHeight);
}
trackMovement(event);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
mTrackingPointer=-1;
trackMovement(event);
if ((mTracking && mTouchSlopExceeded) || Math.abs(x - mInitialTouchX) > mTouchSlop || Math.abs(y - mInitialTouchY) > mTouchSlop || event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
float vel=0f;
float vectorVel=0f;
if (mVelocityTracker != null) {
mVelocityTracker.computeCurrentVelocity(1000);
vel=mVelocityTracker.getYVelocity();
vectorVel=(float)Math.hypot(mVelocityTracker.getXVelocity(),mVelocityTracker.getYVelocity());
}
boolean expand=flingExpands(vel,vectorVel);
onTrackingStopped(expand);
fling(vel,expand);
mUpdateFlingOnLayout=expand && mPanelClosedOnDown && !mHasLayoutedSinceDown;
if (mUpdateFlingOnLayout) {
mUpdateFlingVelocity=vel;
}
}
 else {
boolean expands=onEmptySpaceClick(mInitialTouchX);
onTrackingStopped(expands);
}
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker=null;
}
mTouching=false;
break;
}
return !waitForTouchSlop || mTracking;
}