nus-yam/ex-repair huggingface dataset:
Program: 182162
Project: 182162
Buggy source:
/** 
 * Fling the scroll view
 * @param velocityY The initial velocity in the Y direction. Positivenumbers mean that the finger/cursor is moving down the screen, which means we want to scroll towards the top.
 */
public void fling(int velocityY){
  if (getChildCount() > 0) {
    int height=getHeight() - mPaddingBottom - mPaddingTop;
    int bottom=getChildAt(0).getHeight();
    mScroller.fling(mScrollX,mScrollY,0,velocityY,0,0,0,Math.max(0,bottom - height),0,height / 2);
    final boolean movingDown=velocityY > 0;
    View newFocused=findFocusableViewInMyBounds(movingDown,mScroller.getFinalY(),findFocus());
    if (newFocused == null) {
      newFocused=this;
    }
    if (newFocused != findFocus() && newFocused.requestFocus(movingDown ? View.FOCUS_DOWN : View.FOCUS_UP)) {
      mScrollViewMovedFocus=true;
      mScrollViewMovedFocus=false;
    }
    awakenScrollBars(mScroller.getDuration());
    invalidate();
  }
}

Fixed version (ground truth):
/** 
 * Fling the scroll view
 * @param velocityY The initial velocity in the Y direction. Positivenumbers mean that the finger/cursor is moving down the screen, which means we want to scroll towards the top.
 */
public void fling(int velocityY){
  if (getChildCount() > 0) {
    int height=getHeight() - mPaddingBottom - mPaddingTop;
    int bottom=getChildAt(0).getHeight();
    mScroller.fling(mScrollX,mScrollY,0,velocityY,0,0,0,Math.max(0,bottom - height),0,height / 2);
    final boolean movingDown=velocityY > 0;
    View newFocused=findFocusableViewInMyBounds(movingDown,mScroller.getFinalY(),findFocus());
    if (newFocused == null) {
      newFocused=this;
    }
    if (newFocused != findFocus() && newFocused.requestFocus(movingDown ? View.FOCUS_DOWN : View.FOCUS_UP)) {
      mScrollViewMovedFocus=true;
      mScrollViewMovedFocus=false;
    }
    invalidate();
  }
}
Program: 182163
Project: 182163
Buggy source:
@Override protected void onOverscrolled(int scrollX,int scrollY,boolean clampedX,boolean clampedY){
  if (!mScroller.isFinished()) {
    mScrollX=scrollX;
    mScrollY=scrollY;
    if (clampedY) {
      mScroller.springback(mScrollX,mScrollY,0,0,0,getScrollRange());
    }
  }
 else {
    super.scrollTo(scrollX,scrollY);
  }
}

Fixed version (ground truth):
@Override protected void onOverscrolled(int scrollX,int scrollY,boolean clampedX,boolean clampedY){
  if (!mScroller.isFinished()) {
    mScrollX=scrollX;
    mScrollY=scrollY;
    if (clampedY) {
      mScroller.springback(mScrollX,mScrollY,0,0,0,getScrollRange());
    }
  }
 else {
    super.scrollTo(scrollX,scrollY);
  }
  awakenScrollBars();
}
Program: 182164
Project: 182164
Buggy source:
void scaleAll(){
  for (  ChildView v : mChildren) {
    v.mView.setLayoutParams(computeLayout(v));
  }
}

Fixed version (ground truth):
void scaleAll(){
  for (  ChildView v : mChildren) {
    requestLayout(v);
  }
}
Program: 182165
Project: 182165
Buggy source:
void attachView(int x,int y,int width,int height){
  if (mView == null) {
    return;
  }
  setBounds(x,y,width,height);
  mWebView.mPrivateHandler.post(new Runnable(){
    public void run(){
      AbsoluteLayout.LayoutParams lp=computeLayout(ChildView.this);
      if (mView.getParent() != null) {
        mView.setLayoutParams(lp);
      }
 else {
        attachViewOnUIThread(lp);
      }
    }
  }
);
}

Fixed version (ground truth):
void attachView(int x,int y,int width,int height){
  if (mView == null) {
    return;
  }
  setBounds(x,y,width,height);
  mWebView.mPrivateHandler.post(new Runnable(){
    public void run(){
      requestLayout(ChildView.this);
      if (mView.getParent() == null) {
        attachViewOnUIThread();
      }
    }
  }
);
}
Program: 182166
Project: 182166
Buggy source:
private void attachViewOnUIThread(AbsoluteLayout.LayoutParams lp){
  mWebView.addView(mView,lp);
  mChildren.add(this);
  if (!mReadyToDraw) {
    mView.setVisibility(View.GONE);
  }
}

Fixed version (ground truth):
private void attachViewOnUIThread(){
  mWebView.addView(mView);
  mChildren.add(this);
  if (!mReadyToDraw) {
    mView.setVisibility(View.GONE);
  }
}
Program: 182167
Project: 182167
Buggy source:
public boolean onScaleBegin(ScaleGestureDetector detector){
  cancelTouch();
  dismissZoomControl();
  mInZoomOverview=false;
  if (inEditingMode() && nativeFocusCandidateIsPassword()) {
    mWebTextView.setInPassword(false);
  }
  return true;
}

Fixed version (ground truth):
public boolean onScaleBegin(ScaleGestureDetector detector){
  cancelTouch();
  dismissZoomControl();
  mInZoomOverview=false;
  if (inEditingMode() && nativeFocusCandidateIsPassword()) {
    mWebTextView.setInPassword(false);
  }
  mViewManager.startZoom();
  return true;
}
Program: 182168
Project: 182168
Buggy source:
public void onScaleEnd(ScaleGestureDetector detector){
  if (mPreviewZoomOnly) {
    mPreviewZoomOnly=false;
    mAnchorX=viewToContentX((int)mZoomCenterX + mScrollX);
    mAnchorY=viewToContentY((int)mZoomCenterY + mScrollY);
    boolean reflowNow=(mActualScale - mMinZoomScale <= MINIMUM_SCALE_INCREMENT) || ((mActualScale <= 0.8 * mTextWrapScale));
    setNewZoomScale(mActualScale,reflowNow,true);
    invalidate();
  }
  if (inEditingMode() && didUpdateTextViewBounds(false) && nativeFocusCandidateIsPassword()) {
    mWebTextView.setInPassword(true);
  }
  mTouchMode=TOUCH_PINCH_DRAG;
  mConfirmMove=true;
  startTouch(detector.getFocusX(),detector.getFocusY(),mLastTouchTime);
}

