nus-yam/ex-repair huggingface dataset:
Program: 42209
Project: 42209
Buggy source:
/** 
 * Constructor - fires it up and makes it look like the search UI.
 * @param context Application Context we can use for system acess
 */
public SearchDialog(Context context,SearchManager searchManager){
  super(context,com.android.internal.R.style.Theme_SearchBar);
  mVoiceWebSearchIntent=new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
  mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
  mVoiceAppSearchIntent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  mSearchManager=searchManager;
  IntentFilter filter=new IntentFilter();
  filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
  context.registerReceiver(new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      if (intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
        onConfigurationChanged();
      }
    }
  }
,filter);
}

Fixed version (ground truth):
/** 
 * Constructor - fires it up and makes it look like the search UI.
 * @param context Application Context we can use for system acess
 */
public SearchDialog(Context context,SearchManager searchManager){
  super(context,com.android.internal.R.style.Theme_SearchBar);
  mVoiceWebSearchIntent=new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
  mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
  mVoiceAppSearchIntent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  mSearchManager=searchManager;
}
Program: 42210
Project: 42210
Buggy source:
/** 
 * The search dialog is being dismissed, so handle all of the local shutdown operations. This function is designed to be idempotent so that dismiss() can be safely called at any time (even if already closed) and more likely to really dump any memory.  No leaks!
 */
@Override public void onStop(){
  super.onStop();
  closeSuggestionsAdapter();
  mLaunchComponent=null;
  mAppSearchData=null;
  mSearchable=null;
  mUserQuery=null;
}

Fixed version (ground truth):
/** 
 * The search dialog is being dismissed, so handle all of the local shutdown operations. This function is designed to be idempotent so that dismiss() can be safely called at any time (even if already closed) and more likely to really dump any memory.  No leaks!
 */
@Override public void onStop(){
  super.onStop();
  getContext().unregisterReceiver(mConfChangeListener);
  closeSuggestionsAdapter();
  mLaunchComponent=null;
  mAppSearchData=null;
  mSearchable=null;
  mUserQuery=null;
}
Program: 42212
Project: 42212
Buggy source:
/** 
 * Constructor - fires it up and makes it look like the search UI.
 * @param context Application Context we can use for system acess
 */
public SearchDialog(Context context,SearchManager searchManager){
  super(context,com.android.internal.R.style.Theme_SearchBar);
  mVoiceWebSearchIntent=new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
  mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
  mVoiceAppSearchIntent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  mSearchManager=searchManager;
  IntentFilter filter=new IntentFilter();
  filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
  context.registerReceiver(new BroadcastReceiver(){
    @Override public void onReceive(    Context context,    Intent intent){
      if (intent.getAction().equals(Intent.ACTION_CONFIGURATION_CHANGED)) {
        onConfigurationChanged();
      }
    }
  }
,filter);
}

Fixed version (ground truth):
/** 
 * Constructor - fires it up and makes it look like the search UI.
 * @param context Application Context we can use for system acess
 */
public SearchDialog(Context context,SearchManager searchManager){
  super(context,com.android.internal.R.style.Theme_SearchBar);
  mVoiceWebSearchIntent=new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
  mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
  mVoiceAppSearchIntent=new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
  mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  mSearchManager=searchManager;
}
Program: 42213
Project: 42213
Buggy source:
/** 
 * The search dialog is being dismissed, so handle all of the local shutdown operations. This function is designed to be idempotent so that dismiss() can be safely called at any time (even if already closed) and more likely to really dump any memory.  No leaks!
 */
@Override public void onStop(){
  super.onStop();
  closeSuggestionsAdapter();
  mLaunchComponent=null;
  mAppSearchData=null;
  mSearchable=null;
  mUserQuery=null;
}

Fixed version (ground truth):
/** 
 * The search dialog is being dismissed, so handle all of the local shutdown operations. This function is designed to be idempotent so that dismiss() can be safely called at any time (even if already closed) and more likely to really dump any memory.  No leaks!
 */
@Override public void onStop(){
  super.onStop();
  getContext().unregisterReceiver(mConfChangeListener);
  closeSuggestionsAdapter();
  mLaunchComponent=null;
  mAppSearchData=null;
  mSearchable=null;
  mUserQuery=null;
}
Program: 42214
Project: 42214
Buggy source:
/** 
 * Register a listener for audio focus updates.
 */
public void registerAudioFocusListener(OnAudioFocusChangeListener l){
  if (l == null) {
    return;
  }
synchronized (mFocusListenerLock) {
    if (mAudioFocusIdListenerMap.containsKey(getIdForAudioFocusListener(l))) {
      return;
    }
    mAudioFocusIdListenerMap.put(getIdForAudioFocusListener(l),l);
  }
}

Fixed version (ground truth):
/** 
 * Register a listener for audio focus updates.
 */
public void registerAudioFocusListener(OnAudioFocusChangeListener l){
synchronized (mFocusListenerLock) {
    if (mAudioFocusIdListenerMap.containsKey(getIdForAudioFocusListener(l))) {
      return;
    }
    mAudioFocusIdListenerMap.put(getIdForAudioFocusListener(l),l);
  }
}
Program: 42215
Project: 42215
Buggy source:
private String getIdForAudioFocusListener(OnAudioFocusChangeListener l){
  if (l == null) {
    return new String();
  }
 else {
    return new String(this.toString() + l.toString());
  }
}

Fixed version (ground truth):
private String getIdForAudioFocusListener(OnAudioFocusChangeListener l){
  if (l == null) {
    return new String(this.toString());
  }
 else {
    return new String(this.toString() + l.toString());
  }
}
Program: 42218
Project: 42218
Buggy source:
/** 
 * Register a listener for audio focus updates.
 */
public void registerAudioFocusListener(OnAudioFocusChangeListener l){
  if (l == null) {
    return;
  }
synchronized (mFocusListenerLock) {
    if (mAudioFocusIdListenerMap.containsKey(getIdForAudioFocusListener(l))) {
      return;
    }
    mAudioFocusIdListenerMap.put(getIdForAudioFocusListener(l),l);
  }
}

Fixed version (ground truth):
/** 
 * Register a listener for audio focus updates.
 */
