nus-yam/ex-repair huggingface dataset:
Program: 180850
Project: 180850
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: 180851
Project: 180851
Buggy source:
public void unpair(){
synchronized (workQueue) {
    boolean processNow=false;
    Iterator<BluetoothJob> it=workQueue.iterator();
    while (it.hasNext()) {
      BluetoothJob job=it.next();
      if (job.cachedDevice.mDevice.equals(this.mDevice)) {
        it.remove();
        if (job.timeSent != 0) {
          processNow=true;
        }
      }
    }
    if (processNow) {
      processCommands();
    }
  }
switch (getBondState()) {
case BluetoothDevice.BOND_BONDED:
    mDevice.removeBond();
  break;
case BluetoothDevice.BOND_BONDING:
mDevice.cancelBondProcess();
break;
}
}

Fixed version (ground truth):
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));
  }
}
Program: 180852
Project: 180852
Buggy source:
private boolean processCommand(BluetoothJob job){
  boolean successful=false;
  if (job.timeSent == 0) {
    job.timeSent=System.currentTimeMillis();
switch (job.command) {
case CONNECT:
      successful=connectInt(job.cachedDevice,job.profile);
    break;
case DISCONNECT:
  successful=disconnectInt(job.cachedDevice,job.profile);
break;
}
if (successful) {
if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
}
 else if (V) {
Log.v(TAG,"String_Node_Str" + job.toString());
}
}
 else if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
return successful;
}

Fixed version (ground truth):
private boolean processCommand(BluetoothJob job){
  boolean successful=false;
  if (job.timeSent == 0) {
    job.timeSent=System.currentTimeMillis();
switch (job.command) {
case CONNECT:
      successful=connectInt(job.cachedDevice,job.profile);
    break;
case DISCONNECT:
  successful=disconnectInt(job.cachedDevice,job.profile);
break;
case REMOVE_BOND:
BluetoothDevice dev=job.cachedDevice.getDevice();
if (dev != null) {
successful=dev.removeBond();
}
break;
}
if (successful) {
if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
}
 else if (V) {
Log.v(TAG,"String_Node_Str" + job.toString());
}
}
 else if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
return successful;
}
Program: 180853
Project: 180853
Buggy source:
public void unpair(){
synchronized (workQueue) {
    boolean processNow=false;
    Iterator<BluetoothJob> it=workQueue.iterator();
    while (it.hasNext()) {
      BluetoothJob job=it.next();
      if (job.cachedDevice.mDevice.equals(this.mDevice)) {
        it.remove();
        if (job.timeSent != 0) {
          processNow=true;
        }
      }
    }
    if (processNow) {
      processCommands();
    }
  }
switch (getBondState()) {
case BluetoothDevice.BOND_BONDED:
    mDevice.removeBond();
  break;
case BluetoothDevice.BOND_BONDING:
mDevice.cancelBondProcess();
break;
}
}

Fixed version (ground truth):
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));
  }
}
Program: 180854
Project: 180854
Buggy source:
private boolean processCommand(BluetoothJob job){
  boolean successful=false;
  if (job.timeSent == 0) {
    job.timeSent=System.currentTimeMillis();
switch (job.command) {
case CONNECT:
      successful=connectInt(job.cachedDevice,job.profile);
    break;
case DISCONNECT:
  successful=disconnectInt(job.cachedDevice,job.profile);
break;
}
if (successful) {
if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
}
 else if (V) {
Log.v(TAG,"String_Node_Str" + job.toString());
}
}
 else if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
return successful;
}

