nus-yam/ex-repair huggingface dataset:
Program: 182260
Project: 182260
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: 182261
Project: 182261
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: 182263
Project: 182263
Buggy source:
/** 
 * Re-enable mobile data connectivity after a   {@link #teardown()}.
 */
public boolean reconnect(){
  setTeardownRequested(false);
switch (setEnableApn(mApnType,true)) {
case Phone.APN_ALREADY_ACTIVE:
    mEnabled=true;
  mMobileDataState=Phone.DataState.CONNECTING;
setDetailedState(DetailedState.CONNECTING,Phone.REASON_APN_CHANGED,null);
Intent intent=new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
intent.putExtra(Phone.STATE_KEY,Phone.DataState.CONNECTED.toString());
intent.putExtra(Phone.STATE_CHANGE_REASON_KEY,Phone.REASON_APN_CHANGED);
intent.putExtra(Phone.DATA_APN_TYPES_KEY,mApnTypeToWatchFor);
intent.putExtra(Phone.DATA_APN_KEY,mApnName);
intent.putExtra(Phone.DATA_IFACE_NAME_KEY,mInterfaceName);
intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY,false);
if (mStateReceiver != null) mStateReceiver.onReceive(mContext,intent);
break;
case Phone.APN_REQUEST_STARTED:
mEnabled=true;
break;
case Phone.APN_REQUEST_FAILED:
if (mPhoneService == null && mApnType == Phone.APN_TYPE_DEFAULT) {
mEnabled=true;
return false;
}
case Phone.APN_TYPE_NOT_AVAILABLE:
mEnabled=false;
break;
default :
Log.e(TAG,"String_Node_Str");
mEnabled=false;
break;
}
return mEnabled;
}

Fixed version (ground truth):
/** 
 * Re-enable mobile data connectivity after a   {@link #teardown()}.
 */
public boolean reconnect(){
  setTeardownRequested(false);
switch (setEnableApn(mApnType,true)) {
case Phone.APN_ALREADY_ACTIVE:
    mEnabled=true;
  mMobileDataState=Phone.DataState.CONNECTING;
setDetailedState(DetailedState.CONNECTING,Phone.REASON_APN_CHANGED,null);
Intent intent=new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
intent.putExtra(Phone.STATE_KEY,Phone.DataState.CONNECTED.toString());
intent.putExtra(Phone.STATE_CHANGE_REASON_KEY,Phone.REASON_APN_CHANGED);
intent.putExtra(Phone.DATA_APN_TYPES_KEY,mApnTypeToWatchFor);
intent.putExtra(Phone.DATA_APN_KEY,mApnName);
intent.putExtra(Phone.DATA_IFACE_NAME_KEY,mInterfaceName);
intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY,false);
if (mStateReceiver != null) mStateReceiver.onReceive(mContext,intent);
break;
case Phone.APN_REQUEST_STARTED:
mEnabled=true;
break;
case Phone.APN_REQUEST_FAILED:
if (mPhoneService == null && mApnType == Phone.APN_TYPE_DEFAULT) {
mEnabled=true;
return false;
}
case Phone.APN_TYPE_NOT_AVAILABLE:
if (mApnType != Phone.APN_TYPE_DEFAULT) {
mEnabled=false;
}
break;
default :
Log.e(TAG,"String_Node_Str");
mEnabled=false;
break;
}
return mEnabled;
}
Program: 182264
Project: 182264
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: 182265
Project: 182265
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: 182267
Project: 182267
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: 182268
Project: 182268
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: 182270
Project: 182270
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: 182271
Project: 182271
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: 182272
Project: 182272
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: 182273
Project: 182273
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: 182274
Project: 182274
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: 182275
Project: 182275
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: 182276
Project: 182276
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: 182277
Project: 182277
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: 182279
Project: 182279
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: 182280
Project: 182280
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: 182281
Project: 182281
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: 182283
Project: 182283
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: 182285
Project: 182285
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: 182287
Project: 182287
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: 182288
Project: 182288
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: 182289
Project: 182289
Buggy source:
public void recreateMe(){
  recreateScreens();
}

Fixed version (ground truth):
public void recreateMe(Configuration config){
  mConfiguration=config;
  recreateScreens();
}
Program: 182291
Project: 182291
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: 182292
Project: 182292
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: 182293
Project: 182293
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: 182294
Project: 182294
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: 182295
Project: 182295
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: 182296
Project: 182296
Buggy source:
public DisconnectParams(Message onCompletedMsg){
  this.onCompletedMsg=onCompletedMsg;
}

Fixed version (ground truth):
public DisconnectParams(ResetSynchronouslyLock lockObj){
  this.lockObj=lockObj;
}
Program: 182297
Project: 182297
Buggy source:
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying DataConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  setState(State.DISCONNECTING);
  boolean notificationDeferred=false;
  for (  DataConnection conn : dataConnectionList) {
    if (conn != null) {
      if (tearDown) {
        if (DBG)         log("String_Node_Str");
        conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE,reason));
      }
 else {
        if (DBG)         log("String_Node_Str");
        conn.reset(obtainMessage(EVENT_RESET_DONE,reason));
      }
      notificationDeferred=true;
    }
  }
  stopNetStatPoll();
  if (!notificationDeferred) {
    if (DBG)     log("String_Node_Str");
    gotoIdleAndNotifyDataConnection(reason);
  }
}

