nus-yam/ex-repair huggingface dataset:
Program: 182573
Project: 182573
Buggy source:
/** 
 * Updates the state of each service by starting (or keeping running) enabled ones and stopping the rest.
 * @param installedServices All installed {@link AccessibilityService}s.
 * @param enabledServices The {@link ComponentName}s of the enabled services.
 */
private void updateServicesStateLocked(List<ServiceInfo> installedServices,Set<ComponentName> enabledServices){
  Map<ComponentName,Service> componentNameToServiceMap=mComponentNameToServiceMap;
  List<Service> services=mServices;
  for (int i=0, count=installedServices.size(); i < count; i++) {
    ServiceInfo intalledService=installedServices.get(i);
    ComponentName componentName=new ComponentName(intalledService.packageName,intalledService.name);
    Service service=componentNameToServiceMap.get(componentName);
    if (enabledServices.contains(componentName)) {
      if (service == null) {
        new Service(componentName).bind();
      }
    }
 else {
      if (service != null) {
        service.unbind();
        componentNameToServiceMap.remove(componentName);
        services.remove(service);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Updates the state of each service by starting (or keeping running) enabled ones and stopping the rest.
 * @param installedServices All installed {@link AccessibilityService}s.
 * @param enabledServices The {@link ComponentName}s of the enabled services.
 */
private void updateServicesStateLocked(List<ServiceInfo> installedServices,Set<ComponentName> enabledServices){
  Map<ComponentName,Service> componentNameToServiceMap=mComponentNameToServiceMap;
  List<Service> services=mServices;
  boolean isEnabled=mIsEnabled;
  for (int i=0, count=installedServices.size(); i < count; i++) {
    ServiceInfo intalledService=installedServices.get(i);
    ComponentName componentName=new ComponentName(intalledService.packageName,intalledService.name);
    Service service=componentNameToServiceMap.get(componentName);
    if (isEnabled && enabledServices.contains(componentName)) {
      if (service == null) {
        new Service(componentName).bind();
      }
    }
 else {
      if (service != null) {
        service.unbind();
        componentNameToServiceMap.remove(componentName);
        services.remove(service);
      }
    }
  }
}
Program: 182574
Project: 182574
Buggy source:
/** 
 * Notifies a service for a scheduled event given the event type.
 * @param service The service.
 * @param eventType The type of the event to dispatch.
 */
private void notifyEventListenerLocked(Service service,int eventType){
  IEventListener listener=service.mServiceInterface;
  AccessibilityEvent event=service.mPendingEvents.get(eventType);
  try {
    listener.onAccessibilityEvent(event);
    if (LOGV) {
      Log.i(LOG_TAG,"String_Node_Str" + event + "String_Node_Str"+ listener);
    }
  }
 catch (  RemoteException re) {
    if (re instanceof DeadObjectException) {
      Log.w(LOG_TAG,"String_Node_Str" + service.mService + "String_Node_Str");
synchronized (mLock) {
        removeDeadServiceLocked(service);
      }
    }
 else {
      Log.e(LOG_TAG,"String_Node_Str" + event + "String_Node_Str"+ service.mService,re);
    }
  }
}

Fixed version (ground truth):
/** 
 * Notifies a service for a scheduled event given the event type.
 * @param service The service.
 * @param eventType The type of the event to dispatch.
 */
private void notifyEventListenerLocked(Service service,int eventType){
  IEventListener listener=service.mServiceInterface;
  AccessibilityEvent event=service.mPendingEvents.get(eventType);
  try {
    listener.onAccessibilityEvent(event);
    if (Config.DEBUG) {
      Log.i(LOG_TAG,"String_Node_Str" + event + "String_Node_Str"+ listener);
    }
  }
 catch (  RemoteException re) {
    if (re instanceof DeadObjectException) {
      Log.w(LOG_TAG,"String_Node_Str" + service.mService + "String_Node_Str");
synchronized (mLock) {
        removeDeadServiceLocked(service);
      }
    }
 else {
      Log.e(LOG_TAG,"String_Node_Str" + event + "String_Node_Str"+ service.mService,re);
    }
  }
}
Program: 182575
Project: 182575
Buggy source:
/** 
 * @see AudioManager#adjustStreamVolume(int,int,int) 
 */
public void adjustStreamVolume(int streamType,int direction,int flags){
  ensureValidDirection(direction);
  ensureValidStreamType(streamType);
  VolumeStreamState streamState=mStreamStates[STREAM_VOLUME_ALIAS[streamType]];
  final int oldIndex=streamState.mIndex;
  boolean adjustVolume=true;
  if ((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0 || streamType == AudioSystem.STREAM_RING) {
    adjustVolume=checkForRingerModeChange(oldIndex,direction);
  }
  if (adjustVolume && streamState.adjustIndex(direction)) {
    if (streamState.muteCount() == 0) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,STREAM_VOLUME_ALIAS[streamType],SENDMSG_NOOP,0,0,streamState,0);
    }
  }
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType);
}

Fixed version (ground truth):
/** 
 * @see AudioManager#adjustStreamVolume(int,int,int) 
 */
public void adjustStreamVolume(int streamType,int direction,int flags){
  ensureValidDirection(direction);
  ensureValidStreamType(streamType);
  VolumeStreamState streamState=mStreamStates[STREAM_VOLUME_ALIAS[streamType]];
  final int oldIndex=streamState.mIndex;
  boolean adjustVolume=true;
  if ((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0 || streamType == AudioSystem.STREAM_RING) {
    adjustVolume=checkForRingerModeChange(oldIndex,direction);
  }
  if (adjustVolume && streamState.adjustIndex(direction)) {
    if (streamState.muteCount() == 0) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,STREAM_VOLUME_ALIAS[streamType],SENDMSG_NOOP,0,0,streamState,0);
    }
  }
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,streamState.mIndex);
}
Program: 182576
Project: 182576
Buggy source:
private void sendVolumeUpdate(int streamType){
  Intent intent=new Intent(AudioManager.VOLUME_CHANGED_ACTION);
  intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,streamType);
  intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE,getStreamVolume(streamType));
  if (streamType == AudioSystem.STREAM_BLUETOOTH_SCO) {
    mContext.sendBroadcast(intent);
  }
}