Fixed version (ground truth):
public void onScaleEnd(ScaleGestureDetector detector){
  if (mPreviewZoomOnly) {
    mPreviewZoomOnly=false;
    mAnchorX=viewToContentX((int)mZoomCenterX + mScrollX);
    mAnchorY=viewToContentY((int)mZoomCenterY + mScrollY);
    boolean reflowNow=(mActualScale - mMinZoomScale <= MINIMUM_SCALE_INCREMENT) || ((mActualScale <= 0.8 * mTextWrapScale));
    setNewZoomScale(mActualScale,reflowNow,true);
    invalidate();
  }
  if (inEditingMode() && didUpdateTextViewBounds(false) && nativeFocusCandidateIsPassword()) {
    mWebTextView.setInPassword(true);
  }
  mTouchMode=TOUCH_PINCH_DRAG;
  mConfirmMove=true;
  startTouch(detector.getFocusX(),detector.getFocusY(),mLastTouchTime);
  mViewManager.endZoom();
}
Program: 182171
Project: 182171
Buggy source:
private DateFormat getDateFormat(){
  String format=Settings.System.getString(getContext().getContentResolver(),Settings.System.DATE_FORMAT);
  if (format == null || "String_Node_Str".equals(format)) {
    return DateFormat.getDateInstance(DateFormat.SHORT);
  }
 else {
    return new SimpleDateFormat(format);
  }
}

Fixed version (ground truth):
private DateFormat getDateFormat(){
  String format=Settings.System.getString(getContext().getContentResolver(),Settings.System.DATE_FORMAT);
  if (format == null || "String_Node_Str".equals(format)) {
    return DateFormat.getDateInstance(DateFormat.SHORT);
  }
 else {
    try {
      return new SimpleDateFormat(format);
    }
 catch (    IllegalArgumentException e) {
      return DateFormat.getDateInstance(DateFormat.SHORT);
    }
  }
}
Program: 182172
Project: 182172
Buggy source:
private boolean trackSignalStrength(){
  return getPreferences().getBoolean(SIGNAL_PREF,true);
}

Fixed version (ground truth):
private boolean trackSignalStrength(){
  return getPreferences().getBoolean(SIGNAL_PREF,false);
}
Program: 182173
Project: 182173
Buggy source:
private boolean doDebugLogging(){
  return getPreferences().getBoolean(DEBUG_PREF,true);
}

Fixed version (ground truth):
private boolean doDebugLogging(){
  return getPreferences().getBoolean(DEBUG_PREF,false);
}
Program: 182175
Project: 182175
Buggy source:
public void copyFrom(PackageSettingBase base){
  grantedPermissions=base.grantedPermissions;
  gids=base.gids;
  timeStamp=base.timeStamp;
  timeStampString=base.timeStampString;
  signatures=base.signatures;
  permissionsFixed=base.permissionsFixed;
  disabledComponents=base.disabledComponents;
  enabledComponents=base.enabledComponents;
  enabled=base.enabled;
  installStatus=base.installStatus;
}

Fixed version (ground truth):
public void copyFrom(PackageSettingBase base){
  grantedPermissions=base.grantedPermissions;
  gids=base.gids;
  timeStamp=base.timeStamp;
  timeStampString=base.timeStampString;
  signatures=base.signatures;
  permissionsFixed=base.permissionsFixed;
  haveGids=base.haveGids;
  disabledComponents=base.disabledComponents;
  enabledComponents=base.enabledComponents;
  enabled=base.enabled;
  installStatus=base.installStatus;
}
Program: 182177
Project: 182177
Buggy source:
private boolean trackSignalStrength(){
  return getPreferences().getBoolean(SIGNAL_PREF,true);
}

Fixed version (ground truth):
private boolean trackSignalStrength(){
  return getPreferences().getBoolean(SIGNAL_PREF,false);
}
Program: 182178
Project: 182178
Buggy source:
private boolean doDebugLogging(){
  return getPreferences().getBoolean(DEBUG_PREF,true);
}

Fixed version (ground truth):
private boolean doDebugLogging(){
  return getPreferences().getBoolean(DEBUG_PREF,false);
}
Program: 182179
Project: 182179
Buggy source:
/** 
 * Sets the drawable to use as the right part of the strip below the tab indicators.
 * @param resId the resource identifier of the drawable to use as theright strip drawable
 */
public void setRightStripDrawable(int resId){
  mBottomLeftStrip=mContext.getResources().getDrawable(resId);
  requestLayout();
  invalidate();
}

Fixed version (ground truth):
/** 
 * Sets the drawable to use as the right part of the strip below the tab indicators.
 * @param resId the resource identifier of the drawable to use as theright strip drawable
 */
public void setRightStripDrawable(int resId){
  mBottomRightStrip=mContext.getResources().getDrawable(resId);
  requestLayout();
  invalidate();
}
Program: 182180
Project: 182180
Buggy source:
/** 
 * Sets the drawable to use as the right part of the strip below the tab indicators.
 * @param resId the resource identifier of the drawable to use as theright strip drawable
 */
public void setRightStripDrawable(int resId){
  mBottomLeftStrip=mContext.getResources().getDrawable(resId);
  requestLayout();
  invalidate();
}

Fixed version (ground truth):
/** 
 * Sets the drawable to use as the right part of the strip below the tab indicators.
 * @param resId the resource identifier of the drawable to use as theright strip drawable
 */
