nus-yam/ex-repair huggingface dataset:
Program: 181862
Project: 181862
Buggy source:
private void upgradeScreenTimeoutFromNever(SQLiteDatabase db){
  Cursor c=db.query("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str",new String[]{Settings.System.SCREEN_OFF_TIMEOUT,"String_Node_Str"},null,null,null);
  SQLiteStatement stmt=null;
  if (c.getCount() > 0) {
    c.close();
    try {
      stmt=db.compileStatement("String_Node_Str" + "String_Node_Str");
      loadIntegerSetting(stmt,Settings.System.SCREEN_OFF_TIMEOUT,30 * 60 * 1000);
    }
  finally {
      if (stmt != null)       stmt.close();
    }
  }
 else {
    c.close();
  }
}

Fixed version (ground truth):
private void upgradeScreenTimeoutFromNever(SQLiteDatabase db){
  Cursor c=db.query("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str",new String[]{Settings.System.SCREEN_OFF_TIMEOUT,"String_Node_Str"},null,null,null);
  SQLiteStatement stmt=null;
  if (c.getCount() > 0) {
    c.close();
    try {
      stmt=db.compileStatement("String_Node_Str" + "String_Node_Str");
      loadSetting(stmt,Settings.System.SCREEN_OFF_TIMEOUT,Integer.toString(30 * 60 * 1000));
    }
  finally {
      if (stmt != null)       stmt.close();
    }
  }
 else {
    c.close();
  }
}
Program: 181863
Project: 181863
Buggy source:
private void handleSinkStateChange(BluetoothDevice device,int prevState,int state){
  if (state != prevState) {
    if (state == BluetoothA2dp.STATE_DISCONNECTED || state == BluetoothA2dp.STATE_DISCONNECTING) {
      if (prevState == BluetoothA2dp.STATE_CONNECTED || prevState == BluetoothA2dp.STATE_PLAYING) {
        Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
        mContext.sendBroadcast(intent);
      }
      mSinkCount--;
    }
 else     if (state == BluetoothA2dp.STATE_CONNECTED) {
      mSinkCount++;
    }
    mAudioDevices.put(device,state);
    checkSinkSuspendState(state);
    mTargetA2dpState=-1;
    if (getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF && state == BluetoothA2dp.STATE_CONNECTING || state == BluetoothA2dp.STATE_CONNECTED) {
      setSinkPriority(device,BluetoothA2dp.PRIORITY_AUTO_CONNECT);
    }
    Intent intent=new Intent(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
    intent.putExtra(BluetoothDevice.EXTRA_DEVICE,device);
    intent.putExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE,prevState);
    intent.putExtra(BluetoothA2dp.EXTRA_SINK_STATE,state);
    mContext.sendBroadcast(intent,BLUETOOTH_PERM);
    if (DBG)     log("String_Node_Str" + device + "String_Node_Str"+ prevState+ "String_Node_Str"+ state);
  }
}

Fixed version (ground truth):
private void handleSinkStateChange(BluetoothDevice device,int prevState,int state){
  if (state != prevState) {
    if (state == BluetoothA2dp.STATE_DISCONNECTED || state == BluetoothA2dp.STATE_DISCONNECTING) {
      mSinkCount--;
    }
 else     if (state == BluetoothA2dp.STATE_CONNECTED) {
      mSinkCount++;
    }
    mAudioDevices.put(device,state);
    checkSinkSuspendState(state);
    mTargetA2dpState=-1;
    if (getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF && state == BluetoothA2dp.STATE_CONNECTING || state == BluetoothA2dp.STATE_CONNECTED) {
      setSinkPriority(device,BluetoothA2dp.PRIORITY_AUTO_CONNECT);
    }
    Intent intent=new Intent(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
    intent.putExtra(BluetoothDevice.EXTRA_DEVICE,device);
    intent.putExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE,prevState);
    intent.putExtra(BluetoothA2dp.EXTRA_SINK_STATE,state);
    mContext.sendBroadcast(intent,BLUETOOTH_PERM);
    if (DBG)     log("String_Node_Str" + device + "String_Node_Str"+ prevState+ "String_Node_Str"+ state);
  }
}
Program: 181865
Project: 181865
Buggy source:
private void handleSinkStateChange(BluetoothDevice device,int prevState,int state){
  if (state != prevState) {
    if (state == BluetoothA2dp.STATE_DISCONNECTED || state == BluetoothA2dp.STATE_DISCONNECTING) {
      if (prevState == BluetoothA2dp.STATE_CONNECTED || prevState == BluetoothA2dp.STATE_PLAYING) {
        Intent intent=new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
        mContext.sendBroadcast(intent);
      }
      mSinkCount--;
    }
 else     if (state == BluetoothA2dp.STATE_CONNECTED) {
      mSinkCount++;
    }
    mAudioDevices.put(device,state);
    checkSinkSuspendState(state);
    mTargetA2dpState=-1;
    if (getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF && state == BluetoothA2dp.STATE_CONNECTING || state == BluetoothA2dp.STATE_CONNECTED) {
      setSinkPriority(device,BluetoothA2dp.PRIORITY_AUTO_CONNECT);
    }
    Intent intent=new Intent(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
    intent.putExtra(BluetoothDevice.EXTRA_DEVICE,device);
    intent.putExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE,prevState);
    intent.putExtra(BluetoothA2dp.EXTRA_SINK_STATE,state);
    mContext.sendBroadcast(intent,BLUETOOTH_PERM);
    if (DBG)     log("String_Node_Str" + device + "String_Node_Str"+ prevState+ "String_Node_Str"+ state);
  }
}

