nus-yam/ex-repair huggingface dataset:
Program: 180913
Project: 180913
Buggy source:
/** 
 * Handles the change of the accessibility enabled setting state.
 * @param preference The preference for enabling/disabling accessibility.
 */
private void handleEnableAccessibilityStateChange(CheckBoxPreference preference){
  if (preference.isChecked()) {
    Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,1);
  }
 else {
    final CheckBoxPreference checkBoxPreference=preference;
    AlertDialog dialog=(new AlertDialog.Builder(this)).setTitle(android.R.string.dialog_alert_title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(getString(R.string.accessibility_service_disable_warning)).setCancelable(true).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
      }
    }
).setNegativeButton(android.R.string.cancel,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        checkBoxPreference.setChecked(true);
      }
    }
).create();
    dialog.show();
  }
}

Fixed version (ground truth):
/** 
 * Handles the change of the accessibility enabled setting state.
 * @param preference The preference for enabling/disabling accessibility.
 */
private void handleEnableAccessibilityStateChange(CheckBoxPreference preference){
  if (preference.isChecked()) {
    Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,1);
    setAccessibilityServicePreferencesState(true);
  }
 else {
    final CheckBoxPreference checkBoxPreference=preference;
    AlertDialog dialog=(new AlertDialog.Builder(this)).setTitle(android.R.string.dialog_alert_title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(getString(R.string.accessibility_service_disable_warning)).setCancelable(true).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
        setAccessibilityServicePreferencesState(false);
      }
    }
).setNegativeButton(android.R.string.cancel,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        checkBoxPreference.setChecked(true);
      }
    }
).create();
    dialog.show();
  }
}
Program: 180914
Project: 180914
Buggy source:
@Override protected void onResume(){
  super.onResume();
  final HashSet<String> enabled=new HashSet<String>();
  String settingValue=Settings.Secure.getString(getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
  if (settingValue != null) {
    TextUtils.SimpleStringSplitter splitter=mStringColonSplitter;
    splitter.setString(settingValue);
    while (splitter.hasNext()) {
      enabled.add(splitter.next());
    }
  }
  Map<String,ServiceInfo> accessibilityServices=mAccessibilityServices;
  for (  String key : accessibilityServices.keySet()) {
    CheckBoxPreference preference=(CheckBoxPreference)findPreference(key);
    if (preference != null) {
      preference.setChecked(enabled.contains(key));
    }
  }
  int serviceState=Settings.Secure.getInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
  if (!accessibilityServices.isEmpty()) {
    if (serviceState == 1) {
      mToggleCheckBox.setChecked(true);
    }
    mToggleCheckBox.setEnabled(true);
  }
 else {
    if (serviceState == 1) {
      Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
    }
    mToggleCheckBox.setEnabled(false);
    displayNoAppsAlert();
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  final HashSet<String> enabled=new HashSet<String>();
  String settingValue=Settings.Secure.getString(getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
  if (settingValue != null) {
    TextUtils.SimpleStringSplitter splitter=mStringColonSplitter;
    splitter.setString(settingValue);
    while (splitter.hasNext()) {
      enabled.add(splitter.next());
    }
  }
  Map<String,ServiceInfo> accessibilityServices=mAccessibilityServices;
  for (  String key : accessibilityServices.keySet()) {
    CheckBoxPreference preference=(CheckBoxPreference)findPreference(key);
    if (preference != null) {
      preference.setChecked(enabled.contains(key));
    }
  }
  int serviceState=Settings.Secure.getInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
  if (!accessibilityServices.isEmpty()) {
    if (serviceState == 1) {
      mToggleCheckBox.setChecked(true);
    }
 else {
      setAccessibilityServicePreferencesState(false);
    }
    mToggleCheckBox.setEnabled(true);
  }
 else {
    if (serviceState == 1) {
      Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
    }
    mToggleCheckBox.setEnabled(false);
    displayNoAppsAlert();
  }
}
Program: 180915
Project: 180915
Buggy source:
private String getWord(int position){
  mCursor.moveToPosition(position);
  return mCursor.getString(mCursor.getColumnIndexOrThrow(UserDictionary.Words.WORD));
}

Fixed version (ground truth):
private String getWord(int position){
  mCursor.moveToPosition(position);
  if (mCursor.isAfterLast())   return null;
  return mCursor.getString(mCursor.getColumnIndexOrThrow(UserDictionary.Words.WORD));
}
Program: 180916
Project: 180916
Buggy source:
@Override public boolean onContextItemSelected(MenuItem item){
  ContextMenuInfo menuInfo=item.getMenuInfo();
  if (!(menuInfo instanceof AdapterContextMenuInfo))   return false;
  AdapterContextMenuInfo adapterMenuInfo=(AdapterContextMenuInfo)menuInfo;
  String word=getWord(adapterMenuInfo.position);
switch (item.getItemId()) {
case CONTEXT_MENU_DELETE:
    deleteWord(word);
  return true;
case CONTEXT_MENU_EDIT:
showAddOrEditDialog(word);
return true;
}
return false;
}

Fixed version (ground truth):
@Override public boolean onContextItemSelected(MenuItem item){
  ContextMenuInfo menuInfo=item.getMenuInfo();
  if (!(menuInfo instanceof AdapterContextMenuInfo))   return false;
  AdapterContextMenuInfo adapterMenuInfo=(AdapterContextMenuInfo)menuInfo;
  String word=getWord(adapterMenuInfo.position);
  if (word == null)   return true;
switch (item.getItemId()) {
case CONTEXT_MENU_DELETE:
    deleteWord(word);
  return true;
case CONTEXT_MENU_EDIT:
showAddOrEditDialog(word);
return true;
}
return false;
}
Program: 180917
Project: 180917
Buggy source:
@Override protected void onResume(){
  super.onResume();
  final LockPatternUtils lockPatternUtils=mChooseLockSettingsHelper.utils();
  boolean patternExists=lockPatternUtils.savedPatternExists();
  if (mVisiblePattern != null) {
    mVisiblePattern.setEnabled(patternExists);
    mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled());
  }
  if (mTactileFeedback != null) {
    mTactileFeedback.setEnabled(patternExists);
    mTactileFeedback.setChecked(lockPatternUtils.isTactileFeedbackEnabled());
  }
  mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),Settings.System.TEXT_SHOW_PASSWORD,1) != 0);
  mCredentialStorage.resume();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  final LockPatternUtils lockPatternUtils=mChooseLockSettingsHelper.utils();
  if (mVisiblePattern != null) {
    mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled());
  }
  if (mTactileFeedback != null) {
    mTactileFeedback.setChecked(lockPatternUtils.isTactileFeedbackEnabled());
  }
  mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),Settings.System.TEXT_SHOW_PASSWORD,1) != 0);
  mCredentialStorage.resume();
}
Program: 180919
Project: 180919
Buggy source:
private void setNotificationVolumeVisibility(boolean visible){
  mSeekBarVolumizer[0].getSeekBar().setVisibility(visible ? View.VISIBLE : View.GONE);
  mNotificationVolumeTitle.setVisibility(visible ? View.VISIBLE : View.GONE);
}