Fixed version (ground truth):
private boolean processCommand(BluetoothJob job){
  boolean successful=false;
  if (job.timeSent == 0) {
    job.timeSent=System.currentTimeMillis();
switch (job.command) {
case CONNECT:
      successful=connectInt(job.cachedDevice,job.profile);
    break;
case DISCONNECT:
  successful=disconnectInt(job.cachedDevice,job.profile);
break;
case REMOVE_BOND:
BluetoothDevice dev=job.cachedDevice.getDevice();
if (dev != null) {
successful=dev.removeBond();
}
break;
}
if (successful) {
if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
}
 else if (V) {
Log.v(TAG,"String_Node_Str" + job.toString());
}
}
 else if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
return successful;
}
Program: 180855
Project: 180855
Buggy source:
public void unpair(){
synchronized (workQueue) {
    boolean processNow=false;
    Iterator<BluetoothJob> it=workQueue.iterator();
    while (it.hasNext()) {
      BluetoothJob job=it.next();
      if (job.cachedDevice.mDevice.equals(this.mDevice)) {
        it.remove();
        if (job.timeSent != 0) {
          processNow=true;
        }
      }
    }
    if (processNow) {
      processCommands();
    }
  }
switch (getBondState()) {
case BluetoothDevice.BOND_BONDED:
    mDevice.removeBond();
  break;
case BluetoothDevice.BOND_BONDING:
mDevice.cancelBondProcess();
break;
}
}

Fixed version (ground truth):
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));
  }
}
Program: 180856
Project: 180856
Buggy source:
private boolean processCommand(BluetoothJob job){
  boolean successful=false;
  if (job.timeSent == 0) {
    job.timeSent=System.currentTimeMillis();
switch (job.command) {
case CONNECT:
      successful=connectInt(job.cachedDevice,job.profile);
    break;
case DISCONNECT:
  successful=disconnectInt(job.cachedDevice,job.profile);
break;
}
if (successful) {
if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
}
 else if (V) {
Log.v(TAG,"String_Node_Str" + job.toString());
}
}
 else if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
return successful;
}

Fixed version (ground truth):
private boolean processCommand(BluetoothJob job){
  boolean successful=false;
  if (job.timeSent == 0) {
    job.timeSent=System.currentTimeMillis();
switch (job.command) {
case CONNECT:
      successful=connectInt(job.cachedDevice,job.profile);
    break;
case DISCONNECT:
  successful=disconnectInt(job.cachedDevice,job.profile);
break;
case REMOVE_BOND:
BluetoothDevice dev=job.cachedDevice.getDevice();
if (dev != null) {
successful=dev.removeBond();
}
break;
}
if (successful) {
if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
}
 else if (V) {
Log.v(TAG,"String_Node_Str" + job.toString());
}
}
 else if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
return successful;
}
Program: 180857
Project: 180857
Buggy source:
public void unpair(){
synchronized (workQueue) {
    boolean processNow=false;
    Iterator<BluetoothJob> it=workQueue.iterator();
    while (it.hasNext()) {
      BluetoothJob job=it.next();
      if (job.cachedDevice.mDevice.equals(this.mDevice)) {
        it.remove();
        if (job.timeSent != 0) {
          processNow=true;
        }
      }
    }
    if (processNow) {
      processCommands();
    }
  }
switch (getBondState()) {
case BluetoothDevice.BOND_BONDED:
    mDevice.removeBond();
  break;
case BluetoothDevice.BOND_BONDING:
mDevice.cancelBondProcess();
break;
}
}

Fixed version (ground truth):
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));
  }
}
Program: 180858
Project: 180858
Buggy source:
private boolean processCommand(BluetoothJob job){
  boolean successful=false;
  if (job.timeSent == 0) {
    job.timeSent=System.currentTimeMillis();
switch (job.command) {
case CONNECT:
      successful=connectInt(job.cachedDevice,job.profile);
    break;
case DISCONNECT:
  successful=disconnectInt(job.cachedDevice,job.profile);
break;
}
if (successful) {
if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
}
 else if (V) {
Log.v(TAG,"String_Node_Str" + job.toString());
}
}
 else if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
return successful;
}

