nus-yam/ex-repair huggingface dataset:
Program: 180805
Project: 180805
Buggy source:
public void onBondingStateChanged(int bondState){
  if (bondState == BluetoothDevice.BOND_NONE) {
    mProfiles.clear();
    BluetoothJob job=workQueue.peek();
    if (job != null) {
      if (job.command == BluetoothCommand.REMOVE_BOND && job.cachedDevice.mDevice.equals(mDevice)) {
        workQueue.poll();
      }
 else {
        if (D) {
          Log.d(TAG,"String_Node_Str" + job.command);
          Log.d(TAG,"String_Node_Str" + mDevice + "String_Node_Str"+ job.toString());
        }
        if (!pruneQueue(null)) {
          refresh();
          return;
        }
      }
      processCommands();
    }
  }
  refresh();
}

Fixed version (ground truth):
public void onBondingStateChanged(int bondState){
  if (bondState == BluetoothDevice.BOND_NONE) {
    mProfiles.clear();
  }
  refresh();
}
Program: 180806
Project: 180806
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);
      disconnectConnected(profile);
      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);
      connectInt(this,profile);
    }
  }
}
Program: 180807
Project: 180807
Buggy source:
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  disconnectConnected(profile);
  queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
}

Fixed version (ground truth):
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  disconnectConnected(profile);
  connectInt(this,profile);
}
Program: 180808
Project: 180808
Buggy source:
private void disconnectConnected(Profile profile){
  LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
  CachedBluetoothDeviceManager cachedDeviceManager=mLocalManager.getCachedDeviceManager();
  Set<BluetoothDevice> devices=profileManager.getConnectedDevices();
  if (devices == null)   return;
  for (  BluetoothDevice device : devices) {
    CachedBluetoothDevice cachedDevice=cachedDeviceManager.findDevice(device);
    if (cachedDevice != null) {
      queueCommand(new BluetoothJob(BluetoothCommand.DISCONNECT,cachedDevice,profile));
    }
  }
}

Fixed version (ground truth):
private void disconnectConnected(Profile profile){
  LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
  CachedBluetoothDeviceManager cachedDeviceManager=mLocalManager.getCachedDeviceManager();
  Set<BluetoothDevice> devices=profileManager.getConnectedDevices();
  if (devices == null)   return;
  for (  BluetoothDevice device : devices) {
    CachedBluetoothDevice cachedDevice=cachedDeviceManager.findDevice(device);
    if (cachedDevice != null) {
      disconnectInt(cachedDevice,profile);
    }
  }
}
Program: 180809
Project: 180809
Buggy source:
private boolean connectInt(CachedBluetoothDevice cachedDevice,Profile profile){
  if (!cachedDevice.ensurePaired())   return false;
  LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
  int status=profileManager.getConnectionStatus(cachedDevice.mDevice);
  if (!SettingsBtStatus.isConnectionStatusConnected(status)) {
    if (profileManager.connect(cachedDevice.mDevice)) {
      return true;
    }
    Log.i(TAG,"String_Node_Str" + profile.toString() + "String_Node_Str"+ cachedDevice.mName);
  }
 else {
    Log.i(TAG,"String_Node_Str");
  }
  return false;
}

Fixed version (ground truth):
private boolean connectInt(CachedBluetoothDevice cachedDevice,Profile profile){
  if (!cachedDevice.ensurePaired())   return false;
  LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
  int status=profileManager.getConnectionStatus(cachedDevice.mDevice);
  if (!SettingsBtStatus.isConnectionStatusConnected(status)) {
    if (profileManager.connect(cachedDevice.mDevice)) {
      if (D) {
        Log.d(TAG,"String_Node_Str" + describe(profile));
      }
      return true;
    }
    Log.i(TAG,"String_Node_Str" + profile.toString() + "String_Node_Str"+ cachedDevice.mName);
  }
 else {
    Log.i(TAG,"String_Node_Str");
  }
  return false;
}
Program: 180810
Project: 180810
Buggy source:
public void disconnect(Profile profile){
  queueCommand(new BluetoothJob(BluetoothCommand.DISCONNECT,this,profile));
}

Fixed version (ground truth):
public void disconnect(Profile profile){
  disconnectInt(this,profile);
}
Program: 180811
Project: 180811
Buggy source:
public void onProfileStateChanged(Profile profile,int newProfileState){
synchronized (workQueue) {
    if (D) {
      Log.d(TAG,"String_Node_Str" + workQueue.toString());
    }
    int newState=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile).convertState(newProfileState);
    if (newState == SettingsBtStatus.CONNECTION_STATUS_CONNECTED) {
      if (!mProfiles.contains(profile)) {
        mProfiles.add(profile);
      }
    }
    if (newState == SettingsBtStatus.CONNECTION_STATUS_CONNECTED || newState == SettingsBtStatus.CONNECTION_STATUS_DISCONNECTED) {
      BluetoothJob job=workQueue.peek();
      if (job == null) {
        return;
      }
 else       if (!job.cachedDevice.mDevice.equals(mDevice)) {
        if (D) {
          Log.d(TAG,"String_Node_Str" + mDevice + "String_Node_Str"+ job.toString());
        }
        if (!pruneQueue(null)) {
          return;
        }
      }
 else {
        workQueue.poll();
      }
      processCommands();
    }
  }
}

