Program: 157133
Project: 157133
Buggy source:
private void onFunctionKey(final int primaryCode,final Key key,final int multiTapIndex,final int[] nearByKeyCodes,final boolean fromUI){
  if (BuildConfig.DEBUG)   Logger.d(TAG,"String_Node_Str",primaryCode);
  final InputConnection ic=getCurrentInputConnection();
switch (primaryCode) {
case KeyCodes.DELETE:
    if (ic == null) {
      break;
    }
  if (mUseBackWord && mShiftKeyState.isPressed() && !mShiftKeyState.isLocked()) {
    handleBackWord(ic);
  }
 else {
    handleDeleteLastCharacter(false);
  }
break;
case KeyCodes.SHIFT:
if (fromUI) {
handleShift();
}
 else {
onPress(primaryCode);
onRelease(primaryCode);
}
break;
case KeyCodes.SHIFT_LOCK:
mShiftKeyState.toggleLocked();
handleShift();
break;
case KeyCodes.DELETE_WORD:
if (ic == null) {
break;
}
handleBackWord(ic);
break;
case KeyCodes.CLEAR_INPUT:
if (ic != null) {
ic.beginBatchEdit();
abortCorrectionAndResetPredictionState(false);
ic.deleteSurroundingText(Integer.MAX_VALUE,Integer.MAX_VALUE);
ic.endBatchEdit();
}
break;
case KeyCodes.CTRL:
if (fromUI) {
handleControl();
}
 else {
onPress(primaryCode);
onRelease(primaryCode);
}
break;
case KeyCodes.CTRL_LOCK:
mControlKeyState.toggleLocked();
handleControl();
break;
case KeyCodes.ARROW_LEFT:
case KeyCodes.ARROW_RIGHT:
final int keyEventKeyCode=primaryCode == KeyCodes.ARROW_LEFT ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT;
if (!handleSelectionExpending(keyEventKeyCode,ic,mGlobalSelectionStartPosition,mGlobalCursorPosition)) {
sendDownUpKeyEvents(keyEventKeyCode);
}
break;
case KeyCodes.ARROW_UP:
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_UP);
break;
case KeyCodes.ARROW_DOWN:
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_DOWN);
break;
case KeyCodes.MOVE_HOME:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
sendDownUpKeyEvents(0x0000007a);
}
 else {
if (ic != null) {
CharSequence textBefore=ic.getTextBeforeCursor(1024,0);
if (!TextUtils.isEmpty(textBefore)) {
int newPosition=textBefore.length() - 1;
while (newPosition > 0) {
char chatAt=textBefore.charAt(newPosition - 1);
if (chatAt == '\n' || chatAt == '\r') {
break;
}
newPosition--;
}
if (newPosition < 0) {
newPosition=0;
}
ic.setSelection(newPosition,newPosition);
}
}
}
break;
case KeyCodes.MOVE_END:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
sendDownUpKeyEvents(0x0000007b);
}
 else {
if (ic != null) {
CharSequence textAfter=ic.getTextAfterCursor(1024,0);
if (!TextUtils.isEmpty(textAfter)) {
int newPosition=1;
while (newPosition < textAfter.length()) {
char chatAt=textAfter.charAt(newPosition);
if (chatAt == '\n' || chatAt == '\r') {
break;
}
newPosition++;
}
if (newPosition > textAfter.length()) {
newPosition=textAfter.length();
}
try {
CharSequence textBefore=ic.getTextBeforeCursor(Integer.MAX_VALUE,0);
if (!TextUtils.isEmpty(textBefore)) {
newPosition=newPosition + textBefore.length();
}
ic.setSelection(newPosition,newPosition);
}
 catch (Throwable e) {
Logger.w(TAG,"String_Node_Str",e);
}
}
}
}
break;
case KeyCodes.VOICE_INPUT:
if (mVoiceRecognitionTrigger.isInstalled()) {
mVoiceRecognitionTrigger.startVoiceRecognition(getCurrentAlphabetKeyboard().getDefaultDictionaryLocale());
}
 else {
Intent voiceInputNotInstalledIntent=new Intent(getApplicationContext(),VoiceInputNotInstalledActivity.class);
voiceInputNotInstalledIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(voiceInputNotInstalledIntent);
}
break;
case KeyCodes.CANCEL:
mCancelKeyPressed=true;
hideWindow();
break;
case KeyCodes.SETTINGS:
showOptionsMenu();
break;
case KeyCodes.SPLIT_LAYOUT:
case KeyCodes.MERGE_LAYOUT:
case KeyCodes.COMPACT_LAYOUT_TO_RIGHT:
case KeyCodes.COMPACT_LAYOUT_TO_LEFT:
if (getInputView() != null) {
mKeyboardInCondensedMode=CondenseType.fromKeyCode(primaryCode);
setKeyboardForView(getCurrentKeyboard());
}
break;
case KeyCodes.QUICK_TEXT:
onQuickTextRequested(key);
break;
case KeyCodes.QUICK_TEXT_POPUP:
onQuickTextKeyboardRequested(key);
break;
case KeyCodes.MODE_SYMOBLS:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Symbols);
break;
case KeyCodes.MODE_ALPHABET:
if (getKeyboardSwitcher().shouldPopupForLanguageSwitch()) {
showLanguageSelectionDialog();
}
 else {
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Alphabet);
}
break;
case KeyCodes.UTILITY_KEYBOARD:
getInputView().openUtilityKeyboard();
break;
case KeyCodes.MODE_ALPHABET_POPUP:
showLanguageSelectionDialog();
break;
case KeyCodes.ALT:
nextAlterKeyboard(getCurrentInputEditorInfo());
break;
case KeyCodes.KEYBOARD_CYCLE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Any);
break;
case KeyCodes.KEYBOARD_REVERSE_CYCLE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.PreviousAny);
break;
case KeyCodes.KEYBOARD_CYCLE_INSIDE_MODE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.AnyInsideMode);
break;
case KeyCodes.KEYBOARD_MODE_CHANGE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.OtherMode);
break;
case KeyCodes.CLIPBOARD_COPY:
case KeyCodes.CLIPBOARD_PASTE:
case KeyCodes.CLIPBOARD_CUT:
case KeyCodes.CLIPBOARD_SELECT_ALL:
case KeyCodes.CLIPBOARD_PASTE_POPUP:
case KeyCodes.CLIPBOARD_SELECT:
case KeyCodes.UNDO:
case KeyCodes.REDO:
handleClipboardOperation(key,primaryCode,ic);
if (primaryCode == KeyCodes.CLIPBOARD_PASTE) mCommittedWord="String_Node_Str";
break;
default :
if (BuildConfig.DEBUG) {
throw new RuntimeException("String_Node_Str" + primaryCode);
}
 else {
Logger.w(TAG,"String_Node_Str",primaryCode);
}
}
}