Fixed version (ground truth):
private void sendVolumeUpdate(int streamType,int oldIndex,int index){
  oldIndex=(oldIndex + 5) / 10;
  index=(index + 5) / 10;
  Intent intent=new Intent(AudioManager.VOLUME_CHANGED_ACTION);
  intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,streamType);
  intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE,index);
  intent.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE,oldIndex);
  mContext.sendBroadcast(intent);
}
Program: 182577
Project: 182577
Buggy source:
/** 
 * @see AudioManager#setStreamVolume(int,int,int) 
 */
public void setStreamVolume(int streamType,int index,int flags){
  ensureValidStreamType(streamType);
  index=rescaleIndex(index * 10,streamType,STREAM_VOLUME_ALIAS[streamType]);
  setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType],index,false,true);
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType);
}

Fixed version (ground truth):
/** 
 * @see AudioManager#setStreamVolume(int,int,int) 
 */
public void setStreamVolume(int streamType,int index,int flags){
  ensureValidStreamType(streamType);
  final int oldIndex=mStreamStates[STREAM_VOLUME_ALIAS[streamType]].mIndex;
  index=rescaleIndex(index * 10,streamType,STREAM_VOLUME_ALIAS[streamType]);
  setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType],index,false,true);
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,index);
}
Program: 182578
Project: 182578
Buggy source:
/** 
 * @see AudioManager#adjustStreamVolume(int,int,int) 
 */
public void adjustStreamVolume(int streamType,int direction,int flags){
  ensureValidDirection(direction);
  ensureValidStreamType(streamType);
  VolumeStreamState streamState=mStreamStates[STREAM_VOLUME_ALIAS[streamType]];
  final int oldIndex=streamState.mIndex;
  boolean adjustVolume=true;
  if ((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0 || streamType == AudioSystem.STREAM_RING) {
    adjustVolume=checkForRingerModeChange(oldIndex,direction);
  }
  if (adjustVolume && streamState.adjustIndex(direction)) {
    if (streamState.muteCount() == 0) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,STREAM_VOLUME_ALIAS[streamType],SENDMSG_NOOP,0,0,streamState,0);
    }
  }
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType);
}

Fixed version (ground truth):
/** 
 * @see AudioManager#adjustStreamVolume(int,int,int) 
 */
public void adjustStreamVolume(int streamType,int direction,int flags){
  ensureValidDirection(direction);
  ensureValidStreamType(streamType);
  VolumeStreamState streamState=mStreamStates[STREAM_VOLUME_ALIAS[streamType]];
  final int oldIndex=streamState.mIndex;
  boolean adjustVolume=true;
  if ((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0 || streamType == AudioSystem.STREAM_RING) {
    adjustVolume=checkForRingerModeChange(oldIndex,direction);
  }
  if (adjustVolume && streamState.adjustIndex(direction)) {
    if (streamState.muteCount() == 0) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,STREAM_VOLUME_ALIAS[streamType],SENDMSG_NOOP,0,0,streamState,0);
    }
  }
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,streamState.mIndex);
}
Program: 182579
Project: 182579
Buggy source:
private void sendVolumeUpdate(int streamType){
  Intent intent=new Intent(AudioManager.VOLUME_CHANGED_ACTION);
  intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,streamType);
  intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE,getStreamVolume(streamType));
  if (streamType == AudioSystem.STREAM_BLUETOOTH_SCO) {
    mContext.sendBroadcast(intent);
  }
}

Fixed version (ground truth):
private void sendVolumeUpdate(int streamType,int oldIndex,int index){
  oldIndex=(oldIndex + 5) / 10;
  index=(index + 5) / 10;
  Intent intent=new Intent(AudioManager.VOLUME_CHANGED_ACTION);
  intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,streamType);
  intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE,index);
  intent.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE,oldIndex);
  mContext.sendBroadcast(intent);
}
Program: 182580
Project: 182580
Buggy source:
/** 
 * @see AudioManager#setStreamVolume(int,int,int) 
 */
public void setStreamVolume(int streamType,int index,int flags){
  ensureValidStreamType(streamType);
  index=rescaleIndex(index * 10,streamType,STREAM_VOLUME_ALIAS[streamType]);
  setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType],index,false,true);
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType);
}

Fixed version (ground truth):
/** 
 * @see AudioManager#setStreamVolume(int,int,int) 
 */
public void setStreamVolume(int streamType,int index,int flags){
  ensureValidStreamType(streamType);
  final int oldIndex=mStreamStates[STREAM_VOLUME_ALIAS[streamType]].mIndex;
  index=rescaleIndex(index * 10,streamType,STREAM_VOLUME_ALIAS[streamType]);
  setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType],index,false,true);
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,index);
}
Program: 182582
Project: 182582
Buggy source:
/** 
 * Checks whether a speech recognition service is available on the system. If this method returns   {@code false},   {@link RecognitionManager#createRecognitionManager(Context)} willfail.
 * @param context with which {@code RecognitionManager} will be created
 * @return {@code true} if recognition is available, {@code false} otherwise
 */
public static boolean isRecognitionAvailable(final Context context){
  final List<ResolveInfo> list=context.getPackageManager().queryIntentServices(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),0);
  return list != null && list.size() != 0;
}

Fixed version (ground truth):
/** 
 * Checks whether a speech recognition service is available on the system. If this method returns   {@code false},   {@link RecognitionManager#createRecognitionManager(Context)} willfail.
 * @param context with which {@code RecognitionManager} will be created
 * @return {@code true} if recognition is available, {@code false} otherwise
 */