Fixed version (ground truth):
private void handleSinkStateChange(BluetoothDevice device,int prevState,int state){
  if (state != prevState) {
    if (state == BluetoothA2dp.STATE_DISCONNECTED || state == BluetoothA2dp.STATE_DISCONNECTING) {
      mSinkCount--;
    }
 else     if (state == BluetoothA2dp.STATE_CONNECTED) {
      mSinkCount++;
    }
    mAudioDevices.put(device,state);
    checkSinkSuspendState(state);
    mTargetA2dpState=-1;
    if (getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF && state == BluetoothA2dp.STATE_CONNECTING || state == BluetoothA2dp.STATE_CONNECTED) {
      setSinkPriority(device,BluetoothA2dp.PRIORITY_AUTO_CONNECT);
    }
    Intent intent=new Intent(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
    intent.putExtra(BluetoothDevice.EXTRA_DEVICE,device);
    intent.putExtra(BluetoothA2dp.EXTRA_PREVIOUS_SINK_STATE,prevState);
    intent.putExtra(BluetoothA2dp.EXTRA_SINK_STATE,state);
    mContext.sendBroadcast(intent,BLUETOOTH_PERM);
    if (DBG)     log("String_Node_Str" + device + "String_Node_Str"+ prevState+ "String_Node_Str"+ state);
  }
}
Program: 181867
Project: 181867
Buggy source:
private void upgradeScreenTimeoutFromNever(SQLiteDatabase db){
  Cursor c=db.query("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str",new String[]{Settings.System.SCREEN_OFF_TIMEOUT,"String_Node_Str"},null,null,null);
  SQLiteStatement stmt=null;
  if (c.getCount() > 0) {
    c.close();
    try {
      stmt=db.compileStatement("String_Node_Str" + "String_Node_Str");
      loadIntegerSetting(stmt,Settings.System.SCREEN_OFF_TIMEOUT,30 * 60 * 1000);
    }
  finally {
      if (stmt != null)       stmt.close();
    }
  }
 else {
    c.close();
  }
}

Fixed version (ground truth):
private void upgradeScreenTimeoutFromNever(SQLiteDatabase db){
  Cursor c=db.query("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str",new String[]{Settings.System.SCREEN_OFF_TIMEOUT,"String_Node_Str"},null,null,null);
  SQLiteStatement stmt=null;
  if (c.getCount() > 0) {
    c.close();
    try {
      stmt=db.compileStatement("String_Node_Str" + "String_Node_Str");
      loadSetting(stmt,Settings.System.SCREEN_OFF_TIMEOUT,Integer.toString(30 * 60 * 1000));
    }
  finally {
      if (stmt != null)       stmt.close();
    }
  }
 else {
    c.close();
  }
}
Program: 181868
Project: 181868
Buggy source:
/** 
 * @see AudioManager#abandonAudioFocus(IAudioFocusDispatcher) 
 */
public int abandonAudioFocus(IAudioFocusDispatcher fl,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
  removeFocusStackEntry(clientId,true);
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}

Fixed version (ground truth):
/** 
 * @see AudioManager#abandonAudioFocus(IAudioFocusDispatcher) 
 */
public int abandonAudioFocus(IAudioFocusDispatcher fl,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
synchronized (mFocusStack) {
    removeFocusStackEntry(clientId,true);
  }
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}
Program: 181869
Project: 181869
Buggy source:
public void unregisterAudioFocusClient(String clientId){
  removeFocusStackEntry(clientId,false);
}

Fixed version (ground truth):
public void unregisterAudioFocusClient(String clientId){
synchronized (mFocusStack) {
    removeFocusStackEntry(clientId,false);
  }
}
Program: 181870
Project: 181870
Buggy source:
/** 
 * @see AudioManager#abandonAudioFocus(IAudioFocusDispatcher) 
 */
public int abandonAudioFocus(IAudioFocusDispatcher fl,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
  removeFocusStackEntry(clientId,true);
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}

Fixed version (ground truth):
/** 
 * @see AudioManager#abandonAudioFocus(IAudioFocusDispatcher) 
 */
public int abandonAudioFocus(IAudioFocusDispatcher fl,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
synchronized (mFocusStack) {
    removeFocusStackEntry(clientId,true);
  }
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}
Program: 181871
Project: 181871
Buggy source:
public void unregisterAudioFocusClient(String clientId){
  removeFocusStackEntry(clientId,false);
}

Fixed version (ground truth):
public void unregisterAudioFocusClient(String clientId){
synchronized (mFocusStack) {
    removeFocusStackEntry(clientId,false);
  }
}
Program: 181872
Project: 181872
Buggy source:
private void upgradeScreenTimeoutFromNever(SQLiteDatabase db){
  Cursor c=db.query("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str",new String[]{Settings.System.SCREEN_OFF_TIMEOUT,"String_Node_Str"},null,null,null);
  SQLiteStatement stmt=null;
  if (c.getCount() > 0) {
    c.close();
    try {
      stmt=db.compileStatement("String_Node_Str" + "String_Node_Str");
      loadIntegerSetting(stmt,Settings.System.SCREEN_OFF_TIMEOUT,30 * 60 * 1000);
    }
  finally {
      if (stmt != null)       stmt.close();
    }
  }
 else {
    c.close();
  }
}

Fixed version (ground truth):
private void upgradeScreenTimeoutFromNever(SQLiteDatabase db){
  Cursor c=db.query("String_Node_Str",new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str",new String[]{Settings.System.SCREEN_OFF_TIMEOUT,"String_Node_Str"},null,null,null);
  SQLiteStatement stmt=null;
  if (c.getCount() > 0) {
    c.close();
    try {
      stmt=db.compileStatement("String_Node_Str" + "String_Node_Str");
      loadSetting(stmt,Settings.System.SCREEN_OFF_TIMEOUT,Integer.toString(30 * 60 * 1000));
    }
  finally {
      if (stmt != null)       stmt.close();
    }
  }
 else {
    c.close();
  }
}
Program: 181873
Project: 181873
Buggy source:
/** 
 * @see AudioManager#abandonAudioFocus(IAudioFocusDispatcher) 
 */
public int abandonAudioFocus(IAudioFocusDispatcher fl,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
  removeFocusStackEntry(clientId,true);
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}

Fixed version (ground truth):
/** 
 * @see AudioManager#abandonAudioFocus(IAudioFocusDispatcher) 
 */
public int abandonAudioFocus(IAudioFocusDispatcher fl,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
synchronized (mFocusStack) {
    removeFocusStackEntry(clientId,true);
  }
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}
Program: 181874
Project: 181874
Buggy source:
public void unregisterAudioFocusClient(String clientId){
  removeFocusStackEntry(clientId,false);
}

Fixed version (ground truth):
public void unregisterAudioFocusClient(String clientId){
synchronized (mFocusStack) {
    removeFocusStackEntry(clientId,false);
  }
}
Program: 181876
Project: 181876
Buggy source:
/** 
 * @see AudioManager#abandonAudioFocus(IAudioFocusDispatcher) 
 */
public int abandonAudioFocus(IAudioFocusDispatcher fl,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
  removeFocusStackEntry(clientId,true);
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}

Fixed version (ground truth):
/** 
 * @see AudioManager#abandonAudioFocus(IAudioFocusDispatcher) 
 */
public int abandonAudioFocus(IAudioFocusDispatcher fl,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
synchronized (mFocusStack) {
    removeFocusStackEntry(clientId,true);
  }
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}
Program: 181877
Project: 181877
Buggy source:
public void unregisterAudioFocusClient(String clientId){
  removeFocusStackEntry(clientId,false);
}

Fixed version (ground truth):
public void unregisterAudioFocusClient(String clientId){
synchronized (mFocusStack) {
    removeFocusStackEntry(clientId,false);
  }
}
Program: 181878
Project: 181878
Buggy source:
/** 
 * Something in the current window tells us we need to change the touch mode.  For example, we are not in touch mode, and the user touches the screen. If the touch mode has changed, tell the window manager, and handle it locally.
 * @param inTouchMode Whether we want to be in touch mode.
 * @return True if the touch mode changed and focus changed was changed as a result
 */
boolean ensureTouchMode(boolean inTouchMode){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  try {
    sWindowSession.setInTouchMode(inTouchMode);
  }
 catch (  RemoteException e) {
    throw new RuntimeException(e);
  }
  return ensureTouchModeLocally(inTouchMode,true);
}

Fixed version (ground truth):
/** 
 * Something in the current window tells us we need to change the touch mode.  For example, we are not in touch mode, and the user touches the screen. If the touch mode has changed, tell the window manager, and handle it locally.
 * @param inTouchMode Whether we want to be in touch mode.
 * @return True if the touch mode changed and focus changed was changed as a result
 */
boolean ensureTouchMode(boolean inTouchMode){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  try {
    sWindowSession.setInTouchMode(inTouchMode);
  }
 catch (  RemoteException e) {
    throw new RuntimeException(e);
  }
  return ensureTouchModeLocally(inTouchMode);
}
Program: 181879
Project: 181879
Buggy source:
/** 
 * Ensure that the touch mode for this window is set, and if it is changing, take the appropriate action.
 * @param inTouchMode Whether we want to be in touch mode.
 * @param dispatchFocus
 * @return True if the touch mode changed and focus changed was changed as a result
 */
private boolean ensureTouchModeLocally(boolean inTouchMode,boolean dispatchFocus){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  mAttachInfo.mInTouchMode=inTouchMode;
  mAttachInfo.mTreeObserver.dispatchOnTouchModeChanged(inTouchMode);
  return dispatchFocus && (inTouchMode) ? enterTouchMode() : leaveTouchMode();
}

Fixed version (ground truth):
/** 
 * Ensure that the touch mode for this window is set, and if it is changing, take the appropriate action.
 * @param inTouchMode Whether we want to be in touch mode.
 * @return True if the touch mode changed and focus changed was changed as a result
 */
private boolean ensureTouchModeLocally(boolean inTouchMode){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  mAttachInfo.mInTouchMode=inTouchMode;
  mAttachInfo.mTreeObserver.dispatchOnTouchModeChanged(inTouchMode);
  return (inTouchMode) ? enterTouchMode() : leaveTouchMode();
}
Program: 181881
Project: 181881
Buggy source:
/** 
 * You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event){
  mTempRect.setEmpty();
  if (!canScroll()) {
    if (isFocused()) {
      View currentFocused=findFocus();
      if (currentFocused == this)       currentFocused=null;
      View nextFocused=FocusFinder.getInstance().findNextFocus(this,currentFocused,View.FOCUS_DOWN);
      return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
    }
    return false;
  }
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_UP:
      if (!event.isAltPressed()) {
        handled=arrowScroll(View.FOCUS_UP);
      }
 else {
        handled=fullScroll(View.FOCUS_UP);
      }
    break;
case KeyEvent.KEYCODE_DPAD_DOWN:
  if (!event.isAltPressed()) {
    handled=arrowScroll(View.FOCUS_DOWN);
  }
 else {
    handled=fullScroll(View.FOCUS_DOWN);
  }
break;
case KeyEvent.KEYCODE_SPACE:
pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
break;
}
}
return handled;
}

Fixed version (ground truth):
/** 
 * You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event){
  mTempRect.setEmpty();
  if (!canScroll()) {
    if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) {
      View currentFocused=findFocus();
      if (currentFocused == this)       currentFocused=null;
      View nextFocused=FocusFinder.getInstance().findNextFocus(this,currentFocused,View.FOCUS_DOWN);
      return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
    }
    return false;
  }
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_UP:
      if (!event.isAltPressed()) {
        handled=arrowScroll(View.FOCUS_UP);
      }
 else {
        handled=fullScroll(View.FOCUS_UP);
      }
    break;
case KeyEvent.KEYCODE_DPAD_DOWN:
  if (!event.isAltPressed()) {
    handled=arrowScroll(View.FOCUS_DOWN);
  }
 else {
    handled=fullScroll(View.FOCUS_DOWN);
  }
break;
case KeyEvent.KEYCODE_SPACE:
pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
break;
}
}
return handled;
}
Program: 181882
Project: 181882
Buggy source:
/** 
 * Something in the current window tells us we need to change the touch mode.  For example, we are not in touch mode, and the user touches the screen. If the touch mode has changed, tell the window manager, and handle it locally.
 * @param inTouchMode Whether we want to be in touch mode.
 * @return True if the touch mode changed and focus changed was changed as a result
 */
boolean ensureTouchMode(boolean inTouchMode){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  try {
    sWindowSession.setInTouchMode(inTouchMode);
  }
 catch (  RemoteException e) {
    throw new RuntimeException(e);
  }
  return ensureTouchModeLocally(inTouchMode,true);
}

Fixed version (ground truth):
/** 
 * Something in the current window tells us we need to change the touch mode.  For example, we are not in touch mode, and the user touches the screen. If the touch mode has changed, tell the window manager, and handle it locally.
 * @param inTouchMode Whether we want to be in touch mode.
 * @return True if the touch mode changed and focus changed was changed as a result
 */
boolean ensureTouchMode(boolean inTouchMode){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  try {
    sWindowSession.setInTouchMode(inTouchMode);
  }
 catch (  RemoteException e) {
    throw new RuntimeException(e);
  }
  return ensureTouchModeLocally(inTouchMode);
}
Program: 181883
Project: 181883
Buggy source:
/** 
 * Ensure that the touch mode for this window is set, and if it is changing, take the appropriate action.
 * @param inTouchMode Whether we want to be in touch mode.
 * @param dispatchFocus
 * @return True if the touch mode changed and focus changed was changed as a result
 */
private boolean ensureTouchModeLocally(boolean inTouchMode,boolean dispatchFocus){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  mAttachInfo.mInTouchMode=inTouchMode;
  mAttachInfo.mTreeObserver.dispatchOnTouchModeChanged(inTouchMode);
  return dispatchFocus && (inTouchMode) ? enterTouchMode() : leaveTouchMode();
}

Fixed version (ground truth):
/** 
 * Ensure that the touch mode for this window is set, and if it is changing, take the appropriate action.
 * @param inTouchMode Whether we want to be in touch mode.
 * @return True if the touch mode changed and focus changed was changed as a result
 */
private boolean ensureTouchModeLocally(boolean inTouchMode){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  mAttachInfo.mInTouchMode=inTouchMode;
  mAttachInfo.mTreeObserver.dispatchOnTouchModeChanged(inTouchMode);
  return (inTouchMode) ? enterTouchMode() : leaveTouchMode();
}
Program: 181885
Project: 181885
Buggy source:
/** 
 * You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event){
  mTempRect.setEmpty();
  if (!canScroll()) {
    if (isFocused()) {
      View currentFocused=findFocus();
      if (currentFocused == this)       currentFocused=null;
      View nextFocused=FocusFinder.getInstance().findNextFocus(this,currentFocused,View.FOCUS_DOWN);
      return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
    }
    return false;
  }
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_UP:
      if (!event.isAltPressed()) {
        handled=arrowScroll(View.FOCUS_UP);
      }
 else {
        handled=fullScroll(View.FOCUS_UP);
      }
    break;
case KeyEvent.KEYCODE_DPAD_DOWN:
  if (!event.isAltPressed()) {
    handled=arrowScroll(View.FOCUS_DOWN);
  }
 else {
    handled=fullScroll(View.FOCUS_DOWN);
  }
break;
case KeyEvent.KEYCODE_SPACE:
pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
break;
}
}
return handled;
}

Fixed version (ground truth):
/** 
 * You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event){
  mTempRect.setEmpty();
  if (!canScroll()) {
    if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) {
      View currentFocused=findFocus();
      if (currentFocused == this)       currentFocused=null;
      View nextFocused=FocusFinder.getInstance().findNextFocus(this,currentFocused,View.FOCUS_DOWN);
      return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
    }
    return false;
  }
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_UP:
      if (!event.isAltPressed()) {
        handled=arrowScroll(View.FOCUS_UP);
      }
 else {
        handled=fullScroll(View.FOCUS_UP);
      }
    break;
case KeyEvent.KEYCODE_DPAD_DOWN:
  if (!event.isAltPressed()) {
    handled=arrowScroll(View.FOCUS_DOWN);
  }
 else {
    handled=fullScroll(View.FOCUS_DOWN);
  }
break;
case KeyEvent.KEYCODE_SPACE:
pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
break;
}
}
return handled;
}
Program: 181886
Project: 181886
Buggy source:
/** 
 * Something in the current window tells us we need to change the touch mode.  For example, we are not in touch mode, and the user touches the screen. If the touch mode has changed, tell the window manager, and handle it locally.
 * @param inTouchMode Whether we want to be in touch mode.
 * @return True if the touch mode changed and focus changed was changed as a result
 */
boolean ensureTouchMode(boolean inTouchMode){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  try {
    sWindowSession.setInTouchMode(inTouchMode);
  }
 catch (  RemoteException e) {
    throw new RuntimeException(e);
  }
  return ensureTouchModeLocally(inTouchMode,true);
}

Fixed version (ground truth):
/** 
 * Something in the current window tells us we need to change the touch mode.  For example, we are not in touch mode, and the user touches the screen. If the touch mode has changed, tell the window manager, and handle it locally.
 * @param inTouchMode Whether we want to be in touch mode.
 * @return True if the touch mode changed and focus changed was changed as a result
 */
boolean ensureTouchMode(boolean inTouchMode){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  try {
    sWindowSession.setInTouchMode(inTouchMode);
  }
 catch (  RemoteException e) {
    throw new RuntimeException(e);
  }
  return ensureTouchModeLocally(inTouchMode);
}
Program: 181887
Project: 181887
Buggy source:
/** 
 * Ensure that the touch mode for this window is set, and if it is changing, take the appropriate action.
 * @param inTouchMode Whether we want to be in touch mode.
 * @param dispatchFocus
 * @return True if the touch mode changed and focus changed was changed as a result
 */
private boolean ensureTouchModeLocally(boolean inTouchMode,boolean dispatchFocus){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  mAttachInfo.mInTouchMode=inTouchMode;
  mAttachInfo.mTreeObserver.dispatchOnTouchModeChanged(inTouchMode);
  return dispatchFocus && (inTouchMode) ? enterTouchMode() : leaveTouchMode();
}

Fixed version (ground truth):
/** 
 * Ensure that the touch mode for this window is set, and if it is changing, take the appropriate action.
 * @param inTouchMode Whether we want to be in touch mode.
 * @return True if the touch mode changed and focus changed was changed as a result
 */
private boolean ensureTouchModeLocally(boolean inTouchMode){
  if (DBG)   Log.d("String_Node_Str","String_Node_Str" + inTouchMode + "String_Node_Str"+ "String_Node_Str"+ mAttachInfo.mInTouchMode);
  if (mAttachInfo.mInTouchMode == inTouchMode)   return false;
  mAttachInfo.mInTouchMode=inTouchMode;
  mAttachInfo.mTreeObserver.dispatchOnTouchModeChanged(inTouchMode);
  return (inTouchMode) ? enterTouchMode() : leaveTouchMode();
}
Program: 181889
Project: 181889
Buggy source:
/** 
 * You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event){
  mTempRect.setEmpty();
  if (!canScroll()) {
    if (isFocused()) {
      View currentFocused=findFocus();
      if (currentFocused == this)       currentFocused=null;
      View nextFocused=FocusFinder.getInstance().findNextFocus(this,currentFocused,View.FOCUS_DOWN);
      return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
    }
    return false;
  }
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_UP:
      if (!event.isAltPressed()) {
        handled=arrowScroll(View.FOCUS_UP);
      }
 else {
        handled=fullScroll(View.FOCUS_UP);
      }
    break;
case KeyEvent.KEYCODE_DPAD_DOWN:
  if (!event.isAltPressed()) {
    handled=arrowScroll(View.FOCUS_DOWN);
  }
 else {
    handled=fullScroll(View.FOCUS_DOWN);
  }
break;
case KeyEvent.KEYCODE_SPACE:
pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
break;
}
}
return handled;
}

Fixed version (ground truth):
/** 
 * You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy.
 * @param event The key event to execute.
 * @return Return true if the event was handled, else false.
 */
public boolean executeKeyEvent(KeyEvent event){
  mTempRect.setEmpty();
  if (!canScroll()) {
    if (isFocused() && event.getKeyCode() != KeyEvent.KEYCODE_BACK) {
      View currentFocused=findFocus();
      if (currentFocused == this)       currentFocused=null;
      View nextFocused=FocusFinder.getInstance().findNextFocus(this,currentFocused,View.FOCUS_DOWN);
      return nextFocused != null && nextFocused != this && nextFocused.requestFocus(View.FOCUS_DOWN);
    }
    return false;
  }
  boolean handled=false;
  if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_UP:
      if (!event.isAltPressed()) {
        handled=arrowScroll(View.FOCUS_UP);
      }
 else {
        handled=fullScroll(View.FOCUS_UP);
      }
    break;
case KeyEvent.KEYCODE_DPAD_DOWN:
  if (!event.isAltPressed()) {
    handled=arrowScroll(View.FOCUS_DOWN);
  }
 else {
    handled=fullScroll(View.FOCUS_DOWN);
  }
break;
case KeyEvent.KEYCODE_SPACE:
pageScroll(event.isShiftPressed() ? View.FOCUS_UP : View.FOCUS_DOWN);
break;
}
}
return handled;
}
Program: 181890
Project: 181890
Buggy source:
private void sendResourcesChangedBroadcast(boolean mediaStatus,ArrayList<String> pkgList,int uidArr[]){
  int size=pkgList.size();
  if (size > 0) {
    Bundle extras=new Bundle();
    extras.putStringArray(Intent.EXTRA_CHANGED_PACKAGE_LIST,pkgList.toArray(new String[size]));
    if (uidArr != null) {
      extras.putIntArray(Intent.EXTRA_CHANGED_UID_LIST,uidArr);
    }
    String action=mediaStatus ? Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE : Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE;
    sendPackageBroadcast(action,null,extras);
  }
}

