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

Fixed version (ground truth):
/** 
 * Re-enable mobile data connectivity after a   {@link #teardown()}.
 */
public boolean reconnect(){
  setTeardownRequested(false);
switch (setEnableApn(mApnType,true)) {
case Phone.APN_ALREADY_ACTIVE:
    mEnabled=true;
  mMobileDataState=Phone.DataState.CONNECTING;
Intent intent=new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
intent.putExtra(Phone.STATE_KEY,Phone.DataState.CONNECTED.toString());
intent.putExtra(Phone.STATE_CHANGE_REASON_KEY,Phone.REASON_APN_CHANGED);
intent.putExtra(Phone.DATA_APN_TYPES_KEY,mApnType);
intent.putExtra(Phone.DATA_IFACE_NAME_KEY,mInterfaceName);
intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY,false);
if (mStateReceiver != null) mStateReceiver.onReceive(mContext,intent);
break;
case Phone.APN_REQUEST_STARTED:
mEnabled=true;
break;
case Phone.APN_REQUEST_FAILED:
if (mPhoneService == null && mApnType == Phone.APN_TYPE_DEFAULT) {
return false;
}
case Phone.APN_TYPE_NOT_AVAILABLE:
mEnabled=false;
break;
default :
Log.e(TAG,"String_Node_Str");
mEnabled=false;
break;
}
return mEnabled;
}
Program: 23900
Project: 23900
Buggy source:
private int getNumConnectedNetworks(){
  int numConnectedNets=0;
  for (  NetworkStateTracker nt : mNetTrackers) {
    if (nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) {
      ++numConnectedNets;
    }
  }
  return numConnectedNets;
}

Fixed version (ground truth):
private int getNumConnectedNetworks(){
  int numConnectedNets=0;
  for (  NetworkStateTracker nt : mNetTrackers) {
    if (nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) {
      ++numConnectedNets;
    }
  }
  if (DBG)   Log.d(TAG,"String_Node_Str" + numConnectedNets);
  return numConnectedNets;
}
Program: 23903
Project: 23903
Buggy source:
protected synchronized void setEnabled(int id,boolean enable){
  if (DBG)   Log.d(LOG_TAG,"String_Node_Str" + id + "String_Node_Str"+ enable+ ')');
  if (dataEnabled[id] != enable) {
    dataEnabled[id]=enable;
    if (enable) {
      enabledCount++;
    }
 else {
      enabledCount--;
    }
    if (enabledCount == 0) {
      setPrivateDataEnabled(false);
    }
 else     if (enabledCount == 1) {
      setPrivateDataEnabled(true);
    }
  }
}

Fixed version (ground truth):
protected synchronized void setEnabled(int id,boolean enable){
  if (DBG)   Log.d(LOG_TAG,"String_Node_Str" + id + "String_Node_Str"+ enable+ ')');
  if (dataEnabled[id] != enable) {
    dataEnabled[id]=enable;
    if (enable) {
      enabledCount++;
      if (enabledCount == 1) {
        setPrivateDataEnabled(true);
      }
    }
 else {
      enabledCount--;
      if (enabledCount == 0) {
        setPrivateDataEnabled(false);
      }
    }
  }
}
Program: 23905
Project: 23905
Buggy source:
@Override public boolean onTouchEvent(MotionEvent me){
  int pointerCount=me.getPointerCount();
  boolean result=false;
  if (pointerCount != mOldPointerCount) {
    long now=me.getEventTime();
    if (pointerCount == 1) {
      MotionEvent down=MotionEvent.obtain(now,now,MotionEvent.ACTION_DOWN,me.getX(),me.getY(),me.getMetaState());
      result=onModifiedTouchEvent(down);
      down.recycle();
    }
 else {
      MotionEvent up=MotionEvent.obtain(now,now,MotionEvent.ACTION_UP,mOldPointerX,mOldPointerY,me.getMetaState());
      result=onModifiedTouchEvent(up);
      up.recycle();
    }
  }
 else {
    if (pointerCount == 1) {
      mOldPointerX=me.getX();
      mOldPointerY=me.getY();
      result=onModifiedTouchEvent(me);
    }
 else {
      result=true;
    }
  }
  mOldPointerCount=pointerCount;
  return result;
}

Fixed version (ground truth):
@Override public boolean onTouchEvent(MotionEvent me){
  int pointerCount=me.getPointerCount();
  boolean result=false;
  if (pointerCount != mOldPointerCount) {
    long now=me.getEventTime();
    if (pointerCount == 1) {
      MotionEvent down=MotionEvent.obtain(now,now,MotionEvent.ACTION_DOWN,me.getX(),me.getY(),me.getMetaState());
      result=onModifiedTouchEvent(down);
      down.recycle();
      if (me.getAction() == MotionEvent.ACTION_UP) {
        result=onModifiedTouchEvent(me);
      }
    }
 else {
      MotionEvent up=MotionEvent.obtain(now,now,MotionEvent.ACTION_UP,mOldPointerX,mOldPointerY,me.getMetaState());
      result=onModifiedTouchEvent(up);
      up.recycle();
    }
  }
 else {
    if (pointerCount == 1) {
      mOldPointerX=me.getX();
      mOldPointerY=me.getY();
      result=onModifiedTouchEvent(me);
    }
 else {
      result=true;
    }
  }
  mOldPointerCount=pointerCount;
  return result;
}
Program: 23907
Project: 23907
Buggy source:
public void runTest(TestResult testResult){
  mTestResult=testResult;
  for (  TestListener testListener : mTestListeners) {
    mTestResult.addListener(testListener);
  }
  Context testContext=mInstrumentation.getContext();
  for (  TestCase testCase : mTestCases) {
    setContextIfAndroidTestCase(testCase,mContext,testContext);
    setInstrumentationIfInstrumentationTestCase(testCase,mInstrumentation);
    testCase.run(mTestResult);
  }
}

Fixed version (ground truth):
public void runTest(TestResult testResult){
  mTestResult=testResult;
  for (  TestListener testListener : mTestListeners) {
    mTestResult.addListener(testListener);
  }
  Context testContext=mInstrumentation == null ? mContext : mInstrumentation.getContext();
  for (  TestCase testCase : mTestCases) {
    setContextIfAndroidTestCase(testCase,mContext,testContext);
    setInstrumentationIfInstrumentationTestCase(testCase,mInstrumentation);
    testCase.run(mTestResult);
  }
}
Program: 23909
Project: 23909
Buggy source:
public void onSensorChanged(SensorEvent event){
  long milliseconds=event.timestamp / 1000000;
  if (event.values[0] == 0.0) {
    goToSleep(milliseconds);
  }
 else {
    userActivity(milliseconds,false);
  }
}