public static boolean isRecognitionAvailable(final Context context){
  final List<ResolveInfo> list=context.getPackageManager().queryIntentServices(new Intent(RecognitionService.SERVICE_INTERFACE),0);
  return list != null && list.size() != 0;
}
Program: 182583
Project: 182583
Buggy source:
/** 
 * Checks whether audio routing to the wired headset is on or off.
 * @return true if audio is being routed to/from wired headset;false if otherwise
 */
public boolean isWiredHeadsetOn(){
  if (AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADSET,"String_Node_Str") == AudioSystem.DEVICE_STATE_UNAVAILABLE) {
    return false;
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Checks whether audio routing to the wired headset is on or off.
 * @return true if audio is being routed to/from wired headset;false if otherwise
 */
public boolean isWiredHeadsetOn(){
  if (AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADSET,"String_Node_Str") == AudioSystem.DEVICE_STATE_UNAVAILABLE && AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE,"String_Node_Str") == AudioSystem.DEVICE_STATE_UNAVAILABLE) {
    return false;
  }
 else {
    return true;
  }
}
Program: 182584
Project: 182584
Buggy source:
/** 
 * Checks whether a speech recognition service is available on the system. If this method returns   {@code false},   {@link RecognitionManager#createRecognitionManager(Context)} willfail.
 * @param context with which {@code RecognitionManager} will be created
 * @return {@code true} if recognition is available, {@code false} otherwise
 */
public static boolean isRecognitionAvailable(final Context context){
  final List<ResolveInfo> list=context.getPackageManager().queryIntentServices(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),0);
  return list != null && list.size() != 0;
}

Fixed version (ground truth):
/** 
 * Checks whether a speech recognition service is available on the system. If this method returns   {@code false},   {@link RecognitionManager#createRecognitionManager(Context)} willfail.
 * @param context with which {@code RecognitionManager} will be created
 * @return {@code true} if recognition is available, {@code false} otherwise
 */
public static boolean isRecognitionAvailable(final Context context){
  final List<ResolveInfo> list=context.getPackageManager().queryIntentServices(new Intent(RecognitionService.SERVICE_INTERFACE),0);
  return list != null && list.size() != 0;
}
Program: 182585
Project: 182585
Buggy source:
/** 
 * Checks whether audio routing to the wired headset is on or off.
 * @return true if audio is being routed to/from wired headset;false if otherwise
 */
public boolean isWiredHeadsetOn(){
  if (AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADSET,"String_Node_Str") == AudioSystem.DEVICE_STATE_UNAVAILABLE) {
    return false;
  }
 else {
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Checks whether audio routing to the wired headset is on or off.
 * @return true if audio is being routed to/from wired headset;false if otherwise
 */
public boolean isWiredHeadsetOn(){
  if (AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADSET,"String_Node_Str") == AudioSystem.DEVICE_STATE_UNAVAILABLE && AudioSystem.getDeviceConnectionState(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE,"String_Node_Str") == AudioSystem.DEVICE_STATE_UNAVAILABLE) {
    return false;
  }
 else {
    return true;
  }
}
Program: 182587
Project: 182587
Buggy source:
public void testBasicAccess() throws Exception {
  try {
    byte[] newKey=mSysKeyStore.generateNewKey(128,"String_Node_Str",keyName);
    assertNotNull(newKey);
    byte[] recKey=mSysKeyStore.retrieveKey(keyName);
    assertEquals(newKey.length,recKey.length);
    for (int i=0; i < newKey.length; i++) {
      assertEquals(newKey[i],recKey[i]);
    }
    mSysKeyStore.deleteKey(keyName);
    byte[] nullKey=mSysKeyStore.retrieveKey(keyName);
    assertNull(nullKey);
    String newKeyStr=mSysKeyStore.generateNewKeyHexString(128,"String_Node_Str",keyName2);
    assertNotNull(newKeyStr);
    String recKeyStr=mSysKeyStore.retrieveKeyHexString(keyName2);
    assertEquals(newKeyStr,recKeyStr);
    mSysKeyStore.deleteKey(keyName2);
    String nullKey2=mSysKeyStore.retrieveKeyHexString(keyName);
    assertNull(nullKey2);
  }
 catch (  Exception e) {
    fail();
  }
}

Fixed version (ground truth):
public void testBasicAccess() throws Exception {
  try {
    byte[] newKey=mSysKeyStore.generateNewKey(128,"String_Node_Str",keyName);
    assertNotNull(newKey);
    byte[] recKey=mSysKeyStore.retrieveKey(keyName);
    assertEquals(newKey.length,recKey.length);
    for (int i=0; i < newKey.length; i++) {
      assertEquals(newKey[i],recKey[i]);
    }
    mSysKeyStore.deleteKey(keyName);
    byte[] nullKey=mSysKeyStore.retrieveKey(keyName);
    assertNull(nullKey);
    String newKeyStr=mSysKeyStore.generateNewKeyHexString(128,"String_Node_Str",keyName2);
    assertNotNull(newKeyStr);
    String recKeyStr=mSysKeyStore.retrieveKeyHexString(keyName2);
    assertEquals(newKeyStr,recKeyStr);
    mSysKeyStore.deleteKey(keyName2);
    String nullKey2=mSysKeyStore.retrieveKeyHexString(keyName2);
    assertNull(nullKey2);
  }
 catch (  Exception e) {
    fail();
  }
}
Program: 182588
Project: 182588
Buggy source:
public void testBasicAccess() throws Exception {
  try {
    byte[] newKey=mSysKeyStore.generateNewKey(128,"String_Node_Str",keyName);
    assertNotNull(newKey);
    byte[] recKey=mSysKeyStore.retrieveKey(keyName);
    assertEquals(newKey.length,recKey.length);
    for (int i=0; i < newKey.length; i++) {
      assertEquals(newKey[i],recKey[i]);
    }
    mSysKeyStore.deleteKey(keyName);
    byte[] nullKey=mSysKeyStore.retrieveKey(keyName);
    assertNull(nullKey);
    String newKeyStr=mSysKeyStore.generateNewKeyHexString(128,"String_Node_Str",keyName2);
    assertNotNull(newKeyStr);
    String recKeyStr=mSysKeyStore.retrieveKeyHexString(keyName2);
    assertEquals(newKeyStr,recKeyStr);
    mSysKeyStore.deleteKey(keyName2);
    String nullKey2=mSysKeyStore.retrieveKeyHexString(keyName);
    assertNull(nullKey2);
  }
 catch (  Exception e) {
    fail();
  }
}

