nus-yam/ex-repair huggingface dataset:
Program: 22366
Project: 22366
Buggy source:
/** 
 * Called when the window containing has change its visibility (between   {@link #GONE},   {@link #INVISIBLE}, and   {@link #VISIBLE}).  Note that this tells you whether or not your window is being made visible to the window manager; this does <em>not</em> tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
 * @param visibility The new visibility of the window.
 */
protected void onWindowVisibilityChanged(int visibility){
}

Fixed version (ground truth):
/** 
 * Called when the window containing has change its visibility (between   {@link #GONE},   {@link #INVISIBLE}, and   {@link #VISIBLE}).  Note that this tells you whether or not your window is being made visible to the window manager; this does <em>not</em> tell you whether or not your window is obscured by other windows on the screen, even if it is itself visible.
 * @param visibility The new visibility of the window.
 */
protected void onWindowVisibilityChanged(int visibility){
  if (visibility == VISIBLE) {
    initialAwakenScrollBars();
  }
}
Program: 22367
Project: 22367
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    mPlayer.setOnCompletionListener(this);
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 22368
Project: 22368
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    mPlayer.setOnCompletionListener(this);
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 22369
Project: 22369
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    mPlayer.setOnCompletionListener(this);
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 22370
Project: 22370
Buggy source:
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    mPlayer.setOnCompletionListener(this);
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}

Fixed version (ground truth):
private void startSound(Command cmd){
  try {
    if (mDebug)     Log.d(mTag,"String_Node_Str");
    PlayerCreationThread t=new PlayerCreationThread(cmd);
synchronized (t) {
      t.start();
      t.wait();
    }
    long delay=SystemClock.uptimeMillis() - cmd.requestTime;
    if (delay > 1000) {
      Log.w(mTag,"String_Node_Str" + delay + "String_Node_Str");
    }
  }
 catch (  Exception e) {
    Log.w(mTag,"String_Node_Str" + cmd.uri,e);
  }
}
Program: 22376
Project: 22376
Buggy source:
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.muteCount() != 0) {
    streamState.setLastAudibleIndex(index);
    sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
  }
 else {
    if (streamState.setIndex(index,lastAudible) || force) {
      if (mRingerMode == AudioManager.RINGER_MODE_NORMAL || !isStreamAffectedByRingerMode(streamType) || index == 0) {
        sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
      }
 else {
        sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.muteCount() != 0) {
    if (index != 0) {
      streamState.setLastAudibleIndex(index);
      sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
    }
  }
 else {
    if (streamState.setIndex(index,lastAudible) || force) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
    }
  }
}
Program: 22377
Project: 22377
Buggy source:
/** 
 * Checks if the adjustment should change ringer mode instead of just adjusting volume. If so, this will set the proper ringer mode and volume indices on the stream states.
 */
private boolean checkForRingerModeChange(int oldIndex,int direction){
  boolean adjustVolumeIndex=true;
  int newRingerMode=mRingerMode;
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    if (direction == AudioManager.ADJUST_LOWER && (oldIndex + 5) / 10 == 1) {
      newRingerMode=System.getInt(mContentResolver,System.VIBRATE_IN_SILENT,1) == 1 ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT;
    }
  }
 else {
    if (direction == AudioManager.ADJUST_RAISE) {
      newRingerMode=AudioManager.RINGER_MODE_NORMAL;
    }
  }
  if (newRingerMode != mRingerMode) {
    setRingerMode(newRingerMode);
    adjustVolumeIndex=false;
  }
  return adjustVolumeIndex;
}

Fixed version (ground truth):
/** 
 * Checks if the adjustment should change ringer mode instead of just adjusting volume. If so, this will set the proper ringer mode and volume indices on the stream states.
 */
