nus-yam/ex-repair huggingface dataset:
Program: 41777
Project: 41777
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: 41778
Project: 41778
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: 41779
Project: 41779
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: 41780
Project: 41780
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: 41781
Project: 41781
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: 41782
Project: 41782
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: 41784
Project: 41784
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: 41787
Project: 41787
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: 41788
Project: 41788
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: 41789
Project: 41789
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: 41791
Project: 41791
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: 41792
Project: 41792
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: 41793
Project: 41793
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: 41794
Project: 41794
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: 41795
Project: 41795
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: 41796
Project: 41796
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: 41798
Project: 41798
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: 41799
Project: 41799
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: 41800
Project: 41800
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: 41802
Project: 41802
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: 41803
Project: 41803
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: 41804
Project: 41804
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: 41805
Project: 41805
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: 41808
Project: 41808
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: 41809
Project: 41809
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: 41810
Project: 41810
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;
}