Fixed version (ground truth):
public void onProfileStateChanged(Profile profile,int newProfileState){
  if (D) {
    Log.d(TAG,"String_Node_Str" + profile.toString() + "String_Node_Str"+ newProfileState);
  }
  int newState=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile).convertState(newProfileState);
  if (newState == SettingsBtStatus.CONNECTION_STATUS_CONNECTED) {
    if (!mProfiles.contains(profile)) {
      mProfiles.add(profile);
    }
  }
}
Program: 180812
Project: 180812
Buggy source:
public void unpair(){
  disconnect();
  int state=getBondState();
  if (state == BluetoothDevice.BOND_BONDING) {
    mDevice.cancelBondProcess();
  }
  if (state != BluetoothDevice.BOND_NONE) {
    queueCommand(new BluetoothJob(BluetoothCommand.REMOVE_BOND,this,null));
  }
}

Fixed version (ground truth):
public void unpair(){
  disconnect();
  int state=getBondState();
  if (state == BluetoothDevice.BOND_BONDING) {
    mDevice.cancelBondProcess();
  }
  if (state != BluetoothDevice.BOND_NONE) {
    final BluetoothDevice dev=getDevice();
    if (dev != null) {
      final boolean successful=dev.removeBond();
      if (successful) {
        if (D) {
          Log.d(TAG,"String_Node_Str" + describe(null));
        }
      }
 else       if (V) {
        Log.v(TAG,"String_Node_Str" + describe(null));
      }
    }
  }
}
Program: 180813
Project: 180813
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;
        disconnectConnected(profile);
        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);
        connectInt(this,profile);
      }
    }
  }
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + preferredProfiles);
  if (preferredProfiles == 0) {
    connectAllProfiles();
  }
}
Program: 180814
Project: 180814
Buggy source:
private boolean disconnectInt(CachedBluetoothDevice cachedDevice,Profile profile){
  LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
  int status=profileManager.getConnectionStatus(cachedDevice.mDevice);
  if (SettingsBtStatus.isConnectionStatusConnected(status)) {
    if (profileManager.disconnect(cachedDevice.mDevice)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean disconnectInt(CachedBluetoothDevice cachedDevice,Profile profile){
  LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
  int status=profileManager.getConnectionStatus(cachedDevice.mDevice);
  if (SettingsBtStatus.isConnectionStatusConnected(status)) {
    if (profileManager.disconnect(cachedDevice.mDevice)) {
      if (D) {
        Log.d(TAG,"String_Node_Str" + describe(profile));
      }
      return true;
    }
    if (V) {
      Log.v(TAG,"String_Node_Str" + describe(profile));
    }
  }
  return false;
}
Program: 180815
Project: 180815
Buggy source:
public void onBondingStateChanged(int bondState){
  if (bondState == BluetoothDevice.BOND_NONE) {
    mProfiles.clear();
    BluetoothJob job=workQueue.peek();
    if (job != null) {
      if (job.command == BluetoothCommand.REMOVE_BOND && job.cachedDevice.mDevice.equals(mDevice)) {
        workQueue.poll();
      }
 else {
        if (D) {
          Log.d(TAG,"String_Node_Str" + job.command);
          Log.d(TAG,"String_Node_Str" + mDevice + "String_Node_Str"+ job.toString());
        }
        if (!pruneQueue(null)) {
          refresh();
          return;
        }
      }
      processCommands();
    }
  }
  refresh();
}

Fixed version (ground truth):
public void onBondingStateChanged(int bondState){
  if (bondState == BluetoothDevice.BOND_NONE) {
    mProfiles.clear();
  }
  refresh();
}
Program: 180816
Project: 180816
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);
      disconnectConnected(profile);
      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);
      connectInt(this,profile);
    }
  }
}
Program: 180817
Project: 180817
Buggy source:
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  disconnectConnected(profile);
  queueCommand(new BluetoothJob(BluetoothCommand.CONNECT,this,profile));
}

Fixed version (ground truth):
public void connect(Profile profile){
  mConnectAttempted=SystemClock.elapsedRealtime();
  mIsConnectingErrorPossible=true;
  disconnectConnected(profile);
  connectInt(this,profile);
}
Program: 180818
Project: 180818
Buggy source:
private void disconnectConnected(Profile profile){
  LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
  CachedBluetoothDeviceManager cachedDeviceManager=mLocalManager.getCachedDeviceManager();
  Set<BluetoothDevice> devices=profileManager.getConnectedDevices();
  if (devices == null)   return;
  for (  BluetoothDevice device : devices) {
    CachedBluetoothDevice cachedDevice=cachedDeviceManager.findDevice(device);
    if (cachedDevice != null) {
      queueCommand(new BluetoothJob(BluetoothCommand.DISCONNECT,cachedDevice,profile));
    }
  }
}

Fixed version (ground truth):
private void disconnectConnected(Profile profile){
  LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
  CachedBluetoothDeviceManager cachedDeviceManager=mLocalManager.getCachedDeviceManager();
  Set<BluetoothDevice> devices=profileManager.getConnectedDevices();
  if (devices == null)   return;
  for (  BluetoothDevice device : devices) {
    CachedBluetoothDevice cachedDevice=cachedDeviceManager.findDevice(device);
    if (cachedDevice != null) {
      disconnectInt(cachedDevice,profile);
    }
  }
}
Program: 180819
Project: 180819
Buggy source:
private boolean connectInt(CachedBluetoothDevice cachedDevice,Profile profile){
  if (!cachedDevice.ensurePaired())   return false;
  LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
  int status=profileManager.getConnectionStatus(cachedDevice.mDevice);
  if (!SettingsBtStatus.isConnectionStatusConnected(status)) {
    if (profileManager.connect(cachedDevice.mDevice)) {
      return true;
    }
    Log.i(TAG,"String_Node_Str" + profile.toString() + "String_Node_Str"+ cachedDevice.mName);
  }
 else {
    Log.i(TAG,"String_Node_Str");
  }
  return false;
}