public void registerAudioFocusListener(OnAudioFocusChangeListener l){
synchronized (mFocusListenerLock) {
    if (mAudioFocusIdListenerMap.containsKey(getIdForAudioFocusListener(l))) {
      return;
    }
    mAudioFocusIdListenerMap.put(getIdForAudioFocusListener(l),l);
  }
}
Program: 42219
Project: 42219
Buggy source:
private String getIdForAudioFocusListener(OnAudioFocusChangeListener l){
  if (l == null) {
    return new String();
  }
 else {
    return new String(this.toString() + l.toString());
  }
}

Fixed version (ground truth):
private String getIdForAudioFocusListener(OnAudioFocusChangeListener l){
  if (l == null) {
    return new String(this.toString());
  }
 else {
    return new String(this.toString() + l.toString());
  }
}
Program: 42221
Project: 42221
Buggy source:
/** 
 * @param contentResolver Used to look up and save settings.
 */
public LockPatternUtils(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  mDevicePolicyManager=getDevicePolicyManager();
  if (sLockPatternFilename == null) {
    sLockPatternFilename=android.os.Environment.getDataDirectory().getAbsolutePath() + LOCK_PATTERN_FILE;
    sLockPasswordFilename=android.os.Environment.getDataDirectory().getAbsolutePath() + LOCK_PASSWORD_FILE;
  }
}

Fixed version (ground truth):
/** 
 * @param contentResolver Used to look up and save settings.
 */
public LockPatternUtils(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  if (sLockPatternFilename == null) {
    sLockPatternFilename=android.os.Environment.getDataDirectory().getAbsolutePath() + LOCK_PATTERN_FILE;
    sLockPasswordFilename=android.os.Environment.getDataDirectory().getAbsolutePath() + LOCK_PASSWORD_FILE;
  }
}
Program: 42222
Project: 42222
Buggy source:
public void testScreenRequestsRecreation(){
  mLPKV.wakeWhenReadyTq(0);
  mLPKV.onScreenTurnedOn();
  assertEquals(1,mLPKV.getInjectedLockScreens().size());
  assertEquals(1,mLPKV.getInjectedUnlockScreens().size());
  MockKeyguardScreen lockScreen=mLPKV.getInjectedLockScreens().get(0);
  assertEquals(0,lockScreen.getOnPauseCount());
  assertEquals(1,lockScreen.getOnResumeCount());
  mLPKV.mKeyguardScreenCallback.recreateMe();
  assertEquals(2,mLPKV.getInjectedLockScreens().size());
  assertEquals(2,mLPKV.getInjectedUnlockScreens().size());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(0).getCleanupCount());
  assertEquals(1,mLPKV.getInjectedUnlockScreens().get(0).getCleanupCount());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(0).getOnPauseCount());
  assertEquals(0,mLPKV.getInjectedUnlockScreens().get(0).getOnPauseCount());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(1).getOnResumeCount());
  assertEquals(0,mLPKV.getInjectedUnlockScreens().get(1).getOnResumeCount());
}

Fixed version (ground truth):
public void testScreenRequestsRecreation(){
  mLPKV.wakeWhenReadyTq(0);
  mLPKV.onScreenTurnedOn();
  assertEquals(1,mLPKV.getInjectedLockScreens().size());
  assertEquals(1,mLPKV.getInjectedUnlockScreens().size());
  MockKeyguardScreen lockScreen=mLPKV.getInjectedLockScreens().get(0);
  assertEquals(0,lockScreen.getOnPauseCount());
  assertEquals(1,lockScreen.getOnResumeCount());
  mLPKV.mKeyguardScreenCallback.recreateMe(new Configuration());
  assertEquals(2,mLPKV.getInjectedLockScreens().size());
  assertEquals(2,mLPKV.getInjectedUnlockScreens().size());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(0).getCleanupCount());
  assertEquals(1,mLPKV.getInjectedUnlockScreens().get(0).getCleanupCount());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(0).getOnPauseCount());
  assertEquals(0,mLPKV.getInjectedUnlockScreens().get(0).getOnPauseCount());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(1).getOnResumeCount());
  assertEquals(0,mLPKV.getInjectedUnlockScreens().get(1).getOnResumeCount());
}
Program: 42223
Project: 42223
Buggy source:
public void onTouchModeChanged(boolean isInTouchMode){
  if (isInTouchMode) {
    hideSelector();
    if (getHeight() > 0 && getChildCount() > 0) {
      layoutChildren();
    }
  }
 else {
    int touchMode=mTouchMode;
    if (touchMode == TOUCH_MODE_OVERSCROLL || touchMode == TOUCH_MODE_OVERFLING) {
      if (mFlingRunnable != null) {
        mFlingRunnable.endFling();
      }
      if (mScrollY != 0) {
        mScrollY=0;
        invalidate();
      }
    }
  }
  mLastTouchMode=isInTouchMode ? TOUCH_MODE_ON : TOUCH_MODE_OFF;
}

Fixed version (ground truth):
public void onTouchModeChanged(boolean isInTouchMode){
  if (isInTouchMode) {
    hideSelector();
    if (getHeight() > 0 && getChildCount() > 0) {
      layoutChildren();
    }
  }
 else {
    int touchMode=mTouchMode;
    if (touchMode == TOUCH_MODE_OVERSCROLL || touchMode == TOUCH_MODE_OVERFLING) {
      if (mFlingRunnable != null) {
        mFlingRunnable.endFling();
      }
      if (mScrollY != 0) {
        mScrollY=0;
        invalidate();
      }
    }
  }
}
Program: 42224
Project: 42224
Buggy source:
/** 
 * AccountUnlockScreen constructor.
 */
public AccountUnlockScreen(Context context,KeyguardScreenCallback callback,LockPatternUtils lockPatternUtils){
  super(context);
  mCallback=callback;
  mLockPatternUtils=lockPatternUtils;
  LayoutInflater.from(context).inflate(R.layout.keyguard_screen_glogin_unlock,this,true);
  mTopHeader=(TextView)findViewById(R.id.topHeader);
  mTopHeader.setText(mLockPatternUtils.isPermanentlyLocked() ? R.string.lockscreen_glogin_too_many_attempts : R.string.lockscreen_glogin_forgot_pattern);
  mInstructions=(TextView)findViewById(R.id.instructions);
  mLogin=(EditText)findViewById(R.id.login);
  mLogin.setFilters(new InputFilter[]{new LoginFilter.UsernameFilterGeneric()});
  mLogin.addTextChangedListener(this);
  mPassword=(EditText)findViewById(R.id.password);
  mPassword.addTextChangedListener(this);
  mOk=(Button)findViewById(R.id.ok);
  mOk.setOnClickListener(this);
  mEmergencyCall=(Button)findViewById(R.id.emergencyCall);
  mEmergencyCall.setOnClickListener(this);
  mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCall);
}

