Program: 157365
Project: 157365
Buggy source:
public void setKeyboardMode(final int mode,final EditorInfo attr,final boolean restarting){
  ensureKeyboardsAreBuilt();
  final int previousMode=mMode;
  mMode=mode;
  boolean resubmitToView=true;
  AnyKeyboard keyboard;
switch (mode) {
case MODE_DATETIME:
    mAlphabetMode=false;
  mKeyboardLocked=true;
keyboard=getSymbolsKeyboard(SYMBOLS_KEYBOARD_DATETIME_INDEX,getKeyboardMode(attr));
break;
case MODE_NUMBERS:
mAlphabetMode=false;
mKeyboardLocked=true;
keyboard=getSymbolsKeyboard(SYMBOLS_KEYBOARD_NUMBERS_INDEX,getKeyboardMode(attr));
break;
case MODE_SYMBOLS:
mAlphabetMode=false;
mKeyboardLocked=true;
keyboard=getSymbolsKeyboard(SYMBOLS_KEYBOARD_REGULAR_INDEX,getKeyboardMode(attr));
break;
case MODE_PHONE:
mAlphabetMode=false;
mKeyboardLocked=true;
keyboard=getSymbolsKeyboard(SYMBOLS_KEYBOARD_PHONE_INDEX,getKeyboardMode(attr));
break;
default :
mKeyboardLocked=false;
if ((!restarting && mLatinKeyboardIndex >= 0) && (mode == MODE_URL || mode == MODE_EMAIL)) {
mLastSelectedKeyboardIndex=mLatinKeyboardIndex;
}
 else {
if (AnyApplication.getConfig().getPersistLayoutForPackageId() && (!TextUtils.isEmpty(attr.packageName)) && mAlphabetKeyboardIndexByPackageId.containsKey(attr.packageName)) {
final String reusedKeyboardAddOnId=mAlphabetKeyboardIndexByPackageId.get(attr.packageName);
for (int builderIndex=0; builderIndex < mAlphabetKeyboardsCreators.length; builderIndex++) {
KeyboardAddOnAndBuilder builder=mAlphabetKeyboardsCreators[builderIndex];
if (builder.getId().equals(reusedKeyboardAddOnId)) {
Log.d(TAG,"String_Node_Str",builderIndex,attr.packageName);
mLastSelectedKeyboardIndex=builderIndex;
}
}
}
}
if (!restarting || mMode != previousMode) {
mAlphabetMode=true;
keyboard=getAlphabetKeyboard(mLastSelectedKeyboardIndex,attr);
}
 else {
keyboard=getCurrentKeyboard();
resubmitToView=false;
}
break;
}
keyboard.setImeOptions(mContext.getResources(),attr);
if (resubmitToView) {
mIME.setKeyboardStuffBeforeSetToView(keyboard);
if (mInputView != null) {
mInputView.setKeyboard(keyboard);
}
}
}

Fixed version (ground truth):
public void setKeyboardMode(final int mode,final EditorInfo attr,final boolean restarting){
  ensureKeyboardsAreBuilt();
  final int previousMode=mMode;
  mMode=mode;
  boolean resubmitToView=true;
  AnyKeyboard keyboard;
switch (mode) {
case MODE_DATETIME:
    mAlphabetMode=false;
  mKeyboardLocked=true;
keyboard=getSymbolsKeyboard(SYMBOLS_KEYBOARD_DATETIME_INDEX,getKeyboardMode(attr));
break;
case MODE_NUMBERS:
mAlphabetMode=false;
mKeyboardLocked=true;
keyboard=getSymbolsKeyboard(SYMBOLS_KEYBOARD_NUMBERS_INDEX,getKeyboardMode(attr));
break;
case MODE_SYMBOLS:
mAlphabetMode=false;
mKeyboardLocked=true;
keyboard=getSymbolsKeyboard(SYMBOLS_KEYBOARD_REGULAR_INDEX,getKeyboardMode(attr));
break;
case MODE_PHONE:
mAlphabetMode=false;
mKeyboardLocked=true;
keyboard=getSymbolsKeyboard(SYMBOLS_KEYBOARD_PHONE_INDEX,getKeyboardMode(attr));
break;
default :
mKeyboardLocked=false;
if ((!restarting && mLatinKeyboardIndex >= 0) && (mode == MODE_URL || mode == MODE_EMAIL)) {
mLastSelectedKeyboardIndex=mLatinKeyboardIndex;
}
 else {
if (AnyApplication.getConfig().getPersistLayoutForPackageId() && (!TextUtils.isEmpty(attr.packageName)) && mAlphabetKeyboardIndexByPackageId.containsKey(attr.packageName)) {
final String reusedKeyboardAddOnId=mAlphabetKeyboardIndexByPackageId.get(attr.packageName);
for (int builderIndex=0; builderIndex < mAlphabetKeyboardsCreators.length; builderIndex++) {
KeyboardAddOnAndBuilder builder=mAlphabetKeyboardsCreators[builderIndex];
if (builder.getId().equals(reusedKeyboardAddOnId)) {
Log.d(TAG,"String_Node_Str",builderIndex,attr.packageName);
mLastSelectedKeyboardIndex=builderIndex;
}
}
}
}
if (!restarting || mMode != previousMode) {
mAlphabetMode=true;
keyboard=getAlphabetKeyboard(mLastSelectedKeyboardIndex,attr);
}
 else {
keyboard=getCurrentKeyboard();
resubmitToView=false;
}
break;
}
keyboard.setImeOptions(mContext.getResources(),attr);
if (resubmitToView) {
mIME.setKeyboardForView(keyboard);
}
}