Fixed version (ground truth):
private boolean connectInt(CachedBluetoothDevice cachedDevice,Profile profile){
  if (!cachedDevice.ensurePaired())   return false;
  LocalBluetoothProfileManager profileManager=LocalBluetoothProfileManager.getProfileManager(mLocalManager,profile);
  int status=profileManager.getConnectionStatus(cachedDevice.mDevice);
  if (!SettingsBtStatus.isConnectionStatusConnected(status)) {
    if (profileManager.connect(cachedDevice.mDevice)) {
      if (D) {
        Log.d(TAG,"String_Node_Str" + describe(profile));
      }
      return true;
    }
    Log.i(TAG,"String_Node_Str" + profile.toString() + "String_Node_Str"+ cachedDevice.mName);
  }
 else {
    Log.i(TAG,"String_Node_Str");
  }
  return false;
}
Program: 180821
Project: 180821
Buggy source:
@Override public void onDestroy(){
  if (DEBUG)   Log.d(TAG,"String_Node_Str");
  if (mDialog != null) {
    mDialog.dismiss();
    mDialog=null;
  }
  mServiceLooper.quit();
}

Fixed version (ground truth):
@Override public void onDestroy(){
  if (DEBUG)   Log.d(TAG,"String_Node_Str");
  mRunnable=null;
  LocalBluetoothProfileManager.removeServiceListener(this);
  if (mDialog != null) {
    mDialog.dismiss();
    mDialog=null;
  }
  mServiceLooper.quit();
}
Program: 180822
Project: 180822
Buggy source:
private synchronized void handleUndocked(Context context,LocalBluetoothManager localManager,BluetoothDevice device){
  if (mDialog != null) {
    mDialog.dismiss();
    mDialog=null;
  }
  mDevice=null;
  mPendingDevice=null;
  CachedBluetoothDevice cachedBluetoothDevice=getCachedBluetoothDevice(context,localManager,device);
  cachedBluetoothDevice.disconnect();
}

Fixed version (ground truth):
private synchronized void handleUndocked(Context context,LocalBluetoothManager localManager,BluetoothDevice device){
  mRunnable=null;
  LocalBluetoothProfileManager.removeServiceListener(this);
  if (mDialog != null) {
    mDialog.dismiss();
    mDialog=null;
  }
  mDevice=null;
  mPendingDevice=null;
  CachedBluetoothDevice cachedBluetoothDevice=getCachedBluetoothDevice(context,localManager,device);
  cachedBluetoothDevice.disconnect();
}
Program: 180823
Project: 180823
Buggy source:
public void onServiceDisconnected(){
}

Fixed version (ground truth):
public void onServiceDisconnected(){
  profileReady=false;
  if (mServiceListeners.size() > 0) {
    Iterator<ServiceListener> it=mServiceListeners.iterator();
    while (it.hasNext()) {
      it.next().onServiceDisconnected();
    }
  }
}
Program: 180824
Project: 180824
Buggy source:
public void onServiceConnected(){
  mUiHandler.post(new Runnable(){
    public void run(){
      BluetoothDevice device=mService.getCurrentHeadset();
      if (device == null)       return;
      mLocalManager.getCachedDeviceManager().onProfileStateChanged(device,Profile.HEADSET,BluetoothHeadset.STATE_CONNECTED);
    }
  }
);
}

Fixed version (ground truth):
public void onServiceConnected(){
  profileReady=true;
  mUiHandler.post(new Runnable(){
    public void run(){
      BluetoothDevice device=mService.getCurrentHeadset();
      if (device == null)       return;
      mLocalManager.getCachedDeviceManager().onProfileStateChanged(device,Profile.HEADSET,BluetoothHeadset.STATE_CONNECTED);
    }
  }
);
  if (mServiceListeners.size() > 0) {
    Iterator<ServiceListener> it=mServiceListeners.iterator();
    while (it.hasNext()) {
      it.next().onServiceConnected();
    }
  }
}
Program: 180826
Project: 180826
Buggy source:
@Override public void onDestroy(){
  if (DEBUG)   Log.d(TAG,"String_Node_Str");
  if (mDialog != null) {
    mDialog.dismiss();
    mDialog=null;
  }
  mServiceLooper.quit();
}

Fixed version (ground truth):
@Override public void onDestroy(){
  if (DEBUG)   Log.d(TAG,"String_Node_Str");
  mRunnable=null;
  LocalBluetoothProfileManager.removeServiceListener(this);
  if (mDialog != null) {
    mDialog.dismiss();
    mDialog=null;
  }
  mServiceLooper.quit();
}
Program: 180827
Project: 180827
Buggy source:
private synchronized void handleUndocked(Context context,LocalBluetoothManager localManager,BluetoothDevice device){
  if (mDialog != null) {
    mDialog.dismiss();
    mDialog=null;
  }
  mDevice=null;
  mPendingDevice=null;
  CachedBluetoothDevice cachedBluetoothDevice=getCachedBluetoothDevice(context,localManager,device);
  cachedBluetoothDevice.disconnect();
}

Fixed version (ground truth):
private synchronized void handleUndocked(Context context,LocalBluetoothManager localManager,BluetoothDevice device){
  mRunnable=null;
  LocalBluetoothProfileManager.removeServiceListener(this);
  if (mDialog != null) {
    mDialog.dismiss();
    mDialog=null;
  }
  mDevice=null;
  mPendingDevice=null;
  CachedBluetoothDevice cachedBluetoothDevice=getCachedBluetoothDevice(context,localManager,device);
  cachedBluetoothDevice.disconnect();
}
Program: 180828
Project: 180828
Buggy source:
public void onServiceDisconnected(){
}