private boolean checkForRingerModeChange(int oldIndex,int direction){
  boolean adjustVolumeIndex=true;
  int newRingerMode=mRingerMode;
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    if (direction == AudioManager.ADJUST_LOWER && (oldIndex + 5) / 10 == 1) {
      newRingerMode=System.getInt(mContentResolver,System.VIBRATE_IN_SILENT,1) == 1 ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT;
    }
  }
 else {
    if (direction == AudioManager.ADJUST_RAISE) {
      newRingerMode=AudioManager.RINGER_MODE_NORMAL;
    }
 else {
      adjustVolumeIndex=false;
    }
  }
  if (newRingerMode != mRingerMode) {
    setRingerMode(newRingerMode);
    adjustVolumeIndex=false;
  }
  return adjustVolumeIndex;
}
Program: 22378
Project: 22378
Buggy source:
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.muteCount() != 0) {
    streamState.setLastAudibleIndex(index);
    sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
  }
 else {
    if (streamState.setIndex(index,lastAudible) || force) {
      if (mRingerMode == AudioManager.RINGER_MODE_NORMAL || !isStreamAffectedByRingerMode(streamType) || index == 0) {
        sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
      }
 else {
        sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.muteCount() != 0) {
    if (index != 0) {
      streamState.setLastAudibleIndex(index);
      sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
    }
  }
 else {
    if (streamState.setIndex(index,lastAudible) || force) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
    }
  }
}
Program: 22379
Project: 22379
Buggy source:
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.muteCount() != 0) {
    streamState.setLastAudibleIndex(index);
    sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
  }
 else {
    if (streamState.setIndex(index,lastAudible) || force) {
      if (mRingerMode == AudioManager.RINGER_MODE_NORMAL || !isStreamAffectedByRingerMode(streamType) || index == 0) {
        sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
      }
 else {
        sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the stream state's index, and posts a message to set system volume. This will not call out to the UI. Assumes a valid stream type.
 * @param streamType Type of the stream
 * @param index Desired volume index of the stream
 * @param force If true, set the volume even if the desired volume is sameas the current volume.
 * @param lastAudible If true, stores new index as last audible one
 */
private void setStreamVolumeInt(int streamType,int index,boolean force,boolean lastAudible){
  VolumeStreamState streamState=mStreamStates[streamType];
  if (streamState.muteCount() != 0) {
    if (index != 0) {
      streamState.setLastAudibleIndex(index);
      sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
    }
  }
 else {
    if (streamState.setIndex(index,lastAudible) || force) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,streamType,SENDMSG_NOOP,0,0,streamState,0);
    }
  }
}
Program: 22380
Project: 22380
Buggy source:
/** 
 * Checks if the adjustment should change ringer mode instead of just adjusting volume. If so, this will set the proper ringer mode and volume indices on the stream states.
 */
private boolean checkForRingerModeChange(int oldIndex,int direction){
  boolean adjustVolumeIndex=true;
  int newRingerMode=mRingerMode;
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    if (direction == AudioManager.ADJUST_LOWER && (oldIndex + 5) / 10 == 1) {
      newRingerMode=System.getInt(mContentResolver,System.VIBRATE_IN_SILENT,1) == 1 ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT;
    }
  }
 else {
    if (direction == AudioManager.ADJUST_RAISE) {
      newRingerMode=AudioManager.RINGER_MODE_NORMAL;
    }
  }
  if (newRingerMode != mRingerMode) {
    setRingerMode(newRingerMode);
    adjustVolumeIndex=false;
  }
  return adjustVolumeIndex;
}

Fixed version (ground truth):
/** 
 * Checks if the adjustment should change ringer mode instead of just adjusting volume. If so, this will set the proper ringer mode and volume indices on the stream states.
 */
private boolean checkForRingerModeChange(int oldIndex,int direction){
  boolean adjustVolumeIndex=true;
  int newRingerMode=mRingerMode;
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    if (direction == AudioManager.ADJUST_LOWER && (oldIndex + 5) / 10 == 1) {
      newRingerMode=System.getInt(mContentResolver,System.VIBRATE_IN_SILENT,1) == 1 ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT;
    }
  }
 else {
    if (direction == AudioManager.ADJUST_RAISE) {
      newRingerMode=AudioManager.RINGER_MODE_NORMAL;
    }
 else {
      adjustVolumeIndex=false;
    }
  }
  if (newRingerMode != mRingerMode) {
    setRingerMode(newRingerMode);
    adjustVolumeIndex=false;
  }
  return adjustVolumeIndex;
}
Program: 22381
Project: 22381
Buggy source:
/** 
 * Checks if the adjustment should change ringer mode instead of just adjusting volume. If so, this will set the proper ringer mode and volume indices on the stream states.
 */
private boolean checkForRingerModeChange(int oldIndex,int direction){
  boolean adjustVolumeIndex=true;
  int newRingerMode=mRingerMode;
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    if (direction == AudioManager.ADJUST_LOWER && (oldIndex + 5) / 10 == 1) {
      newRingerMode=System.getInt(mContentResolver,System.VIBRATE_IN_SILENT,1) == 1 ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT;
    }
  }
 else {
    if (direction == AudioManager.ADJUST_RAISE) {
      newRingerMode=AudioManager.RINGER_MODE_NORMAL;
    }
  }
  if (newRingerMode != mRingerMode) {
    setRingerMode(newRingerMode);
    adjustVolumeIndex=false;
  }
  return adjustVolumeIndex;
}