Fixed version (ground truth):
public void onSensorChanged(SensorEvent event){
  long milliseconds=event.timestamp / 1000000;
  if (event.values[0] == 0.0) {
    goToSleep(milliseconds);
  }
 else {
synchronized (mLocks) {
      boolean savedActivityAllowed=mUserActivityAllowed;
      mUserActivityAllowed=true;
      userActivity(milliseconds,false);
      mUserActivityAllowed=savedActivityAllowed;
    }
  }
}
Program: 23912
Project: 23912
Buggy source:
/** 
 * This is the internal entry point for handling Activity.finish().
 * @param token The Binder token referencing the Activity we want to finish.
 * @param resultCode Result code, if any, from this Activity.
 * @param resultData Result data (Intent), if any, from this Activity.
 * @result Returns true if the activity successfully finished, or false if it is still running.
 */
public final boolean finishActivity(IBinder token,int resultCode,Intent resultData){
  if (resultData != null && resultData.hasFileDescriptors() == true) {
    throw new IllegalArgumentException("String_Node_Str");
  }
synchronized (this) {
    if (mController != null) {
      HistoryRecord next=topRunningActivityLocked(token,0);
      if (next != null) {
        boolean resumeOK=true;
        try {
          resumeOK=mController.activityResuming(next.packageName);
        }
 catch (        RemoteException e) {
          mController=null;
        }
        if (!resumeOK) {
          return false;
        }
      }
    }
    final long origId=Binder.clearCallingIdentity();
    boolean res=requestFinishActivityLocked(token,resultCode,resultData,"String_Node_Str");
    Binder.restoreCallingIdentity(origId);
    return res;
  }
}

Fixed version (ground truth):
/** 
 * This is the internal entry point for handling Activity.finish().
 * @param token The Binder token referencing the Activity we want to finish.
 * @param resultCode Result code, if any, from this Activity.
 * @param resultData Result data (Intent), if any, from this Activity.
 * @return Returns true if the activity successfully finished, or false if it is still running.
 */
public final boolean finishActivity(IBinder token,int resultCode,Intent resultData){
  if (resultData != null && resultData.hasFileDescriptors() == true) {
    throw new IllegalArgumentException("String_Node_Str");
  }
synchronized (this) {
    if (mController != null) {
      HistoryRecord next=topRunningActivityLocked(token,0);
      if (next != null) {
        boolean resumeOK=true;
        try {
          resumeOK=mController.activityResuming(next.packageName);
        }
 catch (        RemoteException e) {
          mController=null;
        }
        if (!resumeOK) {
          return false;
        }
      }
    }
    final long origId=Binder.clearCallingIdentity();
    boolean res=requestFinishActivityLocked(token,resultCode,resultData,"String_Node_Str");
    Binder.restoreCallingIdentity(origId);
    return res;
  }
}
Program: 23913
Project: 23913
Buggy source:
/** 
 * Unlocks Wifi Multicast, restoring the filter of packets not addressed specifically to this device and saving power. If this MulticastLock is reference-counted, each call to  {@code release} will decrement the reference count, and themulticast packets will only stop being received when the reference count reaches zero.  If the reference count goes below zero (that is, if  {@code release} is called a greater number of times than{@link #acquire}), an exception is thrown. If this MulticastLock is not reference-counted, the first call to  {@code release} (after the radio was multicast locked using{@linke #acquire}) will unlock the multicast, and subsequent calls will be ignored. Note that if any other Wifi Multicast Locks are still outstanding this   {@code release} call will not have an immediate effect.  Onlywhen all applications have released all their Multicast Locks will the Multicast filter be turned back on. Also note that when an app exits or crashes all of its Multicast Locks will be automatically released.
 */
public void release(){
synchronized (mBinder) {
    if (mRefCounted ? (--mRefCount == 0) : (mHeld)) {
      try {
        mService.releaseMulticastLock();
synchronized (WifiManager.this) {
          mActiveLockCount--;
        }
      }
 catch (      RemoteException ignore) {
      }
      mHeld=false;
    }
    if (mRefCount < 0) {
      throw new RuntimeException("String_Node_Str" + mTag);
    }
  }
}

Fixed version (ground truth):
/** 
 * Unlocks Wifi Multicast, restoring the filter of packets not addressed specifically to this device and saving power. If this MulticastLock is reference-counted, each call to  {@code release} will decrement the reference count, and themulticast packets will only stop being received when the reference count reaches zero.  If the reference count goes below zero (that is, if  {@code release} is called a greater number of times than{@link #acquire}), an exception is thrown. If this MulticastLock is not reference-counted, the first call to  {@code release} (after the radio was multicast locked using{@link #acquire}) will unlock the multicast, and subsequent calls will be ignored. Note that if any other Wifi Multicast Locks are still outstanding this   {@code release} call will not have an immediate effect.  Onlywhen all applications have released all their Multicast Locks will the Multicast filter be turned back on. Also note that when an app exits or crashes all of its Multicast Locks will be automatically released.
 */
public void release(){
synchronized (mBinder) {
    if (mRefCounted ? (--mRefCount == 0) : (mHeld)) {
      try {
        mService.releaseMulticastLock();
synchronized (WifiManager.this) {
          mActiveLockCount--;
        }
      }
 catch (      RemoteException ignore) {
      }
      mHeld=false;
    }
    if (mRefCount < 0) {
      throw new RuntimeException("String_Node_Str" + mTag);
    }
  }
}
Program: 23915
Project: 23915
Buggy source:
/** 
 * True if c is ISO-LATIN characters 0-9, *, # , +, WILD, WAIT, PAUSE   
 */
public final static boolean isNonSeparator(char c){
  return (c >= '0' && c <= '9') || c == '*' || c == '#' || c == '+' || c == WILD || c == WAIT || c == PAUSE;
}

Fixed version (ground truth):
private static boolean isNonSeparator(String address){
  for (int i=0, count=address.length(); i < count; i++) {
    if (!isNonSeparator(address.charAt(i))) {
      return false;
    }
  }
  return true;
}
Program: 23916
Project: 23916
Buggy source:
private static char findPOrWCharToAppend(String phoneNumber,int currPwIndex,int nextNonPwCharIndex){
  char c=phoneNumber.charAt(currPwIndex);
  char ret;
  ret=(isPause(c)) ? PhoneNumberUtils.PAUSE : PhoneNumberUtils.WAIT;
  if (isPause(c) && (nextNonPwCharIndex > (currPwIndex + 1))) {
    ret=PhoneNumberUtils.WAIT;
  }
  return ret;
}