Fixed version (ground truth):
public void onServiceDisconnected(){
  profileReady=false;
  if (mServiceListeners.size() > 0) {
    Iterator<ServiceListener> it=mServiceListeners.iterator();
    while (it.hasNext()) {
      it.next().onServiceDisconnected();
    }
  }
}
Program: 180829
Project: 180829
Buggy source:
public void onServiceConnected(){
  mUiHandler.post(new Runnable(){
    public void run(){
      BluetoothDevice device=mService.getCurrentHeadset();
      if (device == null)       return;
      mLocalManager.getCachedDeviceManager().onProfileStateChanged(device,Profile.HEADSET,BluetoothHeadset.STATE_CONNECTED);
    }
  }
);
}

Fixed version (ground truth):
public void onServiceConnected(){
  profileReady=true;
  mUiHandler.post(new Runnable(){
    public void run(){
      BluetoothDevice device=mService.getCurrentHeadset();
      if (device == null)       return;
      mLocalManager.getCachedDeviceManager().onProfileStateChanged(device,Profile.HEADSET,BluetoothHeadset.STATE_CONNECTED);
    }
  }
);
  if (mServiceListeners.size() > 0) {
    Iterator<ServiceListener> it=mServiceListeners.iterator();
    while (it.hasNext()) {
      it.next().onServiceConnected();
    }
  }
}
Program: 180830
Project: 180830
Buggy source:
protected void onCreate(Bundle savedInstanceState){
  mView=getLayoutInflater().inflate(R.layout.wifi_ap_dialog,null);
  Spinner mSecurity=((Spinner)mView.findViewById(R.id.security));
  setView(mView);
  setInverseBackgroundForced(true);
  Context context=getContext();
  setTitle(R.string.wifi_tether_configure_ap_text);
  mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
  mSsid=(TextView)mView.findViewById(R.id.ssid);
  mPassword=(EditText)mView.findViewById(R.id.password);
  setButton(BUTTON_SUBMIT,context.getString(R.string.wifi_save),mListener);
  setButton(DialogInterface.BUTTON_NEGATIVE,context.getString(R.string.wifi_cancel),mListener);
  if (mWifiConfig != null) {
    mSsid.setText(mWifiConfig.SSID);
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
      mSecurity.setSelection(OPEN_INDEX);
    break;
case AccessPoint.SECURITY_PSK:
  String str=mWifiConfig.preSharedKey;
if (!str.matches("String_Node_Str")) {
  str=str.substring(1,str.length() - 1);
}
mPassword.setText(str);
mSecurity.setSelection(WPA_INDEX);
break;
}
}
mSsid.addTextChangedListener(this);
mPassword.addTextChangedListener(this);
((CheckBox)mView.findViewById(R.id.show_password)).setOnClickListener(this);
mSecurity.setOnItemSelectedListener(this);
super.onCreate(savedInstanceState);
showSecurityFields();
validate();
}

Fixed version (ground truth):
protected void onCreate(Bundle savedInstanceState){
  mView=getLayoutInflater().inflate(R.layout.wifi_ap_dialog,null);
  Spinner mSecurity=((Spinner)mView.findViewById(R.id.security));
  setView(mView);
  setInverseBackgroundForced(true);
  Context context=getContext();
  setTitle(R.string.wifi_tether_configure_ap_text);
  mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
  mSsid=(TextView)mView.findViewById(R.id.ssid);
  mPassword=(EditText)mView.findViewById(R.id.password);
  setButton(BUTTON_SUBMIT,context.getString(R.string.wifi_save),mListener);
  setButton(DialogInterface.BUTTON_NEGATIVE,context.getString(R.string.wifi_cancel),mListener);
  if (mWifiConfig != null) {
    mSsid.setText(AccessPoint.removeDoubleQuotes(mWifiConfig.SSID));
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
      mSecurity.setSelection(OPEN_INDEX);
    break;
case AccessPoint.SECURITY_PSK:
  String str=mWifiConfig.preSharedKey;
if (!str.matches("String_Node_Str")) {
  str=str.substring(1,str.length() - 1);
}
mPassword.setText(str);
mSecurity.setSelection(WPA_INDEX);
break;
}
}
mSsid.addTextChangedListener(this);
mPassword.addTextChangedListener(this);
((CheckBox)mView.findViewById(R.id.show_password)).setOnClickListener(this);
mSecurity.setOnItemSelectedListener(this);
super.onCreate(savedInstanceState);
showSecurityFields();
validate();
}
Program: 180831
Project: 180831
Buggy source:
public WifiConfiguration getConfig(){
  WifiConfiguration config=new WifiConfiguration();
  config.SSID=mSsid.getText().toString();
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
    config.allowedKeyManagement.set(KeyMgmt.NONE);
  return config;
case AccessPoint.SECURITY_PSK:
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
if (mPassword.length() != 0) {
String password=mPassword.getText().toString();
if (password.matches("String_Node_Str")) {
config.preSharedKey=password;
}
 else {
config.preSharedKey='"' + password + '"';
}
}
return config;
}
return null;
}

Fixed version (ground truth):
public WifiConfiguration getConfig(){
  WifiConfiguration config=new WifiConfiguration();
  config.SSID=AccessPoint.convertToQuotedString(mSsid.getText().toString());
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
    config.allowedKeyManagement.set(KeyMgmt.NONE);
  return config;
case AccessPoint.SECURITY_PSK:
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
if (mPassword.length() != 0) {
String password=mPassword.getText().toString();
if (password.matches("String_Node_Str")) {
config.preSharedKey=password;
}
 else {
config.preSharedKey='"' + password + '"';
}
}
return config;
}
return null;
}
Program: 180832
Project: 180832
Buggy source:
void updateConfigSummary(WifiConfiguration wifiConfig){
  String s=mContext.getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
  mCheckBox.setSummary(String.format(mContext.getString(R.string.wifi_tether_enabled_subtext),(wifiConfig == null) ? s : wifiConfig.SSID));
}

