Program: 45650
Project: 45650
Buggy source:
@Override public boolean onTouchEvent(MotionEvent ev){
  if (mLauncher.isWorkspaceLocked() || mLauncher.isAllAppsVisible()) {
    return false;
  }
  if (mVelocityTracker == null) {
    mVelocityTracker=VelocityTracker.obtain();
  }
  mVelocityTracker.addMovement(ev);
  final int action=ev.getAction();
  final float x=ev.getX();
switch (action) {
case MotionEvent.ACTION_DOWN:
    if (!mScroller.isFinished()) {
      mScroller.abortAnimation();
    }
  mLastMotionX=x;
break;
case MotionEvent.ACTION_MOVE:
if (mTouchState == TOUCH_STATE_SCROLLING) {
final int deltaX=(int)(mLastMotionX - x);
mLastMotionX=x;
if (deltaX < 0) {
  if (mScrollX > 0) {
    scrollBy(Math.max(-mScrollX,deltaX),0);
    updateWallpaperOffset();
  }
}
 else if (deltaX > 0) {
  final int availableToScroll=getChildAt(getChildCount() - 1).getRight() - mScrollX - getWidth();
  if (availableToScroll > 0) {
    scrollBy(Math.min(availableToScroll,deltaX),0);
    updateWallpaperOffset();
  }
}
}
break;
case MotionEvent.ACTION_UP:
if (mTouchState == TOUCH_STATE_SCROLLING) {
final VelocityTracker velocityTracker=mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000,mMaximumVelocity);
int velocityX=(int)velocityTracker.getXVelocity();
if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
snapToScreen(mCurrentScreen - 1);
}
 else if (velocityX < -SNAP_VELOCITY && mCurrentScreen < getChildCount() - 1) {
snapToScreen(mCurrentScreen + 1);
}
 else {
snapToDestination();
}
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker=null;
}
}
mTouchState=TOUCH_STATE_REST;
break;
case MotionEvent.ACTION_CANCEL:
mTouchState=TOUCH_STATE_REST;
}
return true;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent ev){
  if (mLauncher.isWorkspaceLocked()) {
    return false;
  }
  if (mLauncher.isAllAppsVisible()) {
    if (!mScroller.isFinished()) {
      mScroller.abortAnimation();
    }
    snapToScreen(mCurrentScreen);
    return false;
  }
  if (mVelocityTracker == null) {
    mVelocityTracker=VelocityTracker.obtain();
  }
  mVelocityTracker.addMovement(ev);
  final int action=ev.getAction();
  final float x=ev.getX();
switch (action) {
case MotionEvent.ACTION_DOWN:
    if (!mScroller.isFinished()) {
      mScroller.abortAnimation();
    }
  mLastMotionX=x;
break;
case MotionEvent.ACTION_MOVE:
if (mTouchState == TOUCH_STATE_SCROLLING) {
final int deltaX=(int)(mLastMotionX - x);
mLastMotionX=x;
if (deltaX < 0) {
  if (mScrollX > 0) {
    scrollBy(Math.max(-mScrollX,deltaX),0);
    updateWallpaperOffset();
  }
}
 else if (deltaX > 0) {
  final int availableToScroll=getChildAt(getChildCount() - 1).getRight() - mScrollX - getWidth();
  if (availableToScroll > 0) {
    scrollBy(Math.min(availableToScroll,deltaX),0);
    updateWallpaperOffset();
  }
}
}
break;
case MotionEvent.ACTION_UP:
if (mTouchState == TOUCH_STATE_SCROLLING) {
final VelocityTracker velocityTracker=mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000,mMaximumVelocity);
int velocityX=(int)velocityTracker.getXVelocity();
if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
snapToScreen(mCurrentScreen - 1);
}
 else if (velocityX < -SNAP_VELOCITY && mCurrentScreen < getChildCount() - 1) {
snapToScreen(mCurrentScreen + 1);
}
 else {
snapToDestination();
}
if (mVelocityTracker != null) {
mVelocityTracker.recycle();
mVelocityTracker=null;
}
}
mTouchState=TOUCH_STATE_REST;
break;
case MotionEvent.ACTION_CANCEL:
mTouchState=TOUCH_STATE_REST;
}
return true;
}