Fixed version (ground truth):
private void onFunctionKey(final int primaryCode,final Key key,final int multiTapIndex,final int[] nearByKeyCodes,final boolean fromUI){
  if (BuildConfig.DEBUG)   Logger.d(TAG,"String_Node_Str",primaryCode);
  final InputConnection ic=getCurrentInputConnection();
switch (primaryCode) {
case KeyCodes.DELETE:
    if (ic == null) {
      break;
    }
  if (mUseBackWord && mShiftKeyState.isPressed() && !mShiftKeyState.isLocked()) {
    handleBackWord(ic);
  }
 else {
    handleDeleteLastCharacter(false);
  }
break;
case KeyCodes.SHIFT:
if (fromUI) {
handleShift();
}
 else {
onPress(primaryCode);
onRelease(primaryCode);
}
break;
case KeyCodes.SHIFT_LOCK:
mShiftKeyState.toggleLocked();
handleShift();
break;
case KeyCodes.DELETE_WORD:
if (ic == null) {
break;
}
handleBackWord(ic);
break;
case KeyCodes.CLEAR_INPUT:
if (ic != null) {
ic.beginBatchEdit();
abortCorrectionAndResetPredictionState(false);
ic.deleteSurroundingText(Integer.MAX_VALUE,Integer.MAX_VALUE);
ic.endBatchEdit();
}
break;
case KeyCodes.CTRL:
if (fromUI) {
handleControl();
}
 else {
onPress(primaryCode);
onRelease(primaryCode);
}
break;
case KeyCodes.CTRL_LOCK:
mControlKeyState.toggleLocked();
handleControl();
break;
case KeyCodes.ARROW_LEFT:
case KeyCodes.ARROW_RIGHT:
final int keyEventKeyCode=primaryCode == KeyCodes.ARROW_LEFT ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT;
if (!handleSelectionExpending(keyEventKeyCode,ic,mGlobalSelectionStartPosition,mGlobalCursorPosition)) {
sendDownUpKeyEvents(keyEventKeyCode);
}
break;
case KeyCodes.ARROW_UP:
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_UP);
break;
case KeyCodes.ARROW_DOWN:
sendDownUpKeyEvents(KeyEvent.KEYCODE_DPAD_DOWN);
break;
case KeyCodes.MOVE_HOME:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
sendDownUpKeyEvents(0x0000007a);
}
 else {
if (ic != null) {
CharSequence textBefore=ic.getTextBeforeCursor(1024,0);
if (!TextUtils.isEmpty(textBefore)) {
int newPosition=textBefore.length() - 1;
while (newPosition > 0) {
char chatAt=textBefore.charAt(newPosition - 1);
if (chatAt == '\n' || chatAt == '\r') {
break;
}
newPosition--;
}
if (newPosition < 0) {
newPosition=0;
}
ic.setSelection(newPosition,newPosition);
}
}
}
break;
case KeyCodes.MOVE_END:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
sendDownUpKeyEvents(0x0000007b);
}
 else {
if (ic != null) {
CharSequence textAfter=ic.getTextAfterCursor(1024,0);
if (!TextUtils.isEmpty(textAfter)) {
int newPosition=1;
while (newPosition < textAfter.length()) {
char chatAt=textAfter.charAt(newPosition);
if (chatAt == '\n' || chatAt == '\r') {
break;
}
newPosition++;
}
if (newPosition > textAfter.length()) {
newPosition=textAfter.length();
}
try {
CharSequence textBefore=ic.getTextBeforeCursor(Integer.MAX_VALUE,0);
if (!TextUtils.isEmpty(textBefore)) {
newPosition=newPosition + textBefore.length();
}
ic.setSelection(newPosition,newPosition);
}
 catch (Throwable e) {
Logger.w(TAG,"String_Node_Str",e);
}
}
}
}
break;
case KeyCodes.VOICE_INPUT:
if (mVoiceRecognitionTrigger.isInstalled()) {
mVoiceRecognitionTrigger.startVoiceRecognition(getCurrentAlphabetKeyboard().getDefaultDictionaryLocale());
}
 else {
Intent voiceInputNotInstalledIntent=new Intent(getApplicationContext(),VoiceInputNotInstalledActivity.class);
voiceInputNotInstalledIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(voiceInputNotInstalledIntent);
}
break;
case KeyCodes.CANCEL:
mCancelKeyPressed=true;
if (mUtilityKeyboardShown) {
mUtilityKeyboardShown=false;
}
hideWindow();
break;
case KeyCodes.SETTINGS:
showOptionsMenu();
break;
case KeyCodes.SPLIT_LAYOUT:
case KeyCodes.MERGE_LAYOUT:
case KeyCodes.COMPACT_LAYOUT_TO_RIGHT:
case KeyCodes.COMPACT_LAYOUT_TO_LEFT:
if (getInputView() != null) {
mKeyboardInCondensedMode=CondenseType.fromKeyCode(primaryCode);
setKeyboardForView(getCurrentKeyboard());
}
break;
case KeyCodes.QUICK_TEXT:
onQuickTextRequested(key);
break;
case KeyCodes.QUICK_TEXT_POPUP:
onQuickTextKeyboardRequested(key);
break;
case KeyCodes.MODE_SYMOBLS:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Symbols);
break;
case KeyCodes.MODE_ALPHABET:
if (getKeyboardSwitcher().shouldPopupForLanguageSwitch()) {
showLanguageSelectionDialog();
}
 else {
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Alphabet);
}
break;
case KeyCodes.UTILITY_KEYBOARD:
mUtilityKeyboardShown=true;
getInputView().openUtilityKeyboard();
break;
case KeyCodes.MODE_ALPHABET_POPUP:
showLanguageSelectionDialog();
break;
case KeyCodes.ALT:
nextAlterKeyboard(getCurrentInputEditorInfo());
break;
case KeyCodes.KEYBOARD_CYCLE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.Any);
break;
case KeyCodes.KEYBOARD_REVERSE_CYCLE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.PreviousAny);
break;
case KeyCodes.KEYBOARD_CYCLE_INSIDE_MODE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.AnyInsideMode);
break;
case KeyCodes.KEYBOARD_MODE_CHANGE:
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.OtherMode);
break;
case KeyCodes.CLIPBOARD_COPY:
case KeyCodes.CLIPBOARD_PASTE:
case KeyCodes.CLIPBOARD_CUT:
case KeyCodes.CLIPBOARD_SELECT_ALL:
case KeyCodes.CLIPBOARD_PASTE_POPUP:
case KeyCodes.CLIPBOARD_SELECT:
case KeyCodes.UNDO:
case KeyCodes.REDO:
handleClipboardOperation(key,primaryCode,ic);
if (primaryCode == KeyCodes.CLIPBOARD_PASTE) mCommittedWord="String_Node_Str";
break;
default :
if (BuildConfig.DEBUG) {
throw new RuntimeException("String_Node_Str" + primaryCode);
}
 else {
Logger.w(TAG,"String_Node_Str",primaryCode);
}
}
}