Fixed version (ground truth):
/** 
 * Checks if the adjustment should change ringer mode instead of just adjusting volume. If so, this will set the proper ringer mode and volume indices on the stream states.
 */
private boolean checkForRingerModeChange(int oldIndex,int direction){
  boolean adjustVolumeIndex=true;
  int newRingerMode=mRingerMode;
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    if (direction == AudioManager.ADJUST_LOWER && (oldIndex + 5) / 10 == 1) {
      newRingerMode=System.getInt(mContentResolver,System.VIBRATE_IN_SILENT,1) == 1 ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT;
    }
  }
 else {
    if (direction == AudioManager.ADJUST_RAISE) {
      newRingerMode=AudioManager.RINGER_MODE_NORMAL;
    }
 else {
      adjustVolumeIndex=false;
    }
  }
  if (newRingerMode != mRingerMode) {
    setRingerMode(newRingerMode);
    adjustVolumeIndex=false;
  }
  return adjustVolumeIndex;
}
Program: 22383
Project: 22383
Buggy source:
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,int flags){
synchronized (this) {
    enforceCallingPermission(android.Manifest.permission.GET_TASKS,"String_Node_Str");
    final int N=mRecentTasks.size();
    ArrayList<ActivityManager.RecentTaskInfo> res=new ArrayList<ActivityManager.RecentTaskInfo>(maxNum < N ? maxNum : N);
    for (int i=0; i < N && maxNum > 0; i++) {
      TaskRecord tr=mRecentTasks.get(i);
      if (((flags & ActivityManager.RECENT_WITH_EXCLUDED) != 0) || (tr.intent == null) || ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
        ActivityManager.RecentTaskInfo rti=new ActivityManager.RecentTaskInfo();
        rti.id=tr.numActivities > 0 ? tr.taskId : -1;
        rti.baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
        rti.origActivity=tr.origActivity;
        res.add(rti);
        maxNum--;
      }
    }
    return res;
  }
}

Fixed version (ground truth):
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,int flags){
synchronized (this) {
    enforceCallingPermission(android.Manifest.permission.GET_TASKS,"String_Node_Str");
    IPackageManager pm=ActivityThread.getPackageManager();
    final int N=mRecentTasks.size();
    ArrayList<ActivityManager.RecentTaskInfo> res=new ArrayList<ActivityManager.RecentTaskInfo>(maxNum < N ? maxNum : N);
    for (int i=0; i < N && maxNum > 0; i++) {
      TaskRecord tr=mRecentTasks.get(i);
      if (((flags & ActivityManager.RECENT_WITH_EXCLUDED) != 0) || (tr.intent == null) || ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
        ActivityManager.RecentTaskInfo rti=new ActivityManager.RecentTaskInfo();
        rti.id=tr.numActivities > 0 ? tr.taskId : -1;
        rti.baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
        rti.origActivity=tr.origActivity;
        if ((flags & ActivityManager.RECENT_IGNORE_UNAVAILABLE) != 0) {
          try {
            if (rti.origActivity != null) {
              if (pm.getActivityInfo(rti.origActivity,0) == null) {
                continue;
              }
            }
 else             if (rti.baseIntent != null) {
              if (pm.queryIntentActivities(rti.baseIntent,null,0) == null) {
                continue;
              }
            }
          }
 catch (          RemoteException e) {
          }
        }
        res.add(rti);
        maxNum--;
      }
    }
    return res;
  }
}
Program: 22384
Project: 22384
Buggy source:
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,int flags){
synchronized (this) {
    enforceCallingPermission(android.Manifest.permission.GET_TASKS,"String_Node_Str");
    final int N=mRecentTasks.size();
    ArrayList<ActivityManager.RecentTaskInfo> res=new ArrayList<ActivityManager.RecentTaskInfo>(maxNum < N ? maxNum : N);
    for (int i=0; i < N && maxNum > 0; i++) {
      TaskRecord tr=mRecentTasks.get(i);
      if (((flags & ActivityManager.RECENT_WITH_EXCLUDED) != 0) || (tr.intent == null) || ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
        ActivityManager.RecentTaskInfo rti=new ActivityManager.RecentTaskInfo();
        rti.id=tr.numActivities > 0 ? tr.taskId : -1;
        rti.baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
        rti.origActivity=tr.origActivity;
        res.add(rti);
        maxNum--;
      }
    }
    return res;
  }
}