Fixed version (ground truth):
void updateConfigSummary(WifiConfiguration wifiConfig){
  String s=mContext.getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
  mCheckBox.setSummary(String.format(mContext.getString(R.string.wifi_tether_enabled_subtext),(wifiConfig == null) ? s : AccessPoint.removeDoubleQuotes(wifiConfig.SSID)));
}
Program: 180833
Project: 180833
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mWifiManager=(WifiManager)getSystemService(Context.WIFI_SERVICE);
  mWifiConfig=mWifiManager.getWifiApConfiguration();
  mSecurityType=getResources().getStringArray(R.array.wifi_ap_security);
  addPreferencesFromResource(R.xml.wifi_ap_settings);
  mCreateNetwork=findPreference(WIFI_AP_SSID_AND_SECURITY);
  mEnableWifiAp=(CheckBoxPreference)findPreference(ENABLE_WIFI_AP);
  mWifiApEnabler=new WifiApEnabler(this,mEnableWifiAp);
  if (mWifiConfig == null) {
    String s=getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),s,mSecurityType[OPEN_INDEX]));
  }
 else {
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),mWifiConfig.SSID,mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mWifiManager=(WifiManager)getSystemService(Context.WIFI_SERVICE);
  mWifiConfig=mWifiManager.getWifiApConfiguration();
  mSecurityType=getResources().getStringArray(R.array.wifi_ap_security);
  addPreferencesFromResource(R.xml.wifi_ap_settings);
  mCreateNetwork=findPreference(WIFI_AP_SSID_AND_SECURITY);
  mEnableWifiAp=(CheckBoxPreference)findPreference(ENABLE_WIFI_AP);
  mWifiApEnabler=new WifiApEnabler(this,mEnableWifiAp);
  if (mWifiConfig == null) {
    String s=getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),s,mSecurityType[OPEN_INDEX]));
  }
 else {
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),AccessPoint.removeDoubleQuotes(mWifiConfig.SSID),mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
  }
}
Program: 180834
Project: 180834
Buggy source:
public void onClick(DialogInterface dialogInterface,int button){
  if (button == DialogInterface.BUTTON_POSITIVE) {
    mWifiConfig=mDialog.getConfig();
    if (mWifiConfig != null) {
      mWifiManager.setWifiApEnabled(mWifiConfig,true);
      mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),mWifiConfig.SSID,mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
      mWifiApEnabler.updateConfigSummary(mWifiConfig);
    }
  }
}

Fixed version (ground truth):
public void onClick(DialogInterface dialogInterface,int button){
  if (button == DialogInterface.BUTTON_POSITIVE) {
    mWifiConfig=mDialog.getConfig();
    if (mWifiConfig != null) {
      mWifiManager.setWifiApEnabled(mWifiConfig,true);
      mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),AccessPoint.removeDoubleQuotes(mWifiConfig.SSID),mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
      mWifiApEnabler.updateConfigSummary(mWifiConfig);
    }
  }
}
Program: 180836
Project: 180836
Buggy source:
@Override public boolean onContextItemSelected(MenuItem item){
  if (mSelected == null) {
    return super.onContextItemSelected(item);
  }
switch (item.getItemId()) {
case MENU_ID_CONNECT:
    if (mSelected.networkId != -1) {
      if (!requireKeyStore(mSelected.getConfig())) {
        connect(mSelected.networkId);
      }
    }
 else     if (mSelected.security == AccessPoint.SECURITY_NONE) {
      WifiConfiguration config=new WifiConfiguration();
      config.SSID=mSelected.ssid;
      config.allowedKeyManagement.set(KeyMgmt.NONE);
      int networkId=mWifiManager.addNetwork(config);
      mWifiManager.enableNetwork(networkId,false);
      connect(networkId);
    }
 else {
      showDialog(mSelected,false);
    }
  return true;
case MENU_ID_FORGET:
forget(mSelected.networkId);
return true;
case MENU_ID_MODIFY:
showDialog(mSelected,true);
return true;
}
return super.onContextItemSelected(item);
}

Fixed version (ground truth):
@Override public boolean onContextItemSelected(MenuItem item){
  if (mSelected == null) {
    return super.onContextItemSelected(item);
  }
switch (item.getItemId()) {
case MENU_ID_CONNECT:
    if (mSelected.networkId != -1) {
      if (!requireKeyStore(mSelected.getConfig())) {
        connect(mSelected.networkId);
      }
    }
 else     if (mSelected.security == AccessPoint.SECURITY_NONE) {
      WifiConfiguration config=new WifiConfiguration();
      config.SSID=AccessPoint.convertToQuotedString(mSelected.ssid);
      config.allowedKeyManagement.set(KeyMgmt.NONE);
      int networkId=mWifiManager.addNetwork(config);
      mWifiManager.enableNetwork(networkId,false);
      connect(networkId);
    }
 else {
      showDialog(mSelected,false);
    }
  return true;
case MENU_ID_FORGET:
forget(mSelected.networkId);
return true;
case MENU_ID_MODIFY:
showDialog(mSelected,true);
return true;
}
return super.onContextItemSelected(item);
}
Program: 180837
Project: 180837
Buggy source:
protected void onCreate(Bundle savedInstanceState){
  mView=getLayoutInflater().inflate(R.layout.wifi_ap_dialog,null);
  Spinner mSecurity=((Spinner)mView.findViewById(R.id.security));
  setView(mView);
  setInverseBackgroundForced(true);
  Context context=getContext();
  setTitle(R.string.wifi_tether_configure_ap_text);
  mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
  mSsid=(TextView)mView.findViewById(R.id.ssid);
  mPassword=(EditText)mView.findViewById(R.id.password);
  setButton(BUTTON_SUBMIT,context.getString(R.string.wifi_save),mListener);
  setButton(DialogInterface.BUTTON_NEGATIVE,context.getString(R.string.wifi_cancel),mListener);
  if (mWifiConfig != null) {
    mSsid.setText(mWifiConfig.SSID);
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
      mSecurity.setSelection(OPEN_INDEX);
    break;
case AccessPoint.SECURITY_PSK:
  String str=mWifiConfig.preSharedKey;
if (!str.matches("String_Node_Str")) {
  str=str.substring(1,str.length() - 1);
}
mPassword.setText(str);
mSecurity.setSelection(WPA_INDEX);
break;
}
}
mSsid.addTextChangedListener(this);
mPassword.addTextChangedListener(this);
((CheckBox)mView.findViewById(R.id.show_password)).setOnClickListener(this);
mSecurity.setOnItemSelectedListener(this);
super.onCreate(savedInstanceState);
showSecurityFields();
validate();
}