Fixed version (ground truth):
public void testBasicAccess() throws Exception {
  try {
    byte[] newKey=mSysKeyStore.generateNewKey(128,"String_Node_Str",keyName);
    assertNotNull(newKey);
    byte[] recKey=mSysKeyStore.retrieveKey(keyName);
    assertEquals(newKey.length,recKey.length);
    for (int i=0; i < newKey.length; i++) {
      assertEquals(newKey[i],recKey[i]);
    }
    mSysKeyStore.deleteKey(keyName);
    byte[] nullKey=mSysKeyStore.retrieveKey(keyName);
    assertNull(nullKey);
    String newKeyStr=mSysKeyStore.generateNewKeyHexString(128,"String_Node_Str",keyName2);
    assertNotNull(newKeyStr);
    String recKeyStr=mSysKeyStore.retrieveKeyHexString(keyName2);
    assertEquals(newKeyStr,recKeyStr);
    mSysKeyStore.deleteKey(keyName2);
    String nullKey2=mSysKeyStore.retrieveKeyHexString(keyName2);
    assertNull(nullKey2);
  }
 catch (  Exception e) {
    fail();
  }
}
Program: 182595
Project: 182595
Buggy source:
/** 
 * Cancels the speech recognition. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 */
public void cancel(){
  checkIsCalledFromMainThread();
  checkIsCommandAllowed();
  putMessage(Message.obtain(mHandler,MSG_CANCEL));
}

Fixed version (ground truth):
/** 
 * Cancels the speech recognition. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 */
public void cancel(){
  checkIsCalledFromMainThread();
  putMessage(Message.obtain(mHandler,MSG_CANCEL));
}
Program: 182596
Project: 182596
Buggy source:
/** 
 * Starts listening for speech. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 * @param recognizerIntent contains parameters for the recognition to be performed. The intentmay also contain optional extras, see  {@link RecognizerIntent}. If these values are not set explicitly, default values will be used by the recognizer.
 */
public void startListening(final Intent recognizerIntent){
  if (recognizerIntent == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  checkIsCalledFromMainThread();
  checkIsCommandAllowed();
  if (mConnection == null) {
    mConnection=new Connection();
    if (!mContext.bindService(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),mConnection,Context.BIND_AUTO_CREATE)) {
      Log.e(TAG,"String_Node_Str");
      mConnection=null;
      mService=null;
      mListener.onError(ERROR_CLIENT);
      return;
    }
  }
  putMessage(Message.obtain(mHandler,MSG_START,recognizerIntent));
}

Fixed version (ground truth):
/** 
 * Starts listening for speech. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 * @param recognizerIntent contains parameters for the recognition to be performed. The intentmay also contain optional extras, see  {@link RecognizerIntent}. If these values are not set explicitly, default values will be used by the recognizer.
 */
public void startListening(final Intent recognizerIntent){
  if (recognizerIntent == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  checkIsCalledFromMainThread();
  if (mConnection == null) {
    mConnection=new Connection();
    if (!mContext.bindService(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),mConnection,Context.BIND_AUTO_CREATE)) {
      Log.e(TAG,"String_Node_Str");
      mConnection=null;
      mService=null;
      mListener.onError(ERROR_CLIENT);
      return;
    }
  }
  putMessage(Message.obtain(mHandler,MSG_START,recognizerIntent));
}
Program: 182597
Project: 182597
Buggy source:
/** 
 * sends the actual message to the service 
 */