Fixed version (ground truth):
/** 
 * AccountUnlockScreen constructor.
 * @param configuration
 */
public AccountUnlockScreen(Context context,Configuration configuration,KeyguardScreenCallback callback,LockPatternUtils lockPatternUtils){
  super(context);
  mCallback=callback;
  mLockPatternUtils=lockPatternUtils;
  LayoutInflater.from(context).inflate(R.layout.keyguard_screen_glogin_unlock,this,true);
  mTopHeader=(TextView)findViewById(R.id.topHeader);
  mTopHeader.setText(mLockPatternUtils.isPermanentlyLocked() ? R.string.lockscreen_glogin_too_many_attempts : R.string.lockscreen_glogin_forgot_pattern);
  mInstructions=(TextView)findViewById(R.id.instructions);
  mLogin=(EditText)findViewById(R.id.login);
  mLogin.setFilters(new InputFilter[]{new LoginFilter.UsernameFilterGeneric()});
  mLogin.addTextChangedListener(this);
  mPassword=(EditText)findViewById(R.id.password);
  mPassword.addTextChangedListener(this);
  mOk=(Button)findViewById(R.id.ok);
  mOk.setOnClickListener(this);
  mEmergencyCall=(Button)findViewById(R.id.emergencyCall);
  mEmergencyCall.setOnClickListener(this);
  mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCall);
}
Program: 42225
Project: 42225
Buggy source:
/** 
 * Stay on me, but recreate me (so I can use a different layout).
 */
void recreateMe();

Fixed version (ground truth):
/** 
 * Stay on me, but recreate me (so I can use a different layout).
 */
void recreateMe(Configuration config);
Program: 42226
Project: 42226
Buggy source:
/** 
 * Remove the given observer from being registered from any of the kinds of callbacks.
 * @param observer The observer to remove (an instance of {@link ConfigurationChangeCallback},  {@link InfoCallback} or {@link SimStateCallback}
 */
public void removeCallback(Object observer){
  mConfigurationChangeCallbacks.remove(observer);
  mInfoCallbacks.remove(observer);
  mSimStateCallbacks.remove(observer);
}

Fixed version (ground truth):
/** 
 * Remove the given observer from being registered from any of the kinds of callbacks.
 * @param observer The observer to remove (an instance of {@link ConfigurationChangeCallback},  {@link InfoCallback} or {@link SimStateCallback}
 */
public void removeCallback(Object observer){
  mInfoCallbacks.remove(observer);
  mSimStateCallbacks.remove(observer);
}
Program: 42228
Project: 42228
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MSG_CONFIGURATION_CHANGED:
    handleConfigurationChange();
  break;
case MSG_TIME_UPDATE:
handleTimeUpdate();
break;
case MSG_BATTERY_UPDATE:
handleBatteryUpdate(msg.arg1,msg.arg2);
break;
case MSG_CARRIER_INFO_UPDATE:
handleCarrierInfoUpdate();
break;
case MSG_SIM_STATE_CHANGE:
handleSimStateChange((SimArgs)msg.obj);
break;
case MSG_RINGER_MODE_CHANGED:
handleRingerModeChange(msg.arg1);
break;
case MSG_PHONE_STATE_CHANGED:
handlePhoneStateChanged((String)msg.obj);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MSG_TIME_UPDATE:
    handleTimeUpdate();
  break;
case MSG_BATTERY_UPDATE:
handleBatteryUpdate(msg.arg1,msg.arg2);
break;
case MSG_CARRIER_INFO_UPDATE:
handleCarrierInfoUpdate();
break;
case MSG_SIM_STATE_CHANGE:
handleSimStateChange((SimArgs)msg.obj);
break;
case MSG_RINGER_MODE_CHANGED:
handleRingerModeChange(msg.arg1);
break;
case MSG_PHONE_STATE_CHANGED:
handlePhoneStateChanged((String)msg.obj);
break;
}
}
Program: 42230
Project: 42230
Buggy source:
View createLockScreen(){
  return new LockScreen(mContext,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback);
}

Fixed version (ground truth):
View createLockScreen(){
  return new LockScreen(mContext,mConfiguration,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback);
}
Program: 42232
Project: 42232
Buggy source:
View createUnlockScreenFor(UnlockMode unlockMode){
  mIsPortrait=getResources().getBoolean(R.bool.lockscreen_isPortrait);
  View unlockView=null;
  if (unlockMode == UnlockMode.Pattern) {
    PatternUnlockScreen view=new PatternUnlockScreen(mContext,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback,mUpdateMonitor.getFailedAttempts());
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + unlockMode + "String_Node_Str"+ mEnableFallback);
    view.setEnableFallback(mEnableFallback);
    unlockView=view;
  }
 else   if (unlockMode == UnlockMode.SimPin) {
    unlockView=new SimUnlockScreen(mContext,mUpdateMonitor,mKeyguardScreenCallback,mLockPatternUtils);
  }
 else   if (unlockMode == UnlockMode.Account) {
    try {
      unlockView=new AccountUnlockScreen(mContext,mKeyguardScreenCallback,mLockPatternUtils);
    }
 catch (    IllegalStateException e) {
      Log.i(TAG,"String_Node_Str" + "String_Node_Str");
      unlockView=createUnlockScreenFor(UnlockMode.Pattern);
    }
  }
 else   if (unlockMode == UnlockMode.Password) {
    unlockView=new PasswordUnlockScreen(mContext,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + unlockMode);
  }
  mCurrentUnlockMode=unlockMode;
  return unlockView;
}

