Program: 797
Project: 797
Buggy source:
private int processKeyEvent(QueuedInputEvent q){
  final KeyEvent event=(KeyEvent)q.mEvent;
  if (mView.dispatchKeyEvent(event)) {
    return FINISH_HANDLED;
  }
  if (event.getAction() == KeyEvent.ACTION_DOWN && event.isCtrlPressed() && event.getRepeatCount() == 0 && !KeyEvent.isModifierKey(event.getKeyCode())) {
    if (mView.dispatchKeyShortcutEvent(event)) {
      return FINISH_HANDLED;
    }
  }
  if (mFallbackEventHandler.dispatchKeyEvent(event)) {
    return FINISH_HANDLED;
  }
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
    int direction=0;
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
      if (event.hasNoModifiers()) {
        direction=View.FOCUS_LEFT;
      }
    break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
  if (event.hasNoModifiers()) {
    direction=View.FOCUS_RIGHT;
  }
break;
case KeyEvent.KEYCODE_DPAD_UP:
if (event.hasNoModifiers()) {
direction=View.FOCUS_UP;
}
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
if (event.hasNoModifiers()) {
direction=View.FOCUS_DOWN;
}
break;
case KeyEvent.KEYCODE_TAB:
if (event.hasNoModifiers()) {
direction=View.FOCUS_FORWARD;
}
 else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
direction=View.FOCUS_BACKWARD;
}
break;
}
if (direction != 0) {
View focused=mView.findFocus();
if (focused != null) {
View v=focused.focusSearch(direction);
if (v != null && v != focused) {
focused.getFocusedRect(mTempRect);
if (mView instanceof ViewGroup) {
((ViewGroup)mView).offsetDescendantRectToMyCoords(focused,mTempRect);
((ViewGroup)mView).offsetRectIntoDescendantCoords(v,mTempRect);
}
if (v.requestFocus(direction,mTempRect)) {
playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
return FINISH_HANDLED;
}
}
if (mView.dispatchUnhandledMove(focused,direction)) {
return FINISH_HANDLED;
}
}
 else {
View v=focusSearch(null,direction);
if (v != null && v.requestFocus(direction)) {
return FINISH_HANDLED;
}
}
}
}
return FORWARD;
}

Fixed version (ground truth):
private int processKeyEvent(QueuedInputEvent q){
  final KeyEvent event=(KeyEvent)q.mEvent;
  if (event.getAction() != KeyEvent.ACTION_UP) {
    handleDispatchDoneAnimating();
  }
  if (mView.dispatchKeyEvent(event)) {
    return FINISH_HANDLED;
  }
  if (event.getAction() == KeyEvent.ACTION_DOWN && event.isCtrlPressed() && event.getRepeatCount() == 0 && !KeyEvent.isModifierKey(event.getKeyCode())) {
    if (mView.dispatchKeyShortcutEvent(event)) {
      return FINISH_HANDLED;
    }
  }
  if (mFallbackEventHandler.dispatchKeyEvent(event)) {
    return FINISH_HANDLED;
  }
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
    int direction=0;
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
      if (event.hasNoModifiers()) {
        direction=View.FOCUS_LEFT;
      }
    break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
  if (event.hasNoModifiers()) {
    direction=View.FOCUS_RIGHT;
  }
break;
case KeyEvent.KEYCODE_DPAD_UP:
if (event.hasNoModifiers()) {
direction=View.FOCUS_UP;
}
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
if (event.hasNoModifiers()) {
direction=View.FOCUS_DOWN;
}
break;
case KeyEvent.KEYCODE_TAB:
if (event.hasNoModifiers()) {
direction=View.FOCUS_FORWARD;
}
 else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
direction=View.FOCUS_BACKWARD;
}
break;
}
if (direction != 0) {
View focused=mView.findFocus();
if (focused != null) {
View v=focused.focusSearch(direction);
if (v != null && v != focused) {
focused.getFocusedRect(mTempRect);
if (mView instanceof ViewGroup) {
((ViewGroup)mView).offsetDescendantRectToMyCoords(focused,mTempRect);
((ViewGroup)mView).offsetRectIntoDescendantCoords(v,mTempRect);
}
if (v.requestFocus(direction,mTempRect)) {
playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
return FINISH_HANDLED;
}
}
if (mView.dispatchUnhandledMove(focused,direction)) {
return FINISH_HANDLED;
}
}
 else {
View v=focusSearch(null,direction);
if (v != null && v.requestFocus(direction)) {
return FINISH_HANDLED;
}
}
}
}
return FORWARD;
}