Fixed version (ground truth):
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying DataConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  setState(State.DISCONNECTING);
  boolean notificationDeferred=false;
  for (  DataConnection conn : dataConnectionList) {
    if (conn != null) {
      if (tearDown) {
        if (DBG)         log("String_Node_Str");
        conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE,reason));
        notificationDeferred=true;
      }
 else {
        if (DBG)         log("String_Node_Str");
        conn.resetSynchronously();
        notificationDeferred=false;
      }
    }
  }
  stopNetStatPoll();
  if (!notificationDeferred) {
    if (DBG)     log("String_Node_Str");
    gotoIdleAndNotifyDataConnection(reason);
  }
}
Program: 182298
Project: 182298
Buggy source:
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying GsmDataConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  setState(State.DISCONNECTING);
  boolean notificationDeferred=false;
  for (  DataConnection conn : pdpList) {
    if (tearDown) {
      if (DBG)       log("String_Node_Str");
      conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE,reason));
    }
 else {
      if (DBG)       log("String_Node_Str");
      conn.reset(obtainMessage(EVENT_RESET_DONE,reason));
    }
    notificationDeferred=true;
  }
  stopNetStatPoll();
  if (!notificationDeferred) {
    if (DBG)     log("String_Node_Str");
    gotoIdleAndNotifyDataConnection(reason);
  }
}

Fixed version (ground truth):
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying GsmDataConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  setState(State.DISCONNECTING);
  boolean notificationDeferred=false;
  for (  DataConnection conn : pdpList) {
    if (tearDown) {
      if (DBG)       log("String_Node_Str");
      conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE,reason));
      notificationDeferred=true;
    }
 else {
      if (DBG)       log("String_Node_Str");
      conn.resetSynchronously();
      notificationDeferred=false;
    }
  }
  stopNetStatPoll();
  if (!notificationDeferred) {
    if (DBG)     log("String_Node_Str");
    gotoIdleAndNotifyDataConnection(reason);
  }
}
Program: 182299
Project: 182299
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: 182300
Project: 182300
Buggy source:
public DisconnectParams(Message onCompletedMsg){
  this.onCompletedMsg=onCompletedMsg;
}

Fixed version (ground truth):
public DisconnectParams(ResetSynchronouslyLock lockObj){
  this.lockObj=lockObj;
}
Program: 182301
Project: 182301
Buggy source:
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying DataConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  setState(State.DISCONNECTING);
  boolean notificationDeferred=false;
  for (  DataConnection conn : dataConnectionList) {
    if (conn != null) {
      if (tearDown) {
        if (DBG)         log("String_Node_Str");
        conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE,reason));
      }
 else {
        if (DBG)         log("String_Node_Str");
        conn.reset(obtainMessage(EVENT_RESET_DONE,reason));
      }
      notificationDeferred=true;
    }
  }
  stopNetStatPoll();
  if (!notificationDeferred) {
    if (DBG)     log("String_Node_Str");
    gotoIdleAndNotifyDataConnection(reason);
  }
}

Fixed version (ground truth):
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying DataConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  setState(State.DISCONNECTING);
  boolean notificationDeferred=false;
  for (  DataConnection conn : dataConnectionList) {
    if (conn != null) {
      if (tearDown) {
        if (DBG)         log("String_Node_Str");
        conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE,reason));
        notificationDeferred=true;
      }
 else {
        if (DBG)         log("String_Node_Str");
        conn.resetSynchronously();
        notificationDeferred=false;
      }
    }
  }
  stopNetStatPoll();
  if (!notificationDeferred) {
    if (DBG)     log("String_Node_Str");
    gotoIdleAndNotifyDataConnection(reason);
  }
}
Program: 182302
Project: 182302
Buggy source:
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying GsmDataConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  setState(State.DISCONNECTING);
  boolean notificationDeferred=false;
  for (  DataConnection conn : pdpList) {
    if (tearDown) {
      if (DBG)       log("String_Node_Str");
      conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE,reason));
    }
 else {
      if (DBG)       log("String_Node_Str");
      conn.reset(obtainMessage(EVENT_RESET_DONE,reason));
    }
    notificationDeferred=true;
  }
  stopNetStatPoll();
  if (!notificationDeferred) {
    if (DBG)     log("String_Node_Str");
    gotoIdleAndNotifyDataConnection(reason);
  }
}

Fixed version (ground truth):
/** 
 * If tearDown is true, this only tears down a CONNECTED session. Presently, there is no mechanism for abandoning an INITING/CONNECTING session, but would likely involve cancelling pending async requests or setting a flag or new state to ignore them when they came in
 * @param tearDown true if the underlying GsmDataConnection should bedisconnected.
 * @param reason reason for the clean up.
 */
private void cleanUpConnection(boolean tearDown,String reason){
  if (DBG)   log("String_Node_Str" + reason);
  if (mReconnectIntent != null) {
    AlarmManager am=(AlarmManager)phone.getContext().getSystemService(Context.ALARM_SERVICE);
    am.cancel(mReconnectIntent);
    mReconnectIntent=null;
  }
  setState(State.DISCONNECTING);
  boolean notificationDeferred=false;
  for (  DataConnection conn : pdpList) {
    if (tearDown) {
      if (DBG)       log("String_Node_Str");
      conn.disconnect(obtainMessage(EVENT_DISCONNECT_DONE,reason));
      notificationDeferred=true;
    }
 else {
      if (DBG)       log("String_Node_Str");
      conn.resetSynchronously();
      notificationDeferred=false;
    }
  }
  stopNetStatPoll();
  if (!notificationDeferred) {
    if (DBG)     log("String_Node_Str");
    gotoIdleAndNotifyDataConnection(reason);
  }
}
Program: 182303
Project: 182303
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);
}