Fixed version (ground truth):
private void setNotificationVolumeVisibility(boolean visible){
  if (mSeekBarVolumizer[0] != null) {
    mSeekBarVolumizer[0].getSeekBar().setVisibility(visible ? View.VISIBLE : View.GONE);
  }
  mNotificationVolumeTitle.setVisibility(visible ? View.VISIBLE : View.GONE);
}
Program: 180920
Project: 180920
Buggy source:
@Override protected void onSampleStarting(SeekBarVolumizer volumizer){
  super.onSampleStarting(volumizer);
  for (  SeekBarVolumizer vol : mSeekBarVolumizer) {
    if (vol != volumizer)     vol.stopSample();
  }
}

Fixed version (ground truth):
@Override protected void onSampleStarting(SeekBarVolumizer volumizer){
  super.onSampleStarting(volumizer);
  for (  SeekBarVolumizer vol : mSeekBarVolumizer) {
    if (vol != null && vol != volumizer)     vol.stopSample();
  }
}
Program: 180921
Project: 180921
Buggy source:
private void setNotificationVolumeVisibility(boolean visible){
  mSeekBarVolumizer[0].getSeekBar().setVisibility(visible ? View.VISIBLE : View.GONE);
  mNotificationVolumeTitle.setVisibility(visible ? View.VISIBLE : View.GONE);
}

Fixed version (ground truth):
private void setNotificationVolumeVisibility(boolean visible){
  if (mSeekBarVolumizer[0] != null) {
    mSeekBarVolumizer[0].getSeekBar().setVisibility(visible ? View.VISIBLE : View.GONE);
  }
  mNotificationVolumeTitle.setVisibility(visible ? View.VISIBLE : View.GONE);
}
Program: 180922
Project: 180922
Buggy source:
@Override protected void onSampleStarting(SeekBarVolumizer volumizer){
  super.onSampleStarting(volumizer);
  for (  SeekBarVolumizer vol : mSeekBarVolumizer) {
    if (vol != volumizer)     vol.stopSample();
  }
}

Fixed version (ground truth):
@Override protected void onSampleStarting(SeekBarVolumizer volumizer){
  super.onSampleStarting(volumizer);
  for (  SeekBarVolumizer vol : mSeekBarVolumizer) {
    if (vol != null && vol != volumizer)     vol.stopSample();
  }
}
Program: 180923
Project: 180923
Buggy source:
/** 
 * Handles the change of the accessibility enabled setting state.
 * @param preference The preference for enabling/disabling accessibility.
 */