Fixed version (ground truth):
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,int flags){
synchronized (this) {
    enforceCallingPermission(android.Manifest.permission.GET_TASKS,"String_Node_Str");
    IPackageManager pm=ActivityThread.getPackageManager();
    final int N=mRecentTasks.size();
    ArrayList<ActivityManager.RecentTaskInfo> res=new ArrayList<ActivityManager.RecentTaskInfo>(maxNum < N ? maxNum : N);
    for (int i=0; i < N && maxNum > 0; i++) {
      TaskRecord tr=mRecentTasks.get(i);
      if (((flags & ActivityManager.RECENT_WITH_EXCLUDED) != 0) || (tr.intent == null) || ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
        ActivityManager.RecentTaskInfo rti=new ActivityManager.RecentTaskInfo();
        rti.id=tr.numActivities > 0 ? tr.taskId : -1;
        rti.baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
        rti.origActivity=tr.origActivity;
        if ((flags & ActivityManager.RECENT_IGNORE_UNAVAILABLE) != 0) {
          try {
            if (rti.origActivity != null) {
              if (pm.getActivityInfo(rti.origActivity,0) == null) {
                continue;
              }
            }
 else             if (rti.baseIntent != null) {
              if (pm.queryIntentActivities(rti.baseIntent,null,0) == null) {
                continue;
              }
            }
          }
 catch (          RemoteException e) {
          }
        }
        res.add(rti);
        maxNum--;
      }
    }
    return res;
  }
}
Program: 22385
Project: 22385
Buggy source:
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,int flags){
synchronized (this) {
    enforceCallingPermission(android.Manifest.permission.GET_TASKS,"String_Node_Str");
    final int N=mRecentTasks.size();
    ArrayList<ActivityManager.RecentTaskInfo> res=new ArrayList<ActivityManager.RecentTaskInfo>(maxNum < N ? maxNum : N);
    for (int i=0; i < N && maxNum > 0; i++) {
      TaskRecord tr=mRecentTasks.get(i);
      if (((flags & ActivityManager.RECENT_WITH_EXCLUDED) != 0) || (tr.intent == null) || ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
        ActivityManager.RecentTaskInfo rti=new ActivityManager.RecentTaskInfo();
        rti.id=tr.numActivities > 0 ? tr.taskId : -1;
        rti.baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
        rti.origActivity=tr.origActivity;
        res.add(rti);
        maxNum--;
      }
    }
    return res;
  }
}

Fixed version (ground truth):
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,int flags){
synchronized (this) {
    enforceCallingPermission(android.Manifest.permission.GET_TASKS,"String_Node_Str");
    IPackageManager pm=ActivityThread.getPackageManager();
    final int N=mRecentTasks.size();
    ArrayList<ActivityManager.RecentTaskInfo> res=new ArrayList<ActivityManager.RecentTaskInfo>(maxNum < N ? maxNum : N);
    for (int i=0; i < N && maxNum > 0; i++) {
      TaskRecord tr=mRecentTasks.get(i);
      if (((flags & ActivityManager.RECENT_WITH_EXCLUDED) != 0) || (tr.intent == null) || ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
        ActivityManager.RecentTaskInfo rti=new ActivityManager.RecentTaskInfo();
        rti.id=tr.numActivities > 0 ? tr.taskId : -1;
        rti.baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
        rti.origActivity=tr.origActivity;
        if ((flags & ActivityManager.RECENT_IGNORE_UNAVAILABLE) != 0) {
          try {
            if (rti.origActivity != null) {
              if (pm.getActivityInfo(rti.origActivity,0) == null) {
                continue;
              }
            }
 else             if (rti.baseIntent != null) {
              if (pm.queryIntentActivities(rti.baseIntent,null,0) == null) {
                continue;
              }
            }
          }
 catch (          RemoteException e) {
          }
        }
        res.add(rti);
        maxNum--;
      }
    }
    return res;
  }
}
Program: 22387
Project: 22387
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: 22388
Project: 22388
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: 22389
Project: 22389
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: 22391
Project: 22391
Buggy source:
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,int flags){
synchronized (this) {
    enforceCallingPermission(android.Manifest.permission.GET_TASKS,"String_Node_Str");
    final int N=mRecentTasks.size();
    ArrayList<ActivityManager.RecentTaskInfo> res=new ArrayList<ActivityManager.RecentTaskInfo>(maxNum < N ? maxNum : N);
    for (int i=0; i < N && maxNum > 0; i++) {
      TaskRecord tr=mRecentTasks.get(i);
      if (((flags & ActivityManager.RECENT_WITH_EXCLUDED) != 0) || (tr.intent == null) || ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
        ActivityManager.RecentTaskInfo rti=new ActivityManager.RecentTaskInfo();
        rti.id=tr.numActivities > 0 ? tr.taskId : -1;
        rti.baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
        rti.origActivity=tr.origActivity;
        res.add(rti);
        maxNum--;
      }
    }
    return res;
  }
}