Fixed version (ground truth):
private boolean processCommand(BluetoothJob job){
  boolean successful=false;
  if (job.timeSent == 0) {
    job.timeSent=System.currentTimeMillis();
switch (job.command) {
case CONNECT:
      successful=connectInt(job.cachedDevice,job.profile);
    break;
case DISCONNECT:
  successful=disconnectInt(job.cachedDevice,job.profile);
break;
case REMOVE_BOND:
BluetoothDevice dev=job.cachedDevice.getDevice();
if (dev != null) {
successful=dev.removeBond();
}
break;
}
if (successful) {
if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
}
 else if (V) {
Log.v(TAG,"String_Node_Str" + job.toString());
}
}
 else if (D) {
Log.d(TAG,"String_Node_Str" + job.toString());
}
return successful;
}
Program: 180859
Project: 180859
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);
  if (mDemoStringIndex > -1) {
    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,TTS_DEFAULT_COUNTRY);
  mDefaultLocVariant=Settings.Secure.getString(resolver,TTS_DEFAULT_VARIANT);
  mDemoStringIndex=mDefaultLocPref.findIndexOfValue(mDefaultLanguage + LOCALE_DELIMITER + mDefaultCountry);
  if (mDemoStringIndex > -1) {
    mDefaultLocPref.setValueIndex(mDemoStringIndex);
  }
}
Program: 180860
Project: 180860
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);
  if (mDemoStringIndex > -1) {
    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,TTS_DEFAULT_COUNTRY);
  mDefaultLocVariant=Settings.Secure.getString(resolver,TTS_DEFAULT_VARIANT);
  mDemoStringIndex=mDefaultLocPref.findIndexOfValue(mDefaultLanguage + LOCALE_DELIMITER + mDefaultCountry);
  if (mDemoStringIndex > -1) {
    mDefaultLocPref.setValueIndex(mDemoStringIndex);
  }
}
Program: 180862
Project: 180862
Buggy source:
/** 
 * (helper function for initDefaultLang() ) Returns whether there is a default language in the TTS settings.
 */
private boolean hasLangPref(){
  String language=Settings.Secure.getString(getContentResolver(),TTS_DEFAULT_LANG);
  return (language != null);
}

Fixed version (ground truth):
/** 
 * (helper function for initDefaultLang() ) Returns whether there is a default language in the TTS settings.
 */
private boolean hasLangPref(){
  ContentResolver resolver=getContentResolver();
  String language=Settings.Secure.getString(resolver,TTS_DEFAULT_LANG);
  if ((language == null) || (language.length() < 1)) {
    return false;
  }
  String country=Settings.Secure.getString(resolver,TTS_DEFAULT_COUNTRY);
  if (country == null) {
    return false;
  }
  String variant=Settings.Secure.getString(resolver,TTS_DEFAULT_VARIANT);
  if (variant == null) {
    return false;
  }
  return true;
}
Program: 180864
Project: 180864
Buggy source:
/** 
 * (helper function for initDefaultLang() ) Returns whether there is a default language in the TTS settings.
 */
private boolean hasLangPref(){
  String language=Settings.Secure.getString(getContentResolver(),TTS_DEFAULT_LANG);
  return (language != null);
}

Fixed version (ground truth):
/** 
 * (helper function for initDefaultLang() ) Returns whether there is a default language in the TTS settings.
 */
private boolean hasLangPref(){
  ContentResolver resolver=getContentResolver();
  String language=Settings.Secure.getString(resolver,TTS_DEFAULT_LANG);
  if ((language == null) || (language.length() < 1)) {
    return false;
  }
  String country=Settings.Secure.getString(resolver,TTS_DEFAULT_COUNTRY);
  if (country == null) {
    return false;
  }
  String variant=Settings.Secure.getString(resolver,TTS_DEFAULT_VARIANT);
  if (variant == null) {
    return false;
  }
  return true;
}
Program: 180866
Project: 180866
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.tts_settings);
  addEngineSpecificSettings();
  mDemoStrings=getResources().getStringArray(R.array.tts_demo_strings);
  setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
  mEnableDemo=false;
  initClickers();
  initDefaultSettings();
  mTts=new TextToSpeech(this,this);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.tts_settings);
  addEngineSpecificSettings();
  mDemoStrings=getResources().getStringArray(R.array.tts_demo_strings);
  setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
  mEnableDemo=false;
  mTtsStarted=false;
  mTts=new TextToSpeech(this,this);
}
Program: 180867
Project: 180867
Buggy source:
@Override protected void onStart(){
  super.onStart();
  initClickers();
  updateWidgetState();
  checkVoiceData();
}