Fixed version (ground truth):
private void sendResourcesChangedBroadcast(boolean mediaStatus,ArrayList<String> pkgList,int uidArr[],IIntentReceiver finishedReceiver){
  int size=pkgList.size();
  if (size > 0) {
    Bundle extras=new Bundle();
    extras.putStringArray(Intent.EXTRA_CHANGED_PACKAGE_LIST,pkgList.toArray(new String[size]));
    if (uidArr != null) {
      extras.putIntArray(Intent.EXTRA_CHANGED_UID_LIST,uidArr);
    }
    String action=mediaStatus ? Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE : Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE;
    sendPackageBroadcast(action,null,extras,finishedReceiver);
  }
}
Program: 181894
Project: 181894
Buggy source:
private void unloadMediaPackages(HashMap<SdInstallArgs,String> processCids,int uidArr[]){
  if (DEBUG_SD_INSTALL)   Log.i(TAG,"String_Node_Str");
  ArrayList<String> pkgList=new ArrayList<String>();
  ArrayList<SdInstallArgs> failedList=new ArrayList<SdInstallArgs>();
  Set<SdInstallArgs> keys=processCids.keySet();
  for (  SdInstallArgs args : keys) {
    String cid=args.cid;
    String pkgName=args.getPackageName();
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str" + pkgName);
    PackageRemovedInfo outInfo=new PackageRemovedInfo();
synchronized (mInstallLock) {
      boolean res=deletePackageLI(pkgName,false,PackageManager.DONT_DELETE_DATA,outInfo);
      if (res) {
        pkgList.add(pkgName);
      }
 else {
        Slog.e(TAG,"String_Node_Str" + pkgName);
        failedList.add(args);
      }
    }
  }
  if (pkgList.size() > 0) {
    sendResourcesChangedBroadcast(false,pkgList,uidArr);
  }
  Runtime.getRuntime().gc();
  for (  SdInstallArgs args : keys) {
synchronized (mInstallLock) {
      args.doPostDeleteLI(false);
    }
  }
}

