Program: 157572
Project: 157572
Buggy source:
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  InputConnection ic=getCurrentInputConnection();
  if (!mPredictionLandscape) {
    commitTyped(ic);
    mPredicting=false;
  }
  if (DEBUG)   Log.d("String_Node_Str","String_Node_Str" + event.getKeyCode() + "String_Node_Str"+ ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0)+ "String_Node_Str"+ ((event.getMetaState() & KeyEvent.META_ALT_ON) != 0)+ "String_Node_Str"+ event.getRepeatCount());
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
    if (event.getRepeatCount() == 0 && mInputView != null) {
      if (mInputView.handleBack()) {
        if (ic != null) {
          ic.clearMetaKeyStates(Integer.MAX_VALUE);
        }
        mMetaState=0;
        return true;
      }
    }
  break;
case KeyEvent.KEYCODE_ALT_LEFT:
case KeyEvent.KEYCODE_ALT_RIGHT:
case KeyEvent.KEYCODE_SHIFT_LEFT:
case KeyEvent.KEYCODE_SHIFT_RIGHT:
case KeyEvent.KEYCODE_SYM:
if (DEBUG) Log.d("String_Node_Str",getMetaKeysStates("String_Node_Str"));
mMetaState=MyMetaKeyKeyListener.handleKeyDown(mMetaState,keyCode,event);
if (DEBUG) Log.d("String_Node_Str",getMetaKeysStates("String_Node_Str"));
break;
case KeyEvent.KEYCODE_SPACE:
if (event.isAltPressed()) {
Log.d("String_Node_Str","String_Node_Str");
if (ic != null) {
ic.clearMetaKeyStates(Integer.MAX_VALUE);
}
mMetaState=0;
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.AlphabetSupportsPhysical);
return true;
}
default :
if (!AnySoftKeyboardConfiguration.getInstance().getUseRepeatingKeys() && event.getRepeatCount() > 0) return true;
if (mKeyboardSwitcher.isCurrentKeyboardPhysical()) {
if (ic != null) ic.beginBatchEdit();
try {
if (event.isPrintingKey()) {
mHardKeyboardAction.initializeAction(event,mMetaState);
AnyKeyboard current=mKeyboardSwitcher.getCurrentKeyboard();
HardKeyboardTranslator keyTranslator=(HardKeyboardTranslator)current;
if (DEBUG) {
final String keyboardName=current.getKeyboardName();
Log.d("String_Node_Str","String_Node_Str" + keyboardName + "String_Node_Str"+ keyCode);
Log.v("String_Node_Str","String_Node_Str" + mHardKeyboardAction.isShiftActive() + "String_Node_Str"+ mHardKeyboardAction.isAltActive()+ "String_Node_Str"+ mHardKeyboardAction.getKeyCode()+ "String_Node_Str"+ mHardKeyboardAction.getKeyCodeWasChanged());
}
keyTranslator.translatePhysicalCharacter(mHardKeyboardAction);
if (DEBUG) Log.v("String_Node_Str","String_Node_Str" + mHardKeyboardAction.getKeyCode() + "String_Node_Str"+ mHardKeyboardAction.getKeyCodeWasChanged());
if (mHardKeyboardAction.getKeyCodeWasChanged()) {
final int translatedChar=mHardKeyboardAction.getKeyCode();
onKey(translatedChar,new int[]{translatedChar});
mMetaState=MyMetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
if (DEBUG) Log.d("String_Node_Str",getMetaKeysStates("String_Node_Str"));
return true;
}
}
}
  finally {
if (ic != null) ic.endBatchEdit();
}
}
if (event.isPrintingKey()) {
mMetaState=MyMetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
if (DEBUG) Log.d("String_Node_Str",getMetaKeysStates("String_Node_Str"));
}
}
return super.onKeyDown(keyCode,event);
}

Fixed version (ground truth):
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  Log.d(TAG,"String_Node_Str" + keyCode);
  InputConnection ic=getCurrentInputConnection();
  if (!mPredictionLandscape) {
    commitTyped(ic);
    mPredicting=false;
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + event.getKeyCode() + "String_Node_Str"+ ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0)+ "String_Node_Str"+ ((event.getMetaState() & KeyEvent.META_ALT_ON) != 0)+ "String_Node_Str"+ event.getRepeatCount());
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
    if (event.getRepeatCount() == 0 && mInputView != null) {
      if (mInputView.handleBack()) {
        if (ic != null) {
          ic.clearMetaKeyStates(Integer.MAX_VALUE);
        }
        mMetaState=0;
        return true;
      }
    }
  break;
case KeyEvent.KEYCODE_ALT_LEFT:
case KeyEvent.KEYCODE_ALT_RIGHT:
case KeyEvent.KEYCODE_SHIFT_LEFT:
case KeyEvent.KEYCODE_SHIFT_RIGHT:
case KeyEvent.KEYCODE_SYM:
if (DEBUG) Log.d(TAG + "String_Node_Str",getMetaKeysStates("String_Node_Str"));
mMetaState=MyMetaKeyKeyListener.handleKeyDown(mMetaState,keyCode,event);
if (DEBUG) Log.d(TAG + "String_Node_Str",getMetaKeysStates("String_Node_Str"));
break;
case KeyEvent.KEYCODE_SPACE:
if (event.isAltPressed()) {
Log.d(TAG,"String_Node_Str");
if (ic != null) {
ic.clearMetaKeyStates(Integer.MAX_VALUE);
}
mMetaState=0;
nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.AlphabetSupportsPhysical);
return true;
}
default :
if (!AnySoftKeyboardConfiguration.getInstance().getUseRepeatingKeys() && event.getRepeatCount() > 0) return true;
if (mKeyboardSwitcher.isCurrentKeyboardPhysical()) {
if (ic != null) ic.beginBatchEdit();
try {
if (event.isPrintingKey()) {
mHardKeyboardAction.initializeAction(event,mMetaState);
AnyKeyboard current=mKeyboardSwitcher.getCurrentKeyboard();
HardKeyboardTranslator keyTranslator=(HardKeyboardTranslator)current;
if (DEBUG) {
final String keyboardName=current.getKeyboardName();
Log.d(TAG,"String_Node_Str" + keyboardName + "String_Node_Str"+ keyCode);
Log.v(TAG,"String_Node_Str" + mHardKeyboardAction.isShiftActive() + "String_Node_Str"+ mHardKeyboardAction.isAltActive()+ "String_Node_Str"+ mHardKeyboardAction.getKeyCode()+ "String_Node_Str"+ mHardKeyboardAction.getKeyCodeWasChanged());
}
keyTranslator.translatePhysicalCharacter(mHardKeyboardAction);
if (DEBUG) Log.v(TAG,"String_Node_Str" + mHardKeyboardAction.getKeyCode() + "String_Node_Str"+ mHardKeyboardAction.getKeyCodeWasChanged());
if (mHardKeyboardAction.getKeyCodeWasChanged()) {
final int translatedChar=mHardKeyboardAction.getKeyCode();
onKey(translatedChar,new int[]{translatedChar});
mMetaState=MyMetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
if (DEBUG) Log.d(TAG + "String_Node_Str",getMetaKeysStates("String_Node_Str"));
return true;
}
}
}
  finally {
if (ic != null) ic.endBatchEdit();
}
}
if (event.isPrintingKey()) {
mMetaState=MyMetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
if (DEBUG) Log.d(TAG + "String_Node_Str",getMetaKeysStates("String_Node_Str"));
}
}
return super.onKeyDown(keyCode,event);
}