Fixed version (ground truth):
View createUnlockScreenFor(UnlockMode unlockMode){
  View unlockView=null;
  if (unlockMode == UnlockMode.Pattern) {
    PatternUnlockScreen view=new PatternUnlockScreen(mContext,mConfiguration,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback,mUpdateMonitor.getFailedAttempts());
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + unlockMode + "String_Node_Str"+ mEnableFallback);
    view.setEnableFallback(mEnableFallback);
    unlockView=view;
  }
 else   if (unlockMode == UnlockMode.SimPin) {
    unlockView=new SimUnlockScreen(mContext,mConfiguration,mUpdateMonitor,mKeyguardScreenCallback,mLockPatternUtils);
  }
 else   if (unlockMode == UnlockMode.Account) {
    try {
      unlockView=new AccountUnlockScreen(mContext,mConfiguration,mKeyguardScreenCallback,mLockPatternUtils);
    }
 catch (    IllegalStateException e) {
      Log.i(TAG,"String_Node_Str" + "String_Node_Str");
      unlockView=createUnlockScreenFor(UnlockMode.Pattern);
    }
  }
 else   if (unlockMode == UnlockMode.Password) {
    unlockView=new PasswordUnlockScreen(mContext,mConfiguration,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + unlockMode);
  }
  mCurrentUnlockMode=unlockMode;
  return unlockView;
}
Program: 42233
Project: 42233
Buggy source:
@Override protected void dispatchDraw(Canvas canvas){
  final int orientation=getResources().getConfiguration().orientation;
  if (mIsPortrait && Configuration.ORIENTATION_PORTRAIT != orientation || getResources().getBoolean(R.bool.lockscreen_isPortrait) != mIsPortrait) {
    postInvalidate();
    ViewGroup view=(ViewGroup)(mMode == Mode.LockScreen ? mLockScreen : mUnlockScreen);
    if (view != null && view.getChildAt(0) != null) {
      Drawable background=view.getChildAt(0).getBackground();
      if (background != null) {
        background.draw(canvas);
      }
    }
    return;
  }
  super.dispatchDraw(canvas);
}

Fixed version (ground truth):
@Override protected void dispatchDraw(Canvas canvas){
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + SystemClock.elapsedRealtime());
  super.dispatchDraw(canvas);
}
Program: 42234
Project: 42234
Buggy source:
public void recreateMe(){
  recreateScreens();
}

Fixed version (ground truth):
public void recreateMe(Configuration config){
  mConfiguration=config;
  recreateScreens();
}
Program: 42235
Project: 42235
Buggy source:
public void onTouchModeChanged(boolean isInTouchMode){
  if (isInTouchMode) {
    hideSelector();
    if (getHeight() > 0 && getChildCount() > 0) {
      layoutChildren();
    }
  }
 else {
    int touchMode=mTouchMode;
    if (touchMode == TOUCH_MODE_OVERSCROLL || touchMode == TOUCH_MODE_OVERFLING) {
      if (mFlingRunnable != null) {
        mFlingRunnable.endFling();
      }
      if (mScrollY != 0) {
        mScrollY=0;
        invalidate();
      }
    }
  }
  mLastTouchMode=isInTouchMode ? TOUCH_MODE_ON : TOUCH_MODE_OFF;
}

Fixed version (ground truth):
public void onTouchModeChanged(boolean isInTouchMode){
  if (isInTouchMode) {
    hideSelector();
    if (getHeight() > 0 && getChildCount() > 0) {
      layoutChildren();
    }
  }
 else {
    int touchMode=mTouchMode;
    if (touchMode == TOUCH_MODE_OVERSCROLL || touchMode == TOUCH_MODE_OVERFLING) {
      if (mFlingRunnable != null) {
        mFlingRunnable.endFling();
      }
      if (mScrollY != 0) {
        mScrollY=0;
        invalidate();
      }
    }
  }
}
Program: 42236
Project: 42236
Buggy source:
/** 
 * Figures out the layout for the menu items.
 * @param width The available width for the icon menu.
 */
private void layoutItems(int width){
  int numItems=getChildCount();
  int curNumRows=Math.min((int)Math.ceil(numItems / (float)mMaxItemsPerRow),mMaxRows);
  for (; curNumRows <= mMaxRows; curNumRows++) {
    layoutItemsUsingGravity(curNumRows,numItems);
    if (curNumRows >= numItems) {
      break;
    }
    if (doItemsFit()) {
      break;
    }
  }
}

Fixed version (ground truth):
/** 
 * Figures out the layout for the menu items.
 * @param width The available width for the icon menu.
 */
private void layoutItems(int width){
  int numItems=getChildCount();
  if (numItems == 0) {
    mLayoutNumRows=0;
    return;
  }
  int curNumRows=Math.min((int)Math.ceil(numItems / (float)mMaxItemsPerRow),mMaxRows);
  for (; curNumRows <= mMaxRows; curNumRows++) {
    layoutItemsUsingGravity(curNumRows,numItems);
    if (curNumRows >= numItems) {
      break;
    }
    if (doItemsFit()) {
      break;
    }
  }
}
Program: 42237
Project: 42237
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  if (mHasStaleChildren) {
    mHasStaleChildren=false;
    updateChildren(false);
  }
  int measuredWidth=resolveSize(Integer.MAX_VALUE,widthMeasureSpec);
  calculateItemFittingMetadata(measuredWidth);
  layoutItems(measuredWidth);
  final int desiredHeight=(mRowHeight + mHorizontalDividerHeight) * mLayoutNumRows - mHorizontalDividerHeight;
  setMeasuredDimension(measuredWidth,resolveSize(desiredHeight,heightMeasureSpec));
  positionChildren(mMeasuredWidth,mMeasuredHeight);
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  if (mHasStaleChildren) {
    mHasStaleChildren=false;
    updateChildren(false);
  }
  int measuredWidth=resolveSize(Integer.MAX_VALUE,widthMeasureSpec);
  calculateItemFittingMetadata(measuredWidth);
  layoutItems(measuredWidth);
  final int layoutNumRows=mLayoutNumRows;
  final int desiredHeight=(mRowHeight + mHorizontalDividerHeight) * layoutNumRows - mHorizontalDividerHeight;
  setMeasuredDimension(measuredWidth,resolveSize(desiredHeight,heightMeasureSpec));
  if (layoutNumRows > 0) {
    positionChildren(mMeasuredWidth,mMeasuredHeight);
  }
}
Program: 42238
Project: 42238
Buggy source:
/** 
 * Figures out the layout for the menu items.
 * @param width The available width for the icon menu.
 */