private void handleEnableAccessibilityStateChange(CheckBoxPreference preference){
  if (preference.isChecked()) {
    Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,1);
    setAccessibilityServicePreferencesState(true);
  }
 else {
    final CheckBoxPreference checkBoxPreference=preference;
    AlertDialog dialog=(new AlertDialog.Builder(this)).setTitle(android.R.string.dialog_alert_title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(getString(R.string.accessibility_service_disable_warning)).setCancelable(true).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
        setAccessibilityServicePreferencesState(false);
      }
    }
).setNegativeButton(android.R.string.cancel,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        checkBoxPreference.setChecked(true);
      }
    }
).create();
    dialog.show();
  }
}

Fixed version (ground truth):
/** 
 * Handles the change of the accessibility enabled setting state.
 * @param preference The preference for enabling/disabling accessibility.
 */
private void handleEnableAccessibilityStateChange(CheckBoxPreference preference){
  if (preference.isChecked()) {
    Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,1);
  }
 else {
    final CheckBoxPreference checkBoxPreference=preference;
    AlertDialog dialog=(new AlertDialog.Builder(this)).setTitle(android.R.string.dialog_alert_title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(getString(R.string.accessibility_service_disable_warning)).setCancelable(true).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
      }
    }
).setNegativeButton(android.R.string.cancel,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        checkBoxPreference.setChecked(true);
      }
    }
).create();
    dialog.show();
  }
}
Program: 180924
Project: 180924
Buggy source:
@Override protected void onResume(){
  super.onResume();
  final HashSet<String> enabled=new HashSet<String>();
  String settingValue=Settings.Secure.getString(getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
  if (settingValue != null) {
    TextUtils.SimpleStringSplitter splitter=mStringColonSplitter;
    splitter.setString(settingValue);
    while (splitter.hasNext()) {
      enabled.add(splitter.next());
    }
  }
  Map<String,ServiceInfo> accessibilityServices=mAccessibilityServices;
  for (  String key : accessibilityServices.keySet()) {
    CheckBoxPreference preference=(CheckBoxPreference)findPreference(key);
    if (preference != null) {
      preference.setChecked(enabled.contains(key));
    }
  }
  int serviceState=Settings.Secure.getInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
  if (!accessibilityServices.isEmpty()) {
    if (serviceState == 1) {
      mToggleCheckBox.setChecked(true);
    }
 else {
      setAccessibilityServicePreferencesState(false);
    }
    mToggleCheckBox.setEnabled(true);
  }
 else {
    if (serviceState == 1) {
      Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
      setAccessibilityServicePreferencesState(false);
    }
    mToggleCheckBox.setEnabled(false);
    displayNoAppsAlert();
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  final HashSet<String> enabled=new HashSet<String>();
  String settingValue=Settings.Secure.getString(getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
  if (settingValue != null) {
    TextUtils.SimpleStringSplitter splitter=mStringColonSplitter;
    splitter.setString(settingValue);
    while (splitter.hasNext()) {
      enabled.add(splitter.next());
    }
  }
  Map<String,ServiceInfo> accessibilityServices=mAccessibilityServices;
  for (  String key : accessibilityServices.keySet()) {
    CheckBoxPreference preference=(CheckBoxPreference)findPreference(key);
    if (preference != null) {
      preference.setChecked(enabled.contains(key));
    }
  }
  int serviceState=Settings.Secure.getInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
  if (!accessibilityServices.isEmpty()) {
    if (serviceState == 1) {
      mToggleCheckBox.setChecked(true);
    }
    mToggleCheckBox.setEnabled(true);
  }
 else {
    if (serviceState == 1) {
      Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
    }
    mToggleCheckBox.setEnabled(false);
    displayNoAppsAlert();
  }
}
Program: 180925
Project: 180925
Buggy source:
/** 
 * Handles the change of the accessibility enabled setting state.
 * @param preference The preference for enabling/disabling accessibility.
 */
private void handleEnableAccessibilityStateChange(CheckBoxPreference preference){
  if (preference.isChecked()) {
    Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,1);
    setAccessibilityServicePreferencesState(true);
  }
 else {
    final CheckBoxPreference checkBoxPreference=preference;
    AlertDialog dialog=(new AlertDialog.Builder(this)).setTitle(android.R.string.dialog_alert_title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(getString(R.string.accessibility_service_disable_warning)).setCancelable(true).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
        setAccessibilityServicePreferencesState(false);
      }
    }
).setNegativeButton(android.R.string.cancel,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        checkBoxPreference.setChecked(true);
      }
    }
).create();
    dialog.show();
  }
}

