Program: 157604
Project: 157604
Buggy source:
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  InputConnection ic=getCurrentInputConnection();
  if (mCompletionOn)   commitTyped(ic);
  mCompletionOn=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());
  boolean handledByAction=mHardKeyboardAction.initializeAction(event);
  if (!handledByAction) {
switch (keyCode) {
case KeyEvent.KEYCODE_SPACE:
      if (mHardKeyboardAction.isAltActive()) {
        Log.d("String_Node_Str","String_Node_Str");
        mHardKeyboardAction.resetMetaState();
        if (ic != null)         ic.clearMetaKeyStates(Integer.MAX_VALUE);
        nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.AlphabetSupportsPhysical);
        return true;
      }
    break;
case KeyEvent.KEYCODE_BACK:
  if (event.getRepeatCount() == 0 && mInputView != null) {
    if (mInputView.handleBack()) {
      mHardKeyboardAction.resetMetaState();
      if (ic != null)       ic.clearMetaKeyStates(Integer.MAX_VALUE);
      return true;
    }
  }
break;
default :
if (mKeyboardSwitcher.isCurrentKeyboardPhysical()) {
AnyKeyboard current=mKeyboardSwitcher.getCurrentKeyboard();
if (AnySoftKeyboard.DEBUG) Log.d("String_Node_Str","String_Node_Str" + current.getKeyboardName() + "String_Node_Str"+ keyCode);
if (ic != null) ic.beginBatchEdit();
try {
  if (DEBUG)   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());
  ((HardKeyboardTranslator)current).translatePhysicalCharacter(mHardKeyboardAction);
  if (DEBUG)   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());
  if (mHardKeyboardAction.getKeyCodeWasChanged()) {
    final char translatedChar=(char)mHardKeyboardAction.getKeyCode();
    if (ic != null) {
      int metaStateToClear=Integer.MAX_VALUE;
      if (mHardKeyboardAction.isStickyShift() || ((event.getMetaState() & KeyEvent.META_SHIFT_ON) != 0))       metaStateToClear-=KeyEvent.META_SHIFT_ON;
      if (mHardKeyboardAction.isStickyAlt() || ((event.getMetaState() & KeyEvent.META_ALT_ON) != 0))       metaStateToClear-=KeyEvent.META_ALT_ON;
      ic.clearMetaKeyStates(metaStateToClear);
    }
    if (AnySoftKeyboard.DEBUG)     Log.d("String_Node_Str","String_Node_Str" + current.getKeyboardName() + "String_Node_Str"+ keyCode+ "String_Node_Str"+ translatedChar);
    onKey(translatedChar,new int[]{translatedChar});
    return true;
  }
 else {
    if (AnySoftKeyboard.DEBUG)     Log.d("String_Node_Str","String_Node_Str" + current.getKeyboardName() + "String_Node_Str"+ keyCode+ "String_Node_Str");
  }
}
  finally {
  mHardKeyboardAction.resetNoneStickyMetaState();
  if (ic != null)   ic.endBatchEdit();
}
}
break;
}
}
return super.onKeyDown(keyCode,event);
}

Fixed version (ground truth):
@Override public boolean onKeyDown(int keyCode,KeyEvent event){
  InputConnection ic=getCurrentInputConnection();
  if (mCompletionOn)   commitTyped(ic);
  mCompletionOn=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());
  boolean handledByAction=mHardKeyboardAction.initializeAction(event);
  if (!handledByAction) {
switch (keyCode) {
case KeyEvent.KEYCODE_SPACE:
      if (mHardKeyboardAction.isAltActive()) {
        Log.d("String_Node_Str","String_Node_Str");
        mHardKeyboardAction.resetMetaState();
        if (ic != null)         ic.clearMetaKeyStates(Integer.MAX_VALUE);
        nextKeyboard(getCurrentInputEditorInfo(),NextKeyboardType.AlphabetSupportsPhysical);
        return true;
      }
    break;
case KeyEvent.KEYCODE_BACK:
  if (event.getRepeatCount() == 0 && mInputView != null) {
    if (mInputView.handleBack()) {
      mHardKeyboardAction.resetMetaState();
      if (ic != null)       ic.clearMetaKeyStates(Integer.MAX_VALUE);
      return true;
    }
  }
break;
default :
if (mKeyboardSwitcher.isCurrentKeyboardPhysical()) {
AnyKeyboard current=mKeyboardSwitcher.getCurrentKeyboard();
if (AnySoftKeyboard.DEBUG) Log.d("String_Node_Str","String_Node_Str" + current.getKeyboardName() + "String_Node_Str"+ keyCode);
if (ic != null) ic.beginBatchEdit();
try {
  if (DEBUG)   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());
  ((HardKeyboardTranslator)current).translatePhysicalCharacter(mHardKeyboardAction);
  if (DEBUG)   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());
  final char translatedChar=(char)mHardKeyboardAction.consumeKeyCode();
  if (mHardKeyboardAction.getKeyCodeWasChanged()) {
    if (ic != null) {
      int metaStateToClear=Integer.MAX_VALUE;
      if (mHardKeyboardAction.isShiftActive())       metaStateToClear-=KeyEvent.META_SHIFT_ON;
      if (mHardKeyboardAction.isAltActive())       metaStateToClear-=KeyEvent.META_ALT_ON;
      ic.clearMetaKeyStates(metaStateToClear);
    }
    if (AnySoftKeyboard.DEBUG)     Log.d("String_Node_Str","String_Node_Str" + current.getKeyboardName() + "String_Node_Str"+ keyCode+ "String_Node_Str"+ translatedChar);
    onKey(translatedChar,new int[]{translatedChar});
    return true;
  }
 else {
    if (AnySoftKeyboard.DEBUG)     Log.d("String_Node_Str","String_Node_Str" + current.getKeyboardName() + "String_Node_Str"+ keyCode+ "String_Node_Str");
  }
}
  finally {
  if (ic != null)   ic.endBatchEdit();
}
}
break;
}
}
return super.onKeyDown(keyCode,event);
}