private void layoutItems(int width){
  int numItems=getChildCount();
  int curNumRows=Math.min((int)Math.ceil(numItems / (float)mMaxItemsPerRow),mMaxRows);
  for (; curNumRows <= mMaxRows; curNumRows++) {
    layoutItemsUsingGravity(curNumRows,numItems);
    if (curNumRows >= numItems) {
      break;
    }
    if (doItemsFit()) {
      break;
    }
  }
}

Fixed version (ground truth):
/** 
 * Figures out the layout for the menu items.
 * @param width The available width for the icon menu.
 */
private void layoutItems(int width){
  int numItems=getChildCount();
  if (numItems == 0) {
    mLayoutNumRows=0;
    return;
  }
  int curNumRows=Math.min((int)Math.ceil(numItems / (float)mMaxItemsPerRow),mMaxRows);
  for (; curNumRows <= mMaxRows; curNumRows++) {
    layoutItemsUsingGravity(curNumRows,numItems);
    if (curNumRows >= numItems) {
      break;
    }
    if (doItemsFit()) {
      break;
    }
  }
}
Program: 42239
Project: 42239
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  if (mHasStaleChildren) {
    mHasStaleChildren=false;
    updateChildren(false);
  }
  int measuredWidth=resolveSize(Integer.MAX_VALUE,widthMeasureSpec);
  calculateItemFittingMetadata(measuredWidth);
  layoutItems(measuredWidth);
  final int desiredHeight=(mRowHeight + mHorizontalDividerHeight) * mLayoutNumRows - mHorizontalDividerHeight;
  setMeasuredDimension(measuredWidth,resolveSize(desiredHeight,heightMeasureSpec));
  positionChildren(mMeasuredWidth,mMeasuredHeight);
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  if (mHasStaleChildren) {
    mHasStaleChildren=false;
    updateChildren(false);
  }
  int measuredWidth=resolveSize(Integer.MAX_VALUE,widthMeasureSpec);
  calculateItemFittingMetadata(measuredWidth);
  layoutItems(measuredWidth);
  final int layoutNumRows=mLayoutNumRows;
  final int desiredHeight=(mRowHeight + mHorizontalDividerHeight) * layoutNumRows - mHorizontalDividerHeight;
  setMeasuredDimension(measuredWidth,resolveSize(desiredHeight,heightMeasureSpec));
  if (layoutNumRows > 0) {
    positionChildren(mMeasuredWidth,mMeasuredHeight);
  }
}
Program: 42240
Project: 42240
Buggy source:
/** 
 * See if the key event means we should leave touch mode (and leave touch mode if so).
 * @param event The key event.
 * @return Whether this key event should be consumed (meaning the act ofleaving touch mode alone is considered the event).
 */
private boolean checkForLeavingTouchModeAndConsume(KeyEvent event){
  if (event.getAction() != KeyEvent.ACTION_DOWN) {
    return false;
  }
  if ((event.getFlags() & KeyEvent.FLAG_KEEP_TOUCH_MODE) != 0) {
    return false;
  }
  if (!mAttachInfo.mInTouchMode) {
    return false;
  }
  if (isKeyboardKey(event) && mView != null && mView.hasFocus()) {
    mFocusedView=mView.findFocus();
    if ((mFocusedView instanceof ViewGroup) && ((ViewGroup)mFocusedView).getDescendantFocusability() == ViewGroup.FOCUS_AFTER_DESCENDANTS) {
      return false;
    }
    if (ensureTouchMode(false)) {
      throw new IllegalStateException("String_Node_Str" + "String_Node_Str");
    }
    return false;
  }
  if (isDirectional(event.getKeyCode())) {
    return ensureTouchMode(false);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * See if the key event means we should leave touch mode (and leave touch mode if so).
 * @param event The key event.
 * @return Whether this key event should be consumed (meaning the act ofleaving touch mode alone is considered the event).
 */
private boolean checkForLeavingTouchModeAndConsume(KeyEvent event){
  final int action=event.getAction();
  if (action != KeyEvent.ACTION_DOWN && action != KeyEvent.ACTION_MULTIPLE) {
    return false;
  }
  if ((event.getFlags() & KeyEvent.FLAG_KEEP_TOUCH_MODE) != 0) {
    return false;
  }
  if (!mAttachInfo.mInTouchMode) {
    return false;
  }
  if (isKeyboardKey(event) && mView != null && mView.hasFocus()) {
    mFocusedView=mView.findFocus();
    if ((mFocusedView instanceof ViewGroup) && ((ViewGroup)mFocusedView).getDescendantFocusability() == ViewGroup.FOCUS_AFTER_DESCENDANTS) {
      return false;
    }
    if (ensureTouchMode(false)) {
      throw new IllegalStateException("String_Node_Str" + "String_Node_Str");
    }
    return false;
  }
  if (isDirectional(event.getKeyCode())) {
    return ensureTouchMode(false);
  }
  return false;
}
Program: 42241
Project: 42241
Buggy source:
public void onTouchModeChanged(boolean isInTouchMode){
  if (isInTouchMode) {
    hideSelector();
    if (getHeight() > 0 && getChildCount() > 0) {
      layoutChildren();
    }
  }
 else {
    int touchMode=mTouchMode;
    if (touchMode == TOUCH_MODE_OVERSCROLL || touchMode == TOUCH_MODE_OVERFLING) {
      if (mFlingRunnable != null) {
        mFlingRunnable.endFling();
        if (mScrollY != 0) {
          mScrollY=0;
          invalidate();
        }
      }
    }
  }
  mLastTouchMode=isInTouchMode ? TOUCH_MODE_ON : TOUCH_MODE_OFF;
}

Fixed version (ground truth):
public void onTouchModeChanged(boolean isInTouchMode){
  if (isInTouchMode) {
    hideSelector();
    if (getHeight() > 0 && getChildCount() > 0) {
      layoutChildren();
    }
  }
 else {
    int touchMode=mTouchMode;
    if (touchMode == TOUCH_MODE_OVERSCROLL || touchMode == TOUCH_MODE_OVERFLING) {
      if (mFlingRunnable != null) {
        mFlingRunnable.endFling();
      }
      if (mScrollY != 0) {
        mScrollY=0;
        invalidate();
      }
    }
  }
  mLastTouchMode=isInTouchMode ? TOUCH_MODE_ON : TOUCH_MODE_OFF;
}
Program: 42242
Project: 42242
Buggy source:
/** 
 * AccountUnlockScreen constructor.
 */
public AccountUnlockScreen(Context context,KeyguardScreenCallback callback,LockPatternUtils lockPatternUtils){
  super(context);
  mCallback=callback;
  mLockPatternUtils=lockPatternUtils;
  LayoutInflater.from(context).inflate(R.layout.keyguard_screen_glogin_unlock,this,true);
  mTopHeader=(TextView)findViewById(R.id.topHeader);
  mTopHeader.setText(mLockPatternUtils.isPermanentlyLocked() ? R.string.lockscreen_glogin_too_many_attempts : R.string.lockscreen_glogin_forgot_pattern);
  mInstructions=(TextView)findViewById(R.id.instructions);
  mLogin=(EditText)findViewById(R.id.login);
  mLogin.setFilters(new InputFilter[]{new LoginFilter.UsernameFilterGeneric()});
  mLogin.addTextChangedListener(this);
  mPassword=(EditText)findViewById(R.id.password);
  mPassword.addTextChangedListener(this);
  mOk=(Button)findViewById(R.id.ok);
  mOk.setOnClickListener(this);
  mEmergencyCall=(Button)findViewById(R.id.emergencyCall);
  mEmergencyCall.setOnClickListener(this);
  mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCall);
}

Fixed version (ground truth):
/** 
 * AccountUnlockScreen constructor.
 * @param configuration
 */
public AccountUnlockScreen(Context context,Configuration configuration,KeyguardScreenCallback callback,LockPatternUtils lockPatternUtils){
  super(context);
  mCallback=callback;
  mLockPatternUtils=lockPatternUtils;
  LayoutInflater.from(context).inflate(R.layout.keyguard_screen_glogin_unlock,this,true);
  mTopHeader=(TextView)findViewById(R.id.topHeader);
  mTopHeader.setText(mLockPatternUtils.isPermanentlyLocked() ? R.string.lockscreen_glogin_too_many_attempts : R.string.lockscreen_glogin_forgot_pattern);
  mInstructions=(TextView)findViewById(R.id.instructions);
  mLogin=(EditText)findViewById(R.id.login);
  mLogin.setFilters(new InputFilter[]{new LoginFilter.UsernameFilterGeneric()});
  mLogin.addTextChangedListener(this);
  mPassword=(EditText)findViewById(R.id.password);
  mPassword.addTextChangedListener(this);
  mOk=(Button)findViewById(R.id.ok);
  mOk.setOnClickListener(this);
  mEmergencyCall=(Button)findViewById(R.id.emergencyCall);
  mEmergencyCall.setOnClickListener(this);
  mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCall);
}
Program: 42243
Project: 42243
Buggy source:
/** 
 * Stay on me, but recreate me (so I can use a different layout).
 */