Fixed version (ground truth):
@Override protected void onStart(){
  super.onStart();
  if (mTtsStarted) {
    initClickers();
    updateWidgetState();
    checkVoiceData();
  }
}
Program: 180868
Project: 180868
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();
    }
    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();
}

Fixed version (ground truth):
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    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));
    initDefaultSettings();
    initClickers();
    updateWidgetState();
    checkVoiceData();
    mTtsStarted=true;
    Log.v(TAG,"String_Node_Str");
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}
Program: 180869
Project: 180869
Buggy source:
public CachedBluetoothDeviceManager(LocalBluetoothManager localManager){
  mLocalManager=localManager;
  mCallbacks=localManager.getCallbacks();
  readPairedDevices();
}

Fixed version (ground truth):
public CachedBluetoothDeviceManager(LocalBluetoothManager localManager){
  mLocalManager=localManager;
  mCallbacks=localManager.getCallbacks();
}
Program: 180870
Project: 180870
Buggy source:
public CachedBluetoothDeviceManager(LocalBluetoothManager localManager){
  mLocalManager=localManager;
  mCallbacks=localManager.getCallbacks();
  readPairedDevices();
}

Fixed version (ground truth):
public CachedBluetoothDeviceManager(LocalBluetoothManager localManager){
  mLocalManager=localManager;
  mCallbacks=localManager.getCallbacks();
}
Program: 180871
Project: 180871
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.tts_settings);
  addEngineSpecificSettings();
  mDemoStrings=getResources().getStringArray(R.array.tts_demo_strings);
  setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
  mEnableDemo=false;
  initClickers();
  initDefaultSettings();
  mTts=new TextToSpeech(this,this);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.tts_settings);
  addEngineSpecificSettings();
  mDemoStrings=getResources().getStringArray(R.array.tts_demo_strings);
  setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
  mEnableDemo=false;
  mTtsStarted=false;
  mTts=new TextToSpeech(this,this);
}
Program: 180872
Project: 180872
Buggy source:
@Override protected void onStart(){
  super.onStart();
  initClickers();
  updateWidgetState();
  checkVoiceData();
}

Fixed version (ground truth):
@Override protected void onStart(){
  super.onStart();
  if (mTtsStarted) {
    initClickers();
    updateWidgetState();
    checkVoiceData();
  }
}
Program: 180873
Project: 180873
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();
    }
    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();
}

Fixed version (ground truth):
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    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));
    initDefaultSettings();
    initClickers();
    updateWidgetState();
    checkVoiceData();
    mTtsStarted=true;
    Log.v(TAG,"String_Node_Str");
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}
Program: 180874
Project: 180874
Buggy source:
public CachedBluetoothDeviceManager(LocalBluetoothManager localManager){
  mLocalManager=localManager;
  mCallbacks=localManager.getCallbacks();
  readPairedDevices();
}

Fixed version (ground truth):
public CachedBluetoothDeviceManager(LocalBluetoothManager localManager){
  mLocalManager=localManager;
  mCallbacks=localManager.getCallbacks();
}
Program: 180875
Project: 180875
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);
  if (mDemoStringIndex > -1) {
    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,TTS_DEFAULT_COUNTRY);
  mDefaultLocVariant=Settings.Secure.getString(resolver,TTS_DEFAULT_VARIANT);
  mDemoStringIndex=mDefaultLocPref.findIndexOfValue(mDefaultLanguage + LOCALE_DELIMITER + mDefaultCountry);
  if (mDemoStringIndex > -1) {
    mDefaultLocPref.setValueIndex(mDemoStringIndex);
  }
}
Program: 180878
Project: 180878
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.tts_settings);
  addEngineSpecificSettings();
  mDemoStrings=getResources().getStringArray(R.array.tts_demo_strings);
  setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
  mEnableDemo=false;
  initClickers();
  initDefaultSettings();
  mTts=new TextToSpeech(this,this);
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.tts_settings);
  addEngineSpecificSettings();
  mDemoStrings=getResources().getStringArray(R.array.tts_demo_strings);
  setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
  mEnableDemo=false;
  mTtsStarted=false;
  mTts=new TextToSpeech(this,this);
}
Program: 180879
Project: 180879
Buggy source:
@Override protected void onStart(){
  super.onStart();
  initClickers();
  updateWidgetState();
  checkVoiceData();
}