Fixed version (ground truth):
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum,int flags){
synchronized (this) {
    enforceCallingPermission(android.Manifest.permission.GET_TASKS,"String_Node_Str");
    IPackageManager pm=ActivityThread.getPackageManager();
    final int N=mRecentTasks.size();
    ArrayList<ActivityManager.RecentTaskInfo> res=new ArrayList<ActivityManager.RecentTaskInfo>(maxNum < N ? maxNum : N);
    for (int i=0; i < N && maxNum > 0; i++) {
      TaskRecord tr=mRecentTasks.get(i);
      if (((flags & ActivityManager.RECENT_WITH_EXCLUDED) != 0) || (tr.intent == null) || ((tr.intent.getFlags() & Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS) == 0)) {
        ActivityManager.RecentTaskInfo rti=new ActivityManager.RecentTaskInfo();
        rti.id=tr.numActivities > 0 ? tr.taskId : -1;
        rti.baseIntent=new Intent(tr.intent != null ? tr.intent : tr.affinityIntent);
        rti.origActivity=tr.origActivity;
        if ((flags & ActivityManager.RECENT_IGNORE_UNAVAILABLE) != 0) {
          try {
            if (rti.origActivity != null) {
              if (pm.getActivityInfo(rti.origActivity,0) == null) {
                continue;
              }
            }
 else             if (rti.baseIntent != null) {
              if (pm.queryIntentActivities(rti.baseIntent,null,0) == null) {
                continue;
              }
            }
          }
 catch (          RemoteException e) {
          }
        }
        res.add(rti);
        maxNum--;
      }
    }
    return res;
  }
}
Program: 22392
Project: 22392
Buggy source:
/** 
 * Checks if the adjustment should change ringer mode instead of just adjusting volume. If so, this will set the proper ringer mode and volume indices on the stream states.
 */
private boolean checkForRingerModeChange(int oldIndex,int direction){
  boolean adjustVolumeIndex=true;
  int newRingerMode=mRingerMode;
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    if (direction == AudioManager.ADJUST_LOWER && (oldIndex + 5) / 10 == 1) {
      newRingerMode=System.getInt(mContentResolver,System.VIBRATE_IN_SILENT,1) == 1 ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT;
    }
  }
 else {
    if (direction == AudioManager.ADJUST_RAISE) {
      newRingerMode=AudioManager.RINGER_MODE_NORMAL;
    }
  }
  if (newRingerMode != mRingerMode) {
    setRingerMode(newRingerMode);
    adjustVolumeIndex=false;
  }
  return adjustVolumeIndex;
}

Fixed version (ground truth):
/** 
 * Checks if the adjustment should change ringer mode instead of just adjusting volume. If so, this will set the proper ringer mode and volume indices on the stream states.
 */
private boolean checkForRingerModeChange(int oldIndex,int direction){
  boolean adjustVolumeIndex=true;
  int newRingerMode=mRingerMode;
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    if (direction == AudioManager.ADJUST_LOWER && (oldIndex + 5) / 10 == 1) {
      newRingerMode=System.getInt(mContentResolver,System.VIBRATE_IN_SILENT,1) == 1 ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT;
    }
  }
 else {
    if (direction == AudioManager.ADJUST_RAISE) {
      newRingerMode=AudioManager.RINGER_MODE_NORMAL;
    }
 else {
      adjustVolumeIndex=false;
    }
  }
  if (newRingerMode != mRingerMode) {
    setRingerMode(newRingerMode);
    adjustVolumeIndex=false;
  }
  return adjustVolumeIndex;
}
Program: 22394
Project: 22394
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: 22395
Project: 22395
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: 22396
Project: 22396
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: 22398
Project: 22398
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: 22399
Project: 22399
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: 22400
Project: 22400
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: 22401
Project: 22401
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: 22403
Project: 22403
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);
  }
}