void recreateMe();

Fixed version (ground truth):
/** 
 * Stay on me, but recreate me (so I can use a different layout).
 */
void recreateMe(Configuration config);
Program: 42244
Project: 42244
Buggy source:
/** 
 * Remove the given observer from being registered from any of the kinds of callbacks.
 * @param observer The observer to remove (an instance of {@link ConfigurationChangeCallback},  {@link InfoCallback} or {@link SimStateCallback}
 */
public void removeCallback(Object observer){
  mConfigurationChangeCallbacks.remove(observer);
  mInfoCallbacks.remove(observer);
  mSimStateCallbacks.remove(observer);
}

Fixed version (ground truth):
/** 
 * Remove the given observer from being registered from any of the kinds of callbacks.
 * @param observer The observer to remove (an instance of {@link ConfigurationChangeCallback},  {@link InfoCallback} or {@link SimStateCallback}
 */
public void removeCallback(Object observer){
  mInfoCallbacks.remove(observer);
  mSimStateCallbacks.remove(observer);
}
Program: 42246
Project: 42246
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MSG_CONFIGURATION_CHANGED:
    handleConfigurationChange();
  break;
case MSG_TIME_UPDATE:
handleTimeUpdate();
break;
case MSG_BATTERY_UPDATE:
handleBatteryUpdate(msg.arg1,msg.arg2);
break;
case MSG_CARRIER_INFO_UPDATE:
handleCarrierInfoUpdate();
break;
case MSG_SIM_STATE_CHANGE:
handleSimStateChange((SimArgs)msg.obj);
break;
case MSG_RINGER_MODE_CHANGED:
handleRingerModeChange(msg.arg1);
break;
case MSG_PHONE_STATE_CHANGED:
handlePhoneStateChanged((String)msg.obj);
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case MSG_TIME_UPDATE:
    handleTimeUpdate();
  break;
case MSG_BATTERY_UPDATE:
handleBatteryUpdate(msg.arg1,msg.arg2);
break;
case MSG_CARRIER_INFO_UPDATE:
handleCarrierInfoUpdate();
break;
case MSG_SIM_STATE_CHANGE:
handleSimStateChange((SimArgs)msg.obj);
break;
case MSG_RINGER_MODE_CHANGED:
handleRingerModeChange(msg.arg1);
break;
case MSG_PHONE_STATE_CHANGED:
handlePhoneStateChanged((String)msg.obj);
break;
}
}
Program: 42248
Project: 42248
Buggy source:
View createLockScreen(){
  return new LockScreen(mContext,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback);
}

