Program: 21865
Project: 21865
Buggy source:
@Override public boolean onTouchEvent(MotionEvent ev){
  if (ev.getAction() == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0) {
    return false;
  }
  if (mVelocityTracker == null) {
    mVelocityTracker=VelocityTracker.obtain();
  }
  mVelocityTracker.addMovement(ev);
  final int action=ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
{
      final float x=ev.getX();
      if (!(mIsBeingDragged=inChild((int)x,(int)ev.getY()))) {
        return false;
      }
      if (!mScroller.isFinished()) {
        mScroller.abortAnimation();
      }
      mLastMotionX=x;
      mActivePointerId=ev.getPointerId(0);
      break;
    }
case MotionEvent.ACTION_MOVE:
  if (mIsBeingDragged) {
    final int activePointerIndex=ev.findPointerIndex(mActivePointerId);
    final float x=ev.getX(activePointerIndex);
    final int deltaX=(int)(mLastMotionX - x);
    mLastMotionX=x;
    final int oldX=mScrollX;
    final int oldY=mScrollY;
    final int range=getScrollRange();
    if (overscrollBy(deltaX,0,mScrollX,0,range,0,mOverscrollDistance,0,true)) {
      mVelocityTracker.clear();
    }
    onScrollChanged(mScrollX,mScrollY,oldX,oldY);
    final int overscrollMode=getOverscrollMode();
    if (overscrollMode == OVERSCROLL_ALWAYS || (overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && range > 0)) {
      final int pulledToX=oldX + deltaX;
      if (pulledToX < 0) {
        mEdgeGlowLeft.onPull((float)deltaX / getWidth());
      }
 else       if (pulledToX > range) {
        mEdgeGlowRight.onPull((float)deltaX / getWidth());
      }
    }
  }
break;
case MotionEvent.ACTION_UP:
if (mIsBeingDragged) {
final VelocityTracker velocityTracker=mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000,mMaximumVelocity);
int initialVelocity=(int)velocityTracker.getXVelocity(mActivePointerId);
if (getChildCount() > 0) {
  if ((Math.abs(initialVelocity) > mMinimumVelocity)) {
    fling(-initialVelocity);
  }
 else {
    final int right=getScrollRange();
    if (mScroller.springback(mScrollX,mScrollY,0,right,0,0)) {
      invalidate();
    }
  }
}
mActivePointerId=INVALID_POINTER;
mIsBeingDragged=false;
if (mVelocityTracker != null) {
  mVelocityTracker.recycle();
  mVelocityTracker=null;
}
if (mEdgeGlowLeft != null) {
  mEdgeGlowLeft.onRelease();
  mEdgeGlowRight.onRelease();
}
}
break;
case MotionEvent.ACTION_CANCEL:
if (mIsBeingDragged && getChildCount() > 0) {
if (mScroller.springback(mScrollX,mScrollY,0,getScrollRange(),0,0)) {
invalidate();
}
mActivePointerId=INVALID_POINTER;
mIsBeingDragged=false;
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker=null;
}
if (mEdgeGlowLeft != null) {
mEdgeGlowLeft.onRelease();
mEdgeGlowRight.onRelease();
}
}
break;
case MotionEvent.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
}
return true;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent ev){
  if (ev.getAction() == MotionEvent.ACTION_DOWN && ev.getEdgeFlags() != 0) {
    return false;
  }
  if (mVelocityTracker == null) {
    mVelocityTracker=VelocityTracker.obtain();
  }
  mVelocityTracker.addMovement(ev);
  final int action=ev.getAction();
switch (action & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
{
      final float x=ev.getX();
      mIsBeingDragged=true;
      if (!mScroller.isFinished()) {
        mScroller.abortAnimation();
      }
      mLastMotionX=x;
      mActivePointerId=ev.getPointerId(0);
      break;
    }
case MotionEvent.ACTION_MOVE:
  if (mIsBeingDragged) {
    final int activePointerIndex=ev.findPointerIndex(mActivePointerId);
    final float x=ev.getX(activePointerIndex);
    final int deltaX=(int)(mLastMotionX - x);
    mLastMotionX=x;
    final int oldX=mScrollX;
    final int oldY=mScrollY;
    final int range=getScrollRange();
    if (overscrollBy(deltaX,0,mScrollX,0,range,0,mOverscrollDistance,0,true)) {
      mVelocityTracker.clear();
    }
    onScrollChanged(mScrollX,mScrollY,oldX,oldY);
    final int overscrollMode=getOverscrollMode();
    if (overscrollMode == OVERSCROLL_ALWAYS || (overscrollMode == OVERSCROLL_IF_CONTENT_SCROLLS && range > 0)) {
      final int pulledToX=oldX + deltaX;
      if (pulledToX < 0) {
        mEdgeGlowLeft.onPull((float)deltaX / getWidth());
      }
 else       if (pulledToX > range) {
        mEdgeGlowRight.onPull((float)deltaX / getWidth());
      }
    }
  }
break;
case MotionEvent.ACTION_UP:
if (mIsBeingDragged) {
final VelocityTracker velocityTracker=mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000,mMaximumVelocity);
int initialVelocity=(int)velocityTracker.getXVelocity(mActivePointerId);
if (getChildCount() > 0) {
  if ((Math.abs(initialVelocity) > mMinimumVelocity)) {
    fling(-initialVelocity);
  }
 else {
    final int right=getScrollRange();
    if (mScroller.springback(mScrollX,mScrollY,0,right,0,0)) {
      invalidate();
    }
  }
}
mActivePointerId=INVALID_POINTER;
mIsBeingDragged=false;
if (mVelocityTracker != null) {
  mVelocityTracker.recycle();
  mVelocityTracker=null;
}
if (mEdgeGlowLeft != null) {
  mEdgeGlowLeft.onRelease();
  mEdgeGlowRight.onRelease();
}
}
break;
case MotionEvent.ACTION_CANCEL:
if (mIsBeingDragged && getChildCount() > 0) {
if (mScroller.springback(mScrollX,mScrollY,0,getScrollRange(),0,0)) {
invalidate();
}
mActivePointerId=INVALID_POINTER;
mIsBeingDragged=false;
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker=null;
}
if (mEdgeGlowLeft != null) {
mEdgeGlowLeft.onRelease();
mEdgeGlowRight.onRelease();
}
}
break;
case MotionEvent.ACTION_POINTER_UP:
onSecondaryPointerUp(ev);
break;
}
return true;
}