nus-yam/ex-repair huggingface dataset:
Program: 157335
Project: 157335
Buggy source:
private CharSequence adjustLabelToShiftState(AnyKey key){
  CharSequence label=key.label;
  if (mKeyboard.isShifted()) {
    if (!TextUtils.isEmpty(key.shiftedKeyLabel)) {
      return key.shiftedKeyLabel;
    }
 else     if (label != null && label.length() == 1) {
      label=Character.toString((char)key.getCodeAtIndex(0,true));
    }
    key.shiftedKeyLabel=label;
  }
  return label;
}

Fixed version (ground truth):
private CharSequence adjustLabelToShiftState(AnyKey key){
  CharSequence label=key.label;
  if (mKeyboard.isShifted()) {
    if (!TextUtils.isEmpty(key.shiftedKeyLabel)) {
      return key.shiftedKeyLabel;
    }
 else     if (label != null && label.length() == 1) {
      label=Character.toString((char)key.getCodeAtIndex(0,mKeyDetector.isKeyShifted(key)));
    }
    if (key.isShiftCodesAlways())     key.shiftedKeyLabel=label;
  }
  return label;
}
Program: 157337
Project: 157337
Buggy source:
public void loadKeyboard(final KeyboardDimens keyboardDimens,@NonNull KeyboardExtension topRowPlugin,@NonNull KeyboardExtension bottomRowPlugin){
  super.loadKeyboard(keyboardDimens);
  addGenericRows(keyboardDimens,topRowPlugin,bottomRowPlugin);
  initKeysMembers(mASKContext);
}

Fixed version (ground truth):
public void loadKeyboard(final KeyboardDimens keyboardDimens,@NonNull KeyboardExtension topRowPlugin,@NonNull KeyboardExtension bottomRowPlugin){
  super.loadKeyboard(keyboardDimens);
  addGenericRows(keyboardDimens,topRowPlugin,bottomRowPlugin);
  initKeysMembers(mASKContext);
  fixEdgeFlags();
}
Program: 157338
Project: 157338
Buggy source:
/** 
 * Informs the key that it has been pressed, in case it needs to change its appearance or state.
 * @see #onReleased(boolean)
 */
public void onPressed(){
  pressed=true;
}

Fixed version (ground truth):
/** 
 * Informs the key that it has been pressed, in case it needs to change its appearance or state.
 * @see #onReleased()
 */
public void onPressed(){
  pressed=true;
}
Program: 157339
Project: 157339
Buggy source:
@NonNull private AnyKeyboard createAndLoadKeyboardForMode(@Keyboard.KeyboardRowModeId int mode,int topRowIndex){
  AnyKeyboard keyboard=Preconditions.checkNotNull(mKeyboardBuilder.createKeyboard(RuntimeEnvironment.application,mode));
  KeyboardExtension topRow=KeyboardExtensionFactory.getAllAvailableExtensions(RuntimeEnvironment.application,KeyboardExtension.TYPE_TOP).get(topRowIndex);
  KeyboardExtension bottomRow=KeyboardExtensionFactory.getCurrentKeyboardExtension(RuntimeEnvironment.application,KeyboardExtension.TYPE_BOTTOM);
  keyboard.loadKeyboard(SIMPLE_KeyboardDimens,topRow,bottomRow);
  return keyboard;
}