Fixed version (ground truth):
/** 
 * Handles the change of the accessibility enabled setting state.
 * @param preference The preference for enabling/disabling accessibility.
 */
private void handleEnableAccessibilityStateChange(CheckBoxPreference preference){
  if (preference.isChecked()) {
    Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,1);
  }
 else {
    final CheckBoxPreference checkBoxPreference=preference;
    AlertDialog dialog=(new AlertDialog.Builder(this)).setTitle(android.R.string.dialog_alert_title).setIcon(android.R.drawable.ic_dialog_alert).setMessage(getString(R.string.accessibility_service_disable_warning)).setCancelable(true).setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
      }
    }
).setNegativeButton(android.R.string.cancel,new DialogInterface.OnClickListener(){
      public void onClick(      DialogInterface dialog,      int which){
        checkBoxPreference.setChecked(true);
      }
    }
).create();
    dialog.show();
  }
}
Program: 180926
Project: 180926
Buggy source:
@Override protected void onResume(){
  super.onResume();
  final HashSet<String> enabled=new HashSet<String>();
  String settingValue=Settings.Secure.getString(getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
  if (settingValue != null) {
    TextUtils.SimpleStringSplitter splitter=mStringColonSplitter;
    splitter.setString(settingValue);
    while (splitter.hasNext()) {
      enabled.add(splitter.next());
    }
  }
  Map<String,ServiceInfo> accessibilityServices=mAccessibilityServices;
  for (  String key : accessibilityServices.keySet()) {
    CheckBoxPreference preference=(CheckBoxPreference)findPreference(key);
    if (preference != null) {
      preference.setChecked(enabled.contains(key));
    }
  }
  int serviceState=Settings.Secure.getInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
  if (!accessibilityServices.isEmpty()) {
    if (serviceState == 1) {
      mToggleCheckBox.setChecked(true);
    }
 else {
      setAccessibilityServicePreferencesState(false);
    }
    mToggleCheckBox.setEnabled(true);
  }
 else {
    if (serviceState == 1) {
      Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
      setAccessibilityServicePreferencesState(false);
    }
    mToggleCheckBox.setEnabled(false);
    displayNoAppsAlert();
  }
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  final HashSet<String> enabled=new HashSet<String>();
  String settingValue=Settings.Secure.getString(getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES);
  if (settingValue != null) {
    TextUtils.SimpleStringSplitter splitter=mStringColonSplitter;
    splitter.setString(settingValue);
    while (splitter.hasNext()) {
      enabled.add(splitter.next());
    }
  }
  Map<String,ServiceInfo> accessibilityServices=mAccessibilityServices;
  for (  String key : accessibilityServices.keySet()) {
    CheckBoxPreference preference=(CheckBoxPreference)findPreference(key);
    if (preference != null) {
      preference.setChecked(enabled.contains(key));
    }
  }
  int serviceState=Settings.Secure.getInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
  if (!accessibilityServices.isEmpty()) {
    if (serviceState == 1) {
      mToggleCheckBox.setChecked(true);
    }
    mToggleCheckBox.setEnabled(true);
  }
 else {
    if (serviceState == 1) {
      Settings.Secure.putInt(getContentResolver(),Settings.Secure.ACCESSIBILITY_ENABLED,0);
    }
    mToggleCheckBox.setEnabled(false);
    displayNoAppsAlert();
  }
}
Program: 180927
Project: 180927
Buggy source:
@Override protected void onResume(){
  super.onResume();
  final LockPatternUtils lockPatternUtils=mChooseLockSettingsHelper.utils();
  boolean patternExists=lockPatternUtils.savedPatternExists();
  if (mVisiblePattern != null) {
    mVisiblePattern.setEnabled(patternExists);
    mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled());
  }
  if (mTactileFeedback != null) {
    mTactileFeedback.setEnabled(patternExists);
    mTactileFeedback.setChecked(lockPatternUtils.isTactileFeedbackEnabled());
  }
  mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),Settings.System.TEXT_SHOW_PASSWORD,1) != 0);
  mCredentialStorage.resume();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  final LockPatternUtils lockPatternUtils=mChooseLockSettingsHelper.utils();
  if (mVisiblePattern != null) {
    mVisiblePattern.setChecked(lockPatternUtils.isVisiblePatternEnabled());
  }
  if (mTactileFeedback != null) {
    mTactileFeedback.setChecked(lockPatternUtils.isTactileFeedbackEnabled());
  }
  mShowPassword.setChecked(Settings.System.getInt(getContentResolver(),Settings.System.TEXT_SHOW_PASSWORD,1) != 0);
  mCredentialStorage.resume();
}
Program: 180928
Project: 180928
Buggy source:
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=true;
    mTts.setLanguage(new Locale(mDefaultLanguage,mDefaultCountry));
    mTts.setSpeechRate((float)(mDefaultRate / 100.0f));
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}