Fixed version (ground truth):
private void unloadMediaPackages(HashMap<SdInstallArgs,String> processCids,int uidArr[]){
  if (DEBUG_SD_INSTALL)   Log.i(TAG,"String_Node_Str");
  ArrayList<String> pkgList=new ArrayList<String>();
  ArrayList<SdInstallArgs> failedList=new ArrayList<SdInstallArgs>();
  Set<SdInstallArgs> keys=processCids.keySet();
  for (  SdInstallArgs args : keys) {
    String cid=args.cid;
    String pkgName=args.getPackageName();
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str" + pkgName);
    PackageRemovedInfo outInfo=new PackageRemovedInfo();
synchronized (mInstallLock) {
      boolean res=deletePackageLI(pkgName,false,PackageManager.DONT_DELETE_DATA,outInfo);
      if (res) {
        pkgList.add(pkgName);
      }
 else {
        Slog.e(TAG,"String_Node_Str" + pkgName);
        failedList.add(args);
      }
    }
  }
  if (pkgList.size() > 0) {
    sendResourcesChangedBroadcast(false,pkgList,uidArr,new IIntentReceiver.Stub(){
      public void performReceive(      Intent intent,      int resultCode,      String data,      Bundle extras,      boolean ordered,      boolean sticky) throws RemoteException {
        Runtime.getRuntime().gc();
      }
    }
);
  }
  for (  SdInstallArgs args : keys) {
synchronized (mInstallLock) {
      args.doPostDeleteLI(false);
    }
  }
}
Program: 181896
Project: 181896
Buggy source:
private static final void sendPackageBroadcast(String action,String pkg,Bundle extras){
  IActivityManager am=ActivityManagerNative.getDefault();
  if (am != null) {
    try {
      final Intent intent=new Intent(action,pkg != null ? Uri.fromParts("String_Node_Str",pkg,null) : null);
      if (extras != null) {
        intent.putExtras(extras);
      }
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
      am.broadcastIntent(null,intent,null,null,0,null,null,null,false,false);
    }
 catch (    RemoteException ex) {
    }
  }
}