Fixed version (ground truth):
private static char findPOrWCharToAppend(String phoneNumber,int currPwIndex,int nextNonPwCharIndex){
  char c=phoneNumber.charAt(currPwIndex);
  char ret;
  ret=(isPause(c)) ? PhoneNumberUtils.PAUSE : PhoneNumberUtils.WAIT;
  if (isPause(c) && (nextNonPwCharIndex > (currPwIndex + 2))) {
    ret=PhoneNumberUtils.WAIT;
  }
  return ret;
}
Program: 23917
Project: 23917
Buggy source:
private static int findNextPCharOrNonPOrNonWCharIndex(String phoneNumber,int currIndex){
  boolean wMatched=false;
  int index=currIndex + 1;
  int length=phoneNumber.length();
  while (index < length) {
    char cNext=phoneNumber.charAt(index);
    if (isWait(cNext)) {
      wMatched=true;
    }
    if (!isWait(cNext) && !isPause(cNext)) {
      break;
    }
    index++;
  }
  if ((index < length) && (index > (currIndex + 1)) && ((wMatched == false) && isPause(phoneNumber.charAt(currIndex)))) {
    return (currIndex + 1);
  }
  return index;
}

Fixed version (ground truth):
private static int findNextPCharOrNonPOrNonWCharIndex(String phoneNumber,int currIndex){
  boolean wMatched=isWait(phoneNumber.charAt(currIndex));
  int index=currIndex + 1;
  int length=phoneNumber.length();
  while (index < length) {
    char cNext=phoneNumber.charAt(index);
    if (isWait(cNext)) {
      wMatched=true;
    }
    if (!isWait(cNext) && !isPause(cNext)) {
      break;
    }
    index++;
  }
  if ((index < length) && (index > (currIndex + 1)) && ((wMatched == false) && isPause(phoneNumber.charAt(currIndex)))) {
    return (currIndex + 1);
  }
  return index;
}
Program: 23918
Project: 23918
Buggy source:
/** 
 * format orignal dial string 1) convert international dialing prefix "+" to string specified per region 2) handle corner cases for PAUSE/WAIT dialing: If PAUSE/WAIT sequence at the end, ignore them. If consecutive PAUSE/WAIT sequence in the middle of the string, and if there is any WAIT in PAUSE/WAIT sequence, treat them like WAIT.
 */
public static String formatDialString(String phoneNumber){
  if (phoneNumber == null) {
    return null;
  }
  int length=phoneNumber.length();
  StringBuilder ret=new StringBuilder();
  char c;
  int currIndex=0;
  while (currIndex < length) {
    c=phoneNumber.charAt(currIndex);
    if (PhoneNumberUtils.isDialable(c)) {
      if (c == '+') {
        String ps=null;
        SystemProperties.get(TelephonyProperties.PROPERTY_IDP_STRING,ps);
        if (TextUtils.isEmpty(ps)) {
          ps="String_Node_Str";
        }
        ret.append(ps);
      }
 else {
        ret.append(c);
      }
    }
 else     if (isPause(c) || isWait(c)) {
      if (currIndex < length - 1) {
        int nextIndex=findNextPCharOrNonPOrNonWCharIndex(phoneNumber,currIndex);
        if (nextIndex < length) {
          char pC=findPOrWCharToAppend(phoneNumber,currIndex,nextIndex);
          ret.append(pC);
          if (nextIndex > (currIndex + 1)) {
            currIndex=nextIndex - 1;
          }
        }
 else         if (nextIndex == length) {
          currIndex=length - 1;
        }
      }
    }
 else {
      ret.append(c);
    }
    currIndex++;
  }
  return ret.toString();
}

Fixed version (ground truth):
/** 
 * format original dial string 1) convert international dialing prefix "+" to string specified per region 2) handle corner cases for PAUSE/WAIT dialing: If PAUSE/WAIT sequence at the end, ignore them. If consecutive PAUSE/WAIT sequence in the middle of the string, and if there is any WAIT in PAUSE/WAIT sequence, treat them like WAIT.
 */
public static String formatDialString(String phoneNumber){
  if (phoneNumber == null) {
    return null;
  }
  int length=phoneNumber.length();
  StringBuilder ret=new StringBuilder();
  char c;
  int currIndex=0;
  while (currIndex < length) {
    c=phoneNumber.charAt(currIndex);
    if (isPause(c) || isWait(c)) {
      if (currIndex < length - 1) {
        int nextIndex=findNextPCharOrNonPOrNonWCharIndex(phoneNumber,currIndex);
        if (nextIndex < length) {
          char pC=findPOrWCharToAppend(phoneNumber,currIndex,nextIndex);
          ret.append(pC);
          if (nextIndex > (currIndex + 2)) {
            currIndex=nextIndex - 1;
          }
        }
 else         if (nextIndex == length) {
          currIndex=length - 1;
        }
      }
    }
 else {
      ret.append(c);
    }
    currIndex++;
  }
  return PhoneNumberUtils.cdmaCheckAndProcessPlusCode(ret.toString());
}
Program: 23921
Project: 23921
Buggy source:
/** 
 * {@link AutoCompleteTextView#onKeyPreIme(int,KeyEvent)}) dismisses the drop-down on BACK, so we must override this method to modify the BACK behavior.
 */