Fixed version (ground truth):
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=true;
    if (mDefaultLanguage == null) {
      mDefaultLanguage=Locale.getDefault().getISO3Language();
    }
    mTts.setLanguage(new Locale(mDefaultLanguage,mDefaultCountry,mDefaultLocVariant));
    mTts.setSpeechRate((float)(mDefaultRate / 100.0f));
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}
Program: 180931
Project: 180931
Buggy source:
@Override protected Dialog onCreateDialog(int id,Bundle args){
switch (id) {
case DIALOG_WARNING:
{
      CharSequence msg=args.getCharSequence(DeviceAdmin.EXTRA_DISABLE_WARNING);
      AlertDialog.Builder builder=new AlertDialog.Builder(DeviceAdminAdd.this);
      builder.setMessage(msg);
      builder.setPositiveButton(R.string.dlg_ok,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
          finish();
        }
      }
);
      builder.setNegativeButton(R.string.dlg_cancel,null);
      return builder.create();
    }
default :
  return super.onCreateDialog(id,args);
}
}

Fixed version (ground truth):
@Override protected Dialog onCreateDialog(int id,Bundle args){
switch (id) {
case DIALOG_WARNING:
{
      CharSequence msg=args.getCharSequence(DeviceAdminReceiver.EXTRA_DISABLE_WARNING);
      AlertDialog.Builder builder=new AlertDialog.Builder(DeviceAdminAdd.this);
      builder.setMessage(msg);
      builder.setPositiveButton(R.string.dlg_ok,new DialogInterface.OnClickListener(){
        public void onClick(        DialogInterface dialog,        int which){
          mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
          finish();
        }
      }
);
      builder.setNegativeButton(R.string.dlg_cancel,null);
      return builder.create();
    }
default :
  return super.onCreateDialog(id,args);
}
}
Program: 180932
Project: 180932
Buggy source:
@Override protected void onResult(Bundle bundle){
  CharSequence msg=bundle != null ? bundle.getCharSequence(DeviceAdmin.EXTRA_DISABLE_WARNING) : null;
  if (msg == null) {
    mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
    finish();
  }
 else {
    Bundle args=new Bundle();
    args.putCharSequence(DeviceAdmin.EXTRA_DISABLE_WARNING,msg);
    showDialog(DIALOG_WARNING,args);
  }
}

Fixed version (ground truth):
@Override protected void onResult(Bundle bundle){
  CharSequence msg=bundle != null ? bundle.getCharSequence(DeviceAdminReceiver.EXTRA_DISABLE_WARNING) : null;
  if (msg == null) {
    mDPM.removeActiveAdmin(mDeviceAdmin.getComponent());
    finish();
  }
 else {
    Bundle args=new Bundle();
    args.putCharSequence(DeviceAdminReceiver.EXTRA_DISABLE_WARNING,msg);
    showDialog(DIALOG_WARNING,args);
  }
}
Program: 180933
Project: 180933
Buggy source:
void updateList(){
  mActiveAdmins.clear();
  List<ComponentName> cur=mDPM.getActiveAdmins();
  if (cur != null) {
    for (int i=0; i < cur.size(); i++) {
      mActiveAdmins.add(cur.get(i));
    }
  }
  mAvailableAdmins.clear();
  List<ResolveInfo> avail=getPackageManager().queryBroadcastReceivers(new Intent(DeviceAdmin.ACTION_DEVICE_ADMIN_ENABLED),PackageManager.GET_META_DATA);
  int count=avail == null ? 0 : avail.size();
  for (int i=0; i < count; i++) {
    ResolveInfo ri=avail.get(i);
    try {
      DeviceAdminInfo dpi=new DeviceAdminInfo(this,ri);
      mAvailableAdmins.add(dpi);
    }
 catch (    XmlPullParserException e) {
      Log.w(TAG,"String_Node_Str" + ri.activityInfo,e);
    }
catch (    IOException e) {
      Log.w(TAG,"String_Node_Str" + ri.activityInfo,e);
    }
  }
  getListView().setAdapter(new PolicyListAdapter());
}