private void handleStopMessage(){
  try {
    mService.stopListening(mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}

Fixed version (ground truth):
/** 
 * sends the actual message to the service 
 */
private void handleStopMessage(){
  if (!checkOpenConnection()) {
    return;
  }
  try {
    mService.stopListening(mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}
Program: 182598
Project: 182598
Buggy source:
/** 
 * sends the actual message to the service 
 */
private void handleCancelMessage(){
  try {
    mService.cancel(mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}

Fixed version (ground truth):
/** 
 * sends the actual message to the service 
 */
private void handleCancelMessage(){
  if (!checkOpenConnection()) {
    return;
  }
  try {
    mService.cancel(mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}
Program: 182599
Project: 182599
Buggy source:
/** 
 * Stops listening for speech. Speech captured so far will be recognized as if the user had stopped speaking at this point. Note that in the default case, this does not need to be called, as the speech endpointer will automatically stop the recognizer listening when it determines speech has completed. However, you can manipulate endpointer parameters directly using the intent extras defined in   {@link RecognizerIntent}, in which case you may sometimes want to manually call this method to stop listening sooner. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 */
public void stopListening(){
  checkIsCalledFromMainThread();
  checkIsCommandAllowed();
  putMessage(Message.obtain(mHandler,MSG_STOP));
}

Fixed version (ground truth):
/** 
 * Stops listening for speech. Speech captured so far will be recognized as if the user had stopped speaking at this point. Note that in the default case, this does not need to be called, as the speech endpointer will automatically stop the recognizer listening when it determines speech has completed. However, you can manipulate endpointer parameters directly using the intent extras defined in   {@link RecognizerIntent}, in which case you may sometimes want to manually call this method to stop listening sooner. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 */
public void stopListening(){
  checkIsCalledFromMainThread();
  putMessage(Message.obtain(mHandler,MSG_STOP));
}
Program: 182600
Project: 182600
Buggy source:
/** 
 * sends the actual message to the service 
 */
private void handleStartListening(Intent recognizerIntent){
  try {
    mService.startListening(recognizerIntent,mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}

Fixed version (ground truth):
/** 
 * sends the actual message to the service 
 */
private void handleStartListening(Intent recognizerIntent){
  if (!checkOpenConnection()) {
    return;
  }
  try {
    mService.startListening(recognizerIntent,mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}
Program: 182601
Project: 182601
Buggy source:
/** 
 * Cancels the speech recognition. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 */
public void cancel(){
  checkIsCalledFromMainThread();
  checkIsCommandAllowed();
  putMessage(Message.obtain(mHandler,MSG_CANCEL));
}

Fixed version (ground truth):
/** 
 * Cancels the speech recognition. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 */
public void cancel(){
  checkIsCalledFromMainThread();
  putMessage(Message.obtain(mHandler,MSG_CANCEL));
}
Program: 182602
Project: 182602
Buggy source:
/** 
 * Starts listening for speech. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 * @param recognizerIntent contains parameters for the recognition to be performed. The intentmay also contain optional extras, see  {@link RecognizerIntent}. If these values are not set explicitly, default values will be used by the recognizer.
 */
public void startListening(final Intent recognizerIntent){
  if (recognizerIntent == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  checkIsCalledFromMainThread();
  checkIsCommandAllowed();
  if (mConnection == null) {
    mConnection=new Connection();
    if (!mContext.bindService(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),mConnection,Context.BIND_AUTO_CREATE)) {
      Log.e(TAG,"String_Node_Str");
      mConnection=null;
      mService=null;
      mListener.onError(ERROR_CLIENT);
      return;
    }
  }
  putMessage(Message.obtain(mHandler,MSG_START,recognizerIntent));
}

Fixed version (ground truth):
/** 
 * Starts listening for speech. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 * @param recognizerIntent contains parameters for the recognition to be performed. The intentmay also contain optional extras, see  {@link RecognizerIntent}. If these values are not set explicitly, default values will be used by the recognizer.
 */
public void startListening(final Intent recognizerIntent){
  if (recognizerIntent == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  checkIsCalledFromMainThread();
  if (mConnection == null) {
    mConnection=new Connection();
    if (!mContext.bindService(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),mConnection,Context.BIND_AUTO_CREATE)) {
      Log.e(TAG,"String_Node_Str");
      mConnection=null;
      mService=null;
      mListener.onError(ERROR_CLIENT);
      return;
    }
  }
  putMessage(Message.obtain(mHandler,MSG_START,recognizerIntent));
}
Program: 182603
Project: 182603
Buggy source:
/** 
 * sends the actual message to the service 
 */
private void handleStopMessage(){
  try {
    mService.stopListening(mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}

Fixed version (ground truth):
/** 
 * sends the actual message to the service 
 */
private void handleStopMessage(){
  if (!checkOpenConnection()) {
    return;
  }
  try {
    mService.stopListening(mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}
Program: 182604
Project: 182604
Buggy source:
/** 
 * sends the actual message to the service 
 */
private void handleCancelMessage(){
  try {
    mService.cancel(mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}

Fixed version (ground truth):
/** 
 * sends the actual message to the service 
 */
private void handleCancelMessage(){
  if (!checkOpenConnection()) {
    return;
  }
  try {
    mService.cancel(mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}
Program: 182605
Project: 182605
Buggy source:
/** 
 * Stops listening for speech. Speech captured so far will be recognized as if the user had stopped speaking at this point. Note that in the default case, this does not need to be called, as the speech endpointer will automatically stop the recognizer listening when it determines speech has completed. However, you can manipulate endpointer parameters directly using the intent extras defined in   {@link RecognizerIntent}, in which case you may sometimes want to manually call this method to stop listening sooner. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 */
public void stopListening(){
  checkIsCalledFromMainThread();
  checkIsCommandAllowed();
  putMessage(Message.obtain(mHandler,MSG_STOP));
}

Fixed version (ground truth):
/** 
 * Stops listening for speech. Speech captured so far will be recognized as if the user had stopped speaking at this point. Note that in the default case, this does not need to be called, as the speech endpointer will automatically stop the recognizer listening when it determines speech has completed. However, you can manipulate endpointer parameters directly using the intent extras defined in   {@link RecognizerIntent}, in which case you may sometimes want to manually call this method to stop listening sooner. Please note that  {@link #setRecognitionListener(RecognitionListener)} must be called beforehand, otherwise a{@link RuntimeException} will be thrown.
 */
public void stopListening(){
  checkIsCalledFromMainThread();
  putMessage(Message.obtain(mHandler,MSG_STOP));
}
Program: 182606
Project: 182606
Buggy source:
/** 
 * sends the actual message to the service 
 */
private void handleStartListening(Intent recognizerIntent){
  try {
    mService.startListening(recognizerIntent,mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}

Fixed version (ground truth):
/** 
 * sends the actual message to the service 
 */
private void handleStartListening(Intent recognizerIntent){
  if (!checkOpenConnection()) {
    return;
  }
  try {
    mService.startListening(recognizerIntent,mListener);
    if (DBG)     Log.d(TAG,"String_Node_Str");
  }
 catch (  final RemoteException e) {
    Log.e(TAG,"String_Node_Str",e);
    mListener.onError(ERROR_CLIENT);
  }
}
Program: 182608
Project: 182608
Buggy source:
private boolean startScrollIfNeeded(int deltaY){
  final int distance=Math.abs(deltaY);
  if (distance > mTouchSlop) {
    createScrollingCache();
    mTouchMode=TOUCH_MODE_SCROLL;
    mMotionCorrection=deltaY;
    final Handler handler=getHandler();
    if (handler != null) {
      handler.removeCallbacks(mPendingCheckForLongPress);
    }
    setPressed(false);
    View motionView=getChildAt(mMotionPosition - mFirstPosition);
    if (motionView != null) {
      motionView.setPressed(false);
    }
    reportScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
    requestDisallowInterceptTouchEvent(true);
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean startScrollIfNeeded(int deltaY){
  final int distance=Math.abs(deltaY);
  final boolean overscroll=mScrollY != 0;
  if (overscroll || distance > mTouchSlop) {
    createScrollingCache();
    mTouchMode=overscroll ? TOUCH_MODE_OVERSCROLL : TOUCH_MODE_SCROLL;
    mMotionCorrection=deltaY;
    final Handler handler=getHandler();
    if (handler != null) {
      handler.removeCallbacks(mPendingCheckForLongPress);
    }
    setPressed(false);
    View motionView=getChildAt(mMotionPosition - mFirstPosition);
    if (motionView != null) {
      motionView.setPressed(false);
    }
    reportScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
    requestDisallowInterceptTouchEvent(true);
    return true;
  }
  return false;
}
Program: 182609
Project: 182609
Buggy source:
private boolean springback(int startX,int startY,int minX,int maxX,int minY,int maxY,Scroller scroller){
  int xoff=0;
  int yoff=0;
  if (startX < minX) {
    xoff=minX - startX;
  }
 else   if (startX > maxX) {
    xoff=maxX - startX;
  }
  if (startY < minY) {
    yoff=minY - startY;
  }
 else   if (startY > maxY) {
    yoff=maxY - startY;
  }
  if (xoff != 0 || yoff != 0) {
    scroller.startScroll(startX,startY,xoff,yoff,SPRINGBACK_DURATION);
    mCurrScroller.abortAnimation();
    mCurrScroller=scroller;
    mScrollMode=MODE_SPRINGBACK;
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean springback(int startX,int startY,int minX,int maxX,int minY,int maxY,Scroller scroller){
  int xoff=0;
  int yoff=0;
  if (startX < minX) {
    xoff=minX - startX;
  }
 else   if (startX > maxX) {
    xoff=maxX - startX;
  }
  if (startY < minY) {
    yoff=minY - startY;
  }
 else   if (startY > maxY) {
    yoff=maxY - startY;
  }
  if (xoff != 0 || yoff != 0) {
    mCurrScroller.abortAnimation();
    scroller.startScroll(startX,startY,xoff,yoff,SPRINGBACK_DURATION);
    mCurrScroller=scroller;
    mScrollMode=MODE_SPRINGBACK;
    return true;
  }
  return false;
}
Program: 182610
Project: 182610
Buggy source:
private void overfling(int startx,int starty,float xvel,float yvel){
  Scroller scroller=mDecelScroller;
  final float durationSecs=(OVERFLING_DURATION / 1000.f);
  int dx=(int)(xvel * durationSecs) / 8;
  int dy=(int)(yvel * durationSecs) / 8;
  scroller.startScroll(startx,starty,dx,dy,OVERFLING_DURATION);
  mCurrScroller.abortAnimation();
  mCurrScroller=scroller;
  mScrollMode=MODE_OVERFLING;
}

Fixed version (ground truth):
private void overfling(int startx,int starty,float xvel,float yvel){
  Scroller scroller=mDecelScroller;
  final float durationSecs=(OVERFLING_DURATION / 1000.f);
  int dx=(int)(xvel * durationSecs) / 8;
  int dy=(int)(yvel * durationSecs) / 8;
  mCurrScroller.abortAnimation();
  scroller.startScroll(startx,starty,dx,dy,OVERFLING_DURATION);
  mCurrScroller=scroller;
  mScrollMode=MODE_OVERFLING;
}
Program: 182612
Project: 182612
Buggy source:
private boolean startScrollIfNeeded(int deltaY){
  final int distance=Math.abs(deltaY);
  if (distance > mTouchSlop) {
    createScrollingCache();
    mTouchMode=TOUCH_MODE_SCROLL;
    mMotionCorrection=deltaY;
    final Handler handler=getHandler();
    if (handler != null) {
      handler.removeCallbacks(mPendingCheckForLongPress);
    }
    setPressed(false);
    View motionView=getChildAt(mMotionPosition - mFirstPosition);
    if (motionView != null) {
      motionView.setPressed(false);
    }
    reportScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
    requestDisallowInterceptTouchEvent(true);
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean startScrollIfNeeded(int deltaY){
  final int distance=Math.abs(deltaY);
  final boolean overscroll=mScrollY != 0;
  if (overscroll || distance > mTouchSlop) {
    createScrollingCache();
    mTouchMode=overscroll ? TOUCH_MODE_OVERSCROLL : TOUCH_MODE_SCROLL;
    mMotionCorrection=deltaY;
    final Handler handler=getHandler();
    if (handler != null) {
      handler.removeCallbacks(mPendingCheckForLongPress);
    }
    setPressed(false);
    View motionView=getChildAt(mMotionPosition - mFirstPosition);
    if (motionView != null) {
      motionView.setPressed(false);
    }
    reportScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
    requestDisallowInterceptTouchEvent(true);
    return true;
  }
  return false;
}
Program: 182613
Project: 182613
Buggy source:
private boolean springback(int startX,int startY,int minX,int maxX,int minY,int maxY,Scroller scroller){
  int xoff=0;
  int yoff=0;
  if (startX < minX) {
    xoff=minX - startX;
  }
 else   if (startX > maxX) {
    xoff=maxX - startX;
  }
  if (startY < minY) {
    yoff=minY - startY;
  }
 else   if (startY > maxY) {
    yoff=maxY - startY;
  }
  if (xoff != 0 || yoff != 0) {
    scroller.startScroll(startX,startY,xoff,yoff,SPRINGBACK_DURATION);
    mCurrScroller.abortAnimation();
    mCurrScroller=scroller;
    mScrollMode=MODE_SPRINGBACK;
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean springback(int startX,int startY,int minX,int maxX,int minY,int maxY,Scroller scroller){
  int xoff=0;
  int yoff=0;
  if (startX < minX) {
    xoff=minX - startX;
  }
 else   if (startX > maxX) {
    xoff=maxX - startX;
  }
  if (startY < minY) {
    yoff=minY - startY;
  }
 else   if (startY > maxY) {
    yoff=maxY - startY;
  }
  if (xoff != 0 || yoff != 0) {
    mCurrScroller.abortAnimation();
    scroller.startScroll(startX,startY,xoff,yoff,SPRINGBACK_DURATION);
    mCurrScroller=scroller;
    mScrollMode=MODE_SPRINGBACK;
    return true;
  }
  return false;
}
Program: 182614
Project: 182614
Buggy source:
private void overfling(int startx,int starty,float xvel,float yvel){
  Scroller scroller=mDecelScroller;
  final float durationSecs=(OVERFLING_DURATION / 1000.f);
  int dx=(int)(xvel * durationSecs) / 8;
  int dy=(int)(yvel * durationSecs) / 8;
  scroller.startScroll(startx,starty,dx,dy,OVERFLING_DURATION);
  mCurrScroller.abortAnimation();
  mCurrScroller=scroller;
  mScrollMode=MODE_OVERFLING;
}

Fixed version (ground truth):
private void overfling(int startx,int starty,float xvel,float yvel){
  Scroller scroller=mDecelScroller;
  final float durationSecs=(OVERFLING_DURATION / 1000.f);
  int dx=(int)(xvel * durationSecs) / 8;
  int dy=(int)(yvel * durationSecs) / 8;
  mCurrScroller.abortAnimation();
  scroller.startScroll(startx,starty,dx,dy,OVERFLING_DURATION);
  mCurrScroller=scroller;
  mScrollMode=MODE_OVERFLING;
}
Program: 182615
Project: 182615
Buggy source:
private DateFormat getDateFormat(){
  String format=Settings.System.getString(getContext().getContentResolver(),Settings.System.DATE_FORMAT);
  if ("String_Node_Str".equals(format)) {
    return DateFormat.getDateInstance(DateFormat.SHORT);
  }
 else {
    return new SimpleDateFormat(format);
  }
}

Fixed version (ground truth):
private DateFormat getDateFormat(){
  String format=Settings.System.getString(getContext().getContentResolver(),Settings.System.DATE_FORMAT);
  if (format == null || "String_Node_Str".equals(format)) {
    return DateFormat.getDateInstance(DateFormat.SHORT);
  }
 else {
    return new SimpleDateFormat(format);
  }
}
Program: 182617
Project: 182617
Buggy source:
void addProvidersForPackageLocked(String pkgName){
  Intent intent=new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
  List<ResolveInfo> broadcastReceivers=mPackageManager.queryBroadcastReceivers(intent,PackageManager.GET_META_DATA);
  final int N=broadcastReceivers.size();
  for (int i=0; i < N; i++) {
    ResolveInfo ri=broadcastReceivers.get(i);
    ActivityInfo ai=ri.activityInfo;
    if (pkgName.equals(ai.packageName)) {
      addProviderLocked(ri);
    }
  }
}

Fixed version (ground truth):
void addProvidersForPackageLocked(String pkgName){
  Intent intent=new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
  intent.setPackage(pkgName);
  List<ResolveInfo> broadcastReceivers=mPackageManager.queryBroadcastReceivers(intent,PackageManager.GET_META_DATA);
  final int N=broadcastReceivers.size();
  for (int i=0; i < N; i++) {
    ResolveInfo ri=broadcastReceivers.get(i);
    ActivityInfo ai=ri.activityInfo;
    if (pkgName.equals(ai.packageName)) {
      addProviderLocked(ri);
    }
  }
}
Program: 182619
Project: 182619
Buggy source:
void addProvidersForPackageLocked(String pkgName){
  Intent intent=new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
  List<ResolveInfo> broadcastReceivers=mPackageManager.queryBroadcastReceivers(intent,PackageManager.GET_META_DATA);
  final int N=broadcastReceivers.size();
  for (int i=0; i < N; i++) {
    ResolveInfo ri=broadcastReceivers.get(i);
    ActivityInfo ai=ri.activityInfo;
    if (pkgName.equals(ai.packageName)) {
      addProviderLocked(ri);
    }
  }
}

Fixed version (ground truth):
void addProvidersForPackageLocked(String pkgName){
  Intent intent=new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
  intent.setPackage(pkgName);
  List<ResolveInfo> broadcastReceivers=mPackageManager.queryBroadcastReceivers(intent,PackageManager.GET_META_DATA);
  final int N=broadcastReceivers.size();
  for (int i=0; i < N; i++) {
    ResolveInfo ri=broadcastReceivers.get(i);
    ActivityInfo ai=ri.activityInfo;
    if (pkgName.equals(ai.packageName)) {
      addProviderLocked(ri);
    }
  }
}
Program: 182620
Project: 182620
Buggy source:
private DateFormat getDateFormat(){
  String format=Settings.System.getString(getContext().getContentResolver(),Settings.System.DATE_FORMAT);
  if ("String_Node_Str".equals(format)) {
    return DateFormat.getDateInstance(DateFormat.SHORT);
  }
 else {
    return new SimpleDateFormat(format);
  }
}

Fixed version (ground truth):
private DateFormat getDateFormat(){
  String format=Settings.System.getString(getContext().getContentResolver(),Settings.System.DATE_FORMAT);
  if (format == null || "String_Node_Str".equals(format)) {
    return DateFormat.getDateInstance(DateFormat.SHORT);
  }
 else {
    return new SimpleDateFormat(format);
  }
}
Program: 182621
Project: 182621
Buggy source:
public void onClick(View v){
  if (mSearchable == null) {
    return;
  }
  try {
    ((SearchManager)getContext().getSystemService(Context.SEARCH_SERVICE)).stopSearch();
    if (mSearchable.getVoiceSearchLaunchWebSearch()) {
      getContext().startActivity(mVoiceWebSearchIntent);
    }
 else     if (mSearchable.getVoiceSearchLaunchRecognizer()) {
      Intent appSearchIntent=createVoiceAppSearchIntent(mVoiceAppSearchIntent);
      getContext().startActivity(appSearchIntent);
    }
  }
 catch (  ActivityNotFoundException e) {
    Log.w(LOG_TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
public void onClick(View v){
  if (mSearchable == null) {
    return;
  }
  SearchableInfo searchable=mSearchable;
  cancel();
  try {
    if (searchable.getVoiceSearchLaunchWebSearch()) {
      getContext().startActivity(mVoiceWebSearchIntent);
    }
 else     if (searchable.getVoiceSearchLaunchRecognizer()) {
      Intent appSearchIntent=createVoiceAppSearchIntent(mVoiceAppSearchIntent);
      getContext().startActivity(appSearchIntent);
    }
  }
 catch (  ActivityNotFoundException e) {
    Log.w(LOG_TAG,"String_Node_Str");
  }
}
Program: 182622
Project: 182622
Buggy source:
public void onClick(View v){
  if (mSearchable == null) {
    return;
  }
  try {
    ((SearchManager)getContext().getSystemService(Context.SEARCH_SERVICE)).stopSearch();
    if (mSearchable.getVoiceSearchLaunchWebSearch()) {
      getContext().startActivity(mVoiceWebSearchIntent);
    }
 else     if (mSearchable.getVoiceSearchLaunchRecognizer()) {
      Intent appSearchIntent=createVoiceAppSearchIntent(mVoiceAppSearchIntent);
      getContext().startActivity(appSearchIntent);
    }
  }
 catch (  ActivityNotFoundException e) {
    Log.w(LOG_TAG,"String_Node_Str");
  }
}

Fixed version (ground truth):
public void onClick(View v){
  if (mSearchable == null) {
    return;
  }
  SearchableInfo searchable=mSearchable;
  cancel();
  try {
    if (searchable.getVoiceSearchLaunchWebSearch()) {
      getContext().startActivity(mVoiceWebSearchIntent);
    }
 else     if (searchable.getVoiceSearchLaunchRecognizer()) {
      Intent appSearchIntent=createVoiceAppSearchIntent(mVoiceAppSearchIntent);
      getContext().startActivity(appSearchIntent);
    }
  }
 catch (  ActivityNotFoundException e) {
    Log.w(LOG_TAG,"String_Node_Str");
  }
}
Program: 182623
Project: 182623
Buggy source:
private synchronized final void update(String newName,int newState){
  int headsetState=newState & SUPPORTED_HEADSETS;
  int newOrOld=headsetState | mHeadsetState;
  if (mHeadsetState == headsetState || ((newOrOld & (newOrOld - 1)) != 0)) {
    return;
  }
  mHeadsetName=newName;
  mPrevHeadsetState=mHeadsetState;
  mHeadsetState=headsetState;
  if (headsetState == 0) {
    Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    mContext.sendBroadcast(intent);
    mWakeLock.acquire();
    mHandler.sendMessageDelayed(mHandler.obtainMessage(0,mHeadsetState,mPrevHeadsetState,mHeadsetName),1000);
  }
 else {
    sendIntents(mHeadsetState,mPrevHeadsetState,mHeadsetName);
  }
}

Fixed version (ground truth):
private synchronized final void update(String newName,int newState){
  int headsetState=newState & SUPPORTED_HEADSETS;
  int newOrOld=headsetState | mHeadsetState;
  int delay=0;
  if (mHeadsetState == headsetState || ((newOrOld & (newOrOld - 1)) != 0)) {
    return;
  }
  mHeadsetName=newName;
  mPrevHeadsetState=mHeadsetState;
  mHeadsetState=headsetState;
  if (headsetState == 0) {
    Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    mContext.sendBroadcast(intent);
    delay=1000;
  }
 else {
    if (mHandler.hasMessages(0)) {
      delay=1000;
    }
  }
  mWakeLock.acquire();
  mHandler.sendMessageDelayed(mHandler.obtainMessage(0,mHeadsetState,mPrevHeadsetState,mHeadsetName),delay);
}
Program: 182624
Project: 182624
Buggy source:
protected void startPhotoQuery(long photoId,Uri lookupKey){
  mQueryHandler.startQuery(TOKEN_PHOTO_QUERY,lookupKey,ContentUris.withAppendedId(Data.CONTENT_URI,photoId),PhotoQuery.COLUMNS,null,null,null);
}

Fixed version (ground truth):
/** 
 * startPhotoQuery internal method to query contact photo by photo id and uri.
 * @param photoId the photo id.
 * @param lookupKey the lookup uri.
 * @param resetQueryHandler whether to use a new AsyncQueryHandler or not.
 */
protected void startPhotoQuery(long photoId,Uri lookupKey,boolean resetQueryHandler){
  if (resetQueryHandler) {
    resetAsyncQueryHandler();
  }
  mQueryHandler.startQuery(TOKEN_PHOTO_QUERY,lookupKey,ContentUris.withAppendedId(Data.CONTENT_URI,photoId),PhotoQuery.COLUMNS,null,null,null);
}