public void setRightStripDrawable(int resId){
  mBottomRightStrip=mContext.getResources().getDrawable(resId);
  requestLayout();
  invalidate();
}
Program: 182181
Project: 182181
Buggy source:
/** 
 * Sets the drawable to use as the left part of the strip below the tab indicators.
 * @param resId the resource identifier of the drawable to use as theleft strip drawable
 */
public void setRightStripDrawable(int resId){
  mBottomLeftStrip=mContext.getResources().getDrawable(resId);
  requestLayout();
  invalidate();
}

Fixed version (ground truth):
/** 
 * Sets the drawable to use as the right part of the strip below the tab indicators.
 * @param resId the resource identifier of the drawable to use as theright strip drawable
 */
public void setRightStripDrawable(int resId){
  mBottomLeftStrip=mContext.getResources().getDrawable(resId);
  requestLayout();
  invalidate();
}
Program: 182182
Project: 182182
Buggy source:
/** 
 * Sets the drawable to use as the left part of the strip below the tab indicators.
 * @param resId the resource identifier of the drawable to use as theleft strip drawable
 */
public void setRightStripDrawable(int resId){
  mBottomLeftStrip=mContext.getResources().getDrawable(resId);
  requestLayout();
  invalidate();
}

Fixed version (ground truth):
/** 
 * Sets the drawable to use as the right part of the strip below the tab indicators.
 * @param resId the resource identifier of the drawable to use as theright strip drawable
 */
public void setRightStripDrawable(int resId){
  mBottomLeftStrip=mContext.getResources().getDrawable(resId);
  requestLayout();
  invalidate();
}
Program: 182183
Project: 182183
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.setIndex(index,lastAudible) || force) {
    if (streamState.muteCount() == 0 && (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) {
    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);
      }
    }
  }
}
Program: 182184
Project: 182184
Buggy source:
public void mute(boolean state){
synchronized (mDeathHandlers) {
    if (state) {
      if (mMuteCount == 0) {
        try {
          mICallback.linkToDeath(this,0);
          mDeathHandlers.add(this);
          if (muteCount() == 0) {
            setIndex(0,false);
            sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
          }
        }
 catch (        RemoteException e) {
          binderDied();
          mDeathHandlers.notify();
          return;
        }
      }
 else {
        Log.w(TAG,"String_Node_Str" + mStreamType + "String_Node_Str");
      }
      mMuteCount++;
    }
 else {
      if (mMuteCount == 0) {
        Log.e(TAG,"String_Node_Str" + mStreamType);
      }
 else {
        mMuteCount--;
        if (mMuteCount == 0) {
          mDeathHandlers.remove(this);
          mICallback.unlinkToDeath(this,0);
          if (muteCount() == 0) {
            if (!isStreamAffectedByRingerMode(mStreamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
              setIndex(mLastAudibleIndex,false);
              sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
            }
          }
        }
      }
    }
    mDeathHandlers.notify();
  }
}

Fixed version (ground truth):
public void mute(boolean state){
synchronized (mDeathHandlers) {
    if (state) {
      if (mMuteCount == 0) {
        try {
          if (mICallback != null) {
            mICallback.linkToDeath(this,0);
          }
          mDeathHandlers.add(this);
          if (muteCount() == 0) {
            setIndex(0,false);
            sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
          }
        }
 catch (        RemoteException e) {
          binderDied();
          mDeathHandlers.notify();
          return;
        }
      }
 else {
        Log.w(TAG,"String_Node_Str" + mStreamType + "String_Node_Str");
      }
      mMuteCount++;
    }
 else {
      if (mMuteCount == 0) {
        Log.e(TAG,"String_Node_Str" + mStreamType);
      }
 else {
        mMuteCount--;
        if (mMuteCount == 0) {
          mDeathHandlers.remove(this);
          if (mICallback != null) {
            mICallback.unlinkToDeath(this,0);
          }
          if (muteCount() == 0) {
            if (!isStreamAffectedByRingerMode(mStreamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
              setIndex(mLastAudibleIndex,false);
              sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
            }
          }
        }
      }
    }
    mDeathHandlers.notify();
  }
}
Program: 182185
Project: 182185
Buggy source:
/** 
 * @see AudioManager#adjustStreamVolume(int,int,int) 
 */
public void adjustStreamVolume(int streamType,int direction,int flags){
  ensureValidDirection(direction);
  ensureValidStreamType(streamType);
  VolumeStreamState streamState=mStreamStates[STREAM_VOLUME_ALIAS[streamType]];
  final int oldIndex=streamState.mIndex;
  boolean adjustVolume=true;
  if ((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0 || streamType == AudioSystem.STREAM_RING) {
    adjustVolume=checkForRingerModeChange(oldIndex,direction);
  }
  if (adjustVolume && streamState.adjustIndex(direction)) {
    if (streamState.muteCount() == 0) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,STREAM_VOLUME_ALIAS[streamType],SENDMSG_NOOP,0,0,streamState,0);
    }
  }
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,streamState.mIndex);
}

Fixed version (ground truth):
/** 
 * @see AudioManager#adjustStreamVolume(int,int,int) 
 */
