Program: 1294
Project: 1294
Buggy source:
private boolean commonKey(int keyCode,int count,KeyEvent event){
  if (mAdapter == null || !mIsAttached) {
    return false;
  }
  if (mDataChanged) {
    layoutChildren();
  }
  boolean handled=false;
  int action=event.getAction();
  if (action != KeyEvent.ACTION_UP) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
      if (event.hasNoModifiers()) {
        handled=resurrectSelectionIfNeeded();
        if (!handled) {
          while (count-- > 0) {
            if (arrowScroll(FOCUS_UP)) {
              handled=true;
            }
 else {
              break;
            }
          }
        }
      }
 else       if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
        handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
      }
    break;
case KeyEvent.KEYCODE_DPAD_DOWN:
  if (event.hasNoModifiers()) {
    handled=resurrectSelectionIfNeeded();
    if (!handled) {
      while (count-- > 0) {
        if (arrowScroll(FOCUS_DOWN)) {
          handled=true;
        }
 else {
          break;
        }
      }
    }
  }
 else   if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
    handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
  }
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
if (event.hasNoModifiers()) {
handled=handleHorizontalFocusWithinListItem(View.FOCUS_LEFT);
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (event.hasNoModifiers()) {
handled=handleHorizontalFocusWithinListItem(View.FOCUS_RIGHT);
}
break;
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded();
if (!handled && event.getRepeatCount() == 0 && getChildCount() > 0) {
keyPressed();
handled=true;
}
}
break;
case KeyEvent.KEYCODE_SPACE:
if (mPopup == null || !mPopup.isShowing()) {
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN);
}
 else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
handled=resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP);
}
handled=true;
}
break;
case KeyEvent.KEYCODE_PAGE_UP:
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP);
}
 else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
}
break;
case KeyEvent.KEYCODE_PAGE_DOWN:
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN);
}
 else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
}
break;
case KeyEvent.KEYCODE_MOVE_HOME:
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
}
break;
case KeyEvent.KEYCODE_MOVE_END:
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
}
break;
case KeyEvent.KEYCODE_TAB:
if (false) {
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || arrowScroll(FOCUS_DOWN);
}
 else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
handled=resurrectSelectionIfNeeded() || arrowScroll(FOCUS_UP);
}
}
break;
}
}
if (handled) {
return true;
}
if (sendToTextFilter(keyCode,count,event)) {
return true;
}
switch (action) {
case KeyEvent.ACTION_DOWN:
return super.onKeyDown(keyCode,event);
case KeyEvent.ACTION_UP:
return super.onKeyUp(keyCode,event);
case KeyEvent.ACTION_MULTIPLE:
return super.onKeyMultiple(keyCode,count,event);
default :
return false;
}
}

Fixed version (ground truth):
private boolean commonKey(int keyCode,int count,KeyEvent event){
  if (mAdapter == null || !isAttachedToWindow()) {
    return false;
  }
  if (mDataChanged) {
    layoutChildren();
  }
  boolean handled=false;
  int action=event.getAction();
  if (action != KeyEvent.ACTION_UP) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
      if (event.hasNoModifiers()) {
        handled=resurrectSelectionIfNeeded();
        if (!handled) {
          while (count-- > 0) {
            if (arrowScroll(FOCUS_UP)) {
              handled=true;
            }
 else {
              break;
            }
          }
        }
      }
 else       if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
        handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
      }
    break;
case KeyEvent.KEYCODE_DPAD_DOWN:
  if (event.hasNoModifiers()) {
    handled=resurrectSelectionIfNeeded();
    if (!handled) {
      while (count-- > 0) {
        if (arrowScroll(FOCUS_DOWN)) {
          handled=true;
        }
 else {
          break;
        }
      }
    }
  }
 else   if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
    handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
  }
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
if (event.hasNoModifiers()) {
handled=handleHorizontalFocusWithinListItem(View.FOCUS_LEFT);
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (event.hasNoModifiers()) {
handled=handleHorizontalFocusWithinListItem(View.FOCUS_RIGHT);
}
break;
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded();
if (!handled && event.getRepeatCount() == 0 && getChildCount() > 0) {
keyPressed();
handled=true;
}
}
break;
case KeyEvent.KEYCODE_SPACE:
if (mPopup == null || !mPopup.isShowing()) {
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN);
}
 else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
handled=resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP);
}
handled=true;
}
break;
case KeyEvent.KEYCODE_PAGE_UP:
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || pageScroll(FOCUS_UP);
}
 else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
}
break;
case KeyEvent.KEYCODE_PAGE_DOWN:
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || pageScroll(FOCUS_DOWN);
}
 else if (event.hasModifiers(KeyEvent.META_ALT_ON)) {
handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
}
break;
case KeyEvent.KEYCODE_MOVE_HOME:
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_UP);
}
break;
case KeyEvent.KEYCODE_MOVE_END:
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || fullScroll(FOCUS_DOWN);
}
break;
case KeyEvent.KEYCODE_TAB:
if (false) {
if (event.hasNoModifiers()) {
handled=resurrectSelectionIfNeeded() || arrowScroll(FOCUS_DOWN);
}
 else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
handled=resurrectSelectionIfNeeded() || arrowScroll(FOCUS_UP);
}
}
break;
}
}
if (handled) {
return true;
}
if (sendToTextFilter(keyCode,count,event)) {
return true;
}
switch (action) {
case KeyEvent.ACTION_DOWN:
return super.onKeyDown(keyCode,event);
case KeyEvent.ACTION_UP:
return super.onKeyUp(keyCode,event);
case KeyEvent.ACTION_MULTIPLE:
return super.onKeyMultiple(keyCode,count,event);
default :
return false;
}
}