Fixed version (ground truth):
@NonNull private AnyKeyboard createAndLoadKeyboardForMode(@Keyboard.KeyboardRowModeId int mode,int topRowIndex) throws Exception {
  AnyKeyboard keyboard=Preconditions.checkNotNull(mKeyboardBuilder.createKeyboard(RuntimeEnvironment.application,mode));
  KeyboardExtension topRow=KeyboardExtensionFactory.getAllAvailableExtensions(RuntimeEnvironment.application,KeyboardExtension.TYPE_TOP).get(topRowIndex);
  KeyboardExtension bottomRow=KeyboardExtensionFactory.getCurrentKeyboardExtension(RuntimeEnvironment.application,KeyboardExtension.TYPE_BOTTOM);
  keyboard.loadKeyboard(SIMPLE_KeyboardDimens,topRow,bottomRow);
  verifyKeysLocationByListOrder(keyboard.getKeys());
  verifyAllEdgesOnKeyboardKeys(keyboard.getKeys());
  return keyboard;
}
Program: 157343
Project: 157343
Buggy source:
@Nullable private AnyKeyboard getLockedKeyboard(EditorInfo currentEditorInfo){
  if (mKeyboardLocked) {
    AnyKeyboard current=getCurrentKeyboard();
    Logger.i(TAG,"String_Node_Str" + current.getKeyboardName());
    mRightToLeftMode=!current.isLeftToRightLanguage();
    current.setImeOptions(mContext.getResources(),currentEditorInfo);
    mIME.onSymbolsKeyboardSet(current);
    return current;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
@Nullable private AnyKeyboard getLockedKeyboard(EditorInfo currentEditorInfo){
  if (mKeyboardLocked) {
    AnyKeyboard current=getCurrentKeyboard();
    Logger.i(TAG,"String_Node_Str" + current.getKeyboardName());
    current.setImeOptions(mContext.getResources(),currentEditorInfo);
    mIME.onSymbolsKeyboardSet(current);
    return current;
  }
 else {
    return null;
  }
}
Program: 157344
Project: 157344
Buggy source:
private AnyKeyboard nextAlphabetKeyboard(EditorInfo currentEditorInfo,boolean supportsPhysical){
  AnyKeyboard current=getLockedKeyboard(currentEditorInfo);
  if (current == null) {
    final int keyboardsCount=getAlphabetKeyboards().length;
    if (isAlphabetMode())     mLastSelectedKeyboardIndex++;
    mAlphabetMode=true;
    if (mLastSelectedKeyboardIndex >= keyboardsCount)     mLastSelectedKeyboardIndex=0;
    current=getAlphabetKeyboard(mLastSelectedKeyboardIndex,currentEditorInfo);
    mLastSelectedSymbolsKeyboard=0;
    if (supportsPhysical) {
      int testsLeft=keyboardsCount;
      while (!(current instanceof HardKeyboardTranslator) && (testsLeft > 0)) {
        mLastSelectedKeyboardIndex++;
        if (mLastSelectedKeyboardIndex >= keyboardsCount)         mLastSelectedKeyboardIndex=0;
        current=getAlphabetKeyboard(mLastSelectedKeyboardIndex,currentEditorInfo);
        testsLeft--;
      }
      if (testsLeft == 0) {
        Logger.w(TAG,"String_Node_Str" + current.getKeyboardName());
      }
    }
    mRightToLeftMode=!current.isLeftToRightLanguage();
    current.setImeOptions(mContext.getResources(),currentEditorInfo);
    mIME.onAlphabetKeyboardSet(current);
    return current;
  }
 else {
    return current;
  }
}

Fixed version (ground truth):
private AnyKeyboard nextAlphabetKeyboard(EditorInfo currentEditorInfo,boolean supportsPhysical){
  AnyKeyboard current=getLockedKeyboard(currentEditorInfo);
  if (current == null) {
    final int keyboardsCount=getAlphabetKeyboards().length;
    if (isAlphabetMode())     mLastSelectedKeyboardIndex++;
    mAlphabetMode=true;
    if (mLastSelectedKeyboardIndex >= keyboardsCount)     mLastSelectedKeyboardIndex=0;
    current=getAlphabetKeyboard(mLastSelectedKeyboardIndex,currentEditorInfo);
    mLastSelectedSymbolsKeyboard=0;
    if (supportsPhysical) {
      int testsLeft=keyboardsCount;
      while (!(current instanceof HardKeyboardTranslator) && (testsLeft > 0)) {
        mLastSelectedKeyboardIndex++;
        if (mLastSelectedKeyboardIndex >= keyboardsCount)         mLastSelectedKeyboardIndex=0;
        current=getAlphabetKeyboard(mLastSelectedKeyboardIndex,currentEditorInfo);
        testsLeft--;
      }
      if (testsLeft == 0) {
        Logger.w(TAG,"String_Node_Str" + current.getKeyboardName());
      }
    }
    current.setImeOptions(mContext.getResources(),currentEditorInfo);
    mIME.onAlphabetKeyboardSet(current);
    return current;
  }
 else {
    return current;
  }
}
Program: 157345
Project: 157345
Buggy source:
public static void d(String TAG,String text,Throwable t){
  if (BuildConfig.TESTING_BUILD) {
    msLogger.d(TAG,text + NEW_LINE + t);
    addLog(LVL_D,TAG,text,t);
  }
}

Fixed version (ground truth):
public synchronized static void d(String TAG,String text,Throwable t){
  if (BuildConfig.TESTING_BUILD) {
    msLogger.d(TAG,text + NEW_LINE + t);
    addLog(LVL_D,TAG,text,t);
  }
}
Program: 157346
Project: 157346
Buggy source:
public static void e(String TAG,String text,Throwable t){
  msLogger.e(TAG,text + NEW_LINE + t);
  addLog(LVL_E,TAG,text,t);
}

Fixed version (ground truth):
public synchronized static void e(String TAG,String text,Throwable t){
  msLogger.e(TAG,text + NEW_LINE + t);
  addLog(LVL_E,TAG,text,t);
}
Program: 157347
Project: 157347
Buggy source:
public static void wtf(String TAG,String text,Throwable t){
  addLog(LVL_WTF,TAG,text,t);
  msLogger.wtf(TAG,text + NEW_LINE + t);
}

Fixed version (ground truth):
public synchronized static void wtf(String TAG,String text,Throwable t){
  addLog(LVL_WTF,TAG,text,t);
  msLogger.wtf(TAG,text + NEW_LINE + t);
}
Program: 157348
Project: 157348
Buggy source:
public static void i(String TAG,String text,Throwable t){
  msLogger.i(TAG,text + NEW_LINE + t);
  addLog(LVL_I,TAG,text,t);
}

Fixed version (ground truth):
public synchronized static void i(String TAG,String text,Throwable t){
  msLogger.i(TAG,text + NEW_LINE + t);
  addLog(LVL_I,TAG,text,t);
}
Program: 157349
Project: 157349
Buggy source:
public static void yell(String TAG,String text,Object... args){
  if (BuildConfig.TESTING_BUILD) {
    String msg=args == null ? text : msFormatter.format(text,args).toString();
    msFormatBuilder.setLength(0);
    msLogger.yell(TAG,msg);
    addLog(LVL_YELL,TAG,msg);
  }
}

Fixed version (ground truth):
public synchronized static void yell(String TAG,String text,Object... args){
  if (BuildConfig.TESTING_BUILD) {
    String msg=args == null ? text : msFormatter.format(text,args).toString();
    msFormatBuilder.setLength(0);
    msLogger.yell(TAG,msg);
    addLog(LVL_YELL,TAG,msg);
  }
}
Program: 157350
Project: 157350
Buggy source:
public static void v(String TAG,String text,Throwable t){
  if (BuildConfig.DEBUG) {
    msLogger.v(TAG,text + NEW_LINE + t);
    addLog(LVL_V,TAG,text,t);
  }
}

Fixed version (ground truth):
public synchronized static void v(String TAG,String text,Throwable t){
  if (BuildConfig.DEBUG) {
    msLogger.v(TAG,text + NEW_LINE + t);
    addLog(LVL_V,TAG,text,t);
  }
}
Program: 157351
Project: 157351
Buggy source:
public static void w(String TAG,Throwable e,String text,Object... args){
  String msg=args == null ? text : msFormatter.format(text,args).toString();
  msFormatBuilder.setLength(0);
  msLogger.e(TAG,msg + NEW_LINE + e);
  addLog(LVL_E,TAG,msg);
}

Fixed version (ground truth):
public synchronized static void w(String TAG,Throwable e,String text,Object... args){
  String msg=args == null ? text : msFormatter.format(text,args).toString();
  msFormatBuilder.setLength(0);
  msLogger.e(TAG,msg + NEW_LINE + e);
  addLog(LVL_E,TAG,msg);
}
Program: 157353
Project: 157353
Buggy source:
public TestableKeyboardSwitcher(@NonNull AnySoftKeyboard ime){
  super(ime);
}

Fixed version (ground truth):
public TestableKeyboardSwitcher(@NonNull AnySoftKeyboard ime){
  super(ime,RuntimeEnvironment.application);
}
Program: 157354
Project: 157354
Buggy source:
@Override public void handleMessage(Message msg){
  SetUpKeyboardWizardFragment fragment=mWeakFragment.get();
  if (fragment == null)   return;
switch (msg.what) {
case KEY_MESSAGE_SCROLL_TO_PAGE:
    int pageToScrollTo=msg.arg1;
  if (fragment.mWizardPager != null) {
    fragment.mWizardPager.setCurrentItem(pageToScrollTo,true);
    fragment.setFullIndicatorTo(pageToScrollTo,0.0f);
  }
break;
case KEY_MESSAGE_UPDATE_INDICATOR:
int position=msg.arg1;
float offset=(Float)msg.obj;
fragment.setFullIndicatorTo(position,offset);
break;
case KEY_MESSAGE_UPDATE_FRAGMENTS:
if (fragment.isResumed() && fragment.getActivity() != null) {
fragment.refreshFragmentsUi();
}
 else {
fragment.mReloadPager=true;
}
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  SetUpKeyboardWizardFragment fragment=mWeakFragment.get();
  if (fragment == null)   return;
switch (msg.what) {
case KEY_MESSAGE_SCROLL_TO_PAGE:
    int pageToScrollTo=msg.arg1;
  if (fragment.mWizardPager != null) {
    fragment.mWizardPager.setCurrentItem(pageToScrollTo,true);
    fragment.setFullIndicatorTo(pageToScrollTo,0.0f);
  }
break;
case KEY_MESSAGE_UPDATE_INDICATOR:
int position=msg.arg1;
float offset=(Float)msg.obj;
fragment.setFullIndicatorTo(position,offset);
break;
case KEY_MESSAGE_UPDATE_FRAGMENTS:
if (fragment.isResumed()) {
fragment.refreshFragmentsUi();
}
 else {
fragment.mReloadPager=true;
}
break;
}
}
Program: 157355
Project: 157355
Buggy source:
private void refreshFragmentUi(FragmentManager fragmentManager,int layoutId){
  Fragment step=fragmentManager.findFragmentById(layoutId);
  if (step instanceof WizardPageBaseFragment) {
    ((WizardPageBaseFragment)step).refreshFragmentUi();
  }
}

Fixed version (ground truth):
private void refreshFragmentUi(@NonNull FragmentManager fragmentManager,@IdRes int layoutId){
  Fragment step=fragmentManager.findFragmentById(layoutId);
  if (step instanceof WizardPageBaseFragment) {
    ((WizardPageBaseFragment)step).refreshFragmentUi();
  }
}
Program: 157356
Project: 157356
Buggy source:
public WizardHandler(SetUpKeyboardWizardFragment setUpKeyboardWizardFragment){
  mWeakFragment=new WeakReference<>(setUpKeyboardWizardFragment);
}

Fixed version (ground truth):
public WizardHandler(@NonNull SetUpKeyboardWizardFragment setUpKeyboardWizardFragment){
  mWeakFragment=new WeakReference<>(setUpKeyboardWizardFragment);
}
Program: 157357
Project: 157357
Buggy source:
public void refreshFragmentUi(){
  final View pareStepNotCompleted=getView().findViewById(R.id.previous_step_not_complete);
  final View thisStepCompleted=getView().findViewById(R.id.this_step_complete);
  final View thisStepSetup=getView().findViewById(R.id.this_step_needs_setup);
  pareStepNotCompleted.setVisibility(View.GONE);
  thisStepCompleted.setVisibility(View.GONE);
  thisStepSetup.setVisibility(View.GONE);
  if (!isStepPreConditionDone()) {
    pareStepNotCompleted.setVisibility(View.VISIBLE);
  }
 else   if (isStepCompleted()) {
    thisStepCompleted.setVisibility(View.VISIBLE);
  }
 else {
    thisStepSetup.setVisibility(View.VISIBLE);
  }
}

Fixed version (ground truth):
public void refreshFragmentUi(){
  if ((!isResumed()) || getActivity() == null) {
    return;
  }
  final View pareStepNotCompleted=getView().findViewById(R.id.previous_step_not_complete);
  final View thisStepCompleted=getView().findViewById(R.id.this_step_complete);
  final View thisStepSetup=getView().findViewById(R.id.this_step_needs_setup);
  pareStepNotCompleted.setVisibility(View.GONE);
  thisStepCompleted.setVisibility(View.GONE);
  thisStepSetup.setVisibility(View.GONE);
  if (!isStepPreConditionDone()) {
    pareStepNotCompleted.setVisibility(View.VISIBLE);
  }
 else   if (isStepCompleted()) {
    thisStepCompleted.setVisibility(View.VISIBLE);
  }
 else {
    thisStepSetup.setVisibility(View.VISIBLE);
  }
}
Program: 157358
Project: 157358
Buggy source:
private void swapPunctuationAndSpace(@NonNull InputConnection ic){
  CharSequence lastTwo=ic.getTextBeforeCursor(2,0);
  if (lastTwo != null && lastTwo.length() == 2 && lastTwo.charAt(0) == KeyCodes.SPACE && isWordSeparator(lastTwo.charAt(1))) {
    ic.beginBatchEdit();
    ic.deleteSurroundingText(2,0);
    ic.commitText(lastTwo.charAt(1) + "String_Node_Str",1);
    ic.endBatchEdit();
    mJustAddedAutoSpace=true;
    Log.d(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
private void swapPunctuationAndSpace(@NonNull InputConnection ic,final char punctuationCharacter){
  CharSequence lastTwo=ic.getTextBeforeCursor(2,0);
  if (lastTwo != null && lastTwo.length() == 2 && lastTwo.charAt(0) == KeyCodes.SPACE && lastTwo.charAt(1) == punctuationCharacter) {
    ic.deleteSurroundingText(2,0);
    ic.commitText(punctuationCharacter + "String_Node_Str",1);
    mJustAddedAutoSpace=true;
  }
}
Program: 157360
Project: 157360
Buggy source:
public boolean isWordSeparator(int code){
  return (!isAlphabet(code));
}

Fixed version (ground truth):
private boolean isWordSeparator(int code){
  return (!isAlphabet(code));
}
Program: 157361
Project: 157361
Buggy source:
private void setKeyboardFinalStuff(@NonNull AnyKeyboard keyboard,@Nullable KeyboardSwitcher.NextKeyboardType type){
  mShiftKeyState.reset();
  mControlKeyState.reset();
  mSuggest.resetNextWordSentence();
  if (!(keyboard instanceof GenericKeyboard)) {
    fillSeparatorsSparseArray(mSentenceSeparators,keyboard.getSentenceSeparators());
  }
  setDictionariesForCurrentKeyboard();
  if ((mKeyboardChangeNotificationType.equals(KEYBOARD_NOTIFICATION_ALWAYS)) || (mKeyboardChangeNotificationType.equals(KEYBOARD_NOTIFICATION_ON_PHYSICAL) && (type == NextKeyboardType.AlphabetSupportsPhysical))) {
    notifyKeyboardChangeIfNeeded();
  }
  postUpdateSuggestions();
  updateShiftStateNow();
}

Fixed version (ground truth):
private void setKeyboardFinalStuff(@NonNull AnyKeyboard keyboard,@NonNull KeyboardSwitcher.NextKeyboardType type){
  mShiftKeyState.reset();
  mControlKeyState.reset();
  mSuggest.resetNextWordSentence();
  fillSeparatorsSparseArray(mSentenceSeparators,keyboard.getSentenceSeparators());
  setDictionariesForCurrentKeyboard();
  if ((mKeyboardChangeNotificationType.equals(KEYBOARD_NOTIFICATION_ALWAYS)) || (mKeyboardChangeNotificationType.equals(KEYBOARD_NOTIFICATION_ON_PHYSICAL) && (type == NextKeyboardType.AlphabetSupportsPhysical))) {
    notifyKeyboardChangeIfNeeded();
  }
  postUpdateSuggestions();
  updateShiftStateNow();
}
Program: 157363
Project: 157363
Buggy source:
@Override public void setInputView(@NonNull View view){
  super.setInputView(view);
  ViewParent parent=view.getParent();
  if (parent instanceof View) {
    ((View)parent).setBackgroundResource(R.drawable.ask_wallpaper);
  }
 else {
    Log.w(TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
@Override public void setInputView(@NonNull View view){
  super.setInputView(view);
  setKeyboardFinalStuff(getCurrentKeyboard(),NextKeyboardType.Alphabet);
  ViewParent parent=view.getParent();
  if (parent instanceof View) {
    ((View)parent).setBackgroundResource(R.drawable.ask_wallpaper);
  }
 else {
    Log.w(TAG,"String_Node_Str");
  }
}
Program: 157366
Project: 157366
Buggy source:
@NonNull private synchronized AnyKeyboard getAlphabetKeyboard(int index,@Nullable EditorInfo editorInfo){
  AnyKeyboard[] keyboards=getAlphabetKeyboards();
  if (index >= keyboards.length)   index=0;
  AnyKeyboard keyboard=keyboards[index];
  final int mode=getKeyboardMode(editorInfo);
  if (keyboard == null || keyboard.getKeyboardMode() != mode) {
    KeyboardAddOnAndBuilder creator=mAlphabetKeyboardsCreators[index];
    if ((keyboard=keyboards[index]=createKeyboardFromCreator(mode,creator)) == null) {
      flushKeyboardsCache();
      index=0;
      return getAlphabetKeyboard(index,editorInfo);
    }
 else {
      if (mInputView != null) {
        keyboard.loadKeyboard(mInputView.getThemedKeyboardDimens());
        mIME.setKeyboardStuffBeforeSetToView(keyboard);
        mInputView.setKeyboard(keyboard);
      }
 else {
        keyboard.loadKeyboard(mKeyboardDimens);
      }
    }
  }
  if (editorInfo != null && !TextUtils.isEmpty(editorInfo.packageName)) {
    mAlphabetKeyboardIndexByPackageId.put(editorInfo.packageName,keyboard.getKeyboardAddOn().getId());
  }
  return keyboard;
}

Fixed version (ground truth):
@NonNull private synchronized AnyKeyboard getAlphabetKeyboard(int index,@Nullable EditorInfo editorInfo){
  AnyKeyboard[] keyboards=getAlphabetKeyboards();
  if (index >= keyboards.length)   index=0;
  AnyKeyboard keyboard=keyboards[index];
  final int mode=getKeyboardMode(editorInfo);
  if (keyboard == null || keyboard.getKeyboardMode() != mode) {
    KeyboardAddOnAndBuilder creator=mAlphabetKeyboardsCreators[index];
    if ((keyboard=keyboards[index]=createKeyboardFromCreator(mode,creator)) == null) {
      flushKeyboardsCache();
      index=0;
      return getAlphabetKeyboard(index,editorInfo);
    }
 else {
      if (mInputView != null) {
        keyboard.loadKeyboard(mInputView.getThemedKeyboardDimens());
        mIME.setKeyboardForView(keyboard);
      }
 else {
        keyboard.loadKeyboard(mKeyboardDimens);
      }
    }
  }
  if (editorInfo != null && !TextUtils.isEmpty(editorInfo.packageName)) {
    mAlphabetKeyboardIndexByPackageId.put(editorInfo.packageName,keyboard.getKeyboardAddOn().getId());
  }
  return keyboard;
}
Program: 157367
Project: 157367
Buggy source:
private AnyKeyboard setKeyboard(EditorInfo currentEditorInfo,AnyKeyboard current){
  current.setImeOptions(mContext.getResources(),currentEditorInfo);
  mIME.setKeyboardStuffBeforeSetToView(current);
  if (mInputView != null)   mInputView.setKeyboard(current);
  return current;
}

Fixed version (ground truth):
private AnyKeyboard setKeyboard(EditorInfo currentEditorInfo,AnyKeyboard current){
  current.setImeOptions(mContext.getResources(),currentEditorInfo);
  mIME.setKeyboardForView(current);
  return current;
}
Program: 157370
Project: 157370
Buggy source:
@Override public boolean sendKeyEvent(KeyEvent event){
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_UP) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
      if (mSelectionEndPosition == mCursorPosition) {
        handled=true;
        deleteSurroundingText(1,0);
      }
 else {
        handled=true;
        mInputText.delete(mCursorPosition,mSelectionEndPosition);
        notifyTextChange(0);
      }
    }
 else     if (event.getKeyCode() == KeyEvent.KEYCODE_SPACE) {
      handled=true;
      commitText("String_Node_Str",1);
    }
  }
  if (!handled) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
      mIme.onKeyDown(event.getKeyCode(),event);
    }
 else {
      mIme.onKeyUp(event.getKeyCode(),event);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean sendKeyEvent(KeyEvent event){
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_UP) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
      if (mSelectionEndPosition == mCursorPosition) {
        handled=true;
        deleteSurroundingText(1,0);
      }
 else {
        handled=true;
        mInputText.delete(mCursorPosition,mSelectionEndPosition);
        notifyTextChange(0);
      }
    }
 else     if (event.getKeyCode() == KeyEvent.KEYCODE_SPACE) {
      handled=true;
      commitText("String_Node_Str",1);
    }
 else     if (event.getKeyCode() >= KeyEvent.KEYCODE_0 || event.getKeyCode() <= KeyEvent.KEYCODE_9) {
      handled=true;
      commitText(Integer.toString(event.getKeyCode() - KeyEvent.KEYCODE_0),1);
    }
 else     if (event.getKeyCode() >= KeyEvent.KEYCODE_A || event.getKeyCode() <= KeyEvent.KEYCODE_Z) {
      handled=true;
      commitText("String_Node_Str" + (char)(event.getKeyCode() - KeyEvent.KEYCODE_A + 'a'),1);
    }
  }
  if (!handled) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
      mIme.onKeyDown(event.getKeyCode(),event);
    }
 else {
      mIme.onKeyUp(event.getKeyCode(),event);
    }
  }
  return true;
}
Program: 157371
Project: 157371
Buggy source:
@Override protected Void doAsyncTask(Void[] params) throws Exception {
  final File externalFolder=Environment.getExternalStorageDirectory();
  final File targetFolder=new File(externalFolder,"String_Node_Str" + mAppContext.getPackageName() + "String_Node_Str");
  targetFolder.mkdirs();
  XmlWriter output=new XmlWriter(new File(targetFolder,mFilename));
  output.writeEntity("String_Node_Str");
  for (  String locale : mLocalesToSave) {
    mLocale=locale;
synchronized (mLocale) {
      Log.d(TAG,"String_Node_Str" + mLocale);
      publishProgress();
      try {
        mLocale.wait();
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
    Log.d(TAG,"String_Node_Str" + locale);
    WordsCursor wordsCursor=mDictionary.getWordsCursor();
    output.writeEntity("String_Node_Str").writeAttribute("String_Node_Str",locale);
    Cursor cursor=wordsCursor.getCursor();
    cursor.moveToFirst();
    final int wordIndex=cursor.getColumnIndex(Words.WORD);
    final int freqIndex=cursor.getColumnIndex(Words.FREQUENCY);
    while (!cursor.isAfterLast()) {
      String word=cursor.getString(wordIndex).trim();
      int freq=cursor.getInt(freqIndex);
      output.writeEntity("String_Node_Str").writeAttribute("String_Node_Str",Integer.toString(freq)).writeText(word).endEntity();
      Log.d(TAG,"String_Node_Str" + word + "String_Node_Str"+ freq);
      cursor.moveToNext();
    }
    wordsCursor.close();
    mDictionary.close();
    output.endEntity();
  }
  output.endEntity();
  output.close();
  return null;
}

Fixed version (ground truth):
@Override protected Void doAsyncTask(Void[] params) throws Exception {
  final File externalFolder=Environment.getExternalStorageDirectory();
  final File targetFolder=new File(externalFolder,"String_Node_Str" + mAppContext.getPackageName() + "String_Node_Str");
  targetFolder.mkdirs();
  XmlWriter output=new XmlWriter(new File(targetFolder,mFilename));
  output.writeEntity("String_Node_Str");
  for (  String locale : mLocalesToSave) {
    Log.d(TAG,"String_Node_Str" + locale);
    UserDictionary dictionary=new UserDictionary(mAppContext,locale);
    dictionary.loadDictionary();
    Log.d(TAG,"String_Node_Str" + locale);
    WordsCursor wordsCursor=dictionary.getWordsCursor();
    output.writeEntity("String_Node_Str").writeAttribute("String_Node_Str",locale);
    Cursor cursor=wordsCursor.getCursor();
    cursor.moveToFirst();
    final int wordIndex=cursor.getColumnIndex(Words.WORD);
    final int freqIndex=cursor.getColumnIndex(Words.FREQUENCY);
    while (!cursor.isAfterLast()) {
      String word=cursor.getString(wordIndex).trim();
      int freq=cursor.getInt(freqIndex);
      output.writeEntity("String_Node_Str").writeAttribute("String_Node_Str",Integer.toString(freq)).writeText(word).endEntity();
      Log.d(TAG,"String_Node_Str" + word + "String_Node_Str"+ freq);
      cursor.moveToNext();
    }
    wordsCursor.close();
    dictionary.close();
    output.endEntity();
  }
  output.endEntity();
  output.close();
  return null;
}
Program: 157373
Project: 157373
Buggy source:
@Override public void startElement(String uri,String localName,String qName,Attributes attributes) throws SAXException {
  super.startElement(uri,localName,qName,attributes);
  if (localName.equals("String_Node_Str")) {
    inWord=true;
    word="String_Node_Str";
    freq=Integer.parseInt(attributes.getValue("String_Node_Str"));
  }
  if (localName.equals("String_Node_Str")) {
    mLocale=attributes.getValue("String_Node_Str");
synchronized (mLoadMonitor) {
      Log.d(TAG,"String_Node_Str" + mLocale);
      publishProgress();
      try {
        mLoadMonitor.wait();
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
    Log.d(TAG,"String_Node_Str" + mLocale);
  }
}

Fixed version (ground truth):
@Override public void startElement(String uri,String localName,String qName,Attributes attributes) throws SAXException {
  super.startElement(uri,localName,qName,attributes);
  if (localName.equals("String_Node_Str")) {
    inWord=true;
    word="String_Node_Str";
    freq=Integer.parseInt(attributes.getValue("String_Node_Str"));
  }
  if (localName.equals("String_Node_Str")) {
    mLocale=attributes.getValue("String_Node_Str");
    Log.d(TAG,"String_Node_Str" + mLocale);
    if (mDictionary != null) {
      mDictionary.close();
    }
    mDictionary=new UserDictionary(mAppContext,mLocale);
    mDictionary.loadDictionary();
    Log.d(TAG,"String_Node_Str" + mLocale);
  }
}
Program: 157374
Project: 157374
Buggy source:
@Override public void handleMessage(Message msg){
  SetUpKeyboardWizardFragment fragment=mWeakFragment.get();
  if (fragment == null)   return;
switch (msg.what) {
case KEY_MESSAGE_SCROLL_TO_PAGE:
    int pageToScrollTo=msg.arg1;
  if (fragment.mWizardPager != null) {
    fragment.mWizardPager.setCurrentItem(pageToScrollTo,true);
    fragment.setFullIndicatorTo(pageToScrollTo,0.0f);
  }
break;
case KEY_MESSAGE_UPDATE_INDICATOR:
int position=msg.arg1;
float offset=(Float)msg.obj;
fragment.setFullIndicatorTo(position,offset);
break;
case KEY_MESSAGE_UPDATE_FRAGMENTS:
if (fragment.isResumed()) {
fragment.refreshFragmentsUi();
}
 else {
fragment.mReloadPager=true;
}
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
  SetUpKeyboardWizardFragment fragment=mWeakFragment.get();
  if (fragment == null)   return;
switch (msg.what) {
case KEY_MESSAGE_SCROLL_TO_PAGE:
    int pageToScrollTo=msg.arg1;
  if (fragment.mWizardPager != null) {
    fragment.mWizardPager.setCurrentItem(pageToScrollTo,true);
    fragment.setFullIndicatorTo(pageToScrollTo,0.0f);
  }
break;
case KEY_MESSAGE_UPDATE_INDICATOR:
int position=msg.arg1;
float offset=(Float)msg.obj;
fragment.setFullIndicatorTo(position,offset);
break;
case KEY_MESSAGE_UPDATE_FRAGMENTS:
if (fragment.isResumed() && fragment.getActivity() != null) {
fragment.refreshFragmentsUi();
}
 else {
fragment.mReloadPager=true;
}
break;
}
}
Program: 157377
Project: 157377
Buggy source:
private boolean pickDefaultSuggestion(){
  if (mKeyboardHandler.hasMessages(KeyboardUIStateHandler.MSG_UPDATE_SUGGESTIONS)) {
    postUpdateSuggestions(-1);
  }
  final CharSequence bestWord=mWord.getPreferredWord();
  Log.d(TAG,"String_Node_Str",bestWord);
  if (!TextUtils.isEmpty(bestWord)) {
    final CharSequence typedWord=mWord.getTypedWord();
    TextEntryState.acceptedDefault(typedWord,bestWord);
    final boolean fixed=!typedWord.equals(pickSuggestion(bestWord,!bestWord.equals(typedWord)));
    if (!fixed) {
      addToDictionaries(mWord,AutoDictionary.AdditionType.Typed);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean pickDefaultSuggestion(boolean autoCorrectToPreferred){
  if (mKeyboardHandler.hasMessages(KeyboardUIStateHandler.MSG_UPDATE_SUGGESTIONS)) {
    postUpdateSuggestions(-1);
  }
  final CharSequence typedWord=mWord.getTypedWord();
  final CharSequence bestWord=autoCorrectToPreferred ? mWord.getPreferredWord() : typedWord;
  Log.d(TAG,"String_Node_Str",bestWord,mAutoCorrectOn);
  if (!TextUtils.isEmpty(bestWord)) {
    TextEntryState.acceptedDefault(typedWord,bestWord);
    final boolean fixed=!typedWord.equals(pickSuggestion(bestWord,!bestWord.equals(typedWord)));
    if (!fixed) {
      checkAddToDictionaryWithAutoDictionary(mWord,mAutoComplete ? AutoDictionary.AdditionType.Picked : AutoDictionary.AdditionType.Typed);
    }
    return true;
  }
  return false;
}
Program: 157378
Project: 157378
Buggy source:
private void commitTyped(InputConnection inputConnection){
  if (mPredicting) {
    mPredicting=false;
    if (mWord.length() > 0) {
      if (inputConnection != null) {
        inputConnection.commitText(mWord.getTypedWord(),1);
      }
      mCommittedLength=mWord.length();
      mCommittedWord=mWord.getTypedWord();
      TextEntryState.acceptedTyped(mWord.getTypedWord());
      addToDictionaries(mWord,AutoDictionary.AdditionType.Typed);
    }
    if (mKeyboardHandler.hasMessages(KeyboardUIStateHandler.MSG_UPDATE_SUGGESTIONS)) {
      postUpdateSuggestions(-1);
    }
  }
}

Fixed version (ground truth):
private void commitTyped(InputConnection inputConnection){
  if (mPredicting) {
    mPredicting=false;
    if (mWord.length() > 0) {
      if (inputConnection != null) {
        inputConnection.commitText(mWord.getTypedWord(),1);
      }
      mCommittedLength=mWord.length();
      mCommittedWord=mWord.getTypedWord();
      TextEntryState.acceptedTyped(mWord.getTypedWord());
      checkAddToDictionaryWithAutoDictionary(mWord,AutoDictionary.AdditionType.Typed);
    }
    if (mKeyboardHandler.hasMessages(KeyboardUIStateHandler.MSG_UPDATE_SUGGESTIONS)) {
      postUpdateSuggestions(-1);
    }
  }
}
Program: 157379
Project: 157379
Buggy source:
public static boolean willUndoCommitOnBackspace(){
switch (sState) {
case ACCEPTED_DEFAULT:
case PICKED_TYPED_ADDED_TO_DICTIONARY:
    return true;
default :
  return false;
}
}

Fixed version (ground truth):
public static boolean willUndoCommitOnBackspace(){
switch (sState) {
case ACCEPTED_DEFAULT:
case SPACE_AFTER_ACCEPTED:
case PICKED_TYPED_ADDED_TO_DICTIONARY:
case SPACE_AFTER_PICKED:
    return true;
default :
  return false;
}
}
Program: 157380
Project: 157380
Buggy source:
public static void backspace(){
  if (sState == State.ACCEPTED_DEFAULT) {
    sState=State.UNDO_COMMIT;
    sAutoSuggestUndoneCount++;
  }
 else   if (sState == State.PICKED_TYPED_ADDED_TO_DICTIONARY) {
    sState=State.UNDO_COMMIT;
  }
 else   if (sState == State.UNDO_COMMIT) {
    sState=State.IN_WORD;
  }
  sBackspaceCount++;
  displayState();
}

Fixed version (ground truth):
public static void backspace(){
switch (sState) {
case ACCEPTED_DEFAULT:
case SPACE_AFTER_ACCEPTED:
    sState=State.UNDO_COMMIT;
  sAutoSuggestUndoneCount++;
break;
case PICKED_TYPED_ADDED_TO_DICTIONARY:
case SPACE_AFTER_PICKED:
sState=State.UNDO_COMMIT;
break;
case UNDO_COMMIT:
sState=State.IN_WORD;
break;
}
sBackspaceCount++;
displayState();
}
Program: 157381
Project: 157381
Buggy source:
@Test public void testAutoPickWordWhenCursorAtTheEndOfTheWord(){
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  verifyNoSuggestionsInteractions(mSpiedCandidateView);
  mAnySoftKeyboardUnderTest.simulateTextTyping("String_Node_Str");
  verifySuggestions(mSpiedCandidateView,true,"String_Node_Str");
  mAnySoftKeyboardUnderTest.simulateTextTyping("String_Node_Str");
  verifySuggestions(mSpiedCandidateView,true,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  mAnySoftKeyboardUnderTest.simulateTextTyping("String_Node_Str");
  verifySuggestions(mSpiedCandidateView,true,"String_Node_Str","String_Node_Str","String_Node_Str");
  Assert.assertEquals("String_Node_Str",inputConnection.getLastCommitCorrection());
  mAnySoftKeyboardUnderTest.simulateKeyPress(' ');
  Assert.assertEquals("String_Node_Str",inputConnection.getLastCommitCorrection());
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
}

Fixed version (ground truth):
@Test public void testAutoPickWordWhenCursorAtTheEndOfTheWord(){
  TestInputConnection inputConnection=(TestInputConnection)mAnySoftKeyboardUnderTest.getCurrentInputConnection();
  verifyNoSuggestionsInteractions(mSpiedCandidateView);
  mAnySoftKeyboardUnderTest.simulateTextTyping("String_Node_Str");
  verifySuggestions(mSpiedCandidateView,true,"String_Node_Str");
  mAnySoftKeyboardUnderTest.simulateTextTyping("String_Node_Str");
  verifySuggestions(mSpiedCandidateView,true,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str");
  mAnySoftKeyboardUnderTest.simulateTextTyping("String_Node_Str");
  verifySuggestions(mSpiedCandidateView,true,"String_Node_Str","String_Node_Str","String_Node_Str");
  Assert.assertEquals("String_Node_Str",inputConnection.getLastCommitCorrection());
  mAnySoftKeyboardUnderTest.simulateKeyPress(' ');
  Assert.assertEquals("String_Node_Str",inputConnection.getLastCommitCorrection());
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
  mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.DELETE);
  Assert.assertEquals("String_Node_Str",inputConnection.getCurrentTextInInputConnection());
}
Program: 157382
Project: 157382
Buggy source:
public void releaseAllPointersOlderThan(final PointerTracker tracker,final long eventTime){
  final ListIterator<PointerTracker> iterator=mQueue.listIterator();
  while (iterator.hasNext()) {
    final PointerTracker t=iterator.next();
    if (t == tracker)     return;
    if (!t.isModifier()) {
      t.onUpEvent(t.getLastX(),t.getLastY(),eventTime);
      t.setAlreadyProcessed();
      iterator.remove();
    }
  }
}

Fixed version (ground truth):
public void releaseAllPointersOlderThan(final PointerTracker tracker,final long eventTime){
  ArrayList<PointerTracker> pointersToRemove=new ArrayList<>();
  for (  PointerTracker t : mQueue) {
    if (t == tracker)     break;
    if (!t.isModifier()) {
      t.onUpEvent(t.getLastX(),t.getLastY(),eventTime);
      t.setAlreadyProcessed();
      pointersToRemove.add(t);
    }
  }
  for (int i=0, pointersToRemoveSize=pointersToRemove.size(); i < pointersToRemoveSize; i++) {
    mQueue.remove(pointersToRemove.get(i));
  }
}
Program: 157383
Project: 157383
Buggy source:
public void deleteNode(int nodeIndexToDelete){
}

Fixed version (ground truth):
public void deleteNode(int nodeIndexToDelete){
  length--;
  if (length > 0) {
    for (int i=nodeIndexToDelete; i < length; i++) {
      data[i]=data[i + 1];
    }
  }
}
Program: 157384
Project: 157384
Buggy source:
public void addSpecialKeySequence(int[] sequence,int specialKey,int result){
  KeyEventState c=this.start;
  for (int i=0; i < sequence.length; i++) {
    if (specialKey != 0) {
      c=addNextState(c,specialKey);
    }
    c=addNextState(c,sequence[i]);
  }
  c.setCharacter(result);
}

Fixed version (ground truth):
public void addSpecialKeySequence(int[] sequence,int specialKey,int result){
  KeyEventState c=this.start;
  for (  int aSequence : sequence) {
    if (specialKey != 0) {
      c=addNextState(c,specialKey);
    }
    c=addNextState(c,aSequence);
  }
  c.setCharacter(result);
}
Program: 157385
Project: 157385
Buggy source:
void putItem(NFAPart item){
  assert(this.count < MAX_NFA_DIVIDES);
  this.buffer[this.end]=item;
  this.end=(this.end + 1) % MAX_NFA_DIVIDES;
  this.count++;
}

Fixed version (ground truth):
void putItem(NFAPart item){
  this.buffer[this.end]=item;
  this.end=(this.end + 1) % MAX_NFA_DIVIDES;
  this.count++;
}
Program: 157386
Project: 157386
Buggy source:
NFAPart getItem(){
  assert(this.count > 0);
  NFAPart result=this.buffer[this.start];
  this.buffer[this.start]=null;
  this.start=(this.start + 1) % MAX_NFA_DIVIDES;
  this.count--;
  return result;
}

Fixed version (ground truth):
NFAPart getItem(){
  NFAPart result=this.buffer[this.start];
  this.buffer[this.start]=null;
  this.start=(this.start + 1) % MAX_NFA_DIVIDES;
  this.count--;
  return result;
}
Program: 157387
Project: 157387
Buggy source:
/** 
 * Handle multi-tap keys by producing the key label for the current multi-tap state.
 */
public CharSequence getPreviewText(Key key,boolean isShifted){
  AnyKey anyKey=(AnyKey)key;
  if (isShifted && !TextUtils.isEmpty(anyKey.shiftedKeyLabel)) {
    return anyKey.shiftedKeyLabel;
  }
 else   if (!TextUtils.isEmpty(anyKey.label)) {
    return isShifted ? anyKey.label.toString().toUpperCase() : anyKey.label;
  }
 else {
    return Character.toString(getMultiTapCode(key,isShifted));
  }
}

Fixed version (ground truth):
/** 
 * Handle multi-tap keys by producing the key label for the current multi-tap state.
 */
public CharSequence getPreviewText(Key key,boolean isShifted){
  AnyKey anyKey=(AnyKey)key;
  if (isShifted && !TextUtils.isEmpty(anyKey.shiftedKeyLabel)) {
    return anyKey.shiftedKeyLabel;
  }
 else   if (!TextUtils.isEmpty(anyKey.label)) {
    return isShifted ? anyKey.label.toString().toUpperCase(Locale.getDefault()) : anyKey.label;
  }
 else {
    return Character.toString(getMultiTapCode(key,isShifted));
  }
}
Program: 157388
Project: 157388
Buggy source:
public void releaseAllPointersOlderThan(PointerTracker tracker,long eventTime){
  LinkedList<PointerTracker> queue=mQueue;
  int oldestPos=0;
  for (PointerTracker t=queue.get(oldestPos); t != tracker; t=queue.get(oldestPos)) {
    if (t.isModifier()) {
      oldestPos++;
    }
 else {
      t.onUpEvent(t.getLastX(),t.getLastY(),eventTime);
      t.setAlreadyProcessed();
      queue.remove(oldestPos);
    }
  }
}

Fixed version (ground truth):
public void releaseAllPointersOlderThan(final PointerTracker tracker,final long eventTime){
  final ListIterator<PointerTracker> iterator=mQueue.listIterator();
  while (iterator.hasNext()) {
    final PointerTracker t=iterator.next();
    if (t == tracker)     return;
    if (!t.isModifier()) {
      t.onUpEvent(t.getLastX(),t.getLastY(),eventTime);
      t.setAlreadyProcessed();
      iterator.remove();
    }
  }
}
Program: 157390
Project: 157390
Buggy source:
public AddOnCheckBoxPreference(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  setPersistent(true);
}

Fixed version (ground truth):
public AddOnCheckBoxPreference(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  setLayoutResource(R.layout.addon_checkbox_pref);
  setPersistent(true);
}
Program: 157391
Project: 157391
Buggy source:
@Override protected View onCreateView(ViewGroup parent){
  LayoutInflater layoutInflater=LayoutInflater.from(getContext());
  ViewGroup layout=(ViewGroup)layoutInflater.inflate(R.layout.addon_checkbox_pref,parent,false);
  mCheckBox=(CheckBox)layout.findViewById(R.id.addon_checkbox);
  mCheckBox.setOnCheckedChangeListener(this);
  mName=(TextView)layout.findViewById(R.id.addon_title);
  mDescription=(TextView)layout.findViewById(R.id.addon_description);
  mAddOnIcon=(ImageView)layout.findViewById(R.id.addon_image);
  mIconOverlay=layout.findViewById(R.id.addon_image_more_overlay);
  populateViews();
  return layout;
}

Fixed version (ground truth):
@Override protected View onCreateView(ViewGroup parent){
  View layout=super.onCreateView(parent);
  mCheckBox=(CheckBox)layout.findViewById(R.id.addon_checkbox);
  mCheckBox.setOnCheckedChangeListener(this);
  mName=(TextView)layout.findViewById(R.id.addon_title);
  mDescription=(TextView)layout.findViewById(R.id.addon_description);
  mAddOnIcon=(ImageView)layout.findViewById(R.id.addon_image);
  mIconOverlay=layout.findViewById(R.id.addon_image_more_overlay);
  populateViews();
  return layout;
}
Program: 157392
Project: 157392
Buggy source:
public AddOnStoreSearchPreference(Context context,AttributeSet attrs){
  super(context,attrs);
  setPersistent(false);
}

Fixed version (ground truth):
public AddOnStoreSearchPreference(Context context,AttributeSet attrs){
  super(context,attrs);
  setLayoutResource(R.layout.addon_store_search_pref);
  setPersistent(false);
}
Program: 157393
Project: 157393
Buggy source:
@Override protected View onCreateView(ViewGroup parent){
  LayoutInflater inflater=LayoutInflater.from(getContext());
  View layout=inflater.inflate(R.layout.addon_store_search_pref,parent,false);
  layout.setOnClickListener(this);
  CharSequence title=getTitle();
  if (!TextUtils.isEmpty(title)) {
    TextView cta=(TextView)layout.findViewById(R.id.cta_title);
    cta.setText(title);
  }
  mStoreNotFoundView=layout.findViewById(R.id.no_store_found_error);
  mStoreNotFoundView.setVisibility(View.GONE);
  return layout;
}

Fixed version (ground truth):
@Override protected View onCreateView(ViewGroup parent){
  View layout=super.onCreateView(parent);
  layout.setOnClickListener(this);
  CharSequence title=getTitle();
  if (!TextUtils.isEmpty(title)) {
    TextView cta=(TextView)layout.findViewById(R.id.cta_title);
    cta.setText(title);
  }
  mStoreNotFoundView=layout.findViewById(R.id.no_store_found_error);
  mStoreNotFoundView.setVisibility(View.GONE);
  return layout;
}
Program: 157394
Project: 157394
Buggy source:
@Override protected View onCreateView(ViewGroup parent){
  LayoutInflater inflater=(LayoutInflater)getContext().getSystemService(Service.LAYOUT_INFLATER_SERVICE);
  ViewGroup rootLayout=(ViewGroup)inflater.inflate(R.layout.about_app_pref,null);
  ImageView appIcon=(ImageView)rootLayout.findViewById(R.id.app_icon);
  if (mAppIconResId == 0) {
    appIcon.setVisibility(View.GONE);
  }
 else {
    appIcon.setImageResource(mAppIconResId);
  }
  TextView name=(TextView)rootLayout.findViewById(R.id.app_name);
  name.setText(mAppName);
  String appVersionName="String_Node_Str";
  int appVersionNumber=0;
  try {
    PackageInfo info=getContext().getPackageManager().getPackageInfo(getContext().getPackageName(),0);
    appVersionName=info.versionName;
    appVersionNumber=info.versionCode;
  }
 catch (  PackageManager.NameNotFoundException e) {
    e.printStackTrace();
  }
  TextView version=(TextView)rootLayout.findViewById(R.id.app_version);
  version.setText(getContext().getString(R.string.version_text,appVersionName,appVersionNumber));
  TextView appCopyright=(TextView)rootLayout.findViewById(R.id.app_copyright);
  if (mAppOwner == null) {
    appCopyright.setVisibility(View.GONE);
  }
 else {
    int year=Calendar.getInstance().get(Calendar.YEAR);
    appCopyright.setText(getContext().getString(R.string.copyright_text,year,mAppOwner));
  }
  return rootLayout;
}

Fixed version (ground truth):
@Override protected View onCreateView(ViewGroup parent){
  View rootLayout=super.onCreateView(parent);
  ImageView appIcon=(ImageView)rootLayout.findViewById(R.id.app_icon);
  if (mAppIconResId == 0) {
    appIcon.setVisibility(View.GONE);
  }
 else {
    appIcon.setImageResource(mAppIconResId);
  }
  TextView name=(TextView)rootLayout.findViewById(R.id.app_name);
  name.setText(mAppName);
  String appVersionName="String_Node_Str";
  int appVersionNumber=0;
  try {
    PackageInfo info=getContext().getPackageManager().getPackageInfo(getContext().getPackageName(),0);
    appVersionName=info.versionName;
    appVersionNumber=info.versionCode;
  }
 catch (  PackageManager.NameNotFoundException e) {
    e.printStackTrace();
  }
  TextView version=(TextView)rootLayout.findViewById(R.id.app_version);
  version.setText(getContext().getString(R.string.version_text,appVersionName,appVersionNumber));
  TextView appCopyright=(TextView)rootLayout.findViewById(R.id.app_copyright);
  if (mAppOwner == null) {
    appCopyright.setVisibility(View.GONE);
  }
 else {
    int year=Calendar.getInstance().get(Calendar.YEAR);
    appCopyright.setText(getContext().getString(R.string.copyright_text,year,mAppOwner));
  }
  return rootLayout;
}
Program: 157395
Project: 157395
Buggy source:
public AboutAppPreference(Context context,AttributeSet attrs){
  super(context,attrs);
  setSelectable(false);
  setPersistent(false);
  TypedArray array=context.obtainStyledAttributes(attrs,R.styleable.AboutAppPreferenceAttributes);
  mAppIconResId=array.getResourceId(R.styleable.AboutAppPreferenceAttributes_appIcon,0);
  mAppName=getStringOrReference(array,R.styleable.AboutAppPreferenceAttributes_appName);
  mAppOwner=getStringOrReference(array,R.styleable.AboutAppPreferenceAttributes_appOwner);
  array.recycle();
}

Fixed version (ground truth):
public AboutAppPreference(Context context,AttributeSet attrs){
  super(context,attrs);
  setLayoutResource(R.layout.about_app_pref);
  setSelectable(false);
  setPersistent(false);
  TypedArray array=context.obtainStyledAttributes(attrs,R.styleable.AboutAppPreferenceAttributes);
  mAppIconResId=array.getResourceId(R.styleable.AboutAppPreferenceAttributes_appIcon,0);
  mAppName=getStringOrReference(array,R.styleable.AboutAppPreferenceAttributes_appName);
  mAppOwner=getStringOrReference(array,R.styleable.AboutAppPreferenceAttributes_appOwner);
  array.recycle();
}
Program: 157396
Project: 157396
Buggy source:
public SlidePreference(Context context,AttributeSet attrs){
  super(context,attrs);
  mContext=context;
  TypedArray array=context.obtainStyledAttributes(attrs,R.styleable.SlidePreferenceAttributes);
  mDefault=array.getInteger(R.styleable.SlidePreferenceAttributes_android_defaultValue,0);
  mMax=array.getInteger(R.styleable.SlidePreferenceAttributes_slideMaximum,100);
  mMin=array.getInteger(R.styleable.SlidePreferenceAttributes_slideMinimum,0);
  int titleResId=array.getResourceId(R.styleable.SlidePreferenceAttributes_android_title,0);
  if (titleResId == 0)   mTitle=array.getString(R.styleable.SlidePreferenceAttributes_android_title);
 else   mTitle=context.getString(titleResId);
  array.recycle();
}

Fixed version (ground truth):
public SlidePreference(Context context,AttributeSet attrs){
  super(context,attrs);
  setLayoutResource(R.layout.slide_pref);
  TypedArray array=context.obtainStyledAttributes(attrs,R.styleable.SlidePreferenceAttributes);
  mDefault=array.getInteger(R.styleable.SlidePreferenceAttributes_android_defaultValue,0);
  mMax=array.getInteger(R.styleable.SlidePreferenceAttributes_slideMaximum,100);
  mMin=array.getInteger(R.styleable.SlidePreferenceAttributes_slideMinimum,0);
  int titleResId=array.getResourceId(R.styleable.SlidePreferenceAttributes_android_title,0);
  if (titleResId == 0)   mTitle=array.getString(R.styleable.SlidePreferenceAttributes_android_title);
 else   mTitle=context.getString(titleResId);
  array.recycle();
}