public void adjustStreamVolume(int streamType,int direction,int flags){
  ensureValidDirection(direction);
  ensureValidStreamType(streamType);
  VolumeStreamState streamState=mStreamStates[STREAM_VOLUME_ALIAS[streamType]];
  final int oldIndex=(streamState.muteCount() != 0) ? streamState.mLastAudibleIndex : streamState.mIndex;
  boolean adjustVolume=true;
  if ((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0 || streamType == AudioSystem.STREAM_RING) {
    adjustVolume=checkForRingerModeChange(oldIndex,direction);
  }
  int index;
  if (streamState.muteCount() != 0) {
    if (adjustVolume) {
      streamState.adjustLastAudibleIndex(direction);
      sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
    }
    index=streamState.mLastAudibleIndex;
  }
 else {
    if (adjustVolume && streamState.adjustIndex(direction)) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,STREAM_VOLUME_ALIAS[streamType],SENDMSG_NOOP,0,0,streamState,0);
    }
    index=streamState.mIndex;
  }
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,index);
}
Program: 182187
Project: 182187
Buggy source:
private void setRingerModeInt(int ringerMode,boolean persist){
  mRingerMode=ringerMode;
  int numStreamTypes=AudioSystem.getNumStreamTypes();
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
      if (!isStreamAffectedByRingerMode(streamType))       continue;
      setStreamVolumeInt(streamType,mStreamStates[streamType].mLastAudibleIndex,true,false);
    }
  }
 else {
    for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
      if (isStreamAffectedByRingerMode(streamType)) {
        setStreamVolumeInt(streamType,0,false,false);
      }
 else {
        setStreamVolumeInt(streamType,mStreamStates[streamType].mLastAudibleIndex,true,false);
      }
    }
  }
  if (persist) {
    sendMsg(mAudioHandler,MSG_PERSIST_RINGER_MODE,SHARED_MSG,SENDMSG_REPLACE,0,0,null,PERSIST_DELAY);
  }
}

Fixed version (ground truth):
private void setRingerModeInt(int ringerMode,boolean persist){
  mRingerMode=ringerMode;
  int numStreamTypes=AudioSystem.getNumStreamTypes();
  for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
    if (isStreamMutedByRingerMode(streamType)) {
      if (!isStreamAffectedByRingerMode(streamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
        mStreamStates[streamType].mute(null,false);
        mRingerModeMutedStreams&=~(1 << streamType);
      }
    }
 else {
      if (isStreamAffectedByRingerMode(streamType) && mRingerMode != AudioManager.RINGER_MODE_NORMAL) {
        mStreamStates[streamType].mute(null,true);
        mRingerModeMutedStreams|=(1 << streamType);
      }
    }
  }
  if (persist) {
    sendMsg(mAudioHandler,MSG_PERSIST_RINGER_MODE,SHARED_MSG,SENDMSG_REPLACE,0,0,null,PERSIST_DELAY);
  }
}
Program: 182188
Project: 182188
Buggy source:
private VolumeDeathHandler getDeathHandler(IBinder cb,boolean state){
synchronized (mDeathHandlers) {
    VolumeDeathHandler handler;
    int size=mDeathHandlers.size();
    for (int i=0; i < size; i++) {
      handler=mDeathHandlers.get(i);
      if (cb.equals(handler.mICallback)) {
        return handler;
      }
    }
    if (state) {
      handler=new VolumeDeathHandler(cb);
    }
 else {
      Log.w(TAG,"String_Node_Str");
      handler=null;
    }
    return handler;
  }
}

Fixed version (ground truth):
private VolumeDeathHandler getDeathHandler(IBinder cb,boolean state){
synchronized (mDeathHandlers) {
    VolumeDeathHandler handler;
    int size=mDeathHandlers.size();
    for (int i=0; i < size; i++) {
      handler=mDeathHandlers.get(i);
      if (cb == handler.mICallback) {
        return handler;
      }
    }
    if (state) {
      handler=new VolumeDeathHandler(cb);
    }
 else {
      Log.w(TAG,"String_Node_Str");
      handler=null;
    }
    return handler;
  }
}
Program: 182189
Project: 182189
Buggy source:
/** 
 * @see AudioManager#setStreamVolume(int,int,int) 
 */
public void setStreamVolume(int streamType,int index,int flags){
  ensureValidStreamType(streamType);
  final int oldIndex=mStreamStates[STREAM_VOLUME_ALIAS[streamType]].mIndex;
  index=rescaleIndex(index * 10,streamType,STREAM_VOLUME_ALIAS[streamType]);
  setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType],index,false,true);
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,index);
}

Fixed version (ground truth):
/** 
 * @see AudioManager#setStreamVolume(int,int,int) 
 */
public void setStreamVolume(int streamType,int index,int flags){
  ensureValidStreamType(streamType);
  VolumeStreamState streamState=mStreamStates[STREAM_VOLUME_ALIAS[streamType]];
  final int oldIndex=(streamState.muteCount() != 0) ? streamState.mLastAudibleIndex : streamState.mIndex;
  index=rescaleIndex(index * 10,streamType,STREAM_VOLUME_ALIAS[streamType]);
  setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType],index,false,true);
  index=(streamState.muteCount() != 0) ? streamState.mLastAudibleIndex : streamState.mIndex;
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,index);
}
Program: 182190
Project: 182190
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.setIndex(index,lastAudible) || force) {
    if (streamState.muteCount() == 0 && (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) {
    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);
      }
    }
  }
}
Program: 182191
Project: 182191
Buggy source:
public void mute(boolean state){
synchronized (mDeathHandlers) {
    if (state) {
      if (mMuteCount == 0) {
        try {
          mICallback.linkToDeath(this,0);
          mDeathHandlers.add(this);
          if (muteCount() == 0) {
            setIndex(0,false);
            sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
          }
        }
 catch (        RemoteException e) {
          binderDied();
          mDeathHandlers.notify();
          return;
        }
      }
 else {
        Log.w(TAG,"String_Node_Str" + mStreamType + "String_Node_Str");
      }
      mMuteCount++;
    }
 else {
      if (mMuteCount == 0) {
        Log.e(TAG,"String_Node_Str" + mStreamType);
      }
 else {
        mMuteCount--;
        if (mMuteCount == 0) {
          mDeathHandlers.remove(this);
          mICallback.unlinkToDeath(this,0);
          if (muteCount() == 0) {
            if (!isStreamAffectedByRingerMode(mStreamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
              setIndex(mLastAudibleIndex,false);
              sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
            }
          }
        }
      }
    }
    mDeathHandlers.notify();
  }
}

Fixed version (ground truth):
public void mute(boolean state){
synchronized (mDeathHandlers) {
    if (state) {
      if (mMuteCount == 0) {
        try {
          if (mICallback != null) {
            mICallback.linkToDeath(this,0);
          }
          mDeathHandlers.add(this);
          if (muteCount() == 0) {
            setIndex(0,false);
            sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
          }
        }
 catch (        RemoteException e) {
          binderDied();
          mDeathHandlers.notify();
          return;
        }
      }
 else {
        Log.w(TAG,"String_Node_Str" + mStreamType + "String_Node_Str");
      }
      mMuteCount++;
    }
 else {
      if (mMuteCount == 0) {
        Log.e(TAG,"String_Node_Str" + mStreamType);
      }
 else {
        mMuteCount--;
        if (mMuteCount == 0) {
          mDeathHandlers.remove(this);
          if (mICallback != null) {
            mICallback.unlinkToDeath(this,0);
          }
          if (muteCount() == 0) {
            if (!isStreamAffectedByRingerMode(mStreamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
              setIndex(mLastAudibleIndex,false);
              sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,mStreamType,SENDMSG_NOOP,0,0,VolumeStreamState.this,0);
            }
          }
        }
      }
    }
    mDeathHandlers.notify();
  }
}
Program: 182192
Project: 182192
Buggy source:
/** 
 * @see AudioManager#adjustStreamVolume(int,int,int) 
 */
public void adjustStreamVolume(int streamType,int direction,int flags){
  ensureValidDirection(direction);
  ensureValidStreamType(streamType);
  VolumeStreamState streamState=mStreamStates[STREAM_VOLUME_ALIAS[streamType]];
  final int oldIndex=streamState.mIndex;
  boolean adjustVolume=true;
  if ((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0 || streamType == AudioSystem.STREAM_RING) {
    adjustVolume=checkForRingerModeChange(oldIndex,direction);
  }
  if (adjustVolume && streamState.adjustIndex(direction)) {
    if (streamState.muteCount() == 0) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,STREAM_VOLUME_ALIAS[streamType],SENDMSG_NOOP,0,0,streamState,0);
    }
  }
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,streamState.mIndex);
}