Fixed version (ground truth):
@Override protected void onStart(){
  super.onStart();
  if (mTtsStarted) {
    initClickers();
    updateWidgetState();
    checkVoiceData();
  }
}
Program: 180880
Project: 180880
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();
    }
    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();
}

Fixed version (ground truth):
/** 
 * Called when the TTS engine is initialized.
 */
public void onInit(int status){
  if (status == TextToSpeech.SUCCESS) {
    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));
    initDefaultSettings();
    initClickers();
    updateWidgetState();
    checkVoiceData();
    mTtsStarted=true;
    Log.v(TAG,"String_Node_Str");
  }
 else {
    Log.v(TAG,"String_Node_Str");
    mEnableDemo=false;
  }
  updateWidgetState();
}
Program: 180881
Project: 180881
Buggy source:
public void bindView(View view,int position){
synchronized (mState.mLock) {
    ViewHolder vh=(ViewHolder)view.getTag();
    if (position >= mState.mItems.size()) {
      return;
    }
    BaseItem item=mState.mItems.get(position);
    vh.name.setText(item.mDisplayLabel);
    vh.separator.setVisibility(item.mNeedDivider ? View.VISIBLE : View.INVISIBLE);
    ActiveItem ai=new ActiveItem();
    ai.mRootView=view;
    ai.mItem=item;
    ai.mHolder=vh;
    ai.mFirstRunTime=item.mActiveSince;
    vh.description.setText(item.mDescription);
    if (item.mIsProcess) {
      view.setBackgroundColor(mProcessBgColor);
      vh.icon.setImageDrawable(null);
      vh.icon.setVisibility(View.GONE);
      vh.description.setText(item.mDescription);
      item.mCurSizeStr=null;
    }
 else {
      view.setBackgroundDrawable(null);
      vh.icon.setImageDrawable(item.mPackageInfo.loadIcon(getPackageManager()));
      vh.icon.setVisibility(View.VISIBLE);
      vh.description.setText(item.mDescription);
      ai.mFirstRunTime=item.mActiveSince;
    }
    ai.updateTime(RunningServices.this);
    mActiveItems.put(view,ai);
  }
}

Fixed version (ground truth):
public void bindView(View view,int position){
synchronized (mState.mLock) {
    ViewHolder vh=(ViewHolder)view.getTag();
    if (position >= mItems.size()) {
      return;
    }
    BaseItem item=mItems.get(position);
    vh.name.setText(item.mDisplayLabel);
    vh.separator.setVisibility(item.mNeedDivider ? View.VISIBLE : View.INVISIBLE);
    ActiveItem ai=new ActiveItem();
    ai.mRootView=view;
    ai.mItem=item;
    ai.mHolder=vh;
    ai.mFirstRunTime=item.mActiveSince;
    vh.description.setText(item.mDescription);
    if (item.mIsProcess) {
      view.setBackgroundColor(mProcessBgColor);
      vh.icon.setImageDrawable(null);
      vh.icon.setVisibility(View.GONE);
      vh.description.setText(item.mDescription);
      item.mCurSizeStr=null;
    }
 else {
      view.setBackgroundDrawable(null);
      vh.icon.setImageDrawable(item.mPackageInfo.loadIcon(getPackageManager()));
      vh.icon.setVisibility(View.VISIBLE);
      vh.description.setText(item.mDescription);
      ai.mFirstRunTime=item.mActiveSince;
    }
    ai.updateTime(RunningServices.this);
    mActiveItems.put(view,ai);
  }
}
Program: 180883
Project: 180883
Buggy source:
public Object getItem(int position){
synchronized (mState.mLock) {
    return mState.mItems.get(position);
  }
}

Fixed version (ground truth):
public Object getItem(int position){
  return mItems.get(position);
}
Program: 180884
Project: 180884
Buggy source:
public long getItemId(int position){
  return position;
}

