Program: 87384
Project: 87384
Buggy source:
/** 
 * React to a code input. It may be a code point to insert, or a symbolic value that influences the keyboard behavior. Typically, this is called whenever a key is pressed on the software keyboard. This is not the entry point for gesture input; see the onBatchInput* family of functions for this.
 * @param settingsValues the current settings values.
 * @param event the event to handle.
 * @param keyboardShiftMode the current shift mode of the keyboard, as returned by{@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()}
 * @return the complete transaction object
 */
public InputTransaction onCodeInput(final SettingsValues settingsValues,final Event event,final int keyboardShiftMode,final LatinIME.UIHandler handler){
  final InputTransaction inputTransaction=new InputTransaction(settingsValues,event,SystemClock.uptimeMillis(),mSpaceState,getActualCapsMode(settingsValues,keyboardShiftMode));
  if (event.mKeyCode != Constants.CODE_DELETE || inputTransaction.mTimestamp > mLastKeyTime + Constants.LONG_PRESS_MILLISECONDS) {
    mDeleteCount=0;
  }
  mLastKeyTime=inputTransaction.mTimestamp;
  mConnection.beginBatchEdit();
  if (!mWordComposer.isComposingWord()) {
    mIsAutoCorrectionIndicatorOn=false;
  }
  if (event.mCodePoint != Constants.CODE_SPACE) {
    cancelDoubleSpacePeriodCountdown();
  }
  boolean didAutoCorrect=false;
  if (Event.NOT_A_KEY_CODE != event.mKeyCode) {
switch (event.mKeyCode) {
case Constants.CODE_DELETE:
      handleBackspace(inputTransaction);
    break;
case Constants.CODE_SHIFT:
  performRecapitalization(inputTransaction.mSettingsValues);
inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
if (mSuggestedWords.mIsPrediction) {
inputTransaction.setRequiresUpdateSuggestions();
}
break;
case Constants.CODE_CAPSLOCK:
break;
case Constants.CODE_SYMBOL_SHIFT:
break;
case Constants.CODE_SWITCH_ALPHA_SYMBOL:
break;
case Constants.CODE_SETTINGS:
onSettingsKeyPressed();
break;
case Constants.CODE_SHORTCUT:
break;
case Constants.CODE_ACTION_NEXT:
performEditorAction(EditorInfo.IME_ACTION_NEXT);
break;
case Constants.CODE_ACTION_PREVIOUS:
performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
break;
case Constants.CODE_LANGUAGE_SWITCH:
handleLanguageSwitchKey();
break;
case Constants.CODE_EMOJI:
break;
case Constants.CODE_ALPHA_FROM_EMOJI:
break;
case Constants.CODE_SHIFT_ENTER:
final Event tmpEvent=Event.createSoftwareKeypressEvent(Constants.CODE_ENTER,event.mKeyCode,event.mX,event.mY,event.isKeyRepeat());
final InputTransaction tmpTransaction=new InputTransaction(inputTransaction.mSettingsValues,tmpEvent,inputTransaction.mTimestamp,inputTransaction.mSpaceState,inputTransaction.mShiftState);
didAutoCorrect=handleNonSpecialCharacter(tmpTransaction,handler);
break;
default :
throw new RuntimeException("String_Node_Str" + event.mKeyCode);
}
}
 else {
switch (event.mCodePoint) {
case Constants.CODE_ENTER:
final EditorInfo editorInfo=getCurrentInputEditorInfo();
final int imeOptionsActionId=InputTypeUtils.getImeOptionsActionIdFromEditorInfo(editorInfo);
if (InputTypeUtils.IME_ACTION_CUSTOM_LABEL == imeOptionsActionId) {
performEditorAction(editorInfo.actionId);
}
 else if (EditorInfo.IME_ACTION_NONE != imeOptionsActionId) {
performEditorAction(imeOptionsActionId);
}
 else {
didAutoCorrect=handleNonSpecialCharacter(inputTransaction,handler);
}
break;
default :
didAutoCorrect=handleNonSpecialCharacter(inputTransaction,handler);
break;
}
}
if (!didAutoCorrect && event.mKeyCode != Constants.CODE_SHIFT && event.mKeyCode != Constants.CODE_CAPSLOCK && event.mKeyCode != Constants.CODE_SWITCH_ALPHA_SYMBOL) mLastComposedWord.deactivate();
if (Constants.CODE_DELETE != event.mKeyCode) {
mEnteredText=null;
}
mConnection.endBatchEdit();
return inputTransaction;
}