Fixed version (ground truth):
/** 
 * @see AudioManager#adjustStreamVolume(int,int,int) 
 */
public void adjustStreamVolume(int streamType,int direction,int flags){
  ensureValidDirection(direction);
  ensureValidStreamType(streamType);
  VolumeStreamState streamState=mStreamStates[STREAM_VOLUME_ALIAS[streamType]];
  final int oldIndex=(streamState.muteCount() != 0) ? streamState.mLastAudibleIndex : streamState.mIndex;
  boolean adjustVolume=true;
  if ((flags & AudioManager.FLAG_ALLOW_RINGER_MODES) != 0 || streamType == AudioSystem.STREAM_RING) {
    adjustVolume=checkForRingerModeChange(oldIndex,direction);
  }
  int index;
  if (streamState.muteCount() != 0) {
    if (adjustVolume) {
      streamState.adjustLastAudibleIndex(direction);
      sendMsg(mAudioHandler,MSG_PERSIST_VOLUME,streamType,SENDMSG_REPLACE,0,1,streamState,PERSIST_DELAY);
    }
    index=streamState.mLastAudibleIndex;
  }
 else {
    if (adjustVolume && streamState.adjustIndex(direction)) {
      sendMsg(mAudioHandler,MSG_SET_SYSTEM_VOLUME,STREAM_VOLUME_ALIAS[streamType],SENDMSG_NOOP,0,0,streamState,0);
    }
    index=streamState.mIndex;
  }
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,index);
}
Program: 182194
Project: 182194
Buggy source:
private void setRingerModeInt(int ringerMode,boolean persist){
  mRingerMode=ringerMode;
  int numStreamTypes=AudioSystem.getNumStreamTypes();
  if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
    for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
      if (!isStreamAffectedByRingerMode(streamType))       continue;
      setStreamVolumeInt(streamType,mStreamStates[streamType].mLastAudibleIndex,true,false);
    }
  }
 else {
    for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
      if (isStreamAffectedByRingerMode(streamType)) {
        setStreamVolumeInt(streamType,0,false,false);
      }
 else {
        setStreamVolumeInt(streamType,mStreamStates[streamType].mLastAudibleIndex,true,false);
      }
    }
  }
  if (persist) {
    sendMsg(mAudioHandler,MSG_PERSIST_RINGER_MODE,SHARED_MSG,SENDMSG_REPLACE,0,0,null,PERSIST_DELAY);
  }
}

Fixed version (ground truth):
private void setRingerModeInt(int ringerMode,boolean persist){
  mRingerMode=ringerMode;
  int numStreamTypes=AudioSystem.getNumStreamTypes();
  for (int streamType=numStreamTypes - 1; streamType >= 0; streamType--) {
    if (isStreamMutedByRingerMode(streamType)) {
      if (!isStreamAffectedByRingerMode(streamType) || mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
        mStreamStates[streamType].mute(null,false);
        mRingerModeMutedStreams&=~(1 << streamType);
      }
    }
 else {
      if (isStreamAffectedByRingerMode(streamType) && mRingerMode != AudioManager.RINGER_MODE_NORMAL) {
        mStreamStates[streamType].mute(null,true);
        mRingerModeMutedStreams|=(1 << streamType);
      }
    }
  }
  if (persist) {
    sendMsg(mAudioHandler,MSG_PERSIST_RINGER_MODE,SHARED_MSG,SENDMSG_REPLACE,0,0,null,PERSIST_DELAY);
  }
}
Program: 182195
Project: 182195
Buggy source:
private VolumeDeathHandler getDeathHandler(IBinder cb,boolean state){
synchronized (mDeathHandlers) {
    VolumeDeathHandler handler;
    int size=mDeathHandlers.size();
    for (int i=0; i < size; i++) {
      handler=mDeathHandlers.get(i);
      if (cb.equals(handler.mICallback)) {
        return handler;
      }
    }
    if (state) {
      handler=new VolumeDeathHandler(cb);
    }
 else {
      Log.w(TAG,"String_Node_Str");
      handler=null;
    }
    return handler;
  }
}