Fixed version (ground truth):
void updateList(){
  mActiveAdmins.clear();
  List<ComponentName> cur=mDPM.getActiveAdmins();
  if (cur != null) {
    for (int i=0; i < cur.size(); i++) {
      mActiveAdmins.add(cur.get(i));
    }
  }
  mAvailableAdmins.clear();
  List<ResolveInfo> avail=getPackageManager().queryBroadcastReceivers(new Intent(DeviceAdminReceiver.ACTION_DEVICE_ADMIN_ENABLED),PackageManager.GET_META_DATA);
  int count=avail == null ? 0 : avail.size();
  for (int i=0; i < count; i++) {
    ResolveInfo ri=avail.get(i);
    try {
      DeviceAdminInfo dpi=new DeviceAdminInfo(this,ri);
      mAvailableAdmins.add(dpi);
    }
 catch (    XmlPullParserException e) {
      Log.w(TAG,"String_Node_Str" + ri.activityInfo,e);
    }
catch (    IOException e) {
      Log.w(TAG,"String_Node_Str" + ri.activityInfo,e);
    }
  }
  getListView().setAdapter(new PolicyListAdapter());
}
Program: 180934
Project: 180934
Buggy source:
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=true;
    if (mDefaultLanguage == null) {
      mDefaultLanguage=Locale.getDefault().getISO3Language();
    }
    mTts.setLanguage(new Locale(mDefaultLanguage,mDefaultCountry,mDefaultLocVariant));
    mTts.setSpeechRate((float)(mDefaultRate / 100.0f));
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}

Fixed version (ground truth):
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=true;
    if (mDefaultLanguage == null) {
      mDefaultLanguage=Locale.getDefault().getISO3Language();
    }
    if (mDefaultCountry == null) {
      mDefaultCountry=Locale.getDefault().getISO3Country();
    }
    if (mDefaultLocVariant == null) {
      mDefaultLocVariant=new String();
    }
    mTts.setLanguage(new Locale(mDefaultLanguage,mDefaultCountry,mDefaultLocVariant));
    mTts.setSpeechRate((float)(mDefaultRate / 100.0f));
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}
Program: 180935
Project: 180935
Buggy source:
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=true;
    if (mDefaultLanguage == null) {
      mDefaultLanguage=Locale.getDefault().getISO3Language();
    }
    mTts.setLanguage(new Locale(mDefaultLanguage,mDefaultCountry,mDefaultLocVariant));
    mTts.setSpeechRate((float)(mDefaultRate / 100.0f));
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}

Fixed version (ground truth):
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=true;
    if (mDefaultLanguage == null) {
      mDefaultLanguage=Locale.getDefault().getISO3Language();
    }
    if (mDefaultCountry == null) {
      mDefaultCountry=Locale.getDefault().getISO3Country();
    }
    if (mDefaultLocVariant == null) {
      mDefaultLocVariant=new String();
    }
    mTts.setLanguage(new Locale(mDefaultLanguage,mDefaultCountry,mDefaultLocVariant));
    mTts.setSpeechRate((float)(mDefaultRate / 100.0f));
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}
Program: 180936
Project: 180936
Buggy source:
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=true;
    mTts.setLanguage(new Locale(mDefaultLanguage,mDefaultCountry));
    mTts.setSpeechRate((float)(mDefaultRate / 100.0f));
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}

Fixed version (ground truth):
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=true;
    if (mDefaultLanguage == null) {
      mDefaultLanguage=Locale.getDefault().getISO3Language();
    }
    mTts.setLanguage(new Locale(mDefaultLanguage,mDefaultCountry,mDefaultLocVariant));
    mTts.setSpeechRate((float)(mDefaultRate / 100.0f));
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}
Program: 180938
Project: 180938
Buggy source:
/** 
 * Initialize the default language in the UI and in the preferences. After this method has been invoked, the default language is a supported Locale.
 */
private void initDefaultLang(){
  if (!hasLangPref()) {
    if (isCurrentLocSupported()) {
      useCurrentLocAsDefault();
    }
 else {
      useSupportedLocAsDefault();
    }
  }
  ContentResolver resolver=getContentResolver();
  mDefaultLanguage=Settings.Secure.getString(resolver,TTS_DEFAULT_LANG);
  mDefaultCountry=Settings.Secure.getString(resolver,KEY_TTS_DEFAULT_COUNTRY);
  mDefaultLocVariant=Settings.Secure.getString(resolver,KEY_TTS_DEFAULT_VARIANT);
  mDemoStringIndex=mDefaultLocPref.findIndexOfValue(mDefaultLanguage + LOCALE_DELIMITER + mDefaultCountry);
  mDefaultLocPref.setValueIndex(mDemoStringIndex);
}

Fixed version (ground truth):
/** 
 * Initialize the default language in the UI and in the preferences. After this method has been invoked, the default language is a supported Locale.
 */