Fixed version (ground truth):
private static final void sendPackageBroadcast(String action,String pkg,Bundle extras,IIntentReceiver finishedReceiver){
  IActivityManager am=ActivityManagerNative.getDefault();
  if (am != null) {
    try {
      final Intent intent=new Intent(action,pkg != null ? Uri.fromParts("String_Node_Str",pkg,null) : null);
      if (extras != null) {
        intent.putExtras(extras);
      }
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
      am.broadcastIntent(null,intent,null,finishedReceiver,0,null,null,null,finishedReceiver != null,false);
    }
 catch (    RemoteException ex) {
    }
  }
}
Program: 181897
Project: 181897
Buggy source:
private void sendPackageChangedBroadcast(String packageName,boolean killFlag,ArrayList<String> componentNames,int packageUid){
  if (false)   Log.v(TAG,"String_Node_Str" + packageName + "String_Node_Str"+ componentNames);
  Bundle extras=new Bundle(4);
  extras.putString(Intent.EXTRA_CHANGED_COMPONENT_NAME,componentNames.get(0));
  String nameList[]=new String[componentNames.size()];
  componentNames.toArray(nameList);
  extras.putStringArray(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST,nameList);
  extras.putBoolean(Intent.EXTRA_DONT_KILL_APP,killFlag);
  extras.putInt(Intent.EXTRA_UID,packageUid);
  sendPackageBroadcast(Intent.ACTION_PACKAGE_CHANGED,packageName,extras);
}

