Program: 45564
Project: 45564
Buggy source:
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  boolean handled=false;
  if (!isVisible()) {
    return false;
  }
  final int iconCount=mRollo.mState.iconCount;
  if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
    if (mArrowNavigation) {
      if (mLastSelection == SELECTION_HOME) {
        reallyPlaySoundEffect(SoundEffectConstants.CLICK);
        mLauncher.closeAllApps(true);
      }
 else {
        int whichApp=mRollo.mState.selectedIconIndex;
        if (whichApp >= 0) {
          ApplicationInfo app=mAllAppsList.get(whichApp);
          mLauncher.startActivitySafely(app.intent);
          handled=true;
        }
      }
    }
  }
  if (mArrowNavigation && iconCount > 0) {
    mArrowNavigation=true;
    int currentSelection=mRollo.mState.selectedIconIndex;
    int currentTopRow=Math.round(mRollo.mMessageProc.mPosX);
    final int currentPageCol=currentSelection % Defines.COLUMNS_PER_PAGE;
    final int currentPageRow=(currentSelection - (currentTopRow * Defines.COLUMNS_PER_PAGE)) / Defines.ROWS_PER_PAGE;
    int newSelection=currentSelection;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
      if (mLastSelection == SELECTION_HOME) {
        mRollo.setHomeSelected(SELECTED_NONE);
        int lastRowCount=iconCount % Defines.COLUMNS_PER_PAGE;
        if (lastRowCount == 0) {
          lastRowCount=Defines.COLUMNS_PER_PAGE;
        }
        newSelection=iconCount - lastRowCount + (Defines.COLUMNS_PER_PAGE / 2);
        if (newSelection >= iconCount) {
          newSelection=iconCount - 1;
        }
        int target=(newSelection / Defines.COLUMNS_PER_PAGE) - (Defines.ROWS_PER_PAGE - 1);
        if (target < 0) {
          target=0;
        }
        if (currentTopRow != target) {
          mRollo.moveTo(target);
        }
      }
 else {
        if (currentPageRow > 0) {
          newSelection=currentSelection - Defines.COLUMNS_PER_PAGE;
        }
 else         if (currentTopRow > 0) {
          newSelection=currentSelection - Defines.COLUMNS_PER_PAGE;
          mRollo.moveTo(newSelection / Defines.COLUMNS_PER_PAGE);
        }
      }
    handled=true;
  break;
case KeyEvent.KEYCODE_DPAD_DOWN:
{
  final int rowCount=iconCount / Defines.COLUMNS_PER_PAGE + (iconCount % Defines.COLUMNS_PER_PAGE == 0 ? 0 : 1);
  final int currentRow=currentSelection / Defines.COLUMNS_PER_PAGE;
  if (mLastSelection != SELECTION_HOME) {
    if (currentRow < rowCount - 1) {
      mRollo.setHomeSelected(SELECTED_NONE);
      newSelection=currentSelection + Defines.COLUMNS_PER_PAGE;
      if (newSelection >= iconCount) {
        newSelection=iconCount - 1;
      }
      if (currentPageRow >= Defines.ROWS_PER_PAGE - 1) {
        mRollo.moveTo((newSelection / Defines.COLUMNS_PER_PAGE) - Defines.ROWS_PER_PAGE + 1);
      }
    }
 else {
      newSelection=-1;
      mRollo.setHomeSelected(SELECTED_FOCUSED);
    }
  }
  handled=true;
  break;
}
case KeyEvent.KEYCODE_DPAD_LEFT:
if (currentPageCol > 0) {
newSelection=currentSelection - 1;
}
handled=true;
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) && (currentSelection < iconCount - 1)) {
newSelection=currentSelection + 1;
}
handled=true;
break;
}
if (newSelection != currentSelection) {
mRollo.selectIcon(newSelection,SELECTED_FOCUSED);
mRollo.mState.save();
}
}
return handled;
}