Fixed version (ground truth):
/** 
 * React to a code input. It may be a code point to insert, or a symbolic value that influences the keyboard behavior. Typically, this is called whenever a key is pressed on the software keyboard. This is not the entry point for gesture input; see the onBatchInput* family of functions for this.
 * @param settingsValues the current settings values.
 * @param event the event to handle.
 * @param keyboardShiftMode the current shift mode of the keyboard, as returned by{@link com.android.inputmethod.keyboard.KeyboardSwitcher#getKeyboardShiftMode()}
 * @return the complete transaction object
 */
public InputTransaction onCodeInput(final SettingsValues settingsValues,final Event event,final int keyboardShiftMode,final LatinIME.UIHandler handler){
  final InputTransaction inputTransaction=new InputTransaction(settingsValues,event,SystemClock.uptimeMillis(),mSpaceState,getActualCapsMode(settingsValues,keyboardShiftMode));
  if (event.mKeyCode != Constants.CODE_DELETE || inputTransaction.mTimestamp > mLastKeyTime + Constants.LONG_PRESS_MILLISECONDS) {
    mDeleteCount=0;
  }
  mLastKeyTime=inputTransaction.mTimestamp;
  mConnection.beginBatchEdit();
  if (!mWordComposer.isComposingWord()) {
    mIsAutoCorrectionIndicatorOn=false;
  }
  if (event.mCodePoint != Constants.CODE_SPACE) {
    cancelDoubleSpacePeriodCountdown();
  }
  boolean didAutoCorrect=false;
  if (event.isFunctionalKeyEvent()) {
switch (event.mKeyCode) {
case Constants.CODE_DELETE:
      handleBackspace(inputTransaction);
    break;
case Constants.CODE_SHIFT:
  performRecapitalization(inputTransaction.mSettingsValues);
inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW);
if (mSuggestedWords.mIsPrediction) {
inputTransaction.setRequiresUpdateSuggestions();
}
break;
case Constants.CODE_CAPSLOCK:
break;
case Constants.CODE_SYMBOL_SHIFT:
break;
case Constants.CODE_SWITCH_ALPHA_SYMBOL:
break;
case Constants.CODE_SETTINGS:
onSettingsKeyPressed();
break;
case Constants.CODE_SHORTCUT:
break;
case Constants.CODE_ACTION_NEXT:
performEditorAction(EditorInfo.IME_ACTION_NEXT);
break;
case Constants.CODE_ACTION_PREVIOUS:
performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);
break;
case Constants.CODE_LANGUAGE_SWITCH:
handleLanguageSwitchKey();
break;
case Constants.CODE_EMOJI:
break;
case Constants.CODE_ALPHA_FROM_EMOJI:
break;
case Constants.CODE_SHIFT_ENTER:
final Event tmpEvent=Event.createSoftwareKeypressEvent(Constants.CODE_ENTER,event.mKeyCode,event.mX,event.mY,event.isKeyRepeat());
final InputTransaction tmpTransaction=new InputTransaction(inputTransaction.mSettingsValues,tmpEvent,inputTransaction.mTimestamp,inputTransaction.mSpaceState,inputTransaction.mShiftState);
didAutoCorrect=handleNonSpecialCharacter(tmpTransaction,handler);
break;
default :
throw new RuntimeException("String_Node_Str" + event.mKeyCode);
}
}
 else {
switch (event.mCodePoint) {
case Constants.CODE_ENTER:
final EditorInfo editorInfo=getCurrentInputEditorInfo();
final int imeOptionsActionId=InputTypeUtils.getImeOptionsActionIdFromEditorInfo(editorInfo);
if (InputTypeUtils.IME_ACTION_CUSTOM_LABEL == imeOptionsActionId) {
performEditorAction(editorInfo.actionId);
}
 else if (EditorInfo.IME_ACTION_NONE != imeOptionsActionId) {
performEditorAction(imeOptionsActionId);
}
 else {
didAutoCorrect=handleNonSpecialCharacter(inputTransaction,handler);
}
break;
default :
didAutoCorrect=handleNonSpecialCharacter(inputTransaction,handler);
break;
}
}
if (!didAutoCorrect && event.mKeyCode != Constants.CODE_SHIFT && event.mKeyCode != Constants.CODE_CAPSLOCK && event.mKeyCode != Constants.CODE_SWITCH_ALPHA_SYMBOL) mLastComposedWord.deactivate();
if (Constants.CODE_DELETE != event.mKeyCode) {
mEnteredText=null;
}
mConnection.endBatchEdit();
return inputTransaction;
}