nus-yam/ex-repair huggingface dataset:
Program: 42112
Project: 42112
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: 42113
Project: 42113
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: 42115
Project: 42115
Buggy source:
public boolean onTouch(View v,MotionEvent event){
  if (event.getAction() == MotionEvent.ACTION_DOWN && mPopup != null && mPopup.isShowing()) {
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    showDropDown();
  }
  return false;
}

Fixed version (ground truth):
public boolean onTouch(View v,MotionEvent event){
  final int action=event.getAction();
  if (action == MotionEvent.ACTION_DOWN && mPopup != null && mPopup.isShowing()) {
    postDelayed(mResizePopupRunnable,EXPAND_LIST_TIMEOUT);
  }
 else   if (action == MotionEvent.ACTION_UP) {
    removeCallbacks(mResizePopupRunnable);
  }
  return false;
}
Program: 42117
Project: 42117
Buggy source:
public boolean onTouch(View v,MotionEvent event){
  if (event.getAction() == MotionEvent.ACTION_DOWN && mPopup != null && mPopup.isShowing()) {
    mPopup.setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
    showDropDown();
  }
  return false;
}

Fixed version (ground truth):
public boolean onTouch(View v,MotionEvent event){
  final int action=event.getAction();
  if (action == MotionEvent.ACTION_DOWN && mPopup != null && mPopup.isShowing()) {
    postDelayed(mResizePopupRunnable,EXPAND_LIST_TIMEOUT);
  }
 else   if (action == MotionEvent.ACTION_UP) {
    removeCallbacks(mResizePopupRunnable);
  }
  return false;
}
Program: 42119
Project: 42119
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: 42122
Project: 42122
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: 42124
Project: 42124
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: 42125
Project: 42125
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: 42126
Project: 42126
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: 42127
Project: 42127
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: 42128
Project: 42128
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: 42129
Project: 42129
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: 42130
Project: 42130
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: 42131
Project: 42131
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: 42132
Project: 42132
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: 42134
Project: 42134
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: 42135
Project: 42135
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: 42136
Project: 42136
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: 42137
Project: 42137
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: 42138
Project: 42138
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: 42139
Project: 42139
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: 42141
Project: 42141
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: 42142
Project: 42142
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: 42143
Project: 42143
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: 42144
Project: 42144
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: 42145
Project: 42145
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: 42146
Project: 42146
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: 42147
Project: 42147
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: 42151
Project: 42151
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);
}
Program: 42153
Project: 42153
Buggy source:
private boolean writeFileLocked(){
  if (mFile.exists()) {
    if (!mFile.renameTo(mBackupFile)) {
      Log.e(TAG,"String_Node_Str" + mFile + "String_Node_Str"+ mBackupFile);
      return false;
    }
  }
  try {
    FileOutputStream str=createFileOutputStream(mFile);
    if (str == null) {
      return false;
    }
    XmlUtils.writeMapXml(mMap,str);
    str.close();
    setFilePermissionsFromMode(mFile.getPath(),mMode,0);
    if (FileUtils.getFileStatus(mFile.getPath(),mFileStatus)) {
      mTimestamp=mFileStatus.mtime;
    }
    mBackupFile.delete();
    return true;
  }
 catch (  XmlPullParserException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
catch (  IOException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
  if (mFile.exists()) {
    if (!mFile.delete()) {
      Log.e(TAG,"String_Node_Str" + mFile);
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean writeFileLocked(){
  if (mFile.exists()) {
    if (!mBackupFile.exists()) {
      if (!mFile.renameTo(mBackupFile)) {
        Log.e(TAG,"String_Node_Str" + mFile + "String_Node_Str"+ mBackupFile);
        return false;
      }
    }
 else {
      mFile.delete();
    }
  }
  try {
    FileOutputStream str=createFileOutputStream(mFile);
    if (str == null) {
      return false;
    }
    XmlUtils.writeMapXml(mMap,str);
    str.close();
    setFilePermissionsFromMode(mFile.getPath(),mMode,0);
    if (FileUtils.getFileStatus(mFile.getPath(),mFileStatus)) {
      mTimestamp=mFileStatus.mtime;
    }
    mBackupFile.delete();
    return true;
  }
 catch (  XmlPullParserException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
catch (  IOException e) {
    Log.w(TAG,"String_Node_Str",e);
  }
  if (mFile.exists()) {
    if (!mFile.delete()) {
      Log.e(TAG,"String_Node_Str" + mFile);
    }
  }
  return false;
}
Program: 42154
Project: 42154
Buggy source:
/** 
 * Copy data from a source stream to destFile. Return true if succeed, return false if failed.
 */
public static boolean copyToFile(InputStream inputStream,File destFile){
  try {
    OutputStream out=new FileOutputStream(destFile);
    try {
      byte[] buffer=new byte[4096];
      int bytesRead;
      while ((bytesRead=inputStream.read(buffer)) >= 0) {
        out.write(buffer,0,bytesRead);
      }
    }
  finally {
      out.close();
    }
    return true;
  }
 catch (  IOException e) {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Copy data from a source stream to destFile. Return true if succeed, return false if failed.
 */
public static boolean copyToFile(InputStream inputStream,File destFile){
  try {
    if (destFile.exists()) {
      destFile.delete();
    }
    OutputStream out=new FileOutputStream(destFile);
    try {
      byte[] buffer=new byte[4096];
      int bytesRead;
      while ((bytesRead=inputStream.read(buffer)) >= 0) {
        out.write(buffer,0,bytesRead);
      }
    }
  finally {
      out.close();
    }
    return true;
  }
 catch (  IOException e) {
    return false;
  }
}
Program: 42157
Project: 42157
Buggy source:
public FileOutputStream startWrite() throws IOException {
  if (mBaseName.exists()) {
    if (!mBaseName.renameTo(mBackupName)) {
      mBackupName.delete();
      if (!mBaseName.renameTo(mBackupName)) {
        Log.w("String_Node_Str","String_Node_Str" + mBaseName + "String_Node_Str"+ mBackupName);
      }
    }
  }
  FileOutputStream str=null;
  try {
    str=new FileOutputStream(mBaseName);
  }
 catch (  FileNotFoundException e) {
    File parent=mBaseName.getParentFile();
    if (!parent.mkdir()) {
      throw new IOException("String_Node_Str" + mBaseName);
    }
    FileUtils.setPermissions(parent.getPath(),FileUtils.S_IRWXU | FileUtils.S_IRWXG | FileUtils.S_IXOTH,-1,-1);
    try {
      str=new FileOutputStream(mBaseName);
    }
 catch (    FileNotFoundException e2) {
      throw new IOException("String_Node_Str" + mBaseName);
    }
  }
  return str;
}

Fixed version (ground truth):
public FileOutputStream startWrite() throws IOException {
  if (mBaseName.exists()) {
    if (!mBackupName.exists()) {
      if (!mBaseName.renameTo(mBackupName)) {
        Log.w("String_Node_Str","String_Node_Str" + mBaseName + "String_Node_Str"+ mBackupName);
      }
    }
 else {
      mBaseName.delete();
    }
  }
  FileOutputStream str=null;
  try {
    str=new FileOutputStream(mBaseName);
  }
 catch (  FileNotFoundException e) {
    File parent=mBaseName.getParentFile();
    if (!parent.mkdir()) {
      throw new IOException("String_Node_Str" + mBaseName);
    }
    FileUtils.setPermissions(parent.getPath(),FileUtils.S_IRWXU | FileUtils.S_IRWXG | FileUtils.S_IXOTH,-1,-1);
    try {
      str=new FileOutputStream(mBaseName);
    }
 catch (    FileNotFoundException e2) {
      throw new IOException("String_Node_Str" + mBaseName);
    }
  }
  return str;
}
Program: 42158
Project: 42158
Buggy source:
public void writeLocked(){
  if ((mFile == null) || (mBackupFile == null)) {
    Log.w("String_Node_Str","String_Node_Str");
    return;
  }
  if (mFile.exists()) {
    if (mBackupFile.exists()) {
      mBackupFile.delete();
    }
    if (!mFile.renameTo(mBackupFile)) {
      Log.w("String_Node_Str","String_Node_Str");
      return;
    }
  }
  try {
    FileOutputStream stream=new FileOutputStream(mFile);
    Parcel out=Parcel.obtain();
    writeSummaryToParcel(out);
    stream.write(out.marshall());
    out.recycle();
    stream.flush();
    stream.close();
    mBackupFile.delete();
    mLastWriteTime=SystemClock.elapsedRealtime();
    return;
  }
 catch (  IOException e) {
    Log.w("String_Node_Str","String_Node_Str",e);
  }
  if (mFile.exists()) {
    if (!mFile.delete()) {
      Log.w(TAG,"String_Node_Str" + mFile);
    }
  }
}

Fixed version (ground truth):
public void writeLocked(){
  if (mFile == null) {
    Slog.w("String_Node_Str","String_Node_Str");
    return;
  }
  try {
    FileOutputStream stream=new FileOutputStream(mFile.chooseForWrite());
    Parcel out=Parcel.obtain();
    writeSummaryToParcel(out);
    stream.write(out.marshall());
    out.recycle();
    stream.flush();
    stream.close();
    mFile.commit();
    mLastWriteTime=SystemClock.elapsedRealtime();
    return;
  }
 catch (  IOException e) {
    Slog.w("String_Node_Str","String_Node_Str",e);
  }
  mFile.rollback();
}
Program: 42159
Project: 42159
Buggy source:
public void updateKernelWakelocksLocked(){
  Map<String,KernelWakelockStats> m=readKernelWakelockStats();
  if (m == null) {
    Log.w(TAG,"String_Node_Str");
    return;
  }
  for (  Map.Entry<String,KernelWakelockStats> ent : m.entrySet()) {
    String name=ent.getKey();
    KernelWakelockStats kws=ent.getValue();
    SamplingTimer kwlt=mKernelWakelockStats.get(name);
    if (kwlt == null) {
      kwlt=new SamplingTimer(mUnpluggables,mOnBatteryInternal,true);
      mKernelWakelockStats.put(name,kwlt);
    }
    kwlt.updateCurrentReportedCount(kws.mCount);
    kwlt.updateCurrentReportedTotalTime(kws.mTotalTime);
    kwlt.setUpdateVersion(sKernelWakelockUpdateVersion);
  }
  if (m.size() != mKernelWakelockStats.size()) {
    for (    Map.Entry<String,SamplingTimer> ent : mKernelWakelockStats.entrySet()) {
      SamplingTimer st=ent.getValue();
      if (st.getUpdateVersion() != sKernelWakelockUpdateVersion) {
        st.setStale();
      }
    }
  }
}

Fixed version (ground truth):
public void updateKernelWakelocksLocked(){
  Map<String,KernelWakelockStats> m=readKernelWakelockStats();
  if (m == null) {
    Slog.w(TAG,"String_Node_Str");
    return;
  }
  for (  Map.Entry<String,KernelWakelockStats> ent : m.entrySet()) {
    String name=ent.getKey();
    KernelWakelockStats kws=ent.getValue();
    SamplingTimer kwlt=mKernelWakelockStats.get(name);
    if (kwlt == null) {
      kwlt=new SamplingTimer(mUnpluggables,mOnBatteryInternal,true);
      mKernelWakelockStats.put(name,kwlt);
    }
    kwlt.updateCurrentReportedCount(kws.mCount);
    kwlt.updateCurrentReportedTotalTime(kws.mTotalTime);
    kwlt.setUpdateVersion(sKernelWakelockUpdateVersion);
  }
  if (m.size() != mKernelWakelockStats.size()) {
    for (    Map.Entry<String,SamplingTimer> ent : mKernelWakelockStats.entrySet()) {
      SamplingTimer st=ent.getValue();
      if (st.getUpdateVersion() != sKernelWakelockUpdateVersion) {
        st.setStale();
      }
    }
  }
}
Program: 42161
Project: 42161
Buggy source:
public void readLocked(){
  if ((mFile == null) || (mBackupFile == null)) {
    Log.w("String_Node_Str","String_Node_Str");
    return;
  }
  mUidStats.clear();
  FileInputStream stream=null;
  if (mBackupFile.exists()) {
    try {
      stream=new FileInputStream(mBackupFile);
    }
 catch (    java.io.IOException e) {
    }
  }
  try {
    if (stream == null) {
      if (!mFile.exists()) {
        return;
      }
      stream=new FileInputStream(mFile);
    }
    byte[] raw=readFully(stream);
    Parcel in=Parcel.obtain();
    in.unmarshall(raw,0,raw.length);
    in.setDataPosition(0);
    stream.close();
    readSummaryFromParcel(in);
  }
 catch (  java.io.IOException e) {
    Log.e("String_Node_Str","String_Node_Str",e);
  }
}

Fixed version (ground truth):
public void readLocked(){
  if (mFile == null) {
    Slog.w("String_Node_Str","String_Node_Str");
    return;
  }
  mUidStats.clear();
  try {
    File file=mFile.chooseForRead();
    if (!file.exists()) {
      return;
    }
    FileInputStream stream=new FileInputStream(file);
    byte[] raw=readFully(stream);
    Parcel in=Parcel.obtain();
    in.unmarshall(raw,0,raw.length);
    in.setDataPosition(0);
    stream.close();
    readSummaryFromParcel(in);
  }
 catch (  java.io.IOException e) {
    Slog.e("String_Node_Str","String_Node_Str",e);
  }
}
Program: 42162
Project: 42162
Buggy source:
public BatteryStatsImpl(Parcel p){
  mFile=mBackupFile=null;
  readFromParcel(p);
}

Fixed version (ground truth):
public BatteryStatsImpl(Parcel p){
  mFile=null;
  readFromParcel(p);
}
Program: 42165
Project: 42165
Buggy source:
private void writeStatsToFile(boolean force){
synchronized (mFileLock) {
    mCal.setTimeInMillis(System.currentTimeMillis());
    final int curDay=mCal.get(Calendar.DAY_OF_YEAR);
    final boolean dayChanged=curDay != mLastWriteDay;
    long currElapsedTime=SystemClock.elapsedRealtime();
    if (!force) {
      if (((currElapsedTime - mLastWriteElapsedTime) < FILE_WRITE_INTERVAL) && (!dayChanged)) {
        return;
      }
    }
    mFileLeaf=getCurrentDateStr(FILE_PREFIX);
    File backupFile=null;
    if (mFile != null && mFile.exists()) {
      backupFile=new File(mFile.getPath() + "String_Node_Str");
      if (!mFile.renameTo(backupFile)) {
        Slog.w(TAG,"String_Node_Str");
        return;
      }
    }
    try {
      writeStatsFLOCK();
      mLastWriteElapsedTime=currElapsedTime;
      if (dayChanged) {
        mLastWriteDay=curDay;
synchronized (mStats) {
          mStats.clear();
        }
        mFile=new File(mDir,mFileLeaf);
        checkFileLimitFLOCK();
      }
      if (backupFile != null) {
        backupFile.delete();
      }
    }
 catch (    IOException e) {
      Slog.w(TAG,"String_Node_Str" + mFile);
      if (backupFile != null) {
        mFile.delete();
        backupFile.renameTo(mFile);
      }
    }
  }
}

Fixed version (ground truth):
private void writeStatsToFile(boolean force){
synchronized (mFileLock) {
    mCal.setTimeInMillis(System.currentTimeMillis());
    final int curDay=mCal.get(Calendar.DAY_OF_YEAR);
    final boolean dayChanged=curDay != mLastWriteDay;
    long currElapsedTime=SystemClock.elapsedRealtime();
    if (!force) {
      if (((currElapsedTime - mLastWriteElapsedTime) < FILE_WRITE_INTERVAL) && (!dayChanged)) {
        return;
      }
    }
    mFileLeaf=getCurrentDateStr(FILE_PREFIX);
    File backupFile=null;
    if (mFile != null && mFile.exists()) {
      backupFile=new File(mFile.getPath() + "String_Node_Str");
      if (!backupFile.exists()) {
        if (!mFile.renameTo(backupFile)) {
          Slog.w(TAG,"String_Node_Str");
          return;
        }
      }
 else {
        mFile.delete();
      }
    }
    try {
      writeStatsFLOCK();
      mLastWriteElapsedTime=currElapsedTime;
      if (dayChanged) {
        mLastWriteDay=curDay;
synchronized (mStats) {
          mStats.clear();
        }
        mFile=new File(mDir,mFileLeaf);
        checkFileLimitFLOCK();
      }
      if (backupFile != null) {
        backupFile.delete();
      }
    }
 catch (    IOException e) {
      Slog.w(TAG,"String_Node_Str" + mFile);
      if (backupFile != null) {
        mFile.delete();
        backupFile.renameTo(mFile);
      }
    }
  }
}