Fixed version (ground truth):
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  boolean handled=false;
  if (!isVisible()) {
    return false;
  }
  final int iconCount=mRollo.mState.iconCount;
  if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
    if (mArrowNavigation) {
      if (mLastSelection == SELECTION_HOME) {
        reallyPlaySoundEffect(SoundEffectConstants.CLICK);
        mLauncher.closeAllApps(true);
      }
 else {
        int whichApp=mRollo.mState.selectedIconIndex;
        if (whichApp >= 0) {
          ApplicationInfo app=mAllAppsList.get(whichApp);
          mLauncher.startActivitySafely(app.intent);
          handled=true;
        }
      }
    }
  }
  if (mArrowNavigation && iconCount > 0) {
    mArrowNavigation=true;
    int currentSelection=mRollo.mState.selectedIconIndex;
    int currentTopRow=Math.round(mMessageProc.mPosX);
    final int currentPageCol=currentSelection % Defines.COLUMNS_PER_PAGE;
    final int currentPageRow=(currentSelection - (currentTopRow * Defines.COLUMNS_PER_PAGE)) / Defines.ROWS_PER_PAGE;
    int newSelection=currentSelection;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
      if (mLastSelection == SELECTION_HOME) {
        mRollo.setHomeSelected(SELECTED_NONE);
        int lastRowCount=iconCount % Defines.COLUMNS_PER_PAGE;
        if (lastRowCount == 0) {
          lastRowCount=Defines.COLUMNS_PER_PAGE;
        }
        newSelection=iconCount - lastRowCount + (Defines.COLUMNS_PER_PAGE / 2);
        if (newSelection >= iconCount) {
          newSelection=iconCount - 1;
        }
        int target=(newSelection / Defines.COLUMNS_PER_PAGE) - (Defines.ROWS_PER_PAGE - 1);
        if (target < 0) {
          target=0;
        }
        if (currentTopRow != target) {
          mRollo.moveTo(target);
        }
      }
 else {
        if (currentPageRow > 0) {
          newSelection=currentSelection - Defines.COLUMNS_PER_PAGE;
        }
 else         if (currentTopRow > 0) {
          newSelection=currentSelection - Defines.COLUMNS_PER_PAGE;
          mRollo.moveTo(newSelection / Defines.COLUMNS_PER_PAGE);
        }
      }
    handled=true;
  break;
case KeyEvent.KEYCODE_DPAD_DOWN:
{
  final int rowCount=iconCount / Defines.COLUMNS_PER_PAGE + (iconCount % Defines.COLUMNS_PER_PAGE == 0 ? 0 : 1);
  final int currentRow=currentSelection / Defines.COLUMNS_PER_PAGE;
  if (mLastSelection != SELECTION_HOME) {
    if (currentRow < rowCount - 1) {
      mRollo.setHomeSelected(SELECTED_NONE);
      newSelection=currentSelection + Defines.COLUMNS_PER_PAGE;
      if (newSelection >= iconCount) {
        newSelection=iconCount - 1;
      }
      if (currentPageRow >= Defines.ROWS_PER_PAGE - 1) {
        mRollo.moveTo((newSelection / Defines.COLUMNS_PER_PAGE) - Defines.ROWS_PER_PAGE + 1);
      }
    }
 else {
      newSelection=-1;
      mRollo.setHomeSelected(SELECTED_FOCUSED);
    }
  }
  handled=true;
  break;
}
case KeyEvent.KEYCODE_DPAD_LEFT:
if (currentPageCol > 0) {
newSelection=currentSelection - 1;
}
handled=true;
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if ((currentPageCol < Defines.COLUMNS_PER_PAGE - 1) && (currentSelection < iconCount - 1)) {
newSelection=currentSelection + 1;
}
handled=true;
break;
}
if (newSelection != currentSelection) {
mRollo.selectIcon(newSelection,SELECTED_FOCUSED);
mRollo.mState.save();
}
}
return handled;
}