Fixed version (ground truth):
private VolumeDeathHandler getDeathHandler(IBinder cb,boolean state){
synchronized (mDeathHandlers) {
    VolumeDeathHandler handler;
    int size=mDeathHandlers.size();
    for (int i=0; i < size; i++) {
      handler=mDeathHandlers.get(i);
      if (cb == handler.mICallback) {
        return handler;
      }
    }
    if (state) {
      handler=new VolumeDeathHandler(cb);
    }
 else {
      Log.w(TAG,"String_Node_Str");
      handler=null;
    }
    return handler;
  }
}
Program: 182196
Project: 182196
Buggy source:
/** 
 * @see AudioManager#setStreamVolume(int,int,int) 
 */
public void setStreamVolume(int streamType,int index,int flags){
  ensureValidStreamType(streamType);
  final int oldIndex=mStreamStates[STREAM_VOLUME_ALIAS[streamType]].mIndex;
  index=rescaleIndex(index * 10,streamType,STREAM_VOLUME_ALIAS[streamType]);
  setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType],index,false,true);
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,index);
}

Fixed version (ground truth):
/** 
 * @see AudioManager#setStreamVolume(int,int,int) 
 */
public void setStreamVolume(int streamType,int index,int flags){
  ensureValidStreamType(streamType);
  VolumeStreamState streamState=mStreamStates[STREAM_VOLUME_ALIAS[streamType]];
  final int oldIndex=(streamState.muteCount() != 0) ? streamState.mLastAudibleIndex : streamState.mIndex;
  index=rescaleIndex(index * 10,streamType,STREAM_VOLUME_ALIAS[streamType]);
  setStreamVolumeInt(STREAM_VOLUME_ALIAS[streamType],index,false,true);
  index=(streamState.muteCount() != 0) ? streamState.mLastAudibleIndex : streamState.mIndex;
  mVolumePanel.postVolumeChanged(streamType,flags);
  sendVolumeUpdate(streamType,oldIndex,index);
}
Program: 182198
Project: 182198
Buggy source:
/** 
 * Helper function: Remove focus listeners from the focus stack for a particular client.
 */
private void removeFocusStackEntryForClient(IBinder cb){
  Iterator<FocusStackEntry> stackIterator=mFocusStack.iterator();
  while (stackIterator.hasNext()) {
    FocusStackEntry fse=(FocusStackEntry)stackIterator.next();
    if (fse.mSourceRef.equals(cb)) {
      Log.i(TAG,"String_Node_Str" + fse.mClientId);
      mFocusStack.remove(fse);
    }
  }
}

Fixed version (ground truth):
/** 
 * Helper function: Remove focus listeners from the focus stack for a particular client.
 */
private void removeFocusStackEntryForClient(IBinder cb){
  boolean isTopOfStackForClientToRemove=!mFocusStack.isEmpty() && mFocusStack.peek().mSourceRef.equals(cb);
  Iterator<FocusStackEntry> stackIterator=mFocusStack.iterator();
  while (stackIterator.hasNext()) {
    FocusStackEntry fse=(FocusStackEntry)stackIterator.next();
    if (fse.mSourceRef.equals(cb)) {
      Log.i(TAG,"String_Node_Str" + fse.mClientId);
      mFocusStack.remove(fse);
    }
  }
  if (isTopOfStackForClientToRemove) {
    notifyTopOfAudioFocusStack();
  }
}
Program: 182199
Project: 182199
Buggy source:
/** 
 * Helper function: Remove a focus listener from the focus stack.
 * @param focusListenerToRemove the focus listener
 * @param signal if true and the listener was at the top of the focus stack, i.e. it was holdingfocus, notify the next item in the stack it gained focus.
 */
