Program: 191758
Project: 191758
Buggy source:
@Override public boolean onInterceptTouchEvent(MotionEvent event){
  if (!mTouchingHeadsUpView && 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.getChildAtRawPosition(x,y);
mTouchingHeadsUpView=false;
if (child instanceof ExpandableNotificationRow) {
mPickedChild=(ExpandableNotificationRow)child;
mTouchingHeadsUpView=!mStackScroller.isExpanded() && mPickedChild.isHeadsUp() && mPickedChild.isPinned();
}
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 (mTouchingHeadsUpView && Math.abs(h) > mTouchSlop && Math.abs(h) > Math.abs(x - mInitialTouchX)) {
setTrackingHeadsUp(true);
mCollapseSnoozes=h < 0;
mInitialTouchX=x;
mInitialTouchY=y;
int expandedHeight=mPickedChild.getActualHeight();
mHeadsUpManager.unpinAll();
mPanel.setPanelScrimMinFraction((float)expandedHeight / mPanel.getMaxPanelHeight());
mPanel.startExpandMotion(x,y,true,expandedHeight);
mPanel.clearNotificationEffects();
return true;
}
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
if (mPickedChild != null && mTouchingHeadsUpView) {
if (mHeadsUpManager.shouldSwallowClick(mPickedChild.getStatusBarNotification().getKey())) {
endMotion();
return true;
}
}
endMotion();
break;
}
return false;
}

Fixed version (ground truth):
@Override public boolean onInterceptTouchEvent(MotionEvent event){
  if (!mTouchingHeadsUpView && 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.getChildAtRawPosition(x,y);
mTouchingHeadsUpView=false;
if (child instanceof ExpandableNotificationRow) {
mPickedChild=(ExpandableNotificationRow)child;
mTouchingHeadsUpView=!mStackScroller.isExpanded() && mPickedChild.isHeadsUp() && mPickedChild.isPinned();
}
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 (mTouchingHeadsUpView && 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.setPanelScrimMinFraction((float)expandedHeight / mPanel.getMaxPanelHeight());
mPanel.startExpandMotion(x,y,true,expandedHeight);
mHeadsUpManager.unpinAll();
mPanel.clearNotificationEffects();
return true;
}
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
if (mPickedChild != null && mTouchingHeadsUpView) {
if (mHeadsUpManager.shouldSwallowClick(mPickedChild.getStatusBarNotification().getKey())) {
endMotion();
return true;
}
}
endMotion();
break;
}
return false;
}