Fixed version (ground truth):
View createLockScreen(){
  return new LockScreen(mContext,mConfiguration,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback);
}
Program: 42250
Project: 42250
Buggy source:
View createUnlockScreenFor(UnlockMode unlockMode){
  mIsPortrait=getResources().getBoolean(R.bool.lockscreen_isPortrait);
  View unlockView=null;
  if (unlockMode == UnlockMode.Pattern) {
    PatternUnlockScreen view=new PatternUnlockScreen(mContext,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback,mUpdateMonitor.getFailedAttempts());
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + unlockMode + "String_Node_Str"+ mEnableFallback);
    view.setEnableFallback(mEnableFallback);
    unlockView=view;
  }
 else   if (unlockMode == UnlockMode.SimPin) {
    unlockView=new SimUnlockScreen(mContext,mUpdateMonitor,mKeyguardScreenCallback,mLockPatternUtils);
  }
 else   if (unlockMode == UnlockMode.Account) {
    try {
      unlockView=new AccountUnlockScreen(mContext,mKeyguardScreenCallback,mLockPatternUtils);
    }
 catch (    IllegalStateException e) {
      Log.i(TAG,"String_Node_Str" + "String_Node_Str");
      unlockView=createUnlockScreenFor(UnlockMode.Pattern);
    }
  }
 else   if (unlockMode == UnlockMode.Password) {
    unlockView=new PasswordUnlockScreen(mContext,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + unlockMode);
  }
  mCurrentUnlockMode=unlockMode;
  return unlockView;
}

Fixed version (ground truth):
View createUnlockScreenFor(UnlockMode unlockMode){
  View unlockView=null;
  if (unlockMode == UnlockMode.Pattern) {
    PatternUnlockScreen view=new PatternUnlockScreen(mContext,mConfiguration,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback,mUpdateMonitor.getFailedAttempts());
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + unlockMode + "String_Node_Str"+ mEnableFallback);
    view.setEnableFallback(mEnableFallback);
    unlockView=view;
  }
 else   if (unlockMode == UnlockMode.SimPin) {
    unlockView=new SimUnlockScreen(mContext,mConfiguration,mUpdateMonitor,mKeyguardScreenCallback,mLockPatternUtils);
  }
 else   if (unlockMode == UnlockMode.Account) {
    try {
      unlockView=new AccountUnlockScreen(mContext,mConfiguration,mKeyguardScreenCallback,mLockPatternUtils);
    }
 catch (    IllegalStateException e) {
      Log.i(TAG,"String_Node_Str" + "String_Node_Str");
      unlockView=createUnlockScreenFor(UnlockMode.Pattern);
    }
  }
 else   if (unlockMode == UnlockMode.Password) {
    unlockView=new PasswordUnlockScreen(mContext,mConfiguration,mLockPatternUtils,mUpdateMonitor,mKeyguardScreenCallback);
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + unlockMode);
  }
  mCurrentUnlockMode=unlockMode;
  return unlockView;
}
Program: 42251
Project: 42251
Buggy source:
@Override protected void dispatchDraw(Canvas canvas){
  final int orientation=getResources().getConfiguration().orientation;
  if (mIsPortrait && Configuration.ORIENTATION_PORTRAIT != orientation || getResources().getBoolean(R.bool.lockscreen_isPortrait) != mIsPortrait) {
    postInvalidate();
    ViewGroup view=(ViewGroup)(mMode == Mode.LockScreen ? mLockScreen : mUnlockScreen);
    if (view != null && view.getChildAt(0) != null) {
      Drawable background=view.getChildAt(0).getBackground();
      if (background != null) {
        background.draw(canvas);
      }
    }
    return;
  }
  super.dispatchDraw(canvas);
}

Fixed version (ground truth):
@Override protected void dispatchDraw(Canvas canvas){
  if (DEBUG)   Log.v(TAG,"String_Node_Str" + SystemClock.elapsedRealtime());
  super.dispatchDraw(canvas);
}
Program: 42252
Project: 42252
Buggy source:
public void recreateMe(){
  recreateScreens();
}

Fixed version (ground truth):
public void recreateMe(Configuration config){
  mConfiguration=config;
  recreateScreens();
}
Program: 42255
Project: 42255
Buggy source:
/** 
 * @param contentResolver Used to look up and save settings.
 */
public LockPatternUtils(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  mDevicePolicyManager=getDevicePolicyManager();
  if (sLockPatternFilename == null) {
    sLockPatternFilename=android.os.Environment.getDataDirectory().getAbsolutePath() + LOCK_PATTERN_FILE;
    sLockPasswordFilename=android.os.Environment.getDataDirectory().getAbsolutePath() + LOCK_PASSWORD_FILE;
  }
}

Fixed version (ground truth):
/** 
 * @param contentResolver Used to look up and save settings.
 */
public LockPatternUtils(Context context){
  mContext=context;
  mContentResolver=context.getContentResolver();
  if (sLockPatternFilename == null) {
    sLockPatternFilename=android.os.Environment.getDataDirectory().getAbsolutePath() + LOCK_PATTERN_FILE;
    sLockPasswordFilename=android.os.Environment.getDataDirectory().getAbsolutePath() + LOCK_PASSWORD_FILE;
  }
}
Program: 42256
Project: 42256
Buggy source:
public void testScreenRequestsRecreation(){
  mLPKV.wakeWhenReadyTq(0);
  mLPKV.onScreenTurnedOn();
  assertEquals(1,mLPKV.getInjectedLockScreens().size());
  assertEquals(1,mLPKV.getInjectedUnlockScreens().size());
  MockKeyguardScreen lockScreen=mLPKV.getInjectedLockScreens().get(0);
  assertEquals(0,lockScreen.getOnPauseCount());
  assertEquals(1,lockScreen.getOnResumeCount());
  mLPKV.mKeyguardScreenCallback.recreateMe();
  assertEquals(2,mLPKV.getInjectedLockScreens().size());
  assertEquals(2,mLPKV.getInjectedUnlockScreens().size());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(0).getCleanupCount());
  assertEquals(1,mLPKV.getInjectedUnlockScreens().get(0).getCleanupCount());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(0).getOnPauseCount());
  assertEquals(0,mLPKV.getInjectedUnlockScreens().get(0).getOnPauseCount());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(1).getOnResumeCount());
  assertEquals(0,mLPKV.getInjectedUnlockScreens().get(1).getOnResumeCount());
}

