Program: 182828
Project: 182828
Buggy source:
/** 
 * Special hack for devices that have bad screen data: aggregate and compute averages of the coordinate data, to reduce the amount of jitter seen by applications.
 */
int[] generateAveragedData(int upOrDownPointer,int lastNumPointers,int nextNumPointers){
  final int numPointers=mLastNumPointers;
  final int[] rawData=mLastData;
  if (DEBUG_HACKS)   Log.v("String_Node_Str","String_Node_Str" + lastNumPointers + "String_Node_Str"+ nextNumPointers+ "String_Node_Str"+ numPointers);
  for (int i=0; i < numPointers; i++) {
    final int ioff=i * MotionEvent.NUM_SAMPLE_DATA;
    final int p=mPointerIds[i];
    final int poff=p * MotionEvent.NUM_SAMPLE_DATA * HISTORY_SIZE;
    if (i == upOrDownPointer && lastNumPointers != nextNumPointers) {
      if (lastNumPointers < nextNumPointers) {
        if (DEBUG_HACKS)         Log.v("String_Node_Str","String_Node_Str" + upOrDownPointer + "String_Node_Str"+ mPointerIds[i]);
        mHistoryDataStart[i]=0;
        mHistoryDataEnd[i]=0;
        System.arraycopy(rawData,ioff,mHistoryData,poff,MotionEvent.NUM_SAMPLE_DATA);
        System.arraycopy(rawData,ioff,mAveragedData,ioff,MotionEvent.NUM_SAMPLE_DATA);
        continue;
      }
 else {
        if (DEBUG_HACKS)         Log.v("String_Node_Str","String_Node_Str" + upOrDownPointer + "String_Node_Str"+ mPointerIds[i]);
      }
    }
 else {
      int end=mHistoryDataEnd[i];
      int eoff=poff + (end * MotionEvent.NUM_SAMPLE_DATA);
      int oldX=mHistoryData[eoff + MotionEvent.SAMPLE_X];
      int oldY=mHistoryData[eoff + MotionEvent.SAMPLE_Y];
      int newX=rawData[ioff + MotionEvent.SAMPLE_X];
      int newY=rawData[ioff + MotionEvent.SAMPLE_Y];
      int dx=newX - oldX;
      int dy=newY - oldY;
      int delta=dx * dx + dy * dy;
      if (DEBUG_HACKS)       Log.v("String_Node_Str","String_Node_Str" + delta);
      if (delta >= (75 * 75)) {
        mHistoryDataStart[i]=0;
        mHistoryDataEnd[i]=0;
        System.arraycopy(rawData,ioff,mHistoryData,poff,MotionEvent.NUM_SAMPLE_DATA);
        System.arraycopy(rawData,ioff,mAveragedData,ioff,MotionEvent.NUM_SAMPLE_DATA);
        continue;
      }
 else {
        end++;
        if (end >= HISTORY_SIZE) {
          end-=HISTORY_SIZE;
        }
        mHistoryDataEnd[i]=end;
        int noff=poff + (end * MotionEvent.NUM_SAMPLE_DATA);
        mHistoryData[noff + MotionEvent.SAMPLE_X]=newX;
        mHistoryData[noff + MotionEvent.SAMPLE_Y]=newY;
        mHistoryData[noff + MotionEvent.SAMPLE_PRESSURE]=rawData[ioff + MotionEvent.SAMPLE_PRESSURE];
        int start=mHistoryDataStart[i];
        if (end == start) {
          start++;
          if (start >= HISTORY_SIZE) {
            start-=HISTORY_SIZE;
          }
          mHistoryDataStart[i]=start;
        }
      }
    }
    int start=mHistoryDataStart[i];
    int end=mHistoryDataEnd[i];
    int x=0, y=0;
    int totalPressure=0;
    while (start != end) {
      int soff=poff + (start * MotionEvent.NUM_SAMPLE_DATA);
      int pressure=mHistoryData[soff + MotionEvent.SAMPLE_PRESSURE];
      if (pressure <= 0)       pressure=1;
      x+=mHistoryData[soff + MotionEvent.SAMPLE_X] * pressure;
      y+=mHistoryData[soff + MotionEvent.SAMPLE_Y] * pressure;
      totalPressure+=pressure;
      start++;
      if (start >= HISTORY_SIZE)       start=0;
    }
    int eoff=poff + (end * MotionEvent.NUM_SAMPLE_DATA);
    int pressure=mHistoryData[eoff + MotionEvent.SAMPLE_PRESSURE];
    if (pressure <= 0)     pressure=1;
    x+=mHistoryData[eoff + MotionEvent.SAMPLE_X] * pressure;
    y+=mHistoryData[eoff + MotionEvent.SAMPLE_Y] * pressure;
    totalPressure+=pressure;
    x/=totalPressure;
    y/=totalPressure;
    if (DEBUG_HACKS)     Log.v("String_Node_Str","String_Node_Str" + totalPressure + "String_Node_Str"+ x+ "String_Node_Str"+ y+ "String_Node_Str");
    mAveragedData[ioff + MotionEvent.SAMPLE_X]=x;
    mAveragedData[ioff + MotionEvent.SAMPLE_Y]=y;
  }
  return mAveragedData;
}

Fixed version (ground truth):
/** 
 * Special hack for devices that have bad screen data: aggregate and compute averages of the coordinate data, to reduce the amount of jitter seen by applications.
 */