private void initDefaultLang(){
  if (!hasLangPref()) {
    if (isCurrentLocSupported()) {
      useCurrentLocAsDefault();
    }
 else {
      useSupportedLocAsDefault();
    }
  }
  ContentResolver resolver=getContentResolver();
  mDefaultLanguage=Settings.Secure.getString(resolver,TTS_DEFAULT_LANG);
  mDefaultCountry=Settings.Secure.getString(resolver,KEY_TTS_DEFAULT_COUNTRY);
  mDefaultLocVariant=Settings.Secure.getString(resolver,KEY_TTS_DEFAULT_VARIANT);
  mDemoStringIndex=mDefaultLocPref.findIndexOfValue(mDefaultLanguage + LOCALE_DELIMITER + mDefaultCountry);
  if (mDemoStringIndex > -1) {
    mDefaultLocPref.setValueIndex(mDemoStringIndex);
  }
}
Program: 180939
Project: 180939
Buggy source:
/** 
 * Initialize the default language in the UI and in the preferences. After this method has been invoked, the default language is a supported Locale.
 */
private void initDefaultLang(){
  if (!hasLangPref()) {
    if (isCurrentLocSupported()) {
      useCurrentLocAsDefault();
    }
 else {
      useSupportedLocAsDefault();
    }
  }
  ContentResolver resolver=getContentResolver();
  mDefaultLanguage=Settings.Secure.getString(resolver,TTS_DEFAULT_LANG);
  mDefaultCountry=Settings.Secure.getString(resolver,KEY_TTS_DEFAULT_COUNTRY);
  mDefaultLocVariant=Settings.Secure.getString(resolver,KEY_TTS_DEFAULT_VARIANT);
  mDemoStringIndex=mDefaultLocPref.findIndexOfValue(mDefaultLanguage + LOCALE_DELIMITER + mDefaultCountry);
  mDefaultLocPref.setValueIndex(mDemoStringIndex);
}

Fixed version (ground truth):
/** 
 * Initialize the default language in the UI and in the preferences. After this method has been invoked, the default language is a supported Locale.
 */
private void initDefaultLang(){
  if (!hasLangPref()) {
    if (isCurrentLocSupported()) {
      useCurrentLocAsDefault();
    }
 else {
      useSupportedLocAsDefault();
    }
  }
  ContentResolver resolver=getContentResolver();
  mDefaultLanguage=Settings.Secure.getString(resolver,TTS_DEFAULT_LANG);
  mDefaultCountry=Settings.Secure.getString(resolver,KEY_TTS_DEFAULT_COUNTRY);
  mDefaultLocVariant=Settings.Secure.getString(resolver,KEY_TTS_DEFAULT_VARIANT);
  mDemoStringIndex=mDefaultLocPref.findIndexOfValue(mDefaultLanguage + LOCALE_DELIMITER + mDefaultCountry);
  if (mDemoStringIndex > -1) {
    mDefaultLocPref.setValueIndex(mDemoStringIndex);
  }
}
Program: 180952
Project: 180952
Buggy source:
private void connectWithoutResettingTimer(){
  if (mProfiles.size() == 0) {
    if (!updateProfiles()) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      return;
    }
  }
  mIsConnectingErrorPossible=true;
  int preferredProfiles=0;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      if (profileManager.isPreferred(mDevice)) {
        ++preferredProfiles;
        queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}

Fixed version (ground truth):
private void connectWithoutResettingTimer(){
  if (mProfiles.size() == 0) {
    if (!updateProfiles()) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      return;
    }
  }
  mIsConnectingErrorPossible=true;
  int preferredProfiles=0;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      if (profileManager.isPreferred(mDevice)) {
        ++preferredProfiles;
        disconnectConnected(profile);
        queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}
Program: 180953
Project: 180953
Buggy source:
private void connectAllProfiles(){
  if (!ensurePaired())   return;
  mIsConnectingErrorPossible=true;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      profileManager.setPreferred(mDevice,false);
      queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
    }
  }
}

Fixed version (ground truth):
private void connectAllProfiles(){
  if (!ensurePaired())   return;
  mIsConnectingErrorPossible=true;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      profileManager.setPreferred(mDevice,false);
      disconnectConnected(profile);
      queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
    }
  }
}
Program: 180954
Project: 180954
Buggy source:
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
}

Fixed version (ground truth):
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  disconnectConnected(profile);
  queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
}
Program: 180955
Project: 180955
Buggy source:
private void connectWithoutResettingTimer(){
  if (mProfiles.size() == 0) {
    if (!updateProfiles()) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      return;
    }
  }
  mIsConnectingErrorPossible=true;
  int preferredProfiles=0;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      if (profileManager.isPreferred(mDevice)) {
        ++preferredProfiles;
        queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}

Fixed version (ground truth):
private void connectWithoutResettingTimer(){
  if (mProfiles.size() == 0) {
    if (!updateProfiles()) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      return;
    }
  }
  mIsConnectingErrorPossible=true;
  int preferredProfiles=0;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      if (profileManager.isPreferred(mDevice)) {
        ++preferredProfiles;
        disconnectConnected(profile);
        queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}
Program: 180956
Project: 180956
Buggy source:
private void connectAllProfiles(){
  if (!ensurePaired())   return;
  mIsConnectingErrorPossible=true;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      profileManager.setPreferred(mDevice,false);
      queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
    }
  }
}