Fixed version (ground truth):
public long getItemId(int position){
  return mItems.get(position).hashCode();
}
Program: 180886
Project: 180886
Buggy source:
public int getCount(){
synchronized (mState.mLock) {
    return mState.mItems.size();
  }
}

Fixed version (ground truth):
public int getCount(){
  return mItems.size();
}
Program: 180887
Project: 180887
Buggy source:
ServiceListAdapter(State state){
synchronized (state.mLock) {
    mState=state;
    mInflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
}

Fixed version (ground truth):
ServiceListAdapter(State state){
  mState=state;
  mInflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  refreshItems();
}
Program: 180888
Project: 180888
Buggy source:
public boolean isEnabled(int position){
synchronized (mState.mLock) {
    return !mState.mItems.get(position).mIsProcess;
  }
}

Fixed version (ground truth):
public boolean isEnabled(int position){
  return !mItems.get(position).mIsProcess;
}
Program: 180889
Project: 180889
Buggy source:
public void bindView(View view,int position){
synchronized (mState.mLock) {
    ViewHolder vh=(ViewHolder)view.getTag();
    if (position >= mState.mItems.size()) {
      return;
    }
    BaseItem item=mState.mItems.get(position);
    vh.name.setText(item.mDisplayLabel);
    vh.separator.setVisibility(item.mNeedDivider ? View.VISIBLE : View.INVISIBLE);
    ActiveItem ai=new ActiveItem();
    ai.mRootView=view;
    ai.mItem=item;
    ai.mHolder=vh;
    ai.mFirstRunTime=item.mActiveSince;
    vh.description.setText(item.mDescription);
    if (item.mIsProcess) {
      view.setBackgroundColor(mProcessBgColor);
      vh.icon.setImageDrawable(null);
      vh.icon.setVisibility(View.GONE);
      vh.description.setText(item.mDescription);
      item.mCurSizeStr=null;
    }
 else {
      view.setBackgroundDrawable(null);
      vh.icon.setImageDrawable(item.mPackageInfo.loadIcon(getPackageManager()));
      vh.icon.setVisibility(View.VISIBLE);
      vh.description.setText(item.mDescription);
      ai.mFirstRunTime=item.mActiveSince;
    }
    ai.updateTime(RunningServices.this);
    mActiveItems.put(view,ai);
  }
}

Fixed version (ground truth):
public void bindView(View view,int position){
synchronized (mState.mLock) {
    ViewHolder vh=(ViewHolder)view.getTag();
    if (position >= mItems.size()) {
      return;
    }
    BaseItem item=mItems.get(position);
    vh.name.setText(item.mDisplayLabel);
    vh.separator.setVisibility(item.mNeedDivider ? View.VISIBLE : View.INVISIBLE);
    ActiveItem ai=new ActiveItem();
    ai.mRootView=view;
    ai.mItem=item;
    ai.mHolder=vh;
    ai.mFirstRunTime=item.mActiveSince;
    vh.description.setText(item.mDescription);
    if (item.mIsProcess) {
      view.setBackgroundColor(mProcessBgColor);
      vh.icon.setImageDrawable(null);
      vh.icon.setVisibility(View.GONE);
      vh.description.setText(item.mDescription);
      item.mCurSizeStr=null;
    }
 else {
      view.setBackgroundDrawable(null);
      vh.icon.setImageDrawable(item.mPackageInfo.loadIcon(getPackageManager()));
      vh.icon.setVisibility(View.VISIBLE);
      vh.description.setText(item.mDescription);
      ai.mFirstRunTime=item.mActiveSince;
    }
    ai.updateTime(RunningServices.this);
    mActiveItems.put(view,ai);
  }
}
Program: 180891
Project: 180891
Buggy source:
public Object getItem(int position){
synchronized (mState.mLock) {
    return mState.mItems.get(position);
  }
}

Fixed version (ground truth):
public Object getItem(int position){
  return mItems.get(position);
}
Program: 180892
Project: 180892
Buggy source:
public long getItemId(int position){
  return position;
}

Fixed version (ground truth):
public long getItemId(int position){
  return mItems.get(position).hashCode();
}
Program: 180894
Project: 180894
Buggy source:
public int getCount(){
synchronized (mState.mLock) {
    return mState.mItems.size();
  }
}

Fixed version (ground truth):
public int getCount(){
  return mItems.size();
}
Program: 180895
Project: 180895
Buggy source:
ServiceListAdapter(State state){
synchronized (state.mLock) {
    mState=state;
    mInflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
}

Fixed version (ground truth):
ServiceListAdapter(State state){
  mState=state;
  mInflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  refreshItems();
}
Program: 180896
Project: 180896
Buggy source:
public boolean isEnabled(int position){
synchronized (mState.mLock) {
    return !mState.mItems.get(position).mIsProcess;
  }
}

Fixed version (ground truth):
public boolean isEnabled(int position){
  return !mItems.get(position).mIsProcess;
}
Program: 180897
Project: 180897
Buggy source:
public void handleMessage(Message msg){
switch (msg.what) {
case CLEAR_USER_DATA:
    processClearMsg(msg);
  break;
case GET_PKG_SIZE:
refreshSizeInfo(msg);
break;
case CLEAR_CACHE:
mPm.getPackageSizeInfo(mAppInfo.packageName,mSizeObserver);
break;
case PACKAGE_MOVE:
processMoveMsg(msg);
break;
default :
break;
}
}

Fixed version (ground truth):
public void handleMessage(Message msg){
  if (isFinishing()) {
    return;
  }
switch (msg.what) {
case CLEAR_USER_DATA:
    processClearMsg(msg);
  break;
case GET_PKG_SIZE:
refreshSizeInfo(msg);
break;
case CLEAR_CACHE:
mPm.getPackageSizeInfo(mAppInfo.packageName,mSizeObserver);
break;
case PACKAGE_MOVE:
processMoveMsg(msg);
break;
default :
break;
}
}
Program: 180898
Project: 180898
Buggy source:
public void bindView(View view,int position){
synchronized (mState.mLock) {
    ViewHolder vh=(ViewHolder)view.getTag();
    if (position >= mState.mItems.size()) {
      return;
    }
    BaseItem item=mState.mItems.get(position);
    vh.name.setText(item.mDisplayLabel);
    vh.separator.setVisibility(item.mNeedDivider ? View.VISIBLE : View.INVISIBLE);
    ActiveItem ai=new ActiveItem();
    ai.mRootView=view;
    ai.mItem=item;
    ai.mHolder=vh;
    ai.mFirstRunTime=item.mActiveSince;
    vh.description.setText(item.mDescription);
    if (item.mIsProcess) {
      view.setBackgroundColor(mProcessBgColor);
      vh.icon.setImageDrawable(null);
      vh.icon.setVisibility(View.GONE);
      vh.description.setText(item.mDescription);
      item.mCurSizeStr=null;
    }
 else {
      view.setBackgroundDrawable(null);
      vh.icon.setImageDrawable(item.mPackageInfo.loadIcon(getPackageManager()));
      vh.icon.setVisibility(View.VISIBLE);
      vh.description.setText(item.mDescription);
      ai.mFirstRunTime=item.mActiveSince;
    }
    ai.updateTime(RunningServices.this);
    mActiveItems.put(view,ai);
  }
}

Fixed version (ground truth):
public void bindView(View view,int position){
synchronized (mState.mLock) {
    ViewHolder vh=(ViewHolder)view.getTag();
    if (position >= mItems.size()) {
      return;
    }
    BaseItem item=mItems.get(position);
    vh.name.setText(item.mDisplayLabel);
    vh.separator.setVisibility(item.mNeedDivider ? View.VISIBLE : View.INVISIBLE);
    ActiveItem ai=new ActiveItem();
    ai.mRootView=view;
    ai.mItem=item;
    ai.mHolder=vh;
    ai.mFirstRunTime=item.mActiveSince;
    vh.description.setText(item.mDescription);
    if (item.mIsProcess) {
      view.setBackgroundColor(mProcessBgColor);
      vh.icon.setImageDrawable(null);
      vh.icon.setVisibility(View.GONE);
      vh.description.setText(item.mDescription);
      item.mCurSizeStr=null;
    }
 else {
      view.setBackgroundDrawable(null);
      vh.icon.setImageDrawable(item.mPackageInfo.loadIcon(getPackageManager()));
      vh.icon.setVisibility(View.VISIBLE);
      vh.description.setText(item.mDescription);
      ai.mFirstRunTime=item.mActiveSince;
    }
    ai.updateTime(RunningServices.this);
    mActiveItems.put(view,ai);
  }
}
Program: 180900
Project: 180900
Buggy source:
public Object getItem(int position){
synchronized (mState.mLock) {
    return mState.mItems.get(position);
  }
}

Fixed version (ground truth):
public Object getItem(int position){
  return mItems.get(position);
}
Program: 180901
Project: 180901
Buggy source:
public long getItemId(int position){
  return position;
}

Fixed version (ground truth):
public long getItemId(int position){
  return mItems.get(position).hashCode();
}
Program: 180903
Project: 180903
Buggy source:
public int getCount(){
synchronized (mState.mLock) {
    return mState.mItems.size();
  }
}

Fixed version (ground truth):
public int getCount(){
  return mItems.size();
}
Program: 180904
Project: 180904
Buggy source:
ServiceListAdapter(State state){
synchronized (state.mLock) {
    mState=state;
    mInflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
}

Fixed version (ground truth):
ServiceListAdapter(State state){
  mState=state;
  mInflater=(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  refreshItems();
}
Program: 180905
Project: 180905
Buggy source:
public boolean isEnabled(int position){
synchronized (mState.mLock) {
    return !mState.mItems.get(position).mIsProcess;
  }
}

Fixed version (ground truth):
public boolean isEnabled(int position){
  return !mItems.get(position).mIsProcess;
}
Program: 180906
Project: 180906
Buggy source:
public void handleMessage(Message msg){
switch (msg.what) {
case CLEAR_USER_DATA:
    processClearMsg(msg);
  break;
case GET_PKG_SIZE:
refreshSizeInfo(msg);
break;
case CLEAR_CACHE:
mPm.getPackageSizeInfo(mAppInfo.packageName,mSizeObserver);
break;
case PACKAGE_MOVE:
processMoveMsg(msg);
break;
default :
break;
}
}

Fixed version (ground truth):
public void handleMessage(Message msg){
  if (isFinishing()) {
    return;
  }
switch (msg.what) {
case CLEAR_USER_DATA:
    processClearMsg(msg);
  break;
case GET_PKG_SIZE:
refreshSizeInfo(msg);
break;
case CLEAR_CACHE:
mPm.getPackageSizeInfo(mAppInfo.packageName,mSizeObserver);
break;
case PACKAGE_MOVE:
processMoveMsg(msg);
break;
default :
break;
}
}
Program: 180907
Project: 180907
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.tts_settings);
  addEngineSpecificSettings();
  mDemoStrings=getResources().getStringArray(R.array.tts_demo_strings);
  setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
  mEnableDemo=false;
  initClickers();
  initDefaultSettings();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.tts_settings);
  addEngineSpecificSettings();
  mDemoStrings=getResources().getStringArray(R.array.tts_demo_strings);
  setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
  mEnableDemo=false;
  initClickers();
  initDefaultSettings();
  mTts=new TextToSpeech(this,this);
}
Program: 180909
Project: 180909
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.tts_settings);
  addEngineSpecificSettings();
  mDemoStrings=getResources().getStringArray(R.array.tts_demo_strings);
  setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
  mEnableDemo=false;
  initClickers();
  initDefaultSettings();
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  addPreferencesFromResource(R.xml.tts_settings);
  addEngineSpecificSettings();
  mDemoStrings=getResources().getStringArray(R.array.tts_demo_strings);
  setVolumeControlStream(TextToSpeech.Engine.DEFAULT_STREAM);
  mEnableDemo=false;
  initClickers();
  initDefaultSettings();
  mTts=new TextToSpeech(this,this);
}
Program: 180911
Project: 180911
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: 180912
Project: 180912
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();
  }
}