Fixed version (ground truth):
protected void onCreate(Bundle savedInstanceState){
  mView=getLayoutInflater().inflate(R.layout.wifi_ap_dialog,null);
  Spinner mSecurity=((Spinner)mView.findViewById(R.id.security));
  setView(mView);
  setInverseBackgroundForced(true);
  Context context=getContext();
  setTitle(R.string.wifi_tether_configure_ap_text);
  mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
  mSsid=(TextView)mView.findViewById(R.id.ssid);
  mPassword=(EditText)mView.findViewById(R.id.password);
  setButton(BUTTON_SUBMIT,context.getString(R.string.wifi_save),mListener);
  setButton(DialogInterface.BUTTON_NEGATIVE,context.getString(R.string.wifi_cancel),mListener);
  if (mWifiConfig != null) {
    mSsid.setText(AccessPoint.removeDoubleQuotes(mWifiConfig.SSID));
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
      mSecurity.setSelection(OPEN_INDEX);
    break;
case AccessPoint.SECURITY_PSK:
  String str=mWifiConfig.preSharedKey;
if (!str.matches("String_Node_Str")) {
  str=str.substring(1,str.length() - 1);
}
mPassword.setText(str);
mSecurity.setSelection(WPA_INDEX);
break;
}
}
mSsid.addTextChangedListener(this);
mPassword.addTextChangedListener(this);
((CheckBox)mView.findViewById(R.id.show_password)).setOnClickListener(this);
mSecurity.setOnItemSelectedListener(this);
super.onCreate(savedInstanceState);
showSecurityFields();
validate();
}
Program: 180838
Project: 180838
Buggy source:
public WifiConfiguration getConfig(){
  WifiConfiguration config=new WifiConfiguration();
  config.SSID=mSsid.getText().toString();
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
    config.allowedKeyManagement.set(KeyMgmt.NONE);
  return config;
case AccessPoint.SECURITY_PSK:
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
if (mPassword.length() != 0) {
String password=mPassword.getText().toString();
if (password.matches("String_Node_Str")) {
config.preSharedKey=password;
}
 else {
config.preSharedKey='"' + password + '"';
}
}
return config;
}
return null;
}

Fixed version (ground truth):
public WifiConfiguration getConfig(){
  WifiConfiguration config=new WifiConfiguration();
  config.SSID=AccessPoint.convertToQuotedString(mSsid.getText().toString());
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
    config.allowedKeyManagement.set(KeyMgmt.NONE);
  return config;
case AccessPoint.SECURITY_PSK:
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
if (mPassword.length() != 0) {
String password=mPassword.getText().toString();
if (password.matches("String_Node_Str")) {
config.preSharedKey=password;
}
 else {
config.preSharedKey='"' + password + '"';
}
}
return config;
}
return null;
}
Program: 180839
Project: 180839
Buggy source:
void updateConfigSummary(WifiConfiguration wifiConfig){
  String s=mContext.getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
  mCheckBox.setSummary(String.format(mContext.getString(R.string.wifi_tether_enabled_subtext),(wifiConfig == null) ? s : wifiConfig.SSID));
}

Fixed version (ground truth):
void updateConfigSummary(WifiConfiguration wifiConfig){
  String s=mContext.getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
  mCheckBox.setSummary(String.format(mContext.getString(R.string.wifi_tether_enabled_subtext),(wifiConfig == null) ? s : AccessPoint.removeDoubleQuotes(wifiConfig.SSID)));
}
Program: 180840
Project: 180840
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mWifiManager=(WifiManager)getSystemService(Context.WIFI_SERVICE);
  mWifiConfig=mWifiManager.getWifiApConfiguration();
  mSecurityType=getResources().getStringArray(R.array.wifi_ap_security);
  addPreferencesFromResource(R.xml.wifi_ap_settings);
  mCreateNetwork=findPreference(WIFI_AP_SSID_AND_SECURITY);
  mEnableWifiAp=(CheckBoxPreference)findPreference(ENABLE_WIFI_AP);
  mWifiApEnabler=new WifiApEnabler(this,mEnableWifiAp);
  if (mWifiConfig == null) {
    String s=getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),s,mSecurityType[OPEN_INDEX]));
  }
 else {
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),mWifiConfig.SSID,mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mWifiManager=(WifiManager)getSystemService(Context.WIFI_SERVICE);
  mWifiConfig=mWifiManager.getWifiApConfiguration();
  mSecurityType=getResources().getStringArray(R.array.wifi_ap_security);
  addPreferencesFromResource(R.xml.wifi_ap_settings);
  mCreateNetwork=findPreference(WIFI_AP_SSID_AND_SECURITY);
  mEnableWifiAp=(CheckBoxPreference)findPreference(ENABLE_WIFI_AP);
  mWifiApEnabler=new WifiApEnabler(this,mEnableWifiAp);
  if (mWifiConfig == null) {
    String s=getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),s,mSecurityType[OPEN_INDEX]));
  }
 else {
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),AccessPoint.removeDoubleQuotes(mWifiConfig.SSID),mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
  }
}
Program: 180841
Project: 180841
Buggy source:
public void onClick(DialogInterface dialogInterface,int button){
  if (button == DialogInterface.BUTTON_POSITIVE) {
    mWifiConfig=mDialog.getConfig();
    if (mWifiConfig != null) {
      mWifiManager.setWifiApEnabled(mWifiConfig,true);
      mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),mWifiConfig.SSID,mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
      mWifiApEnabler.updateConfigSummary(mWifiConfig);
    }
  }
}