Fixed version (ground truth):
private void sendPackageChangedBroadcast(String packageName,boolean killFlag,ArrayList<String> componentNames,int packageUid){
  if (false)   Log.v(TAG,"String_Node_Str" + packageName + "String_Node_Str"+ componentNames);
  Bundle extras=new Bundle(4);
  extras.putString(Intent.EXTRA_CHANGED_COMPONENT_NAME,componentNames.get(0));
  String nameList[]=new String[componentNames.size()];
  componentNames.toArray(nameList);
  extras.putStringArray(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST,nameList);
  extras.putBoolean(Intent.EXTRA_DONT_KILL_APP,killFlag);
  extras.putInt(Intent.EXTRA_UID,packageUid);
  sendPackageBroadcast(Intent.ACTION_PACKAGE_CHANGED,packageName,extras,null);
}
Program: 181899
Project: 181899
Buggy source:
void sendBroadcast(boolean fullRemove,boolean replacing){
  Bundle extras=new Bundle(1);
  extras.putInt(Intent.EXTRA_UID,removedUid >= 0 ? removedUid : uid);
  extras.putBoolean(Intent.EXTRA_DATA_REMOVED,fullRemove);
  if (replacing) {
    extras.putBoolean(Intent.EXTRA_REPLACING,true);
  }
  if (removedPackage != null) {
    sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,removedPackage,extras);
  }
  if (removedUid >= 0) {
    sendPackageBroadcast(Intent.ACTION_UID_REMOVED,null,extras);
  }
}