Fixed version (ground truth):
public void testScreenRequestsRecreation(){
  mLPKV.wakeWhenReadyTq(0);
  mLPKV.onScreenTurnedOn();
  assertEquals(1,mLPKV.getInjectedLockScreens().size());
  assertEquals(1,mLPKV.getInjectedUnlockScreens().size());
  MockKeyguardScreen lockScreen=mLPKV.getInjectedLockScreens().get(0);
  assertEquals(0,lockScreen.getOnPauseCount());
  assertEquals(1,lockScreen.getOnResumeCount());
  mLPKV.mKeyguardScreenCallback.recreateMe(new Configuration());
  assertEquals(2,mLPKV.getInjectedLockScreens().size());
  assertEquals(2,mLPKV.getInjectedUnlockScreens().size());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(0).getCleanupCount());
  assertEquals(1,mLPKV.getInjectedUnlockScreens().get(0).getCleanupCount());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(0).getOnPauseCount());
  assertEquals(0,mLPKV.getInjectedUnlockScreens().get(0).getOnPauseCount());
  assertEquals(1,mLPKV.getInjectedLockScreens().get(1).getOnResumeCount());
  assertEquals(0,mLPKV.getInjectedUnlockScreens().get(1).getOnResumeCount());
}
Program: 42257
Project: 42257
Buggy source:
/** 
 * See if the key event means we should leave touch mode (and leave touch mode if so).
 * @param event The key event.
 * @return Whether this key event should be consumed (meaning the act ofleaving touch mode alone is considered the event).
 */
private boolean checkForLeavingTouchModeAndConsume(KeyEvent event){
  if (event.getAction() != KeyEvent.ACTION_DOWN) {
    return false;
  }
  if ((event.getFlags() & KeyEvent.FLAG_KEEP_TOUCH_MODE) != 0) {
    return false;
  }
  if (!mAttachInfo.mInTouchMode) {
    return false;
  }
  if (isKeyboardKey(event) && mView != null && mView.hasFocus()) {
    mFocusedView=mView.findFocus();
    if ((mFocusedView instanceof ViewGroup) && ((ViewGroup)mFocusedView).getDescendantFocusability() == ViewGroup.FOCUS_AFTER_DESCENDANTS) {
      return false;
    }
    if (ensureTouchMode(false)) {
      throw new IllegalStateException("String_Node_Str" + "String_Node_Str");
    }
    return false;
  }
  if (isDirectional(event.getKeyCode())) {
    return ensureTouchMode(false);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * See if the key event means we should leave touch mode (and leave touch mode if so).
 * @param event The key event.
 * @return Whether this key event should be consumed (meaning the act ofleaving touch mode alone is considered the event).
 */
private boolean checkForLeavingTouchModeAndConsume(KeyEvent event){
  final int action=event.getAction();
  if (action != KeyEvent.ACTION_DOWN && action != KeyEvent.ACTION_MULTIPLE) {
    return false;
  }
  if ((event.getFlags() & KeyEvent.FLAG_KEEP_TOUCH_MODE) != 0) {
    return false;
  }
  if (!mAttachInfo.mInTouchMode) {
    return false;
  }
  if (isKeyboardKey(event) && mView != null && mView.hasFocus()) {
    mFocusedView=mView.findFocus();
    if ((mFocusedView instanceof ViewGroup) && ((ViewGroup)mFocusedView).getDescendantFocusability() == ViewGroup.FOCUS_AFTER_DESCENDANTS) {
      return false;
    }
    if (ensureTouchMode(false)) {
      throw new IllegalStateException("String_Node_Str" + "String_Node_Str");
    }
    return false;
  }
  if (isDirectional(event.getKeyCode())) {
    return ensureTouchMode(false);
  }
  return false;
}
Program: 42258
Project: 42258
Buggy source:
public void onTouchModeChanged(boolean isInTouchMode){
  if (isInTouchMode) {
    hideSelector();
    if (getHeight() > 0 && getChildCount() > 0) {
      layoutChildren();
    }
  }
 else {
    int touchMode=mTouchMode;
    if (touchMode == TOUCH_MODE_OVERSCROLL || touchMode == TOUCH_MODE_OVERFLING) {
      if (mFlingRunnable != null) {
        mFlingRunnable.endFling();
        if (mScrollY != 0) {
          mScrollY=0;
          invalidate();
        }
      }
    }
  }
  mLastTouchMode=isInTouchMode ? TOUCH_MODE_ON : TOUCH_MODE_OFF;
}

Fixed version (ground truth):
public void onTouchModeChanged(boolean isInTouchMode){
  if (isInTouchMode) {
    hideSelector();
    if (getHeight() > 0 && getChildCount() > 0) {
      layoutChildren();
    }
  }
 else {
    int touchMode=mTouchMode;
    if (touchMode == TOUCH_MODE_OVERSCROLL || touchMode == TOUCH_MODE_OVERFLING) {
      if (mFlingRunnable != null) {
        mFlingRunnable.endFling();
      }
      if (mScrollY != 0) {
        mScrollY=0;
        invalidate();
      }
    }
  }
  mLastTouchMode=isInTouchMode ? TOUCH_MODE_ON : TOUCH_MODE_OFF;
}
Program: 42259
Project: 42259
Buggy source:
/** 
 * Send ar.userObj if its a message, which is should be back to originator.
 * @param dp is the DisconnectParams.
 */
private void notifyDisconnectCompleted(DisconnectParams dp){
  if (DBG)   log("String_Node_Str");
  Message msg=dp.onCompletedMsg;
  log(String.format("String_Node_Str",msg.what,((msg.obj instanceof String) ? (String)msg.obj : "String_Node_Str")));
  AsyncResult.forMessage(msg);
  msg.sendToTarget();
  clearSettings();
}

Fixed version (ground truth):
/** 
 * Send ar.userObj if its a message, which is should be back to originator.
 * @param dp is the DisconnectParams.
 */
private void notifyDisconnectCompleted(DisconnectParams dp){
  if (DBG)   log("String_Node_Str");
  if (dp.onCompletedMsg != null) {
    Message msg=dp.onCompletedMsg;
    log(String.format("String_Node_Str",msg.what,((msg.obj instanceof String) ? (String)msg.obj : "String_Node_Str")));
    AsyncResult.forMessage(msg);
    msg.sendToTarget();
  }
  if (dp.lockObj != null) {
synchronized (dp.lockObj) {
      dp.lockObj.notify();
    }
  }
  clearSettings();
}
Program: 42260
Project: 42260
Buggy source:
public DisconnectParams(Message onCompletedMsg){
  this.onCompletedMsg=onCompletedMsg;
}

Fixed version (ground truth):
public DisconnectParams(ResetSynchronouslyLock lockObj){
  this.lockObj=lockObj;
}