Program: 1290
Project: 1290
Buggy source:
private void onTouchUp(MotionEvent ev){
switch (mTouchMode) {
case TOUCH_MODE_DOWN:
case TOUCH_MODE_TAP:
case TOUCH_MODE_DONE_WAITING:
    final int motionPosition=mMotionPosition;
  final View child=getChildAt(motionPosition - mFirstPosition);
if (child != null) {
  if (mTouchMode != TOUCH_MODE_DOWN) {
    child.setPressed(false);
  }
  final float x=ev.getX();
  final boolean inList=x > mListPadding.left && x < getWidth() - mListPadding.right;
  if (inList && !child.hasFocusable()) {
    if (mPerformClick == null) {
      mPerformClick=new PerformClick();
    }
    final AbsListView.PerformClick performClick=mPerformClick;
    performClick.mClickMotionPosition=motionPosition;
    performClick.rememberWindowAttachCount();
    mResurrectToPosition=motionPosition;
    if (mTouchMode == TOUCH_MODE_DOWN || mTouchMode == TOUCH_MODE_TAP) {
      removeCallbacks(mTouchMode == TOUCH_MODE_DOWN ? mPendingCheckForTap : mPendingCheckForLongPress);
      mLayoutMode=LAYOUT_NORMAL;
      if (!mDataChanged && mAdapter.isEnabled(motionPosition)) {
        mTouchMode=TOUCH_MODE_TAP;
        setSelectedPositionInt(mMotionPosition);
        layoutChildren();
        child.setPressed(true);
        positionSelector(mMotionPosition,child);
        setPressed(true);
        if (mSelector != null) {
          Drawable d=mSelector.getCurrent();
          if (d != null && d instanceof TransitionDrawable) {
            ((TransitionDrawable)d).resetTransition();
          }
        }
        if (mTouchModeReset != null) {
          removeCallbacks(mTouchModeReset);
        }
        mTouchModeReset=new Runnable(){
          @Override public void run(){
            mTouchModeReset=null;
            mTouchMode=TOUCH_MODE_REST;
            child.setPressed(false);
            setPressed(false);
            if (!mDataChanged) {
              performClick.run();
            }
          }
        }
;
        postDelayed(mTouchModeReset,ViewConfiguration.getPressedStateDuration());
      }
 else {
        mTouchMode=TOUCH_MODE_REST;
        updateSelectorState();
      }
      return;
    }
 else     if (!mDataChanged && mAdapter.isEnabled(motionPosition)) {
      performClick.run();
    }
  }
}
mTouchMode=TOUCH_MODE_REST;
updateSelectorState();
break;
case TOUCH_MODE_SCROLL:
final int childCount=getChildCount();
if (childCount > 0) {
final int firstChildTop=getChildAt(0).getTop();
final int lastChildBottom=getChildAt(childCount - 1).getBottom();
final int contentTop=mListPadding.top;
final int contentBottom=getHeight() - mListPadding.bottom;
if (mFirstPosition == 0 && firstChildTop >= contentTop && mFirstPosition + childCount < mItemCount && lastChildBottom <= getHeight() - contentBottom) {
mTouchMode=TOUCH_MODE_REST;
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
}
 else {
final VelocityTracker velocityTracker=mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000,mMaximumVelocity);
final int initialVelocity=(int)(velocityTracker.getYVelocity(mActivePointerId) * mVelocityScale);
if (Math.abs(initialVelocity) > mMinimumVelocity && !((mFirstPosition == 0 && firstChildTop == contentTop - mOverscrollDistance) || (mFirstPosition + childCount == mItemCount && lastChildBottom == contentBottom + mOverscrollDistance))) {
if (mFlingRunnable == null) {
mFlingRunnable=new FlingRunnable();
}
reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
mFlingRunnable.start(-initialVelocity);
}
 else {
mTouchMode=TOUCH_MODE_REST;
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
if (mFlingRunnable != null) {
mFlingRunnable.endFling();
}
if (mPositionScroller != null) {
mPositionScroller.stop();
}
}
}
}
 else {
mTouchMode=TOUCH_MODE_REST;
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
}
break;
case TOUCH_MODE_OVERSCROLL:
if (mFlingRunnable == null) {
mFlingRunnable=new FlingRunnable();
}
final VelocityTracker velocityTracker=mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000,mMaximumVelocity);
final int initialVelocity=(int)velocityTracker.getYVelocity(mActivePointerId);
reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
if (Math.abs(initialVelocity) > mMinimumVelocity) {
mFlingRunnable.startOverfling(-initialVelocity);
}
 else {
mFlingRunnable.startSpringback();
}
break;
}
setPressed(false);
if (mEdgeGlowTop != null) {
mEdgeGlowTop.onRelease();
mEdgeGlowBottom.onRelease();
}
invalidate();
removeCallbacks(mPendingCheckForLongPress);
recycleVelocityTracker();
mActivePointerId=INVALID_POINTER;
if (PROFILE_SCROLLING) {
if (mScrollProfilingStarted) {
Debug.stopMethodTracing();
mScrollProfilingStarted=false;
}
}
if (mScrollStrictSpan != null) {
mScrollStrictSpan.finish();
mScrollStrictSpan=null;
}
}