Fixed version (ground truth):
void sendBroadcast(boolean fullRemove,boolean replacing){
  Bundle extras=new Bundle(1);
  extras.putInt(Intent.EXTRA_UID,removedUid >= 0 ? removedUid : uid);
  extras.putBoolean(Intent.EXTRA_DATA_REMOVED,fullRemove);
  if (replacing) {
    extras.putBoolean(Intent.EXTRA_REPLACING,true);
  }
  if (removedPackage != null) {
    sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,removedPackage,extras,null);
  }
  if (removedUid >= 0) {
    sendPackageBroadcast(Intent.ACTION_UID_REMOVED,null,extras,null);
  }
}
Program: 181901
Project: 181901
Buggy source:
private void sendResourcesChangedBroadcast(boolean mediaStatus,ArrayList<String> pkgList,int uidArr[]){
  int size=pkgList.size();
  if (size > 0) {
    Bundle extras=new Bundle();
    extras.putStringArray(Intent.EXTRA_CHANGED_PACKAGE_LIST,pkgList.toArray(new String[size]));
    if (uidArr != null) {
      extras.putIntArray(Intent.EXTRA_CHANGED_UID_LIST,uidArr);
    }
    String action=mediaStatus ? Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE : Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE;
    sendPackageBroadcast(action,null,extras);
  }
}

Fixed version (ground truth):
private void sendResourcesChangedBroadcast(boolean mediaStatus,ArrayList<String> pkgList,int uidArr[],IIntentReceiver finishedReceiver){
  int size=pkgList.size();
  if (size > 0) {
    Bundle extras=new Bundle();
    extras.putStringArray(Intent.EXTRA_CHANGED_PACKAGE_LIST,pkgList.toArray(new String[size]));
    if (uidArr != null) {
      extras.putIntArray(Intent.EXTRA_CHANGED_UID_LIST,uidArr);
    }
    String action=mediaStatus ? Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE : Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE;
    sendPackageBroadcast(action,null,extras,finishedReceiver);
  }
}
Program: 181905
Project: 181905
Buggy source:
private void unloadMediaPackages(HashMap<SdInstallArgs,String> processCids,int uidArr[]){
  if (DEBUG_SD_INSTALL)   Log.i(TAG,"String_Node_Str");
  ArrayList<String> pkgList=new ArrayList<String>();
  ArrayList<SdInstallArgs> failedList=new ArrayList<SdInstallArgs>();
  Set<SdInstallArgs> keys=processCids.keySet();
  for (  SdInstallArgs args : keys) {
    String cid=args.cid;
    String pkgName=args.getPackageName();
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str" + pkgName);
    PackageRemovedInfo outInfo=new PackageRemovedInfo();
synchronized (mInstallLock) {
      boolean res=deletePackageLI(pkgName,false,PackageManager.DONT_DELETE_DATA,outInfo);
      if (res) {
        pkgList.add(pkgName);
      }
 else {
        Slog.e(TAG,"String_Node_Str" + pkgName);
        failedList.add(args);
      }
    }
  }
  if (pkgList.size() > 0) {
    sendResourcesChangedBroadcast(false,pkgList,uidArr);
  }
  Runtime.getRuntime().gc();
  for (  SdInstallArgs args : keys) {
synchronized (mInstallLock) {
      args.doPostDeleteLI(false);
    }
  }
}

Fixed version (ground truth):
private void unloadMediaPackages(HashMap<SdInstallArgs,String> processCids,int uidArr[]){
  if (DEBUG_SD_INSTALL)   Log.i(TAG,"String_Node_Str");
  ArrayList<String> pkgList=new ArrayList<String>();
  ArrayList<SdInstallArgs> failedList=new ArrayList<SdInstallArgs>();
  Set<SdInstallArgs> keys=processCids.keySet();
  for (  SdInstallArgs args : keys) {
    String cid=args.cid;
    String pkgName=args.getPackageName();
    if (DEBUG_SD_INSTALL)     Log.i(TAG,"String_Node_Str" + pkgName);
    PackageRemovedInfo outInfo=new PackageRemovedInfo();
synchronized (mInstallLock) {
      boolean res=deletePackageLI(pkgName,false,PackageManager.DONT_DELETE_DATA,outInfo);
      if (res) {
        pkgList.add(pkgName);
      }
 else {
        Slog.e(TAG,"String_Node_Str" + pkgName);
        failedList.add(args);
      }
    }
  }
  if (pkgList.size() > 0) {
    sendResourcesChangedBroadcast(false,pkgList,uidArr,new IIntentReceiver.Stub(){
      public void performReceive(      Intent intent,      int resultCode,      String data,      Bundle extras,      boolean ordered,      boolean sticky) throws RemoteException {
        Runtime.getRuntime().gc();
      }
    }
);
  }
  for (  SdInstallArgs args : keys) {
synchronized (mInstallLock) {
      args.doPostDeleteLI(false);
    }
  }
}
Program: 181907
Project: 181907
Buggy source:
private static final void sendPackageBroadcast(String action,String pkg,Bundle extras){
  IActivityManager am=ActivityManagerNative.getDefault();
  if (am != null) {
    try {
      final Intent intent=new Intent(action,pkg != null ? Uri.fromParts("String_Node_Str",pkg,null) : null);
      if (extras != null) {
        intent.putExtras(extras);
      }
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
      am.broadcastIntent(null,intent,null,null,0,null,null,null,false,false);
    }
 catch (    RemoteException ex) {
    }
  }
}