Fixed version (ground truth):
public void onClick(DialogInterface dialogInterface,int button){
  if (button == DialogInterface.BUTTON_POSITIVE) {
    mWifiConfig=mDialog.getConfig();
    if (mWifiConfig != null) {
      mWifiManager.setWifiApEnabled(mWifiConfig,true);
      mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),AccessPoint.removeDoubleQuotes(mWifiConfig.SSID),mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
      mWifiApEnabler.updateConfigSummary(mWifiConfig);
    }
  }
}
Program: 180843
Project: 180843
Buggy source:
@Override public boolean onContextItemSelected(MenuItem item){
  if (mSelected == null) {
    return super.onContextItemSelected(item);
  }
switch (item.getItemId()) {
case MENU_ID_CONNECT:
    if (mSelected.networkId != -1) {
      if (!requireKeyStore(mSelected.getConfig())) {
        connect(mSelected.networkId);
      }
    }
 else     if (mSelected.security == AccessPoint.SECURITY_NONE) {
      WifiConfiguration config=new WifiConfiguration();
      config.SSID=mSelected.ssid;
      config.allowedKeyManagement.set(KeyMgmt.NONE);
      int networkId=mWifiManager.addNetwork(config);
      mWifiManager.enableNetwork(networkId,false);
      connect(networkId);
    }
 else {
      showDialog(mSelected,false);
    }
  return true;
case MENU_ID_FORGET:
forget(mSelected.networkId);
return true;
case MENU_ID_MODIFY:
showDialog(mSelected,true);
return true;
}
return super.onContextItemSelected(item);
}

Fixed version (ground truth):
@Override public boolean onContextItemSelected(MenuItem item){
  if (mSelected == null) {
    return super.onContextItemSelected(item);
  }
switch (item.getItemId()) {
case MENU_ID_CONNECT:
    if (mSelected.networkId != -1) {
      if (!requireKeyStore(mSelected.getConfig())) {
        connect(mSelected.networkId);
      }
    }
 else     if (mSelected.security == AccessPoint.SECURITY_NONE) {
      WifiConfiguration config=new WifiConfiguration();
      config.SSID=AccessPoint.convertToQuotedString(mSelected.ssid);
      config.allowedKeyManagement.set(KeyMgmt.NONE);
      int networkId=mWifiManager.addNetwork(config);
      mWifiManager.enableNetwork(networkId,false);
      connect(networkId);
    }
 else {
      showDialog(mSelected,false);
    }
  return true;
case MENU_ID_FORGET:
forget(mSelected.networkId);
return true;
case MENU_ID_MODIFY:
showDialog(mSelected,true);
return true;
}
return super.onContextItemSelected(item);
}
Program: 180844
Project: 180844
Buggy source:
protected void onCreate(Bundle savedInstanceState){
  mView=getLayoutInflater().inflate(R.layout.wifi_ap_dialog,null);
  Spinner mSecurity=((Spinner)mView.findViewById(R.id.security));
  setView(mView);
  setInverseBackgroundForced(true);
  Context context=getContext();
  setTitle(R.string.wifi_tether_configure_ap_text);
  mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
  mSsid=(TextView)mView.findViewById(R.id.ssid);
  mPassword=(EditText)mView.findViewById(R.id.password);
  setButton(BUTTON_SUBMIT,context.getString(R.string.wifi_save),mListener);
  setButton(DialogInterface.BUTTON_NEGATIVE,context.getString(R.string.wifi_cancel),mListener);
  if (mWifiConfig != null) {
    mSsid.setText(mWifiConfig.SSID);
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
      mSecurity.setSelection(OPEN_INDEX);
    break;
case AccessPoint.SECURITY_PSK:
  String str=mWifiConfig.preSharedKey;
if (!str.matches("String_Node_Str")) {
  str=str.substring(1,str.length() - 1);
}
mPassword.setText(str);
mSecurity.setSelection(WPA_INDEX);
break;
}
}
mSsid.addTextChangedListener(this);
mPassword.addTextChangedListener(this);
((CheckBox)mView.findViewById(R.id.show_password)).setOnClickListener(this);
mSecurity.setOnItemSelectedListener(this);
super.onCreate(savedInstanceState);
showSecurityFields();
validate();
}