Fixed version (ground truth):
private void onTouchUp(MotionEvent ev){
switch (mTouchMode) {
case TOUCH_MODE_DOWN:
case TOUCH_MODE_TAP:
case TOUCH_MODE_DONE_WAITING:
    final int motionPosition=mMotionPosition;
  final View child=getChildAt(motionPosition - mFirstPosition);
if (child != null) {
  if (mTouchMode != TOUCH_MODE_DOWN) {
    child.setPressed(false);
  }
  final float x=ev.getX();
  final boolean inList=x > mListPadding.left && x < getWidth() - mListPadding.right;
  if (inList && !child.hasFocusable()) {
    if (mPerformClick == null) {
      mPerformClick=new PerformClick();
    }
    final AbsListView.PerformClick performClick=mPerformClick;
    performClick.mClickMotionPosition=motionPosition;
    performClick.rememberWindowAttachCount();
    mResurrectToPosition=motionPosition;
    if (mTouchMode == TOUCH_MODE_DOWN || mTouchMode == TOUCH_MODE_TAP) {
      removeCallbacks(mTouchMode == TOUCH_MODE_DOWN ? mPendingCheckForTap : mPendingCheckForLongPress);
      mLayoutMode=LAYOUT_NORMAL;
      if (!mDataChanged && mAdapter.isEnabled(motionPosition)) {
        mTouchMode=TOUCH_MODE_TAP;
        setSelectedPositionInt(mMotionPosition);
        layoutChildren();
        child.setPressed(true);
        positionSelector(mMotionPosition,child);
        setPressed(true);
        if (mSelector != null) {
          Drawable d=mSelector.getCurrent();
          if (d != null && d instanceof TransitionDrawable) {
            ((TransitionDrawable)d).resetTransition();
          }
        }
        if (mTouchModeReset != null) {
          removeCallbacks(mTouchModeReset);
        }
        mTouchModeReset=new Runnable(){
          @Override public void run(){
            mTouchModeReset=null;
            mTouchMode=TOUCH_MODE_REST;
            child.setPressed(false);
            setPressed(false);
            if (!mDataChanged && isAttachedToWindow()) {
              performClick.run();
            }
          }
        }
;
        postDelayed(mTouchModeReset,ViewConfiguration.getPressedStateDuration());
      }
 else {
        mTouchMode=TOUCH_MODE_REST;
        updateSelectorState();
      }
      return;
    }
 else     if (!mDataChanged && mAdapter.isEnabled(motionPosition)) {
      performClick.run();
    }
  }
}
mTouchMode=TOUCH_MODE_REST;
updateSelectorState();
break;
case TOUCH_MODE_SCROLL:
final int childCount=getChildCount();
if (childCount > 0) {
final int firstChildTop=getChildAt(0).getTop();
final int lastChildBottom=getChildAt(childCount - 1).getBottom();
final int contentTop=mListPadding.top;
final int contentBottom=getHeight() - mListPadding.bottom;
if (mFirstPosition == 0 && firstChildTop >= contentTop && mFirstPosition + childCount < mItemCount && lastChildBottom <= getHeight() - contentBottom) {
mTouchMode=TOUCH_MODE_REST;
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
}
 else {
final VelocityTracker velocityTracker=mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000,mMaximumVelocity);
final int initialVelocity=(int)(velocityTracker.getYVelocity(mActivePointerId) * mVelocityScale);
if (Math.abs(initialVelocity) > mMinimumVelocity && !((mFirstPosition == 0 && firstChildTop == contentTop - mOverscrollDistance) || (mFirstPosition + childCount == mItemCount && lastChildBottom == contentBottom + mOverscrollDistance))) {
if (mFlingRunnable == null) {
mFlingRunnable=new FlingRunnable();
}
reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
mFlingRunnable.start(-initialVelocity);
}
 else {
mTouchMode=TOUCH_MODE_REST;
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
if (mFlingRunnable != null) {
mFlingRunnable.endFling();
}
if (mPositionScroller != null) {
mPositionScroller.stop();
}
}
}
}
 else {
mTouchMode=TOUCH_MODE_REST;
reportScrollStateChange(OnScrollListener.SCROLL_STATE_IDLE);
}
break;
case TOUCH_MODE_OVERSCROLL:
if (mFlingRunnable == null) {
mFlingRunnable=new FlingRunnable();
}
final VelocityTracker velocityTracker=mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000,mMaximumVelocity);
final int initialVelocity=(int)velocityTracker.getYVelocity(mActivePointerId);
reportScrollStateChange(OnScrollListener.SCROLL_STATE_FLING);
if (Math.abs(initialVelocity) > mMinimumVelocity) {
mFlingRunnable.startOverfling(-initialVelocity);
}
 else {
mFlingRunnable.startSpringback();
}
break;
}
setPressed(false);
if (mEdgeGlowTop != null) {
mEdgeGlowTop.onRelease();
mEdgeGlowBottom.onRelease();
}
invalidate();
removeCallbacks(mPendingCheckForLongPress);
recycleVelocityTracker();
mActivePointerId=INVALID_POINTER;
if (PROFILE_SCROLLING) {
if (mScrollProfilingStarted) {
Debug.stopMethodTracing();
mScrollProfilingStarted=false;
}
}
if (mScrollStrictSpan != null) {
mScrollStrictSpan.finish();
mScrollStrictSpan=null;
}
}