Program: 199389
Project: 199389
Buggy source:
public boolean onSettingsEvent(MotionEvent event){
  if (mSettingsTracker != null) {
    mSettingsTracker.addMovement(event);
  }
  if (event.getAction() == MotionEvent.ACTION_DOWN) {
    mSettingsTracker=VelocityTracker.obtain();
    mSettingsDownY=event.getY();
    mSettingsCancelled=false;
    mSettingsClosing=mFlipSettingsView.getVisibility() == View.VISIBLE;
    mFlipSettingsView.setVisibility(View.VISIBLE);
    mStackScroller.setVisibility(View.VISIBLE);
    positionSettings(0);
    if (!mSettingsClosing) {
      mFlipSettingsView.setTranslationY(-mNotificationPanel.getMeasuredHeight());
    }
    dispatchSettingsEvent(event);
  }
 else   if (mSettingsTracker != null && (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL)) {
    final float dy=event.getY() - mSettingsDownY;
    final FlipperButton flipper=mOnKeyguard ? mKeyguardFlipper : mHeaderFlipper;
    final boolean inButton=flipper.inHolderBounds(event);
    final int slop=ViewConfiguration.get(mContext).getScaledTouchSlop();
    final boolean qsTap=mSettingsClosing && Math.abs(dy) < slop;
    if (!qsTap && !inButton) {
      mSettingsTracker.computeCurrentVelocity(1000);
      final float vy=mSettingsTracker.getYVelocity();
      if (dy <= slop || vy <= 0) {
        flipToNotifications();
      }
 else {
        flipToSettings();
      }
    }
    mSettingsTracker.recycle();
    mSettingsTracker=null;
    dispatchSettingsEvent(event);
  }
 else   if (mSettingsTracker != null && event.getAction() == MotionEvent.ACTION_MOVE) {
    final float dy=event.getY() - mSettingsDownY;
    positionSettings(dy);
    if (mSettingsClosing) {
      final boolean qsTap=Math.abs(dy) < ViewConfiguration.get(mContext).getScaledTouchSlop();
      if (!mSettingsCancelled && !qsTap) {
        MotionEvent cancelEvent=MotionEvent.obtainNoHistory(event);
        cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
        dispatchSettingsEvent(cancelEvent);
        mSettingsCancelled=true;
      }
    }
 else {
      dispatchSettingsEvent(event);
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean onSettingsEvent(MotionEvent event){
  userActivity();
  if (mSettingsClosing && mFlipSettingsViewAnim != null && mFlipSettingsViewAnim.isRunning()) {
    return true;
  }
  if (mSettingsTracker != null) {
    mSettingsTracker.addMovement(event);
  }
  if (event.getAction() == MotionEvent.ACTION_DOWN) {
    mSettingsTracker=VelocityTracker.obtain();
    mSettingsDownY=event.getY();
    mSettingsCancelled=false;
    mSettingsClosing=mFlipSettingsView.getVisibility() == View.VISIBLE;
    mFlipSettingsView.setVisibility(View.VISIBLE);
    mStackScroller.setVisibility(View.VISIBLE);
    positionSettings(0);
    if (!mSettingsClosing) {
      mFlipSettingsView.setTranslationY(-mNotificationPanel.getMeasuredHeight());
    }
    dispatchSettingsEvent(event);
  }
 else   if (mSettingsTracker != null && (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL)) {
    final float dy=event.getY() - mSettingsDownY;
    final FlipperButton flipper=mOnKeyguard ? mKeyguardFlipper : mHeaderFlipper;
    final boolean inButton=flipper.inHolderBounds(event);
    final int slop=ViewConfiguration.get(mContext).getScaledTouchSlop();
    final boolean qsTap=mSettingsClosing && Math.abs(dy) < slop;
    if (!qsTap && !inButton) {
      mSettingsTracker.computeCurrentVelocity(1000);
      final float vy=mSettingsTracker.getYVelocity();
      if (dy <= slop || vy <= 0) {
        flipToNotifications();
      }
 else {
        flipToSettings();
      }
    }
    mSettingsTracker.recycle();
    mSettingsTracker=null;
    dispatchSettingsEvent(event);
  }
 else   if (mSettingsTracker != null && event.getAction() == MotionEvent.ACTION_MOVE) {
    final float dy=event.getY() - mSettingsDownY;
    positionSettings(dy);
    if (mSettingsClosing) {
      final boolean qsTap=Math.abs(dy) < ViewConfiguration.get(mContext).getScaledTouchSlop();
      if (!mSettingsCancelled && !qsTap) {
        MotionEvent cancelEvent=MotionEvent.obtainNoHistory(event);
        cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
        dispatchSettingsEvent(cancelEvent);
        mSettingsCancelled=true;
      }
    }
 else {
      dispatchSettingsEvent(event);
    }
  }
  return true;
}