Fixed version (ground truth):
private static final void sendPackageBroadcast(String action,String pkg,Bundle extras,IIntentReceiver finishedReceiver){
  IActivityManager am=ActivityManagerNative.getDefault();
  if (am != null) {
    try {
      final Intent intent=new Intent(action,pkg != null ? Uri.fromParts("String_Node_Str",pkg,null) : null);
      if (extras != null) {
        intent.putExtras(extras);
      }
      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
      am.broadcastIntent(null,intent,null,finishedReceiver,0,null,null,null,finishedReceiver != null,false);
    }
 catch (    RemoteException ex) {
    }
  }
}
Program: 181908
Project: 181908
Buggy source:
private void sendPackageChangedBroadcast(String packageName,boolean killFlag,ArrayList<String> componentNames,int packageUid){
  if (false)   Log.v(TAG,"String_Node_Str" + packageName + "String_Node_Str"+ componentNames);
  Bundle extras=new Bundle(4);
  extras.putString(Intent.EXTRA_CHANGED_COMPONENT_NAME,componentNames.get(0));
  String nameList[]=new String[componentNames.size()];
  componentNames.toArray(nameList);
  extras.putStringArray(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST,nameList);
  extras.putBoolean(Intent.EXTRA_DONT_KILL_APP,killFlag);
  extras.putInt(Intent.EXTRA_UID,packageUid);
  sendPackageBroadcast(Intent.ACTION_PACKAGE_CHANGED,packageName,extras);
}

Fixed version (ground truth):
private void sendPackageChangedBroadcast(String packageName,boolean killFlag,ArrayList<String> componentNames,int packageUid){
  if (false)   Log.v(TAG,"String_Node_Str" + packageName + "String_Node_Str"+ componentNames);
  Bundle extras=new Bundle(4);
  extras.putString(Intent.EXTRA_CHANGED_COMPONENT_NAME,componentNames.get(0));
  String nameList[]=new String[componentNames.size()];
  componentNames.toArray(nameList);
  extras.putStringArray(Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST,nameList);
  extras.putBoolean(Intent.EXTRA_DONT_KILL_APP,killFlag);
  extras.putInt(Intent.EXTRA_UID,packageUid);
  sendPackageBroadcast(Intent.ACTION_PACKAGE_CHANGED,packageName,extras,null);
}
Program: 181910
Project: 181910
Buggy source:
void sendBroadcast(boolean fullRemove,boolean replacing){
  Bundle extras=new Bundle(1);
  extras.putInt(Intent.EXTRA_UID,removedUid >= 0 ? removedUid : uid);
  extras.putBoolean(Intent.EXTRA_DATA_REMOVED,fullRemove);
  if (replacing) {
    extras.putBoolean(Intent.EXTRA_REPLACING,true);
  }
  if (removedPackage != null) {
    sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,removedPackage,extras);
  }
  if (removedUid >= 0) {
    sendPackageBroadcast(Intent.ACTION_UID_REMOVED,null,extras);
  }
}

Fixed version (ground truth):
void sendBroadcast(boolean fullRemove,boolean replacing){
  Bundle extras=new Bundle(1);
  extras.putInt(Intent.EXTRA_UID,removedUid >= 0 ? removedUid : uid);
  extras.putBoolean(Intent.EXTRA_DATA_REMOVED,fullRemove);
  if (replacing) {
    extras.putBoolean(Intent.EXTRA_REPLACING,true);
  }
  if (removedPackage != null) {
    sendPackageBroadcast(Intent.ACTION_PACKAGE_REMOVED,removedPackage,extras,null);
  }
  if (removedUid >= 0) {
    sendPackageBroadcast(Intent.ACTION_UID_REMOVED,null,extras,null);
  }
}
Program: 181912
Project: 181912
Buggy source:
private void sendResourcesChangedBroadcast(boolean mediaStatus,ArrayList<String> pkgList,int uidArr[]){
  int size=pkgList.size();
  if (size > 0) {
    Bundle extras=new Bundle();
    extras.putStringArray(Intent.EXTRA_CHANGED_PACKAGE_LIST,pkgList.toArray(new String[size]));
    if (uidArr != null) {
      extras.putIntArray(Intent.EXTRA_CHANGED_UID_LIST,uidArr);
    }
    String action=mediaStatus ? Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE : Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE;
    sendPackageBroadcast(action,null,extras);
  }
}

Fixed version (ground truth):
private void sendResourcesChangedBroadcast(boolean mediaStatus,ArrayList<String> pkgList,int uidArr[],IIntentReceiver finishedReceiver){
  int size=pkgList.size();
  if (size > 0) {
    Bundle extras=new Bundle();
    extras.putStringArray(Intent.EXTRA_CHANGED_PACKAGE_LIST,pkgList.toArray(new String[size]));
    if (uidArr != null) {
      extras.putIntArray(Intent.EXTRA_CHANGED_UID_LIST,uidArr);
    }
    String action=mediaStatus ? Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE : Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE;
    sendPackageBroadcast(action,null,extras,finishedReceiver);
  }
}