int[] generateAveragedData(int upOrDownPointer,int lastNumPointers,int nextNumPointers){
  final int numPointers=mLastNumPointers;
  final int[] rawData=mLastData;
  if (DEBUG_HACKS)   Log.v("String_Node_Str","String_Node_Str" + lastNumPointers + "String_Node_Str"+ nextNumPointers+ "String_Node_Str"+ numPointers);
  for (int i=0; i < numPointers; i++) {
    final int ioff=i * MotionEvent.NUM_SAMPLE_DATA;
    final int p=mPointerIds[i];
    final int poff=p * MotionEvent.NUM_SAMPLE_DATA * HISTORY_SIZE;
    if (i == upOrDownPointer && lastNumPointers != nextNumPointers) {
      if (lastNumPointers < nextNumPointers) {
        if (DEBUG_HACKS)         Log.v("String_Node_Str","String_Node_Str" + upOrDownPointer + "String_Node_Str"+ mPointerIds[i]);
        mHistoryDataStart[i]=0;
        mHistoryDataEnd[i]=0;
        System.arraycopy(rawData,ioff,mHistoryData,poff,MotionEvent.NUM_SAMPLE_DATA);
        System.arraycopy(rawData,ioff,mAveragedData,ioff,MotionEvent.NUM_SAMPLE_DATA);
        continue;
      }
 else {
        if (DEBUG_HACKS)         Log.v("String_Node_Str","String_Node_Str" + upOrDownPointer + "String_Node_Str"+ mPointerIds[i]);
      }
    }
 else {
      int end=mHistoryDataEnd[i];
      int eoff=poff + (end * MotionEvent.NUM_SAMPLE_DATA);
      int oldX=mHistoryData[eoff + MotionEvent.SAMPLE_X];
      int oldY=mHistoryData[eoff + MotionEvent.SAMPLE_Y];
      int newX=rawData[ioff + MotionEvent.SAMPLE_X];
      int newY=rawData[ioff + MotionEvent.SAMPLE_Y];
      int dx=newX - oldX;
      int dy=newY - oldY;
      int delta=dx * dx + dy * dy;
      if (DEBUG_HACKS)       Log.v("String_Node_Str","String_Node_Str" + delta);
      if (delta >= (75 * 75)) {
        mHistoryDataStart[i]=0;
        mHistoryDataEnd[i]=0;
        System.arraycopy(rawData,ioff,mHistoryData,poff,MotionEvent.NUM_SAMPLE_DATA);
        System.arraycopy(rawData,ioff,mAveragedData,ioff,MotionEvent.NUM_SAMPLE_DATA);
        continue;
      }
 else {
        end++;
        if (end >= HISTORY_SIZE) {
          end-=HISTORY_SIZE;
        }
        mHistoryDataEnd[i]=end;
        int noff=poff + (end * MotionEvent.NUM_SAMPLE_DATA);
        mHistoryData[noff + MotionEvent.SAMPLE_X]=newX;
        mHistoryData[noff + MotionEvent.SAMPLE_Y]=newY;
        mHistoryData[noff + MotionEvent.SAMPLE_PRESSURE]=rawData[ioff + MotionEvent.SAMPLE_PRESSURE];
        int start=mHistoryDataStart[i];
        if (end == start) {
          start++;
          if (start >= HISTORY_SIZE) {
            start-=HISTORY_SIZE;
          }
          mHistoryDataStart[i]=start;
        }
      }
    }
    int start=mHistoryDataStart[i];
    int end=mHistoryDataEnd[i];
    int x=0, y=0;
    int totalPressure=0;
    while (start != end) {
      int soff=poff + (start * MotionEvent.NUM_SAMPLE_DATA);
      int pressure=mHistoryData[soff + MotionEvent.SAMPLE_PRESSURE];
      if (pressure <= 0)       pressure=1;
      x+=mHistoryData[soff + MotionEvent.SAMPLE_X] * pressure;
      y+=mHistoryData[soff + MotionEvent.SAMPLE_Y] * pressure;
      totalPressure+=pressure;
      start++;
      if (start >= HISTORY_SIZE)       start=0;
    }
    int eoff=poff + (end * MotionEvent.NUM_SAMPLE_DATA);
    int pressure=mHistoryData[eoff + MotionEvent.SAMPLE_PRESSURE];
    if (pressure <= 0)     pressure=1;
    x+=mHistoryData[eoff + MotionEvent.SAMPLE_X] * pressure;
    y+=mHistoryData[eoff + MotionEvent.SAMPLE_Y] * pressure;
    totalPressure+=pressure;
    x/=totalPressure;
    y/=totalPressure;
    if (DEBUG_HACKS)     Log.v("String_Node_Str","String_Node_Str" + totalPressure + "String_Node_Str"+ x+ "String_Node_Str"+ y+ "String_Node_Str");
    mAveragedData[ioff + MotionEvent.SAMPLE_X]=x;
    mAveragedData[ioff + MotionEvent.SAMPLE_Y]=y;
    mAveragedData[ioff + MotionEvent.SAMPLE_PRESSURE]=rawData[ioff + MotionEvent.SAMPLE_PRESSURE];
    mAveragedData[ioff + MotionEvent.SAMPLE_SIZE]=rawData[ioff + MotionEvent.SAMPLE_SIZE];
  }
  return mAveragedData;
}