@Override public boolean onKeyPreIme(int keyCode,KeyEvent event){
  if (mSearchDialog.mSearchable == null) {
    return false;
  }
  if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
    if (mSearchDialog.backToPreviousComponent()) {
      return true;
    }
    if (isInputMethodNotNeeded() || (isEmpty() && getDropDownChildCount() >= getAdapter().getCount())) {
      mSearchDialog.cancel();
      return true;
    }
    return false;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * {@link AutoCompleteTextView#onKeyPreIme(int,KeyEvent)}) dismisses the drop-down on BACK, so we must override this method to modify the BACK behavior.
 */
@Override public boolean onKeyPreIme(int keyCode,KeyEvent event){
  if (mSearchDialog.mSearchable == null) {
    return false;
  }
  if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
    if (mSearchDialog.backToPreviousComponent()) {
      return true;
    }
    if (isInputMethodNotNeeded() || (isEmpty() && getDropDownChildCount() >= getAdapterCount())) {
      mSearchDialog.cancel();
      return true;
    }
    return false;
  }
  return false;
}
Program: 23922
Project: 23922
Buggy source:
/** 
 * Returns a Locale instance describing the language currently being used by the TTS engine.
 * @return language, country (if any) and variant (if any) used by the engine stored in a Localeinstance, or null is the TTS engine has failed.
 */
public Locale getLanguage(){
synchronized (mStartLock) {
    if (!mStarted) {
      return null;
    }
    try {
      String[] locStrings=mITts.getLanguage();
      if (locStrings.length == 3) {
        return new Locale(locStrings[0],locStrings[1],locStrings[2]);
      }
 else {
        return null;
      }
    }
 catch (    RemoteException e) {
      Log.e("String_Node_Str","String_Node_Str");
      e.printStackTrace();
      mStarted=false;
      initTts();
    }
catch (    NullPointerException e) {
      Log.e("String_Node_Str","String_Node_Str");
      e.printStackTrace();
      mStarted=false;
      initTts();
    }
catch (    IllegalStateException e) {
      Log.e("String_Node_Str","String_Node_Str");
      e.printStackTrace();
      mStarted=false;
      initTts();
    }
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Returns a Locale instance describing the language currently being used by the TTS engine.
 * @return language, country (if any) and variant (if any) used by the engine stored in a Localeinstance, or null is the TTS engine has failed.
 */
public Locale getLanguage(){
synchronized (mStartLock) {
    if (!mStarted) {
      return null;
    }
    try {
      String[] locStrings=mITts.getLanguage();
      if ((locStrings != null) && (locStrings.length == 3)) {
        return new Locale(locStrings[0],locStrings[1],locStrings[2]);
      }
 else {
        return null;
      }
    }
 catch (    RemoteException e) {
      Log.e("String_Node_Str","String_Node_Str");
      e.printStackTrace();
      mStarted=false;
      initTts();
    }
catch (    NullPointerException e) {
      Log.e("String_Node_Str","String_Node_Str");
      e.printStackTrace();
      mStarted=false;
      initTts();
    }
catch (    IllegalStateException e) {
      Log.e("String_Node_Str","String_Node_Str");
      e.printStackTrace();
      mStarted=false;
      initTts();
    }
    return null;
  }
}
Program: 23924
Project: 23924
Buggy source:
/** 
 * Stops all speech output and removes any utterances still in the queue globally.
 */
private int stopAll(String callingApp){
  int result=TextToSpeech.ERROR;
  boolean speechQueueAvailable=false;
  try {
    speechQueueAvailable=speechQueueLock.tryLock(SPEECHQUEUELOCK_TIMEOUT,TimeUnit.MILLISECONDS);
    if (speechQueueAvailable) {
      for (int i=mSpeechQueue.size() - 1; i > -1; i--) {
        if (mSpeechQueue.get(i).mType != SpeechItem.TEXT_TO_FILE) {
          mSpeechQueue.remove(i);
        }
      }
      if ((mCurrentSpeechItem != null) && ((mCurrentSpeechItem.mType != SpeechItem.TEXT_TO_FILE) || mCurrentSpeechItem.mCallingApp.equals(callingApp))) {
        result=sNativeSynth.stop();
        mKillList.put(mCurrentSpeechItem,true);
        if (mPlayer != null) {
          try {
            mPlayer.stop();
          }
 catch (          IllegalStateException e) {
          }
        }
        mIsSpeaking=false;
        mCurrentSpeechItem=null;
      }
 else {
        result=TextToSpeech.SUCCESS;
      }
      Log.i("String_Node_Str","String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
    Log.e("String_Node_Str","String_Node_Str");
    e.printStackTrace();
  }
 finally {
    if (speechQueueAvailable) {
      speechQueueLock.unlock();
    }
    return result;
  }
}

Fixed version (ground truth):
/** 
 * Stops all speech output and removes any utterances still in the queue globally, except those intended to be synthesized to file.
 */
private int stopAll(String callingApp){
  int result=TextToSpeech.ERROR;
  boolean speechQueueAvailable=false;
  try {
    speechQueueAvailable=speechQueueLock.tryLock(SPEECHQUEUELOCK_TIMEOUT,TimeUnit.MILLISECONDS);
    if (speechQueueAvailable) {
      for (int i=mSpeechQueue.size() - 1; i > -1; i--) {
        if (mSpeechQueue.get(i).mType != SpeechItem.TEXT_TO_FILE) {
          mSpeechQueue.remove(i);
        }
      }
      if ((mCurrentSpeechItem != null) && ((mCurrentSpeechItem.mType != SpeechItem.TEXT_TO_FILE) || mCurrentSpeechItem.mCallingApp.equals(callingApp))) {
        try {
          result=sNativeSynth.stop();
        }
 catch (        NullPointerException e1) {
          result=TextToSpeech.ERROR;
        }
        mKillList.put(mCurrentSpeechItem,true);
        if (mPlayer != null) {
          try {
            mPlayer.stop();
          }
 catch (          IllegalStateException e) {
          }
        }
        mIsSpeaking=false;
        mCurrentSpeechItem=null;
      }
 else {
        result=TextToSpeech.SUCCESS;
      }
      Log.i("String_Node_Str","String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
    Log.e("String_Node_Str","String_Node_Str");
    e.printStackTrace();
  }
 finally {
    if (speechQueueAvailable) {
      speechQueueLock.unlock();
    }
    return result;
  }
}
Program: 23925
Project: 23925
Buggy source:
@Override public void onDestroy(){
  super.onDestroy();
  cleanUpPlayer();
  sNativeSynth.shutdown();
  sNativeSynth=null;
  mCallbacks.kill();
}

Fixed version (ground truth):
@Override public void onDestroy(){
  super.onDestroy();
  stopAll("String_Node_Str");
  cleanUpPlayer();
  if (sNativeSynth != null) {
    sNativeSynth.shutdown();
  }
  sNativeSynth=null;
  mCallbacks.kill();
}
Program: 23928
Project: 23928
Buggy source:
/** 
 * {@link AutoCompleteTextView#onKeyPreIme(int,KeyEvent)}) dismisses the drop-down on BACK, so we must override this method to modify the BACK behavior.
 */
@Override public boolean onKeyPreIme(int keyCode,KeyEvent event){
  if (mSearchDialog.mSearchable == null) {
    return false;
  }
  if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
    if (mSearchDialog.backToPreviousComponent()) {
      return true;
    }
    if (isInputMethodNotNeeded() || (isEmpty() && getDropDownChildCount() >= getAdapter().getCount())) {
      mSearchDialog.cancel();
      return true;
    }
    return false;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * {@link AutoCompleteTextView#onKeyPreIme(int,KeyEvent)}) dismisses the drop-down on BACK, so we must override this method to modify the BACK behavior.
 */
@Override public boolean onKeyPreIme(int keyCode,KeyEvent event){
  if (mSearchDialog.mSearchable == null) {
    return false;
  }
  if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
    if (mSearchDialog.backToPreviousComponent()) {
      return true;
    }
    if (isInputMethodNotNeeded() || (isEmpty() && getDropDownChildCount() >= getAdapterCount())) {
      mSearchDialog.cancel();
      return true;
    }
    return false;
  }
  return false;
}
Program: 23929
Project: 23929
Buggy source:
synchronized int getSocketError(){
  for (  DaemonProxy s : mDaemonList) {
switch (getResultFromSocket(s)) {
case 0:
      return 0;
case AUTH_ERROR_CODE:
    return VpnManager.VPN_ERROR_AUTH;
case CHALLENGE_ERROR_CODE:
  return VpnManager.VPN_ERROR_CHALLENGE;
case REMOTE_HUNG_UP_ERROR_CODE:
return VpnManager.VPN_ERROR_REMOTE_HUNG_UP;
default :
return VpnManager.VPN_ERROR_CONNECTION_FAILED;
}
}
return 0;
}

Fixed version (ground truth):
synchronized int getSocketError(){
  for (  DaemonProxy s : mDaemonList) {
switch (getResultFromSocket(s)) {
case 0:
      continue;
case AUTH_ERROR_CODE:
    return VpnManager.VPN_ERROR_AUTH;
case CHALLENGE_ERROR_CODE:
  return VpnManager.VPN_ERROR_CHALLENGE;
case REMOTE_HUNG_UP_ERROR_CODE:
return VpnManager.VPN_ERROR_REMOTE_HUNG_UP;
default :
return VpnManager.VPN_ERROR_CONNECTION_FAILED;
}
}
return 0;
}
Program: 23930
Project: 23930
Buggy source:
public void setFilename(String filename){
  mFilename=filename;
}

Fixed version (ground truth):
public void setFilename(String filename){
  if (mFilename == null || !mFilename.equals(filename)) {
    mFilename=filename;
    mCachedAttributes=null;
  }
}
Program: 23931
Project: 23931
Buggy source:
static public Allocation createSized(RenderScript rs,Element e,int count){
  int id;
  if (e.mIsPredefined) {
    id=rs.nAllocationCreatePredefSized(e.mPredefinedID,count);
  }
 else {
    id=rs.nAllocationCreateSized(e.mID,count);
  }
  return new Allocation(id,rs);
}

Fixed version (ground truth):
static public Allocation createSized(RenderScript rs,Element e,int count) throws IllegalArgumentException {
  int id;
  if (e.mIsPredefined) {
    id=rs.nAllocationCreatePredefSized(e.mPredefinedID,count);
  }
 else {
    id=rs.nAllocationCreateSized(e.mID,count);
    if (id == 0) {
      throw new IllegalStateException("String_Node_Str");
    }
  }
  return new Allocation(id,rs);
}
Program: 23932
Project: 23932
Buggy source:
static public Allocation createTyped(RenderScript rs,Type type){
  int id=rs.nAllocationCreateTyped(type.mID);
  return new Allocation(id,rs);
}

Fixed version (ground truth):
static public Allocation createTyped(RenderScript rs,Type type) throws IllegalArgumentException {
  if (type.mID == 0) {
    throw new IllegalStateException("String_Node_Str");
  }
  int id=rs.nAllocationCreateTyped(type.mID);
  return new Allocation(id,rs);
}
Program: 23933
Project: 23933
Buggy source:
BaseObj(RenderScript rs){
  mRS=rs;
  mID=0;
}

Fixed version (ground truth):
BaseObj(RenderScript rs){
  mRS=rs;
  mID=0;
  mDestroyed=false;
}
Program: 23934
Project: 23934
Buggy source:
protected void finalize() throws Throwable {
  if (mID != 0) {
    Log.v(RenderScript.LOG_TAG,"String_Node_Str");
  }
  super.finalize();
}

Fixed version (ground truth):
protected void finalize() throws Throwable {
  if (!mDestroyed) {
    Log.v(RenderScript.LOG_TAG,"String_Node_Str");
  }
  super.finalize();
}
Program: 23935
Project: 23935
Buggy source:
public void destroy() throws IllegalStateException {
  if (mIsPredefined) {
    throw new IllegalStateException("String_Node_Str");
  }
  mRS.nElementDestroy(mID);
  mID=0;
}

Fixed version (ground truth):
public void destroy() throws IllegalStateException {
  if (mIsPredefined) {
    throw new IllegalStateException("String_Node_Str");
  }
  if (mDestroyed) {
    throw new IllegalStateException("String_Node_Str");
  }
  mDestroyed=true;
  mRS.nElementDestroy(mID);
}
Program: 23936
Project: 23936
Buggy source:
static synchronized Element internalCreate(RenderScript rs,Builder b){
  rs.nElementBegin();
  for (int ct=0; ct < b.mEntryCount; ct++) {
    Entry en=b.mEntries[ct];
    if (en.mElement != null) {
      rs.nElementAddPredefined(en.mElement.mPredefinedID);
    }
 else {
      int norm=0;
      if (en.mIsNormalized) {
        norm=1;
      }
      rs.nElementAdd(en.mType.mID,en.mKind.mID,norm,en.mBits);
    }
  }
  int id=rs.nElementCreate();
  return new Element(id,rs);
}

Fixed version (ground truth):
static synchronized Element internalCreate(RenderScript rs,Builder b){
  rs.nElementBegin();
  for (int ct=0; ct < b.mEntryCount; ct++) {
    Entry en=b.mEntries[ct];
    if (en.mElement != null) {
      rs.nElementAddPredefined(en.mElement.mPredefinedID);
    }
 else {
      int norm=0;
      if (en.mIsNormalized) {
        norm=1;
      }
      rs.nElementAdd(en.mKind.mID,en.mType.mID,norm,en.mBits);
    }
  }
  int id=rs.nElementCreate();
  return new Element(id,rs);
}
Program: 23937
Project: 23937
Buggy source:
public void destroy(){
  mRS.nProgramFragmentStoreDestroy(mID);
  mID=0;
}

Fixed version (ground truth):
public void destroy(){
  if (mDestroyed) {
    throw new IllegalStateException("String_Node_Str");
  }
  mDestroyed=true;
  mRS.nProgramFragmentStoreDestroy(mID);
}
Program: 23938
Project: 23938
Buggy source:
public void destroy(){
  mRS.nProgramFragmentStoreDestroy(mID);
  mID=0;
}

Fixed version (ground truth):
public void destroy(){
  if (mDestroyed) {
    throw new IllegalStateException("String_Node_Str");
  }
  mDestroyed=true;
  mRS.nProgramFragmentStoreDestroy(mID);
}
Program: 23939
Project: 23939
Buggy source:
public void destroy(){
  mRS.nScriptDestroy(mID);
  mID=0;
}

Fixed version (ground truth):
public void destroy(){
  if (mDestroyed) {
    throw new IllegalStateException("String_Node_Str");
  }
  mDestroyed=true;
  mRS.nScriptDestroy(mID);
}
Program: 23940
Project: 23940
Buggy source:
private void removePackageDataLI(PackageParser.Package p,PackageRemovedInfo outInfo,int flags){
  String packageName=p.packageName;
  if (outInfo != null) {
    outInfo.removedPackage=packageName;
  }
  removePackageLI(p,true);
  PackageSetting deletedPs;
synchronized (mPackages) {
    deletedPs=mSettings.mPackages.get(packageName);
  }
  if ((flags & PackageManager.DONT_DELETE_DATA) == 0) {
    if (mInstaller != null) {
      int retCode=mInstaller.remove(packageName);
      if (retCode < 0) {
        Log.w(TAG,"String_Node_Str" + packageName + "String_Node_Str"+ retCode);
      }
    }
 else {
      PackageParser.Package pkg=mPackages.get(packageName);
      File dataDir=new File(pkg.applicationInfo.dataDir);
      dataDir.delete();
    }
synchronized (mPackages) {
      if (outInfo != null) {
        outInfo.removedUid=mSettings.removePackageLP(packageName);
      }
    }
  }
synchronized (mPackages) {
    if ((deletedPs != null) && (deletedPs.sharedUser != null)) {
      mSettings.updateSharedUserPerms(deletedPs);
    }
    mSettings.writeLP();
  }
}

Fixed version (ground truth):
private void removePackageDataLI(PackageParser.Package p,PackageRemovedInfo outInfo,int flags){
  String packageName=p.packageName;
  if (outInfo != null) {
    outInfo.removedPackage=packageName;
  }
  removePackageLI(p,true);
  PackageSetting deletedPs;
synchronized (mPackages) {
    deletedPs=mSettings.mPackages.get(packageName);
  }
  if ((flags & PackageManager.DONT_DELETE_DATA) == 0) {
    if (mInstaller != null) {
      int retCode=mInstaller.remove(packageName);
      if (retCode < 0) {
        Log.w(TAG,"String_Node_Str" + packageName + "String_Node_Str"+ retCode);
      }
    }
 else {
      PackageParser.Package pkg=mPackages.get(packageName);
      File dataDir=new File(pkg.applicationInfo.dataDir);
      dataDir.delete();
    }
synchronized (mPackages) {
      if (outInfo != null) {
        outInfo.removedUid=mSettings.removePackageLP(packageName);
      }
    }
  }
synchronized (mPackages) {
    if ((deletedPs != null) && (deletedPs.sharedUser != null)) {
      mSettings.updateSharedUserPermsLP(deletedPs,mGlobalGids);
    }
    mSettings.writeLP();
  }
}
Program: 23941
Project: 23941
Buggy source:
private void handleExitEmergencyCallbackMode(Message msg){
  Log.d(LOG_TAG,"String_Node_Str");
  AsyncResult ar=(AsyncResult)msg.obj;
  h.removeCallbacks(mExitEcmRunnable);
  if (mECMExitRespRegistrant != null) {
    mECMExitRespRegistrant.notifyRegistrant(ar);
  }
  if (ar.exception == null) {
    if (mIsPhoneInECMState) {
      mIsPhoneInECMState=false;
      setSystemProperty(TelephonyProperties.PROPERTY_INECM_MODE,"String_Node_Str");
    }
    sendEmergencyCallbackModeChange();
  }
}

Fixed version (ground truth):
private void handleExitEmergencyCallbackMode(Message msg){
  Log.d(LOG_TAG,"String_Node_Str");
  AsyncResult ar=(AsyncResult)msg.obj;
  h.removeCallbacks(mExitEcmRunnable);
  if (mECMExitRespRegistrant != null) {
    mECMExitRespRegistrant.notifyRegistrant(ar);
  }
  if (ar.exception == null) {
    if (mIsPhoneInECMState) {
      mIsPhoneInECMState=false;
      setSystemProperty(TelephonyProperties.PROPERTY_INECM_MODE,"String_Node_Str");
    }
    sendEmergencyCallbackModeChange();
    mDataConnection.setDataEnabled(true);
  }
}
Program: 23942
Project: 23942
Buggy source:
private void removeMulticasterLocked(int i,int uid){
  Multicaster removed=mMulticasters.remove(i);
  if (removed != null) {
    removed.unlinkDeathRecipient();
  }
  if (mMulticasters.size() == 0) {
    WifiNative.startPacketFiltering();
  }
  Long ident=Binder.clearCallingIdentity();
  try {
    mBatteryStats.noteWifiMulticastDisabled(uid);
  }
 catch (  RemoteException e) {
  }
 finally {
    Binder.restoreCallingIdentity(ident);
  }
}

Fixed version (ground truth):
private void removeMulticasterLocked(int i,int uid){
  Multicaster removed=mMulticasters.remove(i);
  if (removed != null) {
    removed.unlinkDeathRecipient();
  }
  if (mMulticasters.size() == 0) {
synchronized (mWifiStateTracker) {
      WifiNative.startPacketFiltering();
    }
  }
  Long ident=Binder.clearCallingIdentity();
  try {
    mBatteryStats.noteWifiMulticastDisabled(uid);
  }
 catch (  RemoteException e) {
  }
 finally {
    Binder.restoreCallingIdentity(ident);
  }
}
Program: 23943
Project: 23943
Buggy source:
public void acquireMulticastLock(IBinder binder,String tag){
  enforceMulticastChangePermission();
synchronized (mMulticasters) {
    mMulticastEnabled++;
    mMulticasters.add(new Multicaster(tag,binder));
    WifiNative.stopPacketFiltering();
  }
  int uid=Binder.getCallingUid();
  Long ident=Binder.clearCallingIdentity();
  try {
    mBatteryStats.noteWifiMulticastEnabled(uid);
  }
 catch (  RemoteException e) {
  }
 finally {
    Binder.restoreCallingIdentity(ident);
  }
}

Fixed version (ground truth):
public void acquireMulticastLock(IBinder binder,String tag){
  enforceMulticastChangePermission();
synchronized (mMulticasters) {
    mMulticastEnabled++;
    mMulticasters.add(new Multicaster(tag,binder));
synchronized (mWifiStateTracker) {
      WifiNative.stopPacketFiltering();
    }
  }
  int uid=Binder.getCallingUid();
  Long ident=Binder.clearCallingIdentity();
  try {
    mBatteryStats.noteWifiMulticastEnabled(uid);
  }
 catch (  RemoteException e) {
  }
 finally {
    Binder.restoreCallingIdentity(ident);
  }
}
Program: 23945
Project: 23945
Buggy source:
public void data(float[] d){
  mRS.nAdapter1DData(mID,d);
}

Fixed version (ground truth):
public void data(float[] d){
  mRS.nAdapter2DData(mID,d);
}
Program: 23946
Project: 23946
Buggy source:
public void destroy(){
  mRS.nAdapter1DDestroy(mID);
  mID=0;
}

Fixed version (ground truth):
public void destroy(){
  mRS.nAdapter2DDestroy(mID);
  mID=0;
}
Program: 23947
Project: 23947
Buggy source:
public void setConstraint(Dimension dim,int value){
  mRS.nAdapter1DSetConstraint(mID,dim.mID,value);
}

Fixed version (ground truth):
public void setConstraint(Dimension dim,int value){
  mRS.nAdapter2DSetConstraint(mID,dim.mID,value);
}
Program: 23948
Project: 23948
Buggy source:
public void subData(int off,int count,float[] d){
  mRS.nAdapter1DSubData(mID,off,count,d);
}

Fixed version (ground truth):
public void subData(int xoff,int yoff,int w,int h,float[] d){
  mRS.nAdapter2DSubData(mID,xoff,yoff,w,h,d);
}
Program: 23950
Project: 23950
Buggy source:
/** 
 * Stops all speech output and removes any utterances still in the queue globally.
 */
private int stopAll(String callingApp){
  int result=TextToSpeech.ERROR;
  boolean speechQueueAvailable=false;
  try {
    speechQueueAvailable=speechQueueLock.tryLock(SPEECHQUEUELOCK_TIMEOUT,TimeUnit.MILLISECONDS);
    if (speechQueueAvailable) {
      for (int i=mSpeechQueue.size() - 1; i > -1; i--) {
        if (mSpeechQueue.get(i).mType != SpeechItem.TEXT_TO_FILE) {
          mSpeechQueue.remove(i);
        }
      }
      if ((mCurrentSpeechItem != null) && ((mCurrentSpeechItem.mType != SpeechItem.TEXT_TO_FILE) || mCurrentSpeechItem.mCallingApp.equals(callingApp))) {
        if (sIsKillingSynth) {
          Log.v("String_Node_Str","String_Node_Str");
          result=TextToSpeech.ERROR;
        }
 else {
          result=sNativeSynth.stop();
        }
        mKillList.put(mCurrentSpeechItem,true);
        if (mPlayer != null) {
          try {
            mPlayer.stop();
          }
 catch (          IllegalStateException e) {
          }
        }
        mIsSpeaking=false;
        mCurrentSpeechItem=null;
      }
 else {
        result=TextToSpeech.SUCCESS;
      }
      Log.i("String_Node_Str","String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
    Log.e("String_Node_Str","String_Node_Str");
    e.printStackTrace();
  }
 finally {
    if (speechQueueAvailable) {
      speechQueueLock.unlock();
    }
    return result;
  }
}

Fixed version (ground truth):
/** 
 * Stops all speech output and removes any utterances still in the queue globally.
 */
private int stopAll(String callingApp){
  int result=TextToSpeech.ERROR;
  boolean speechQueueAvailable=false;
  try {
    speechQueueAvailable=speechQueueLock.tryLock(SPEECHQUEUELOCK_TIMEOUT,TimeUnit.MILLISECONDS);
    if (speechQueueAvailable) {
      for (int i=mSpeechQueue.size() - 1; i > -1; i--) {
        if (mSpeechQueue.get(i).mType != SpeechItem.TEXT_TO_FILE) {
          mSpeechQueue.remove(i);
        }
      }
      if ((mCurrentSpeechItem != null) && ((mCurrentSpeechItem.mType != SpeechItem.TEXT_TO_FILE) || mCurrentSpeechItem.mCallingApp.equals(callingApp))) {
        result=sNativeSynth.stop();
        mKillList.put(mCurrentSpeechItem,true);
        if (mPlayer != null) {
          try {
            mPlayer.stop();
          }
 catch (          IllegalStateException e) {
          }
        }
        mIsSpeaking=false;
        mCurrentSpeechItem=null;
      }
 else {
        result=TextToSpeech.SUCCESS;
      }
      Log.i("String_Node_Str","String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
    Log.e("String_Node_Str","String_Node_Str");
    e.printStackTrace();
  }
 finally {
    if (speechQueueAvailable) {
      speechQueueLock.unlock();
    }
    return result;
  }
}
Program: 23951
Project: 23951
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  Log.i("String_Node_Str","String_Node_Str");
  mResolver=getContentResolver();
  String soLibPath="String_Node_Str";
  if (sNativeSynth == null) {
    sNativeSynth=new SynthProxy(soLibPath);
    sIsKillingSynth=false;
  }
  mSelf=this;
  mIsSpeaking=false;
  mEarcons=new HashMap<String,SoundResource>();
  mUtterances=new HashMap<String,SoundResource>();
  mCallbacksMap=new HashMap<String,android.speech.tts.ITtsCallback>();
  mSpeechQueue=new ArrayList<SpeechItem>();
  mPlayer=null;
  mCurrentSpeechItem=null;
  mKillList=new HashMap<SpeechItem,Boolean>();
  setDefaultSettings();
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  Log.i("String_Node_Str","String_Node_Str");
  mResolver=getContentResolver();
  String soLibPath="String_Node_Str";
  if (sNativeSynth == null) {
    sNativeSynth=new SynthProxy(soLibPath);
  }
  mSelf=this;
  mIsSpeaking=false;
  mEarcons=new HashMap<String,SoundResource>();
  mUtterances=new HashMap<String,SoundResource>();
  mCallbacksMap=new HashMap<String,android.speech.tts.ITtsCallback>();
  mSpeechQueue=new ArrayList<SpeechItem>();
  mPlayer=null;
  mCurrentSpeechItem=null;
  mKillList=new HashMap<SpeechItem,Boolean>();
  setDefaultSettings();
}
Program: 23952
Project: 23952
Buggy source:
@Override public void onDestroy(){
  super.onDestroy();
  sIsKillingSynth=true;
  Log.i("String_Node_Str","String_Node_Str");
  cleanUpPlayer();
  sNativeSynth.shutdown();
  sNativeSynth=null;
  mCallbacks.kill();
}

Fixed version (ground truth):
@Override public void onDestroy(){
  super.onDestroy();
  cleanUpPlayer();
  sNativeSynth.shutdown();
  sNativeSynth=null;
  mCallbacks.kill();
}
Program: 23956
Project: 23956
Buggy source:
/** 
 * Stops all speech output and removes any utterances still in the queue globally.
 */
private int stopAll(String callingApp){
  int result=TextToSpeech.ERROR;
  boolean speechQueueAvailable=false;
  try {
    speechQueueAvailable=speechQueueLock.tryLock(SPEECHQUEUELOCK_TIMEOUT,TimeUnit.MILLISECONDS);
    if (speechQueueAvailable) {
      for (int i=mSpeechQueue.size() - 1; i > -1; i--) {
        if (mSpeechQueue.get(i).mType != SpeechItem.TEXT_TO_FILE) {
          mSpeechQueue.remove(i);
        }
      }
      if ((mCurrentSpeechItem != null) && ((mCurrentSpeechItem.mType != SpeechItem.TEXT_TO_FILE) || mCurrentSpeechItem.mCallingApp.equals(callingApp))) {
        if (sIsKillingSynth) {
          Log.v("String_Node_Str","String_Node_Str");
          result=TextToSpeech.ERROR;
        }
 else {
          result=sNativeSynth.stop();
        }
        mKillList.put(mCurrentSpeechItem,true);
        if (mPlayer != null) {
          try {
            mPlayer.stop();
          }
 catch (          IllegalStateException e) {
          }
        }
        mIsSpeaking=false;
        mCurrentSpeechItem=null;
      }
 else {
        result=TextToSpeech.SUCCESS;
      }
      Log.i("String_Node_Str","String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
    Log.e("String_Node_Str","String_Node_Str");
    e.printStackTrace();
  }
 finally {
    if (speechQueueAvailable) {
      speechQueueLock.unlock();
    }
    return result;
  }
}

Fixed version (ground truth):
/** 
 * Stops all speech output and removes any utterances still in the queue globally.
 */
private int stopAll(String callingApp){
  int result=TextToSpeech.ERROR;
  boolean speechQueueAvailable=false;
  try {
    speechQueueAvailable=speechQueueLock.tryLock(SPEECHQUEUELOCK_TIMEOUT,TimeUnit.MILLISECONDS);
    if (speechQueueAvailable) {
      for (int i=mSpeechQueue.size() - 1; i > -1; i--) {
        if (mSpeechQueue.get(i).mType != SpeechItem.TEXT_TO_FILE) {
          mSpeechQueue.remove(i);
        }
      }
      if ((mCurrentSpeechItem != null) && ((mCurrentSpeechItem.mType != SpeechItem.TEXT_TO_FILE) || mCurrentSpeechItem.mCallingApp.equals(callingApp))) {
        result=sNativeSynth.stop();
        mKillList.put(mCurrentSpeechItem,true);
        if (mPlayer != null) {
          try {
            mPlayer.stop();
          }
 catch (          IllegalStateException e) {
          }
        }
        mIsSpeaking=false;
        mCurrentSpeechItem=null;
      }
 else {
        result=TextToSpeech.SUCCESS;
      }
      Log.i("String_Node_Str","String_Node_Str");
    }
  }
 catch (  InterruptedException e) {
    Log.e("String_Node_Str","String_Node_Str");
    e.printStackTrace();
  }
 finally {
    if (speechQueueAvailable) {
      speechQueueLock.unlock();
    }
    return result;
  }
}
Program: 23957
Project: 23957
Buggy source:
@Override public void onCreate(){
  super.onCreate();
  Log.i("String_Node_Str","String_Node_Str");
  mResolver=getContentResolver();
  String soLibPath="String_Node_Str";
  if (sNativeSynth == null) {
    sNativeSynth=new SynthProxy(soLibPath);
    sIsKillingSynth=false;
  }
  mSelf=this;
  mIsSpeaking=false;
  mEarcons=new HashMap<String,SoundResource>();
  mUtterances=new HashMap<String,SoundResource>();
  mCallbacksMap=new HashMap<String,android.speech.tts.ITtsCallback>();
  mSpeechQueue=new ArrayList<SpeechItem>();
  mPlayer=null;
  mCurrentSpeechItem=null;
  mKillList=new HashMap<SpeechItem,Boolean>();
  setDefaultSettings();
}

Fixed version (ground truth):
@Override public void onCreate(){
  super.onCreate();
  Log.i("String_Node_Str","String_Node_Str");
  mResolver=getContentResolver();
  String soLibPath="String_Node_Str";
  if (sNativeSynth == null) {
    sNativeSynth=new SynthProxy(soLibPath);
  }
  mSelf=this;
  mIsSpeaking=false;
  mEarcons=new HashMap<String,SoundResource>();
  mUtterances=new HashMap<String,SoundResource>();
  mCallbacksMap=new HashMap<String,android.speech.tts.ITtsCallback>();
  mSpeechQueue=new ArrayList<SpeechItem>();
  mPlayer=null;
  mCurrentSpeechItem=null;
  mKillList=new HashMap<SpeechItem,Boolean>();
  setDefaultSettings();
}
Program: 23958
Project: 23958
Buggy source:
@Override public void onDestroy(){
  super.onDestroy();
  sIsKillingSynth=true;
  Log.i("String_Node_Str","String_Node_Str");
  cleanUpPlayer();
  sNativeSynth.shutdown();
  sNativeSynth=null;
  mCallbacks.kill();
}

Fixed version (ground truth):
@Override public void onDestroy(){
  super.onDestroy();
  cleanUpPlayer();
  sNativeSynth.shutdown();
  sNativeSynth=null;
  mCallbacks.kill();
}