Fixed version (ground truth):
protected void onCreate(Bundle savedInstanceState){
  mView=getLayoutInflater().inflate(R.layout.wifi_ap_dialog,null);
  Spinner mSecurity=((Spinner)mView.findViewById(R.id.security));
  setView(mView);
  setInverseBackgroundForced(true);
  Context context=getContext();
  setTitle(R.string.wifi_tether_configure_ap_text);
  mView.findViewById(R.id.type).setVisibility(View.VISIBLE);
  mSsid=(TextView)mView.findViewById(R.id.ssid);
  mPassword=(EditText)mView.findViewById(R.id.password);
  setButton(BUTTON_SUBMIT,context.getString(R.string.wifi_save),mListener);
  setButton(DialogInterface.BUTTON_NEGATIVE,context.getString(R.string.wifi_cancel),mListener);
  if (mWifiConfig != null) {
    mSsid.setText(AccessPoint.removeDoubleQuotes(mWifiConfig.SSID));
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
      mSecurity.setSelection(OPEN_INDEX);
    break;
case AccessPoint.SECURITY_PSK:
  String str=mWifiConfig.preSharedKey;
if (!str.matches("String_Node_Str")) {
  str=str.substring(1,str.length() - 1);
}
mPassword.setText(str);
mSecurity.setSelection(WPA_INDEX);
break;
}
}
mSsid.addTextChangedListener(this);
mPassword.addTextChangedListener(this);
((CheckBox)mView.findViewById(R.id.show_password)).setOnClickListener(this);
mSecurity.setOnItemSelectedListener(this);
super.onCreate(savedInstanceState);
showSecurityFields();
validate();
}
Program: 180845
Project: 180845
Buggy source:
public WifiConfiguration getConfig(){
  WifiConfiguration config=new WifiConfiguration();
  config.SSID=mSsid.getText().toString();
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
    config.allowedKeyManagement.set(KeyMgmt.NONE);
  return config;
case AccessPoint.SECURITY_PSK:
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
if (mPassword.length() != 0) {
String password=mPassword.getText().toString();
if (password.matches("String_Node_Str")) {
config.preSharedKey=password;
}
 else {
config.preSharedKey='"' + password + '"';
}
}
return config;
}
return null;
}

Fixed version (ground truth):
public WifiConfiguration getConfig(){
  WifiConfiguration config=new WifiConfiguration();
  config.SSID=AccessPoint.convertToQuotedString(mSsid.getText().toString());
switch (mSecurityType) {
case AccessPoint.SECURITY_NONE:
    config.allowedKeyManagement.set(KeyMgmt.NONE);
  return config;
case AccessPoint.SECURITY_PSK:
config.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
config.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
if (mPassword.length() != 0) {
String password=mPassword.getText().toString();
if (password.matches("String_Node_Str")) {
config.preSharedKey=password;
}
 else {
config.preSharedKey='"' + password + '"';
}
}
return config;
}
return null;
}
Program: 180846
Project: 180846
Buggy source:
void updateConfigSummary(WifiConfiguration wifiConfig){
  String s=mContext.getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
  mCheckBox.setSummary(String.format(mContext.getString(R.string.wifi_tether_enabled_subtext),(wifiConfig == null) ? s : wifiConfig.SSID));
}

Fixed version (ground truth):
void updateConfigSummary(WifiConfiguration wifiConfig){
  String s=mContext.getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
  mCheckBox.setSummary(String.format(mContext.getString(R.string.wifi_tether_enabled_subtext),(wifiConfig == null) ? s : AccessPoint.removeDoubleQuotes(wifiConfig.SSID)));
}
Program: 180847
Project: 180847
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mWifiManager=(WifiManager)getSystemService(Context.WIFI_SERVICE);
  mWifiConfig=mWifiManager.getWifiApConfiguration();
  mSecurityType=getResources().getStringArray(R.array.wifi_ap_security);
  addPreferencesFromResource(R.xml.wifi_ap_settings);
  mCreateNetwork=findPreference(WIFI_AP_SSID_AND_SECURITY);
  mEnableWifiAp=(CheckBoxPreference)findPreference(ENABLE_WIFI_AP);
  mWifiApEnabler=new WifiApEnabler(this,mEnableWifiAp);
  if (mWifiConfig == null) {
    String s=getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),s,mSecurityType[OPEN_INDEX]));
  }
 else {
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),mWifiConfig.SSID,mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  mWifiManager=(WifiManager)getSystemService(Context.WIFI_SERVICE);
  mWifiConfig=mWifiManager.getWifiApConfiguration();
  mSecurityType=getResources().getStringArray(R.array.wifi_ap_security);
  addPreferencesFromResource(R.xml.wifi_ap_settings);
  mCreateNetwork=findPreference(WIFI_AP_SSID_AND_SECURITY);
  mEnableWifiAp=(CheckBoxPreference)findPreference(ENABLE_WIFI_AP);
  mWifiApEnabler=new WifiApEnabler(this,mEnableWifiAp);
  if (mWifiConfig == null) {
    String s=getString(com.android.internal.R.string.wifi_tether_configure_ssid_default);
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),s,mSecurityType[OPEN_INDEX]));
  }
 else {
    mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),AccessPoint.removeDoubleQuotes(mWifiConfig.SSID),mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
  }
}
Program: 180848
Project: 180848
Buggy source:
public void onClick(DialogInterface dialogInterface,int button){
  if (button == DialogInterface.BUTTON_POSITIVE) {
    mWifiConfig=mDialog.getConfig();
    if (mWifiConfig != null) {
      mWifiManager.setWifiApEnabled(mWifiConfig,true);
      mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),mWifiConfig.SSID,mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
      mWifiApEnabler.updateConfigSummary(mWifiConfig);
    }
  }
}

Fixed version (ground truth):
public void onClick(DialogInterface dialogInterface,int button){
  if (button == DialogInterface.BUTTON_POSITIVE) {
    mWifiConfig=mDialog.getConfig();
    if (mWifiConfig != null) {
      mWifiManager.setWifiApEnabled(mWifiConfig,true);
      mCreateNetwork.setSummary(String.format(getString(CONFIG_SUBTEXT),AccessPoint.removeDoubleQuotes(mWifiConfig.SSID),mWifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ? mSecurityType[WPA_INDEX] : mSecurityType[OPEN_INDEX]));
      mWifiApEnabler.updateConfigSummary(mWifiConfig);
    }
  }
}