nus-yam/ex-repair huggingface dataset:
Program: 22405
Project: 22405
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: 22406
Project: 22406
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: 22407
Project: 22407
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: 22408
Project: 22408
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: 22411
Project: 22411
Buggy source:
public void performEnableScreen(){
synchronized (mWindowMap) {
    if (mDisplayEnabled) {
      return;
    }
    if (!mSystemBooted) {
      return;
    }
    final int N=mWindows.size();
    for (int i=0; i < N; i++) {
      WindowState w=(WindowState)mWindows.get(i);
      if (w.isVisibleLw() && !w.mObscured && !w.isDrawnLw()) {
        return;
      }
    }
    mDisplayEnabled=true;
    if (false) {
      Slog.i(TAG,"String_Node_Str");
      StringWriter sw=new StringWriter();
      PrintWriter pw=new PrintWriter(sw);
      this.dump(null,pw,null);
      Slog.i(TAG,sw.toString());
    }
    try {
      IBinder surfaceFlinger=ServiceManager.getService("String_Node_Str");
      if (surfaceFlinger != null) {
        Parcel data=Parcel.obtain();
        data.writeInterfaceToken("String_Node_Str");
        surfaceFlinger.transact(IBinder.FIRST_CALL_TRANSACTION,data,null,0);
        data.recycle();
      }
    }
 catch (    RemoteException ex) {
      Slog.e(TAG,"String_Node_Str");
    }
  }
  mPolicy.enableScreenAfterBoot();
  setRotationUnchecked(WindowManagerPolicy.USE_LAST_ROTATION,false,mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE);
}

Fixed version (ground truth):
public void performEnableScreen(){
synchronized (mWindowMap) {
    if (mDisplayEnabled) {
      return;
    }
    if (!mSystemBooted) {
      return;
    }
    final int N=mWindows.size();
    for (int i=0; i < N; i++) {
      WindowState w=(WindowState)mWindows.get(i);
      if (w.isVisibleLw() && !w.mObscured && (w.mOrientationChanging || !w.isDrawnLw())) {
        return;
      }
    }
    mDisplayEnabled=true;
    if (false) {
      Slog.i(TAG,"String_Node_Str");
      StringWriter sw=new StringWriter();
      PrintWriter pw=new PrintWriter(sw);
      this.dump(null,pw,null);
      Slog.i(TAG,sw.toString());
    }
    try {
      IBinder surfaceFlinger=ServiceManager.getService("String_Node_Str");
      if (surfaceFlinger != null) {
        Parcel data=Parcel.obtain();
        data.writeInterfaceToken("String_Node_Str");
        surfaceFlinger.transact(IBinder.FIRST_CALL_TRANSACTION,data,null,0);
        data.recycle();
      }
    }
 catch (    RemoteException ex) {
      Slog.e(TAG,"String_Node_Str");
    }
  }
  mPolicy.enableScreenAfterBoot();
  setRotationUnchecked(WindowManagerPolicy.USE_LAST_ROTATION,false,mLastRotationFlags | Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE);
}
Program: 22412
Project: 22412
Buggy source:
/** 
 * Returns true if the window has a surface that it has drawn a complete UI in to.
 */
public boolean isDrawnLw(){
  final AppWindowToken atoken=mAppToken;
  return mSurface != null && !mDestroying && !mDrawPending && !mCommitDrawPending;
}

Fixed version (ground truth):
/** 
 * Returns true if the window has a surface that it has drawn a complete UI in to.  Note that this returns true if the orientation is changing even if the window hasn't redrawn because we don't want to stop things from executing during that time.
 */
public boolean isDrawnLw(){
  final AppWindowToken atoken=mAppToken;
  return mSurface != null && !mDestroying && (mOrientationChanging || (!mDrawPending && !mCommitDrawPending));
}
Program: 22413
Project: 22413
Buggy source:
/** 
 * Like   {@link #isVisibleLw}, but also counts a window that is currently "hidden" behind the keyguard as visible.  This allows us to apply things like window flags that impact the keyguard. XXX I am starting to think we need to have ANOTHER visibility flag for this "hidden behind keyguard" state rather than overloading mPolicyVisibility.  Ungh.
 */
public boolean isVisibleOrBehindKeyguardLw(){
  final AppWindowToken atoken=mAppToken;
  return mSurface != null && !mAttachedHidden && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested) && !mDrawPending && !mCommitDrawPending && !mExiting && !mDestroying;
}

Fixed version (ground truth):
/** 
 * Like   {@link #isVisibleLw}, but also counts a window that is currently "hidden" behind the keyguard as visible.  This allows us to apply things like window flags that impact the keyguard. XXX I am starting to think we need to have ANOTHER visibility flag for this "hidden behind keyguard" state rather than overloading mPolicyVisibility.  Ungh.
 */
public boolean isVisibleOrBehindKeyguardLw(){
  final AppWindowToken atoken=mAppToken;
  return mSurface != null && !mAttachedHidden && (atoken == null ? mPolicyVisibility : !atoken.hiddenRequested) && (mOrientationChanging || (!mDrawPending && !mCommitDrawPending)) && !mExiting && !mDestroying;
}
Program: 22414
Project: 22414
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: 22416
Project: 22416
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: 22417
Project: 22417
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: 22419
Project: 22419
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: 22420
Project: 22420
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: 22421
Project: 22421
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: 22422
Project: 22422
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: 22423
Project: 22423
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: 22424
Project: 22424
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: 22425
Project: 22425
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: 22427
Project: 22427
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: 22428
Project: 22428
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: 22430
Project: 22430
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: 22431
Project: 22431
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: 22432
Project: 22432
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: 22434
Project: 22434
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: 22435
Project: 22435
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: 22436
Project: 22436
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: 22437
Project: 22437
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: 22438
Project: 22438
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: 22440
Project: 22440
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: 22441
Project: 22441
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: 22445
Project: 22445
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: 22447
Project: 22447
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: 22448
Project: 22448
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: 22450
Project: 22450
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: 22452
Project: 22452
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);
  }
}