Program: 195312
Project: 195312
Buggy source:
@Override public boolean onInterceptTouchEvent(MotionEvent event){
  if (!mMotionOnHeadsUpView && event.getActionMasked() != MotionEvent.ACTION_DOWN) {
    return false;
  }
  int pointerIndex=event.findPointerIndex(mTrackingPointer);
  if (pointerIndex < 0) {
    pointerIndex=0;
    mTrackingPointer=event.getPointerId(pointerIndex);
  }
  final float x=event.getX(pointerIndex);
  final float y=event.getY(pointerIndex);
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
    mInitialTouchY=y;
  mInitialTouchX=x;
setTrackingHeadsUp(false);
ExpandableView child=mStackScroller.getChildAtPosition(x,y);
mMotionOnHeadsUpView=false;
if (child instanceof ExpandableNotificationRow) {
mPickedChild=(ExpandableNotificationRow)child;
mMotionOnHeadsUpView=mPickedChild.isHeadsUp() && !mPickedChild.isInShade();
}
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;
mTrackingPointer=event.getPointerId(newIndex);
mInitialTouchX=event.getX(newIndex);
mInitialTouchY=event.getY(newIndex);
}
break;
case MotionEvent.ACTION_MOVE:
final float h=y - mInitialTouchY;
if (Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX)) {
setTrackingHeadsUp(true);
mCollapseSnoozes=h < 0;
mInitialTouchX=x;
mInitialTouchY=y;
mHeadsUpManager.releaseAllToShade();
int expandedHeight=mPickedChild.getActualHeight();
mPanel.startExpandMotion(x,y,true,expandedHeight);
return true;
}
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
if (mPickedChild != null && mMotionOnHeadsUpView) {
if (mHeadsUpManager.shouldSwallowClick(mPickedChild.getStatusBarNotification().getKey())) {
endMotion();
return true;
}
}
endMotion();
break;
}
return false;
}

Fixed version (ground truth):
@Override public boolean onInterceptTouchEvent(MotionEvent event){
  if (!mMotionOnHeadsUpView && event.getActionMasked() != MotionEvent.ACTION_DOWN) {
    return false;
  }
  int pointerIndex=event.findPointerIndex(mTrackingPointer);
  if (pointerIndex < 0) {
    pointerIndex=0;
    mTrackingPointer=event.getPointerId(pointerIndex);
  }
  final float x=event.getX(pointerIndex);
  final float y=event.getY(pointerIndex);
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
    mInitialTouchY=y;
  mInitialTouchX=x;
setTrackingHeadsUp(false);
ExpandableView child=mStackScroller.getChildAtPosition(x,y);
mMotionOnHeadsUpView=false;
if (child instanceof ExpandableNotificationRow) {
mPickedChild=(ExpandableNotificationRow)child;
mMotionOnHeadsUpView=mPickedChild.isHeadsUp() && !mPickedChild.isInShade();
}
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;
mTrackingPointer=event.getPointerId(newIndex);
mInitialTouchX=event.getX(newIndex);
mInitialTouchY=event.getY(newIndex);
}
break;
case MotionEvent.ACTION_MOVE:
final float h=y - mInitialTouchY;
if (Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX)) {
setTrackingHeadsUp(true);
mCollapseSnoozes=h < 0;
mInitialTouchX=x;
mInitialTouchY=y;
int expandedHeight=mPickedChild.getActualHeight();
mPanel.startExpandMotion(x,y,true,expandedHeight);
return true;
}
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
if (mPickedChild != null && mMotionOnHeadsUpView) {
if (mHeadsUpManager.shouldSwallowClick(mPickedChild.getStatusBarNotification().getKey())) {
endMotion();
return true;
}
}
endMotion();
break;
}
return false;
}