private void removeFocusStackEntry(String clientToRemove,boolean signal){
  if (!mFocusStack.empty() && mFocusStack.peek().mClientId.equals(clientToRemove)) {
    mFocusStack.pop();
    if (signal) {
      if (!mFocusStack.empty() && (mFocusStack.peek().mFocusDispatcher != null) && canReassignAudioFocus()) {
        try {
          mFocusStack.peek().mFocusDispatcher.dispatchAudioFocusChange(AudioManager.AUDIOFOCUS_GAIN,mFocusStack.peek().mClientId);
        }
 catch (        RemoteException e) {
          Log.e(TAG,"String_Node_Str" + e);
          e.printStackTrace();
        }
      }
    }
  }
 else {
    Iterator<FocusStackEntry> stackIterator=mFocusStack.iterator();
    while (stackIterator.hasNext()) {
      FocusStackEntry fse=(FocusStackEntry)stackIterator.next();
      if (fse.mClientId.equals(clientToRemove)) {
        Log.i(TAG,"String_Node_Str" + fse.mClientId);
        mFocusStack.remove(fse);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Helper function: Remove a focus listener from the focus stack.
 * @param focusListenerToRemove the focus listener
 * @param signal if true and the listener was at the top of the focus stack, i.e. it was holdingfocus, notify the next item in the stack it gained focus.
 */
private void removeFocusStackEntry(String clientToRemove,boolean signal){
  if (!mFocusStack.empty() && mFocusStack.peek().mClientId.equals(clientToRemove)) {
    mFocusStack.pop();
    if (signal) {
      notifyTopOfAudioFocusStack();
    }
  }
 else {
    Iterator<FocusStackEntry> stackIterator=mFocusStack.iterator();
    while (stackIterator.hasNext()) {
      FocusStackEntry fse=(FocusStackEntry)stackIterator.next();
      if (fse.mClientId.equals(clientToRemove)) {
        Log.i(TAG,"String_Node_Str" + fse.mClientId);
        mFocusStack.remove(fse);
      }
    }
  }
}
Program: 182200
Project: 182200
Buggy source:
/** 
 * @see AudioManager#requestAudioFocus(IAudioFocusDispatcher,int,int) 
 */
public int requestAudioFocus(int mainStreamType,int focusChangeHint,IBinder cb,IAudioFocusDispatcher fd,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
  if ((cb == null) || !cb.pingBinder()) {
    Log.i(TAG,"String_Node_Str");
    return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
  }
  if (!canReassignAudioFocus()) {
    return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
  }
synchronized (mFocusStack) {
    if (!mFocusStack.empty() && mFocusStack.peek().mClientId.equals(clientId)) {
      mFocusStack.peek().mFocusChangeType=focusChangeHint;
      return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
    }
    if (!mFocusStack.empty() && (mFocusStack.peek().mFocusDispatcher != null)) {
      try {
        mFocusStack.peek().mFocusDispatcher.dispatchAudioFocusChange(-1 * focusChangeHint,mFocusStack.peek().mClientId);
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str" + e);
        e.printStackTrace();
      }
    }
    mFocusStack.push(new FocusStackEntry(mainStreamType,focusChangeHint,false,fd,cb,clientId));
  }
  AudioFocusDeathHandler afdh=new AudioFocusDeathHandler(cb);
  try {
    cb.linkToDeath(afdh,0);
  }
 catch (  RemoteException e) {
    Log.w(TAG,"String_Node_Str" + cb + "String_Node_Str");
  }
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}

Fixed version (ground truth):
/** 
 * @see AudioManager#requestAudioFocus(IAudioFocusDispatcher,int,int) 
 */
public int requestAudioFocus(int mainStreamType,int focusChangeHint,IBinder cb,IAudioFocusDispatcher fd,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
  if ((cb == null) || !cb.pingBinder()) {
    Log.i(TAG,"String_Node_Str");
    return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
  }
  if (!canReassignAudioFocus()) {
    return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
  }
synchronized (mFocusStack) {
    if (!mFocusStack.empty() && mFocusStack.peek().mClientId.equals(clientId)) {
      if (mFocusStack.peek().mFocusChangeType == focusChangeHint) {
        return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
      }
      mFocusStack.pop();
    }
    if (!mFocusStack.empty() && (mFocusStack.peek().mFocusDispatcher != null)) {
      try {
        mFocusStack.peek().mFocusDispatcher.dispatchAudioFocusChange(-1 * focusChangeHint,mFocusStack.peek().mClientId);
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str" + e);
        e.printStackTrace();
      }
    }
    mFocusStack.push(new FocusStackEntry(mainStreamType,focusChangeHint,false,fd,cb,clientId));
  }
  AudioFocusDeathHandler afdh=new AudioFocusDeathHandler(cb);
  try {
    cb.linkToDeath(afdh,0);
  }
 catch (  RemoteException e) {
    Log.w(TAG,"String_Node_Str" + cb + "String_Node_Str");
  }
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}
Program: 182202
Project: 182202
Buggy source:
/** 
 * Helper function: Remove focus listeners from the focus stack for a particular client.
 */
private void removeFocusStackEntryForClient(IBinder cb){
  Iterator<FocusStackEntry> stackIterator=mFocusStack.iterator();
  while (stackIterator.hasNext()) {
    FocusStackEntry fse=(FocusStackEntry)stackIterator.next();
    if (fse.mSourceRef.equals(cb)) {
      Log.i(TAG,"String_Node_Str" + fse.mClientId);
      mFocusStack.remove(fse);
    }
  }
}

Fixed version (ground truth):
/** 
 * Helper function: Remove focus listeners from the focus stack for a particular client.
 */
private void removeFocusStackEntryForClient(IBinder cb){
  boolean isTopOfStackForClientToRemove=!mFocusStack.isEmpty() && mFocusStack.peek().mSourceRef.equals(cb);
  Iterator<FocusStackEntry> stackIterator=mFocusStack.iterator();
  while (stackIterator.hasNext()) {
    FocusStackEntry fse=(FocusStackEntry)stackIterator.next();
    if (fse.mSourceRef.equals(cb)) {
      Log.i(TAG,"String_Node_Str" + fse.mClientId);
      mFocusStack.remove(fse);
    }
  }
  if (isTopOfStackForClientToRemove) {
    notifyTopOfAudioFocusStack();
  }
}
Program: 182203
Project: 182203
Buggy source:
/** 
 * Helper function: Remove a focus listener from the focus stack.
 * @param focusListenerToRemove the focus listener
 * @param signal if true and the listener was at the top of the focus stack, i.e. it was holdingfocus, notify the next item in the stack it gained focus.
 */
private void removeFocusStackEntry(String clientToRemove,boolean signal){
  if (!mFocusStack.empty() && mFocusStack.peek().mClientId.equals(clientToRemove)) {
    mFocusStack.pop();
    if (signal) {
      if (!mFocusStack.empty() && (mFocusStack.peek().mFocusDispatcher != null) && canReassignAudioFocus()) {
        try {
          mFocusStack.peek().mFocusDispatcher.dispatchAudioFocusChange(AudioManager.AUDIOFOCUS_GAIN,mFocusStack.peek().mClientId);
        }
 catch (        RemoteException e) {
          Log.e(TAG,"String_Node_Str" + e);
          e.printStackTrace();
        }
      }
    }
  }
 else {
    Iterator<FocusStackEntry> stackIterator=mFocusStack.iterator();
    while (stackIterator.hasNext()) {
      FocusStackEntry fse=(FocusStackEntry)stackIterator.next();
      if (fse.mClientId.equals(clientToRemove)) {
        Log.i(TAG,"String_Node_Str" + fse.mClientId);
        mFocusStack.remove(fse);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Helper function: Remove a focus listener from the focus stack.
 * @param focusListenerToRemove the focus listener
 * @param signal if true and the listener was at the top of the focus stack, i.e. it was holdingfocus, notify the next item in the stack it gained focus.
 */
private void removeFocusStackEntry(String clientToRemove,boolean signal){
  if (!mFocusStack.empty() && mFocusStack.peek().mClientId.equals(clientToRemove)) {
    mFocusStack.pop();
    if (signal) {
      notifyTopOfAudioFocusStack();
    }
  }
 else {
    Iterator<FocusStackEntry> stackIterator=mFocusStack.iterator();
    while (stackIterator.hasNext()) {
      FocusStackEntry fse=(FocusStackEntry)stackIterator.next();
      if (fse.mClientId.equals(clientToRemove)) {
        Log.i(TAG,"String_Node_Str" + fse.mClientId);
        mFocusStack.remove(fse);
      }
    }
  }
}
Program: 182204
Project: 182204
Buggy source:
/** 
 * @see AudioManager#requestAudioFocus(IAudioFocusDispatcher,int,int) 
 */
public int requestAudioFocus(int mainStreamType,int focusChangeHint,IBinder cb,IAudioFocusDispatcher fd,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
  if ((cb == null) || !cb.pingBinder()) {
    Log.i(TAG,"String_Node_Str");
    return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
  }
  if (!canReassignAudioFocus()) {
    return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
  }
synchronized (mFocusStack) {
    if (!mFocusStack.empty() && mFocusStack.peek().mClientId.equals(clientId)) {
      mFocusStack.peek().mFocusChangeType=focusChangeHint;
      return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
    }
    if (!mFocusStack.empty() && (mFocusStack.peek().mFocusDispatcher != null)) {
      try {
        mFocusStack.peek().mFocusDispatcher.dispatchAudioFocusChange(-1 * focusChangeHint,mFocusStack.peek().mClientId);
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str" + e);
        e.printStackTrace();
      }
    }
    mFocusStack.push(new FocusStackEntry(mainStreamType,focusChangeHint,false,fd,cb,clientId));
  }
  AudioFocusDeathHandler afdh=new AudioFocusDeathHandler(cb);
  try {
    cb.linkToDeath(afdh,0);
  }
 catch (  RemoteException e) {
    Log.w(TAG,"String_Node_Str" + cb + "String_Node_Str");
  }
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}

Fixed version (ground truth):
/** 
 * @see AudioManager#requestAudioFocus(IAudioFocusDispatcher,int,int) 
 */
public int requestAudioFocus(int mainStreamType,int focusChangeHint,IBinder cb,IAudioFocusDispatcher fd,String clientId){
  Log.i(TAG,"String_Node_Str" + clientId);
  if ((cb == null) || !cb.pingBinder()) {
    Log.i(TAG,"String_Node_Str");
    return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
  }
  if (!canReassignAudioFocus()) {
    return AudioManager.AUDIOFOCUS_REQUEST_FAILED;
  }
synchronized (mFocusStack) {
    if (!mFocusStack.empty() && mFocusStack.peek().mClientId.equals(clientId)) {
      if (mFocusStack.peek().mFocusChangeType == focusChangeHint) {
        return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
      }
      mFocusStack.pop();
    }
    if (!mFocusStack.empty() && (mFocusStack.peek().mFocusDispatcher != null)) {
      try {
        mFocusStack.peek().mFocusDispatcher.dispatchAudioFocusChange(-1 * focusChangeHint,mFocusStack.peek().mClientId);
      }
 catch (      RemoteException e) {
        Log.e(TAG,"String_Node_Str" + e);
        e.printStackTrace();
      }
    }
    mFocusStack.push(new FocusStackEntry(mainStreamType,focusChangeHint,false,fd,cb,clientId));
  }
  AudioFocusDeathHandler afdh=new AudioFocusDeathHandler(cb);
  try {
    cb.linkToDeath(afdh,0);
  }
 catch (  RemoteException e) {
    Log.w(TAG,"String_Node_Str" + cb + "String_Node_Str");
  }
  return AudioManager.AUDIOFOCUS_REQUEST_GRANTED;
}
Program: 182208
Project: 182208
Buggy source:
public PointerLocationView(Context c){
  super(c);
  mVC=ViewConfiguration.get(c);
  mTextPaint=new Paint();
  mTextPaint.setAntiAlias(true);
  mTextPaint.setTextSize(10 * getResources().getDisplayMetrics().density);
  mTextPaint.setARGB(255,0,0,0);
  mTextBackgroundPaint=new Paint();
  mTextBackgroundPaint.setAntiAlias(false);
  mTextBackgroundPaint.setARGB(128,255,255,255);
  mTextLevelPaint=new Paint();
  mTextLevelPaint.setAntiAlias(false);
  mTextLevelPaint.setARGB(192,255,0,0);
  mPaint=new Paint();
  mPaint.setAntiAlias(true);
  mPaint.setARGB(255,255,255,255);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeWidth(2);
  mTargetPaint=new Paint();
  mTargetPaint.setAntiAlias(false);
  mTargetPaint.setARGB(255,0,0,192);
  mPathPaint=new Paint();
  mPathPaint.setAntiAlias(false);
  mPathPaint.setARGB(255,0,96,255);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeWidth(1);
  PointerState ps=new PointerState();
  ps.mVelocity=VelocityTracker.obtain();
  mPointers.add(ps);
}

Fixed version (ground truth):
public PointerLocationView(Context c){
  super(c);
  setFocusable(true);
  mVC=ViewConfiguration.get(c);
  mTextPaint=new Paint();
  mTextPaint.setAntiAlias(true);
  mTextPaint.setTextSize(10 * getResources().getDisplayMetrics().density);
  mTextPaint.setARGB(255,0,0,0);
  mTextBackgroundPaint=new Paint();
  mTextBackgroundPaint.setAntiAlias(false);
  mTextBackgroundPaint.setARGB(128,255,255,255);
  mTextLevelPaint=new Paint();
  mTextLevelPaint.setAntiAlias(false);
  mTextLevelPaint.setARGB(192,255,0,0);
  mPaint=new Paint();
  mPaint.setAntiAlias(true);
  mPaint.setARGB(255,255,255,255);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeWidth(2);
  mTargetPaint=new Paint();
  mTargetPaint.setAntiAlias(false);
  mTargetPaint.setARGB(255,0,0,192);
  mPathPaint=new Paint();
  mPathPaint.setAntiAlias(false);
  mPathPaint.setARGB(255,0,96,255);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeWidth(1);
  PointerState ps=new PointerState();
  ps.mVelocity=VelocityTracker.obtain();
  mPointers.add(ps);
}