Fixed version (ground truth):
private void connectAllProfiles(){
  if (!ensurePaired())   return;
  mIsConnectingErrorPossible=true;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      profileManager.setPreferred(mDevice,false);
      disconnectConnected(profile);
      queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
    }
  }
}
Program: 180957
Project: 180957
Buggy source:
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
}

Fixed version (ground truth):
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  disconnectConnected(profile);
  queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
}
Program: 180958
Project: 180958
Buggy source:
private void connectWithoutResettingTimer(){
  if (mProfiles.size() == 0) {
    if (!updateProfiles()) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      return;
    }
  }
  mIsConnectingErrorPossible=true;
  int preferredProfiles=0;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      if (profileManager.isPreferred(mDevice)) {
        ++preferredProfiles;
        queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}

Fixed version (ground truth):
private void connectWithoutResettingTimer(){
  if (mProfiles.size() == 0) {
    if (!updateProfiles()) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      return;
    }
  }
  mIsConnectingErrorPossible=true;
  int preferredProfiles=0;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      if (profileManager.isPreferred(mDevice)) {
        ++preferredProfiles;
        disconnectConnected(profile);
        queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}
Program: 180959
Project: 180959
Buggy source:
private void connectAllProfiles(){
  if (!ensurePaired())   return;
  mIsConnectingErrorPossible=true;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      profileManager.setPreferred(mDevice,false);
      queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
    }
  }
}

Fixed version (ground truth):
private void connectAllProfiles(){
  if (!ensurePaired())   return;
  mIsConnectingErrorPossible=true;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      profileManager.setPreferred(mDevice,false);
      disconnectConnected(profile);
      queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
    }
  }
}
Program: 180960
Project: 180960
Buggy source:
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
}

Fixed version (ground truth):
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  disconnectConnected(profile);
  queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
}
Program: 180961
Project: 180961
Buggy source:
private void connectWithoutResettingTimer(){
  if (mProfiles.size() == 0) {
    if (!updateProfiles()) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      return;
    }
  }
  mIsConnectingErrorPossible=true;
  int preferredProfiles=0;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      if (profileManager.isPreferred(mDevice)) {
        ++preferredProfiles;
        queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}

Fixed version (ground truth):
private void connectWithoutResettingTimer(){
  if (mProfiles.size() == 0) {
    if (!updateProfiles()) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      return;
    }
  }
  mIsConnectingErrorPossible=true;
  int preferredProfiles=0;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      if (profileManager.isPreferred(mDevice)) {
        ++preferredProfiles;
        disconnectConnected(profile);
        queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}
Program: 180962
Project: 180962
Buggy source:
private void connectAllProfiles(){
  if (!ensurePaired())   return;
  mIsConnectingErrorPossible=true;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      profileManager.setPreferred(mDevice,false);
      queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
    }
  }
}

Fixed version (ground truth):
private void connectAllProfiles(){
  if (!ensurePaired())   return;
  mIsConnectingErrorPossible=true;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      profileManager.setPreferred(mDevice,false);
      disconnectConnected(profile);
      queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
    }
  }
}
Program: 180963
Project: 180963
Buggy source:
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
}

Fixed version (ground truth):
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  disconnectConnected(profile);
  queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
}
Program: 180964
Project: 180964
Buggy source:
private void connectWithoutResettingTimer(){
  if (mProfiles.size() == 0) {
    if (!updateProfiles()) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      return;
    }
  }
  mIsConnectingErrorPossible=true;
  int preferredProfiles=0;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      if (profileManager.isPreferred(mDevice)) {
        ++preferredProfiles;
        queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}

Fixed version (ground truth):
private void connectWithoutResettingTimer(){
  if (mProfiles.size() == 0) {
    if (!updateProfiles()) {
      if (DEBUG)       Log.d(TAG,"String_Node_Str");
      return;
    }
  }
  mIsConnectingErrorPossible=true;
  int preferredProfiles=0;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      if (profileManager.isPreferred(mDevice)) {
        ++preferredProfiles;
        disconnectConnected(profile);
        queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}
Program: 180965
Project: 180965
Buggy source:
private void connectAllProfiles(){
  if (!ensurePaired())   return;
  mIsConnectingErrorPossible=true;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      profileManager.setPreferred(mDevice,false);
      queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
    }
  }
}

Fixed version (ground truth):
private void connectAllProfiles(){
  if (!ensurePaired())   return;
  mIsConnectingErrorPossible=true;
  for (  Profile profile : mProfiles) {
    if (isConnectableProfile(profile)) {
      LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
      profileManager.setPreferred(mDevice,false);
      disconnectConnected(profile);
      queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
    }
  }
}