Program: 157426
Project: 157426
Buggy source:
@Override public boolean onTouchEvent(@NonNull MotionEvent nativeMotionEvent){
  if (mKeyboard == null)   return false;
  final int action=MotionEventCompat.getActionMasked(nativeMotionEvent);
  final int pointerCount=MotionEventCompat.getPointerCount(nativeMotionEvent);
  final int oldPointerCount=mOldPointerCount;
  mOldPointerCount=pointerCount;
  if (pointerCount > 1)   mLastTimeHadTwoFingers=SystemClock.elapsedRealtime();
  if (mTouchesAreDisabledTillLastFingerIsUp) {
    if (mOldPointerCount == 1 && (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP)) {
      mTouchesAreDisabledTillLastFingerIsUp=false;
    }
    return true;
  }
  if (!mHasDistinctMultitouch && pointerCount > 1 && oldPointerCount > 1) {
    return true;
  }
  if (!mMiniKeyboardVisible && mGestureDetector != null && (mGestureDetector.onTouchEvent(nativeMotionEvent))) {
    Log.d(TAG,"String_Node_Str");
    mHandler.cancelKeyTimers();
    dismissKeyPreview();
    return true;
  }
  final long eventTime=nativeMotionEvent.getEventTime();
  final int index=MotionEventCompat.getActionIndex(nativeMotionEvent);
  final int id=nativeMotionEvent.getPointerId(index);
  final int x=(int)nativeMotionEvent.getX(index);
  final int y=(int)nativeMotionEvent.getY(index);
  if (mMiniKeyboard != null && mMiniKeyboardVisible) {
    final int miniKeyboardPointerIndex=nativeMotionEvent.findPointerIndex(mMiniKeyboardTrackerId);
    if (miniKeyboardPointerIndex >= 0 && miniKeyboardPointerIndex < pointerCount) {
      final int miniKeyboardX=(int)nativeMotionEvent.getX(miniKeyboardPointerIndex);
      final int miniKeyboardY=(int)nativeMotionEvent.getY(miniKeyboardPointerIndex);
      MotionEvent translated=generateMiniKeyboardMotionEvent(action,miniKeyboardX,miniKeyboardY,eventTime);
      mMiniKeyboard.onTouchEvent(translated);
      translated.recycle();
    }
    return true;
  }
  if (mHandler.isInKeyRepeat()) {
    if (action == MotionEvent.ACTION_MOVE) {
      return true;
    }
    final PointerTracker tracker=getPointerTracker(id);
    if (pointerCount > 1 && !tracker.isModifier()) {
      mHandler.cancelKeyRepeatTimer();
    }
  }
  if (!mHasDistinctMultitouch) {
    PointerTracker tracker=getPointerTracker(0);
    if (pointerCount == 1 && oldPointerCount == 2) {
      tracker.onDownEvent(x,y,eventTime);
    }
 else     if (pointerCount == 2 && oldPointerCount == 1) {
      tracker.onUpEvent(tracker.getLastX(),tracker.getLastY(),eventTime);
    }
 else     if (pointerCount == 1 && oldPointerCount == 1) {
      tracker.onTouchEvent(action,x,y,eventTime);
    }
 else {
      Log.w(TAG,"String_Node_Str" + pointerCount + "String_Node_Str"+ oldPointerCount+ "String_Node_Str");
    }
    return true;
  }
  if (action == MotionEvent.ACTION_MOVE) {
    for (int i=0; i < pointerCount; i++) {
      PointerTracker tracker=getPointerTracker(nativeMotionEvent.getPointerId(i));
      tracker.onMoveEvent((int)nativeMotionEvent.getX(i),(int)nativeMotionEvent.getY(i),eventTime);
    }
  }
 else {
    PointerTracker tracker=getPointerTracker(id);
    sendOnXEvent(action,eventTime,x,y,tracker);
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(@NonNull MotionEvent nativeMotionEvent){
  if (mKeyboard == null)   return false;
  final int action=MotionEventCompat.getActionMasked(nativeMotionEvent);
  final int pointerCount=MotionEventCompat.getPointerCount(nativeMotionEvent);
  final int oldPointerCount=mOldPointerCount;
  mOldPointerCount=pointerCount;
  if (pointerCount > 1)   mLastTimeHadTwoFingers=SystemClock.elapsedRealtime();
  if (mTouchesAreDisabledTillLastFingerIsUp) {
    if (mOldPointerCount == 1 && (action == MotionEvent.ACTION_CANCEL || action == MotionEvent.ACTION_UP)) {
      mTouchesAreDisabledTillLastFingerIsUp=false;
    }
    return true;
  }
  if (!mHasDistinctMultitouch && pointerCount > 1 && oldPointerCount > 1) {
    return true;
  }
  if (!mMiniKeyboardPopup.isShowing() && mGestureDetector != null && mGestureDetector.onTouchEvent(nativeMotionEvent)) {
    Log.d(TAG,"String_Node_Str");
    mHandler.cancelKeyTimers();
    dismissKeyPreview();
    return true;
  }
  final long eventTime=nativeMotionEvent.getEventTime();
  final int index=MotionEventCompat.getActionIndex(nativeMotionEvent);
  final int id=nativeMotionEvent.getPointerId(index);
  final int x=(int)nativeMotionEvent.getX(index);
  final int y=(int)nativeMotionEvent.getY(index);
  if (mMiniKeyboard != null && mMiniKeyboardPopup.isShowing()) {
    final int miniKeyboardPointerIndex=nativeMotionEvent.findPointerIndex(mMiniKeyboardTrackerId);
    if (miniKeyboardPointerIndex >= 0 && miniKeyboardPointerIndex < pointerCount) {
      final int miniKeyboardX=(int)nativeMotionEvent.getX(miniKeyboardPointerIndex);
      final int miniKeyboardY=(int)nativeMotionEvent.getY(miniKeyboardPointerIndex);
      MotionEvent translated=generateMiniKeyboardMotionEvent(action,miniKeyboardX,miniKeyboardY,eventTime);
      mMiniKeyboard.onTouchEvent(translated);
      translated.recycle();
    }
    return true;
  }
  if (mHandler.isInKeyRepeat()) {
    if (action == MotionEvent.ACTION_MOVE) {
      return true;
    }
    final PointerTracker tracker=getPointerTracker(id);
    if (pointerCount > 1 && !tracker.isModifier()) {
      mHandler.cancelKeyRepeatTimer();
    }
  }
  if (!mHasDistinctMultitouch) {
    PointerTracker tracker=getPointerTracker(0);
    if (pointerCount == 1 && oldPointerCount == 2) {
      tracker.onDownEvent(x,y,eventTime);
    }
 else     if (pointerCount == 2 && oldPointerCount == 1) {
      tracker.onUpEvent(tracker.getLastX(),tracker.getLastY(),eventTime);
    }
 else     if (pointerCount == 1 && oldPointerCount == 1) {
      tracker.onTouchEvent(action,x,y,eventTime);
    }
 else {
      Log.w(TAG,"String_Node_Str" + pointerCount + "String_Node_Str"+ oldPointerCount+ "String_Node_Str");
    }
    return true;
  }
  if (action == MotionEvent.ACTION_MOVE) {
    for (int i=0; i < pointerCount; i++) {
      PointerTracker tracker=getPointerTracker(nativeMotionEvent.getPointerId(i));
      tracker.onMoveEvent((int)nativeMotionEvent.getX(i),(int)nativeMotionEvent.getY(i),eventTime);
    }
  }
 else {
    PointerTracker tracker=getPointerTracker(id);
    sendOnXEvent(action,eventTime,x,y,tracker);
  }
  return true;
}