nus-yam/ex-repair huggingface dataset:
Program: 38147
Project: 38147
Buggy source:
private void processNewReprocessImage(Message msg){
  boolean isBayer=(msg.arg1 == CAM_TYPE_BAYER);
  Image image=(Image)msg.obj;
  long ts=image.getTimestamp();
  Log.d(TAG,"String_Node_Str" + ts);
  if (mDumpImages) {
    saveDebugImageAsJpeg(mMediaSaveService,image,isBayer,mNamedEntity,ClearSightNativeEngine.getInstance().getImageCount(isBayer));
  }
  if (mDumpYUV) {
    saveDebugImageAsNV21(image,isBayer,mNamedEntity,ClearSightNativeEngine.getInstance().getImageCount(isBayer));
  }
  if (!ClearSightNativeEngine.getInstance().hasReferenceImage(isBayer)) {
    ClearSightNativeEngine.getInstance().setReferenceImage(isBayer,image);
  }
 else {
    mClearsightRegisterHandler.obtainMessage(MSG_NEW_IMG,msg.arg1,0,msg.obj).sendToTarget();
  }
  mReprocessingFrames.removeAt(mReprocessingFrames.indexOfValue(ts));
  checkReprocessDone();
}

Fixed version (ground truth):
private void processNewReprocessImage(Message msg){
  boolean isBayer=(msg.arg1 == CAM_TYPE_BAYER);
  Image image=(Image)msg.obj;
  long ts=image.getTimestamp();
  Log.d(TAG,"String_Node_Str" + msg.arg1 + "String_Node_Str"+ ts);
  int frameCount=isBayer ? ++mReprocessedBayerCount : ++mReprocessedMonoCount;
  if (mDumpImages) {
    saveDebugImageAsJpeg(mMediaSaveService,image,isBayer,mNamedEntity,frameCount,ts / 1000000);
  }
  if (mDumpYUV) {
    saveDebugImageAsNV21(image,isBayer,mNamedEntity,frameCount,ts / 1000000);
  }
  if (!ClearSightNativeEngine.getInstance().hasReferenceImage(isBayer)) {
    ClearSightNativeEngine.getInstance().setReferenceImage(isBayer,image);
  }
 else {
    mClearsightRegisterHandler.obtainMessage(MSG_NEW_IMG,msg.arg1,0,msg.obj).sendToTarget();
  }
  mReprocessingFrames.removeAt(mReprocessingFrames.indexOfValue(ts));
  checkReprocessDone();
}
Program: 38148
Project: 38148
Buggy source:
public void saveDebugImageAsNV21(Image image,boolean isBayer,NamedEntity namedEntity,int count){
  if (image.getFormat() != ImageFormat.YUV_420_888) {
    Log.d(TAG,"String_Node_Str");
  }
  String type=isBayer ? "String_Node_Str" : "String_Node_Str";
  String title=String.format("String_Node_Str",namedEntity.title,image.getWidth(),image.getHeight(),type,count);
  YuvImage yuv=createYuvImage(image);
  String path=Storage.generateFilepath(title,"String_Node_Str");
  Storage.writeFile(path,yuv.getYuvData(),null,"String_Node_Str");
}

Fixed version (ground truth):
public void saveDebugImageAsNV21(Image image,boolean isBayer,NamedEntity namedEntity,int count,long ts){
  if (image.getFormat() != ImageFormat.YUV_420_888) {
    Log.d(TAG,"String_Node_Str");
  }
  String type=isBayer ? "String_Node_Str" : "String_Node_Str";
  String title=String.format("String_Node_Str",namedEntity.title,image.getWidth(),image.getHeight(),type,count,ts);
  YuvImage yuv=createYuvImage(image);
  String path=Storage.generateFilepath(title,"String_Node_Str");
  Storage.writeFile(path,yuv.getYuvData(),null,"String_Node_Str");
}
Program: 38149
Project: 38149
Buggy source:
public void saveDebugImageAsJpeg(MediaSaveService service,Image image,boolean isBayer,NamedEntity namedEntity,int count){
  if (image.getFormat() == ImageFormat.YUV_420_888)   saveDebugImageAsJpeg(service,createYuvImage(image),isBayer,namedEntity,count);
 else   if (image.getFormat() == ImageFormat.JPEG) {
    saveDebugImageAsJpeg(service,getJpegData(image),image.getWidth(),image.getHeight(),isBayer,namedEntity,count);
  }
}

Fixed version (ground truth):
public void saveDebugImageAsJpeg(MediaSaveService service,Image image,boolean isBayer,NamedEntity namedEntity,int count,long ts){
  if (image.getFormat() == ImageFormat.YUV_420_888)   saveDebugImageAsJpeg(service,createYuvImage(image),isBayer,namedEntity,count,ts);
 else   if (image.getFormat() == ImageFormat.JPEG) {
    saveDebugImageAsJpeg(service,getJpegData(image),image.getWidth(),image.getHeight(),isBayer,namedEntity,count,ts);
  }
}
Program: 38150
Project: 38150
Buggy source:
private void handlePermissionsSuccess(){
  if (mIntent != null) {
    mIsReturnResult=true;
    mIntent.setClass(this,CameraActivity.class);
    startActivityForResult(mIntent,1);
  }
 else {
    mIsReturnResult=false;
    Intent intent=new Intent(this,CameraActivity.class);
    startActivity(intent);
    finish();
  }
}

Fixed version (ground truth):
private void handlePermissionsSuccess(){
  if (mIntent != null) {
    mIsReturnResult=true;
    mIntent.setClass(this,CameraActivity.class);
    mIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
    startActivity(mIntent);
    finish();
  }
 else {
    mIsReturnResult=false;
    Intent intent=new Intent(this,CameraActivity.class);
    startActivity(intent);
    finish();
  }
}
Program: 38151
Project: 38151
Buggy source:
private void doReturnToCaller(boolean valid){
  Intent resultIntent=new Intent();
  int resultCode;
  if (valid) {
    resultCode=Activity.RESULT_OK;
    resultIntent.setData(mCurrentVideoUri);
  }
 else {
    resultCode=Activity.RESULT_CANCELED;
  }
  mActivity.setResultEx(resultCode,resultIntent);
  mActivity.finish();
}

Fixed version (ground truth):
private void doReturnToCaller(boolean valid){
  Intent resultIntent=new Intent();
  int resultCode;
  if (valid) {
    resultCode=Activity.RESULT_OK;
    resultIntent.setData(mCurrentVideoUri);
    resultIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
  }
 else {
    resultCode=Activity.RESULT_CANCELED;
  }
  mActivity.setResultEx(resultCode,resultIntent);
  mActivity.finish();
}
Program: 38152
Project: 38152
Buggy source:
private void processNewReprocessImage(Message msg){
  boolean isBayer=(msg.arg1 == CAM_TYPE_BAYER);
  Image image=(Image)msg.obj;
  long ts=image.getTimestamp();
  Log.d(TAG,"String_Node_Str" + ts);
  if (mDumpImages) {
    saveDebugImageAsJpeg(mMediaSaveService,image,isBayer,mNamedEntity,ClearSightNativeEngine.getInstance().getImageCount(isBayer));
  }
  if (mDumpYUV) {
    saveDebugImageAsNV21(image,isBayer,mNamedEntity,ClearSightNativeEngine.getInstance().getImageCount(isBayer));
  }
  if (!ClearSightNativeEngine.getInstance().hasReferenceImage(isBayer)) {
    ClearSightNativeEngine.getInstance().setReferenceImage(isBayer,image);
  }
 else {
    mClearsightRegisterHandler.obtainMessage(MSG_NEW_IMG,msg.arg1,0,msg.obj).sendToTarget();
  }
  mReprocessingFrames.removeAt(mReprocessingFrames.indexOfValue(ts));
  checkReprocessDone();
}

Fixed version (ground truth):
private void processNewReprocessImage(Message msg){
  boolean isBayer=(msg.arg1 == CAM_TYPE_BAYER);
  Image image=(Image)msg.obj;
  long ts=image.getTimestamp();
  Log.d(TAG,"String_Node_Str" + msg.arg1 + "String_Node_Str"+ ts);
  int frameCount=isBayer ? ++mReprocessedBayerCount : ++mReprocessedMonoCount;
  if (mDumpImages) {
    saveDebugImageAsJpeg(mMediaSaveService,image,isBayer,mNamedEntity,frameCount,ts / 1000000);
  }
  if (mDumpYUV) {
    saveDebugImageAsNV21(image,isBayer,mNamedEntity,frameCount,ts / 1000000);
  }
  if (!ClearSightNativeEngine.getInstance().hasReferenceImage(isBayer)) {
    ClearSightNativeEngine.getInstance().setReferenceImage(isBayer,image);
  }
 else {
    mClearsightRegisterHandler.obtainMessage(MSG_NEW_IMG,msg.arg1,0,msg.obj).sendToTarget();
  }
  mReprocessingFrames.removeAt(mReprocessingFrames.indexOfValue(ts));
  checkReprocessDone();
}
Program: 38153
Project: 38153
Buggy source:
public void saveDebugImageAsNV21(Image image,boolean isBayer,NamedEntity namedEntity,int count){
  if (image.getFormat() != ImageFormat.YUV_420_888) {
    Log.d(TAG,"String_Node_Str");
  }
  String type=isBayer ? "String_Node_Str" : "String_Node_Str";
  String title=String.format("String_Node_Str",namedEntity.title,image.getWidth(),image.getHeight(),type,count);
  YuvImage yuv=createYuvImage(image);
  String path=Storage.generateFilepath(title,"String_Node_Str");
  Storage.writeFile(path,yuv.getYuvData(),null,"String_Node_Str");
}

Fixed version (ground truth):
public void saveDebugImageAsNV21(Image image,boolean isBayer,NamedEntity namedEntity,int count,long ts){
  if (image.getFormat() != ImageFormat.YUV_420_888) {
    Log.d(TAG,"String_Node_Str");
  }
  String type=isBayer ? "String_Node_Str" : "String_Node_Str";
  String title=String.format("String_Node_Str",namedEntity.title,image.getWidth(),image.getHeight(),type,count,ts);
  YuvImage yuv=createYuvImage(image);
  String path=Storage.generateFilepath(title,"String_Node_Str");
  Storage.writeFile(path,yuv.getYuvData(),null,"String_Node_Str");
}
Program: 38154
Project: 38154
Buggy source:
public void saveDebugImageAsJpeg(MediaSaveService service,Image image,boolean isBayer,NamedEntity namedEntity,int count){
  if (image.getFormat() == ImageFormat.YUV_420_888)   saveDebugImageAsJpeg(service,createYuvImage(image),isBayer,namedEntity,count);
 else   if (image.getFormat() == ImageFormat.JPEG) {
    saveDebugImageAsJpeg(service,getJpegData(image),image.getWidth(),image.getHeight(),isBayer,namedEntity,count);
  }
}

Fixed version (ground truth):
public void saveDebugImageAsJpeg(MediaSaveService service,Image image,boolean isBayer,NamedEntity namedEntity,int count,long ts){
  if (image.getFormat() == ImageFormat.YUV_420_888)   saveDebugImageAsJpeg(service,createYuvImage(image),isBayer,namedEntity,count,ts);
 else   if (image.getFormat() == ImageFormat.JPEG) {
    saveDebugImageAsJpeg(service,getJpegData(image),image.getWidth(),image.getHeight(),isBayer,namedEntity,count,ts);
  }
}
Program: 38156
Project: 38156
Buggy source:
private void updateVideoSize(){
  String videoSize=mSettingsManager.getValue(SettingsManager.KEY_VIDEO_QUALITY);
  mVideoSize=parsePictureSize(videoSize);
}

Fixed version (ground truth):
private void updateVideoSize(){
  String videoSize=mSettingsManager.getValue(SettingsManager.KEY_VIDEO_QUALITY);
  mVideoSize=parsePictureSize(videoSize);
  Point screenSize=new Point();
  mActivity.getWindowManager().getDefaultDisplay().getSize(screenSize);
  Size[] prevSizes=mSettingsManager.getSupportedOutputSize(getMainCameraId(),MediaRecorder.class);
  mVideoPreviewSize=getOptimalPreviewSize(mVideoSize,prevSizes,screenSize.x,screenSize.y);
}
Program: 38157
Project: 38157
Buggy source:
private void updateFilterModeIcon(ListPreference scenePref,ListPreference hdrPref){
  if (scenePref == null || hdrPref == null)   return;
  if ((notSame(scenePref,CameraSettings.KEY_SCENE_MODE,Parameters.SCENE_MODE_AUTO)) || (notSame(hdrPref,CameraSettings.KEY_CAMERA_HDR,mSettingOff))) {
    buttonSetEnabled(mFilterModeSwitcher,false);
    changeFilterModeControlIcon("String_Node_Str");
  }
 else {
    buttonSetEnabled(mFilterModeSwitcher,true);
  }
}

Fixed version (ground truth):
private void updateFilterModeIcon(ListPreference scenePref,ListPreference hdrPref){
  if (scenePref == null || hdrPref == null)   return;
  if ((notSame(scenePref,CameraSettings.KEY_SCENE_MODE,Parameters.SCENE_MODE_AUTO)) || (notSame(hdrPref,CameraSettings.KEY_CAMERA_HDR,mSettingOff))) {
    buttonSetEnabled(mFilterModeSwitcher,false);
    changeFilterModeControlIcon("String_Node_Str");
  }
 else   if (same(scenePref,CameraSettings.KEY_SCENE_MODE,Parameters.SCENE_MODE_AUTO) && (same(hdrPref,CameraSettings.KEY_CAMERA_HDR,mSettingOff) || !hdrPref.getKey().equals(CameraSettings.KEY_CAMERA_HDR))) {
    buttonSetEnabled(mFilterModeSwitcher,true);
  }
}
Program: 38158
Project: 38158
Buggy source:
public void enableTouch(boolean enable){
  if (enable) {
    ((ShutterButton)mShutter).setPressed(false);
    mVideoShutter.setPressed(false);
    mSwitcher.setPressed(false);
    mMenu.setPressed(false);
    mMute.setPressed(false);
    mFrontBackSwitcher.setPressed(false);
    if (TsMakeupManager.HAS_TS_MAKEUP) {
      mTsMakeupSwitcher.setPressed(false);
    }
 else {
      mHdrSwitcher.setPressed(false);
    }
    mSceneModeSwitcher.setPressed(false);
    mFilterModeSwitcher.setPressed(false);
  }
 else {
    mTempEnabled[FILTER_MODE_INDEX]=mFilterModeSwitcher.isEnabled();
  }
  ((ShutterButton)mShutter).enableTouch(enable);
  mVideoShutter.setClickable(enable);
  ((ModuleSwitcher)mSwitcher).enableTouch(enable);
  mMenu.setEnabled(enable);
  mMute.setEnabled(enable);
  mFrontBackSwitcher.setEnabled(enable);
  if (TsMakeupManager.HAS_TS_MAKEUP) {
    mTsMakeupSwitcher.setEnabled(enable);
  }
 else {
    mHdrSwitcher.setEnabled(enable);
  }
  mSceneModeSwitcher.setEnabled(enable);
  mPreview.setEnabled(enable);
  mFilterModeSwitcher.setEnabled(enable && mTempEnabled[FILTER_MODE_INDEX]);
}

Fixed version (ground truth):
public void enableTouch(boolean enable){
  if (enable) {
    ((ShutterButton)mShutter).setPressed(false);
    mVideoShutter.setPressed(false);
    mSwitcher.setPressed(false);
    mMenu.setPressed(false);
    mMute.setPressed(false);
    mFrontBackSwitcher.setPressed(false);
    if (TsMakeupManager.HAS_TS_MAKEUP) {
      mTsMakeupSwitcher.setPressed(false);
    }
 else {
      mHdrSwitcher.setPressed(false);
    }
    mSceneModeSwitcher.setPressed(false);
  }
  ((ShutterButton)mShutter).enableTouch(enable);
  mVideoShutter.setClickable(enable);
  ((ModuleSwitcher)mSwitcher).enableTouch(enable);
  mMenu.setEnabled(enable);
  mMute.setEnabled(enable);
  mFrontBackSwitcher.setEnabled(enable);
  if (TsMakeupManager.HAS_TS_MAKEUP) {
    mTsMakeupSwitcher.setEnabled(enable);
  }
 else {
    mHdrSwitcher.setEnabled(enable);
  }
  mSceneModeSwitcher.setEnabled(enable);
  mPreview.setEnabled(enable);
}
Program: 38159
Project: 38159
Buggy source:
private void updateFilterModeIcon(ListPreference scenePref,ListPreference hdrPref){
  if (scenePref == null || hdrPref == null)   return;
  if ((notSame(scenePref,CameraSettings.KEY_SCENE_MODE,Parameters.SCENE_MODE_AUTO)) || (notSame(hdrPref,CameraSettings.KEY_CAMERA_HDR,mSettingOff))) {
    buttonSetEnabled(mFilterModeSwitcher,false);
    changeFilterModeControlIcon("String_Node_Str");
  }
 else {
    buttonSetEnabled(mFilterModeSwitcher,true);
  }
}

Fixed version (ground truth):
private void updateFilterModeIcon(ListPreference scenePref,ListPreference hdrPref){
  if (scenePref == null || hdrPref == null)   return;
  if ((notSame(scenePref,CameraSettings.KEY_SCENE_MODE,Parameters.SCENE_MODE_AUTO)) || (notSame(hdrPref,CameraSettings.KEY_CAMERA_HDR,mSettingOff))) {
    buttonSetEnabled(mFilterModeSwitcher,false);
    changeFilterModeControlIcon("String_Node_Str");
  }
 else   if (same(scenePref,CameraSettings.KEY_SCENE_MODE,Parameters.SCENE_MODE_AUTO) && (same(hdrPref,CameraSettings.KEY_CAMERA_HDR,mSettingOff) || !hdrPref.getKey().equals(CameraSettings.KEY_CAMERA_HDR))) {
    buttonSetEnabled(mFilterModeSwitcher,true);
  }
}
Program: 38160
Project: 38160
Buggy source:
public void enableTouch(boolean enable){
  if (enable) {
    ((ShutterButton)mShutter).setPressed(false);
    mVideoShutter.setPressed(false);
    mSwitcher.setPressed(false);
    mMenu.setPressed(false);
    mMute.setPressed(false);
    mFrontBackSwitcher.setPressed(false);
    if (TsMakeupManager.HAS_TS_MAKEUP) {
      mTsMakeupSwitcher.setPressed(false);
    }
 else {
      mHdrSwitcher.setPressed(false);
    }
    mSceneModeSwitcher.setPressed(false);
    mFilterModeSwitcher.setPressed(false);
  }
 else {
    mTempEnabled[FILTER_MODE_INDEX]=mFilterModeSwitcher.isEnabled();
  }
  ((ShutterButton)mShutter).enableTouch(enable);
  mVideoShutter.setClickable(enable);
  ((ModuleSwitcher)mSwitcher).enableTouch(enable);
  mMenu.setEnabled(enable);
  mMute.setEnabled(enable);
  mFrontBackSwitcher.setEnabled(enable);
  if (TsMakeupManager.HAS_TS_MAKEUP) {
    mTsMakeupSwitcher.setEnabled(enable);
  }
 else {
    mHdrSwitcher.setEnabled(enable);
  }
  mSceneModeSwitcher.setEnabled(enable);
  mPreview.setEnabled(enable);
  mFilterModeSwitcher.setEnabled(enable && mTempEnabled[FILTER_MODE_INDEX]);
}

Fixed version (ground truth):
public void enableTouch(boolean enable){
  if (enable) {
    ((ShutterButton)mShutter).setPressed(false);
    mVideoShutter.setPressed(false);
    mSwitcher.setPressed(false);
    mMenu.setPressed(false);
    mMute.setPressed(false);
    mFrontBackSwitcher.setPressed(false);
    if (TsMakeupManager.HAS_TS_MAKEUP) {
      mTsMakeupSwitcher.setPressed(false);
    }
 else {
      mHdrSwitcher.setPressed(false);
    }
    mSceneModeSwitcher.setPressed(false);
  }
  ((ShutterButton)mShutter).enableTouch(enable);
  mVideoShutter.setClickable(enable);
  ((ModuleSwitcher)mSwitcher).enableTouch(enable);
  mMenu.setEnabled(enable);
  mMute.setEnabled(enable);
  mFrontBackSwitcher.setEnabled(enable);
  if (TsMakeupManager.HAS_TS_MAKEUP) {
    mTsMakeupSwitcher.setEnabled(enable);
  }
 else {
    mHdrSwitcher.setEnabled(enable);
  }
  mSceneModeSwitcher.setEnabled(enable);
  mPreview.setEnabled(enable);
}
Program: 38162
Project: 38162
Buggy source:
@Override public boolean onScale(ScaleGestureDetector detector){
  final float sf=detector.getScaleFactor();
  float circle=mCircleSize * sf * sf;
  circle=Math.max(mMinCircle,circle);
  circle=Math.min(mMaxCircle,circle);
  if (mListener != null && circle != mCircleSize) {
    mCircleSize=circle;
    if (mCamera2) {
      float zoom=mZoomMinValue + (mZoomMaxValue - mZoomMinValue) / (mMaxCircle - mMinCircle) * (mCircleSize - mMinCircle);
      zoom=((int)(zoom * 10)) / 10.0f;
      mListener.onZoomValueChanged(zoom);
    }
 else {
      int zoom=mMinZoom + (int)((mCircleSize - mMinCircle) * (mMaxZoom - mMinZoom) / (mMaxCircle - mMinCircle));
      mListener.onZoomValueChanged(zoom);
    }
    update();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onScale(ScaleGestureDetector detector){
  final float sf=detector.getScaleFactor();
  float circle=mCircleSize * sf * sf;
  circle=Math.max(mMinCircle,circle);
  circle=Math.min(mMaxCircle,circle);
  if (mListener != null && circle != mCircleSize) {
    mCircleSize=circle;
    if (mCamera2) {
      float zoom=mZoomMinValue + (mZoomMaxValue - mZoomMinValue) / (mMaxCircle - mMinCircle) * (mCircleSize - mMinCircle);
      mListener.onZoomValueChanged(zoom);
    }
 else {
      int zoom=mMinZoom + (int)((mCircleSize - mMinCircle) * (mMaxZoom - mMinZoom) / (mMaxCircle - mMinCircle));
      mListener.onZoomValueChanged(zoom);
    }
    update();
  }
  return true;
}
Program: 38163
Project: 38163
Buggy source:
public void setZoom(float zoomValue){
  mCamera2=true;
  mZoomValue=zoomValue;
  mCircleSize=(int)(mMinCircle + (mMaxCircle - mMinCircle) * (mZoomValue - mZoomMinValue) / (mZoomMaxValue - mZoomMinValue));
}

Fixed version (ground truth):
public void setZoom(float zoomValue){
  mCamera2=true;
  mZoomSig=(int)zoomValue;
  mZoomFraction=(int)(zoomValue * 10) % 10;
  mCircleSize=(int)(mMinCircle + (mMaxCircle - mMinCircle) * (zoomValue - mZoomMinValue) / (mZoomMaxValue - mZoomMinValue));
}
Program: 38164
Project: 38164
Buggy source:
@Override public void onDraw(Canvas canvas){
  canvas.rotate(mOrientation,mCenterX,mCenterY);
  mPaint.setStrokeWidth(mInnerStroke);
  canvas.drawCircle(mCenterX,mCenterY,mMinCircle,mPaint);
  canvas.drawCircle(mCenterX,mCenterY,mMaxCircle,mPaint);
  canvas.drawLine(mCenterX - mMinCircle,mCenterY,mCenterX - mMaxCircle - 4,mCenterY,mPaint);
  mPaint.setStrokeWidth(mOuterStroke);
  canvas.drawCircle((float)mCenterX,(float)mCenterY,mCircleSize,mPaint);
  String txt=mZoomSig + "String_Node_Str" + mZoomFraction+ "String_Node_Str";
  if (mCamera2)   txt="String_Node_Str" + mZoomValue;
  mTextPaint.getTextBounds(txt,0,txt.length(),mTextBounds);
  canvas.drawText(txt,mCenterX - mTextBounds.centerX(),mCenterY - mTextBounds.centerY(),mTextPaint);
}

Fixed version (ground truth):
@Override public void onDraw(Canvas canvas){
  canvas.rotate(mOrientation,mCenterX,mCenterY);
  mPaint.setStrokeWidth(mInnerStroke);
  canvas.drawCircle(mCenterX,mCenterY,mMinCircle,mPaint);
  canvas.drawCircle(mCenterX,mCenterY,mMaxCircle,mPaint);
  canvas.drawLine(mCenterX - mMinCircle,mCenterY,mCenterX - mMaxCircle - 4,mCenterY,mPaint);
  mPaint.setStrokeWidth(mOuterStroke);
  canvas.drawCircle((float)mCenterX,(float)mCenterY,mCircleSize,mPaint);
  String txt=mZoomSig + "String_Node_Str" + mZoomFraction+ "String_Node_Str";
  mTextPaint.getTextBounds(txt,0,txt.length(),mTextBounds);
  canvas.drawText(txt,mCenterX - mTextBounds.centerX(),mCenterY - mTextBounds.centerY(),mTextPaint);
}
Program: 38165
Project: 38165
Buggy source:
public void initSwitchItem(final String prefKey,View switcher){
  final IconListPreference pref=(IconListPreference)mPreferenceGroup.findPreference(prefKey);
  if (pref == null)   return;
  int[] iconIds=pref.getLargeIconIds();
  int resid=-1;
  int index=pref.findIndexOfValue(pref.getValue());
  if (!pref.getUseSingleIcon() && iconIds != null) {
    resid=iconIds[index];
  }
 else {
    resid=pref.getSingleIcon();
  }
  ((ImageView)switcher).setImageResource(resid);
  switcher.setVisibility(View.VISIBLE);
  mPreferences.add(pref);
  mPreferenceMap.put(pref,switcher);
  switcher.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      IconListPreference pref=(IconListPreference)mPreferenceGroup.findPreference(prefKey);
      if (pref == null)       return;
      mUI.hideUI();
      int index=pref.findIndexOfValue(pref.getValue());
      CharSequence[] values=pref.getEntryValues();
      index=(index + 1) % values.length;
      pref.setValueIndex(index);
      ((ImageView)v).setImageResource(((IconListPreference)pref).getLargeIconIds()[index]);
      if (prefKey.equals(CameraSettings.KEY_CAMERA_ID))       mListener.onCameraPickerClicked(index);
      reloadPreference(pref);
      onSettingChanged(pref);
    }
  }
);
}

Fixed version (ground truth):
public void initSwitchItem(final String prefKey,View switcher){
  final IconListPreference pref=(IconListPreference)mPreferenceGroup.findPreference(prefKey);
  if (pref == null)   return;
  int[] iconIds=pref.getLargeIconIds();
  int resid=-1;
  int index=pref.findIndexOfValue(pref.getValue());
  if (!pref.getUseSingleIcon() && iconIds != null) {
    resid=iconIds[index];
  }
 else {
    resid=pref.getSingleIcon();
  }
  ((ImageView)switcher).setImageResource(resid);
  switcher.setVisibility(View.VISIBLE);
  mPreferences.add(pref);
  mPreferenceMap.put(pref,switcher);
  switcher.setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      IconListPreference pref=(IconListPreference)mPreferenceGroup.findPreference(prefKey);
      if (pref == null)       return;
      if (prefKey.equals(CameraSettings.KEY_CAMERA_ID)) {
        mUI.hideUI();
      }
      int index=pref.findIndexOfValue(pref.getValue());
      CharSequence[] values=pref.getEntryValues();
      index=(index + 1) % values.length;
      pref.setValueIndex(index);
      ((ImageView)v).setImageResource(((IconListPreference)pref).getLargeIconIds()[index]);
      if (prefKey.equals(CameraSettings.KEY_CAMERA_ID))       mListener.onCameraPickerClicked(index);
      reloadPreference(pref);
      onSettingChanged(pref);
    }
  }
);
}
Program: 38167
Project: 38167
Buggy source:
@Override public void init(CameraActivity activity,View parent){
  mActivity=activity;
  mRootView=parent;
  mPreferences=new ComboPreferences(mActivity);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),activity);
  mCameraId=getPreferredCameraId(mPreferences);
  mContentResolver=mActivity.getContentResolver();
  mIsImageCaptureIntent=isImageCaptureIntent();
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
  mUI=new PhotoUI(activity,this,parent);
  if (mOpenCameraThread == null) {
    mOpenCameraThread=new OpenCameraThread();
    mOpenCameraThread.start();
  }
  initializeControlByIntent();
  mQuickCapture=mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE,false);
  mLocationManager=new LocationManager(mActivity,mUI);
  mSensorManager=(SensorManager)(mActivity.getSystemService(Context.SENSOR_SERVICE));
  brightnessProgressBar=(ProgressBar)mRootView.findViewById(R.id.progress);
  if (brightnessProgressBar instanceof SeekBar) {
    SeekBar seeker=(SeekBar)brightnessProgressBar;
    seeker.setOnSeekBarChangeListener(mSeekListener);
  }
  brightnessProgressBar.setMax(MAXIMUM_BRIGHTNESS);
  mbrightness=mPreferences.getInt(CameraSettings.KEY_BRIGHTNESS,DEFAULT_BRIGHTNESS);
  brightnessProgressBar.setProgress(mbrightness);
  brightnessProgressBar.setVisibility(View.INVISIBLE);
  Storage.setSaveSDCard(mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH,"String_Node_Str").equals("String_Node_Str"));
}

Fixed version (ground truth):
@Override public void init(CameraActivity activity,View parent){
  mActivity=activity;
  mRootView=parent;
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),activity);
  mCameraId=getPreferredCameraId(mPreferences);
  mContentResolver=mActivity.getContentResolver();
  mIsImageCaptureIntent=isImageCaptureIntent();
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
  mUI=new PhotoUI(activity,this,parent);
  if (mOpenCameraThread == null) {
    mOpenCameraThread=new OpenCameraThread();
    mOpenCameraThread.start();
  }
  initializeControlByIntent();
  mQuickCapture=mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE,false);
  mLocationManager=new LocationManager(mActivity,mUI);
  mSensorManager=(SensorManager)(mActivity.getSystemService(Context.SENSOR_SERVICE));
  brightnessProgressBar=(ProgressBar)mRootView.findViewById(R.id.progress);
  if (brightnessProgressBar instanceof SeekBar) {
    SeekBar seeker=(SeekBar)brightnessProgressBar;
    seeker.setOnSeekBarChangeListener(mSeekListener);
  }
  brightnessProgressBar.setMax(MAXIMUM_BRIGHTNESS);
  mbrightness=mPreferences.getInt(CameraSettings.KEY_BRIGHTNESS,DEFAULT_BRIGHTNESS);
  brightnessProgressBar.setProgress(mbrightness);
  brightnessProgressBar.setVisibility(View.INVISIBLE);
  Storage.setSaveSDCard(mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH,"String_Node_Str").equals("String_Node_Str"));
}
Program: 38168
Project: 38168
Buggy source:
public void reinit(){
  mPreferences=new ComboPreferences(mActivity);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}

Fixed version (ground truth):
public void reinit(){
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}
Program: 38169
Project: 38169
Buggy source:
private SettingsManager(Context context){
  mListeners=new ArrayList<>();
  mCharacteristics=new ArrayList<>();
  mContext=context;
  mPreferences=new ComboPreferences(mContext);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mContext);
  CameraManager manager=(CameraManager)mContext.getSystemService(Context.CAMERA_SERVICE);
  try {
    String[] cameraIdList=manager.getCameraIdList();
    for (int i=0; i < cameraIdList.length; i++) {
      String cameraId=cameraIdList[i];
      CameraCharacteristics characteristics=manager.getCameraCharacteristics(cameraId);
      Byte monoOnly=0;
      try {
        monoOnly=characteristics.get(CaptureModule.MetaDataMonoOnlyKey);
      }
 catch (      Exception e) {
      }
      if (monoOnly == 1) {
        CaptureModule.MONO_ID=i;
        mIsMonoCameraPresent=true;
      }
      int facing=characteristics.get(CameraCharacteristics.LENS_FACING);
      if (facing == CameraCharacteristics.LENS_FACING_FRONT) {
        CaptureModule.FRONT_ID=i;
        mIsFrontCameraPresent=true;
      }
      mCharacteristics.add(i,characteristics);
    }
  }
 catch (  CameraAccessException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private SettingsManager(Context context){
  mListeners=new ArrayList<>();
  mCharacteristics=new ArrayList<>();
  mContext=context;
  mPreferences=ComboPreferences.get(mContext);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mContext);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mContext);
  CameraManager manager=(CameraManager)mContext.getSystemService(Context.CAMERA_SERVICE);
  try {
    String[] cameraIdList=manager.getCameraIdList();
    for (int i=0; i < cameraIdList.length; i++) {
      String cameraId=cameraIdList[i];
      CameraCharacteristics characteristics=manager.getCameraCharacteristics(cameraId);
      Byte monoOnly=0;
      try {
        monoOnly=characteristics.get(CaptureModule.MetaDataMonoOnlyKey);
      }
 catch (      Exception e) {
      }
      if (monoOnly == 1) {
        CaptureModule.MONO_ID=i;
        mIsMonoCameraPresent=true;
      }
      int facing=characteristics.get(CameraCharacteristics.LENS_FACING);
      if (facing == CameraCharacteristics.LENS_FACING_FRONT) {
        CaptureModule.FRONT_ID=i;
        mIsFrontCameraPresent=true;
      }
      mCharacteristics.add(i,characteristics);
    }
  }
 catch (  CameraAccessException e) {
    e.printStackTrace();
  }
}
Program: 38170
Project: 38170
Buggy source:
@Override public void init(CameraActivity activity,View root){
  mActivity=activity;
  mUI=new VideoUI(activity,this,root);
  mPreferences=new ComboPreferences(mActivity);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),activity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
  mOrientationManager=new OrientationManager(mActivity);
  CameraOpenThread cameraOpenThread=new CameraOpenThread();
  cameraOpenThread.start();
  mContentResolver=mActivity.getContentResolver();
  Storage.setSaveSDCard(mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH,"String_Node_Str").equals("String_Node_Str"));
  mSaveToSDCard=Storage.isSaveSDCard();
  mIsVideoCaptureIntent=isVideoCaptureIntent();
  initializeSurfaceView();
  try {
    cameraOpenThread.join();
    if (mCameraDevice == null) {
      return;
    }
  }
 catch (  InterruptedException ex) {
  }
  readVideoPreferences();
  mUI.setPrefChangedListener(this);
  mQuickCapture=mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE,false);
  mLocationManager=new LocationManager(mActivity,null);
  mUI.setOrientationIndicator(0,false);
  setDisplayOrientation();
  mUI.showTimeLapseUI(mCaptureTimeLapse);
  initializeVideoSnapshot();
  resizeForPreviewAspectRatio();
  initializeVideoControl();
  mPendingSwitchCameraId=-1;
}

Fixed version (ground truth):
@Override public void init(CameraActivity activity,View root){
  mActivity=activity;
  mUI=new VideoUI(activity,this,root);
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),activity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
  mOrientationManager=new OrientationManager(mActivity);
  CameraOpenThread cameraOpenThread=new CameraOpenThread();
  cameraOpenThread.start();
  mContentResolver=mActivity.getContentResolver();
  Storage.setSaveSDCard(mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH,"String_Node_Str").equals("String_Node_Str"));
  mSaveToSDCard=Storage.isSaveSDCard();
  mIsVideoCaptureIntent=isVideoCaptureIntent();
  initializeSurfaceView();
  try {
    cameraOpenThread.join();
    if (mCameraDevice == null) {
      return;
    }
  }
 catch (  InterruptedException ex) {
  }
  readVideoPreferences();
  mUI.setPrefChangedListener(this);
  mQuickCapture=mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE,false);
  mLocationManager=new LocationManager(mActivity,null);
  mUI.setOrientationIndicator(0,false);
  setDisplayOrientation();
  mUI.showTimeLapseUI(mCaptureTimeLapse);
  initializeVideoSnapshot();
  resizeForPreviewAspectRatio();
  initializeVideoControl();
  mPendingSwitchCameraId=-1;
}
Program: 38171
Project: 38171
Buggy source:
public void reinit(){
  mPreferences=new ComboPreferences(mActivity);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}

Fixed version (ground truth):
public void reinit(){
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}
Program: 38173
Project: 38173
Buggy source:
@Override public void onResumeBeforeSuper(){
  mPaused=false;
  mPreferences=new ComboPreferences(mActivity);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mPreferences.setLocalId(mActivity,getPreferredCameraId(mPreferences));
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}

Fixed version (ground truth):
@Override public void onResumeBeforeSuper(){
  mPaused=false;
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mPreferences.setLocalId(mActivity,getPreferredCameraId(mPreferences));
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}
Program: 38174
Project: 38174
Buggy source:
@Override public boolean onScale(ScaleGestureDetector detector){
  final float sf=detector.getScaleFactor();
  float circle=mCircleSize * sf * sf;
  circle=Math.max(mMinCircle,circle);
  circle=Math.min(mMaxCircle,circle);
  if (mListener != null && circle != mCircleSize) {
    mCircleSize=circle;
    if (mCamera2) {
      float zoom=mZoomMinValue + (mZoomMaxValue - mZoomMinValue) / (mMaxCircle - mMinCircle) * (mCircleSize - mMinCircle);
      zoom=((int)(zoom * 10)) / 10.0f;
      mListener.onZoomValueChanged(zoom);
    }
 else {
      int zoom=mMinZoom + (int)((mCircleSize - mMinCircle) * (mMaxZoom - mMinZoom) / (mMaxCircle - mMinCircle));
      mListener.onZoomValueChanged(zoom);
    }
    update();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean onScale(ScaleGestureDetector detector){
  final float sf=detector.getScaleFactor();
  float circle=mCircleSize * sf * sf;
  circle=Math.max(mMinCircle,circle);
  circle=Math.min(mMaxCircle,circle);
  if (mListener != null && circle != mCircleSize) {
    mCircleSize=circle;
    if (mCamera2) {
      float zoom=mZoomMinValue + (mZoomMaxValue - mZoomMinValue) / (mMaxCircle - mMinCircle) * (mCircleSize - mMinCircle);
      mListener.onZoomValueChanged(zoom);
    }
 else {
      int zoom=mMinZoom + (int)((mCircleSize - mMinCircle) * (mMaxZoom - mMinZoom) / (mMaxCircle - mMinCircle));
      mListener.onZoomValueChanged(zoom);
    }
    update();
  }
  return true;
}
Program: 38175
Project: 38175
Buggy source:
public void setZoom(float zoomValue){
  mCamera2=true;
  mZoomValue=zoomValue;
  mCircleSize=(int)(mMinCircle + (mMaxCircle - mMinCircle) * (mZoomValue - mZoomMinValue) / (mZoomMaxValue - mZoomMinValue));
}

Fixed version (ground truth):
public void setZoom(float zoomValue){
  mCamera2=true;
  mZoomSig=(int)zoomValue;
  mZoomFraction=(int)(zoomValue * 10) % 10;
  mCircleSize=(int)(mMinCircle + (mMaxCircle - mMinCircle) * (zoomValue - mZoomMinValue) / (mZoomMaxValue - mZoomMinValue));
}
Program: 38176
Project: 38176
Buggy source:
@Override public void onDraw(Canvas canvas){
  canvas.rotate(mOrientation,mCenterX,mCenterY);
  mPaint.setStrokeWidth(mInnerStroke);
  canvas.drawCircle(mCenterX,mCenterY,mMinCircle,mPaint);
  canvas.drawCircle(mCenterX,mCenterY,mMaxCircle,mPaint);
  canvas.drawLine(mCenterX - mMinCircle,mCenterY,mCenterX - mMaxCircle - 4,mCenterY,mPaint);
  mPaint.setStrokeWidth(mOuterStroke);
  canvas.drawCircle((float)mCenterX,(float)mCenterY,mCircleSize,mPaint);
  String txt=mZoomSig + "String_Node_Str" + mZoomFraction+ "String_Node_Str";
  if (mCamera2)   txt="String_Node_Str" + mZoomValue;
  mTextPaint.getTextBounds(txt,0,txt.length(),mTextBounds);
  canvas.drawText(txt,mCenterX - mTextBounds.centerX(),mCenterY - mTextBounds.centerY(),mTextPaint);
}

Fixed version (ground truth):
@Override public void onDraw(Canvas canvas){
  canvas.rotate(mOrientation,mCenterX,mCenterY);
  mPaint.setStrokeWidth(mInnerStroke);
  canvas.drawCircle(mCenterX,mCenterY,mMinCircle,mPaint);
  canvas.drawCircle(mCenterX,mCenterY,mMaxCircle,mPaint);
  canvas.drawLine(mCenterX - mMinCircle,mCenterY,mCenterX - mMaxCircle - 4,mCenterY,mPaint);
  mPaint.setStrokeWidth(mOuterStroke);
  canvas.drawCircle((float)mCenterX,(float)mCenterY,mCircleSize,mPaint);
  String txt=mZoomSig + "String_Node_Str" + mZoomFraction+ "String_Node_Str";
  mTextPaint.getTextBounds(txt,0,txt.length(),mTextBounds);
  canvas.drawText(txt,mCenterX - mTextBounds.centerX(),mCenterY - mTextBounds.centerY(),mTextPaint);
}
Program: 38177
Project: 38177
Buggy source:
@Override public void init(CameraActivity activity,View parent){
  mActivity=activity;
  mRootView=parent;
  mPreferences=new ComboPreferences(mActivity);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),activity);
  mCameraId=getPreferredCameraId(mPreferences);
  mContentResolver=mActivity.getContentResolver();
  mIsImageCaptureIntent=isImageCaptureIntent();
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
  mUI=new PhotoUI(activity,this,parent);
  if (mOpenCameraThread == null) {
    mOpenCameraThread=new OpenCameraThread();
    mOpenCameraThread.start();
  }
  initializeControlByIntent();
  mQuickCapture=mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE,false);
  mLocationManager=new LocationManager(mActivity,mUI);
  mSensorManager=(SensorManager)(mActivity.getSystemService(Context.SENSOR_SERVICE));
  brightnessProgressBar=(ProgressBar)mRootView.findViewById(R.id.progress);
  if (brightnessProgressBar instanceof SeekBar) {
    SeekBar seeker=(SeekBar)brightnessProgressBar;
    seeker.setOnSeekBarChangeListener(mSeekListener);
  }
  brightnessProgressBar.setMax(MAXIMUM_BRIGHTNESS);
  mbrightness=mPreferences.getInt(CameraSettings.KEY_BRIGHTNESS,DEFAULT_BRIGHTNESS);
  brightnessProgressBar.setProgress(mbrightness);
  brightnessProgressBar.setVisibility(View.INVISIBLE);
  Storage.setSaveSDCard(mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH,"String_Node_Str").equals("String_Node_Str"));
}

Fixed version (ground truth):
@Override public void init(CameraActivity activity,View parent){
  mActivity=activity;
  mRootView=parent;
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),activity);
  mCameraId=getPreferredCameraId(mPreferences);
  mContentResolver=mActivity.getContentResolver();
  mIsImageCaptureIntent=isImageCaptureIntent();
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
  mUI=new PhotoUI(activity,this,parent);
  if (mOpenCameraThread == null) {
    mOpenCameraThread=new OpenCameraThread();
    mOpenCameraThread.start();
  }
  initializeControlByIntent();
  mQuickCapture=mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE,false);
  mLocationManager=new LocationManager(mActivity,mUI);
  mSensorManager=(SensorManager)(mActivity.getSystemService(Context.SENSOR_SERVICE));
  brightnessProgressBar=(ProgressBar)mRootView.findViewById(R.id.progress);
  if (brightnessProgressBar instanceof SeekBar) {
    SeekBar seeker=(SeekBar)brightnessProgressBar;
    seeker.setOnSeekBarChangeListener(mSeekListener);
  }
  brightnessProgressBar.setMax(MAXIMUM_BRIGHTNESS);
  mbrightness=mPreferences.getInt(CameraSettings.KEY_BRIGHTNESS,DEFAULT_BRIGHTNESS);
  brightnessProgressBar.setProgress(mbrightness);
  brightnessProgressBar.setVisibility(View.INVISIBLE);
  Storage.setSaveSDCard(mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH,"String_Node_Str").equals("String_Node_Str"));
}
Program: 38178
Project: 38178
Buggy source:
public void reinit(){
  mPreferences=new ComboPreferences(mActivity);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}

Fixed version (ground truth):
public void reinit(){
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}
Program: 38179
Project: 38179
Buggy source:
private SettingsManager(Context context){
  mListeners=new ArrayList<>();
  mCharacteristics=new ArrayList<>();
  mContext=context;
  mPreferences=new ComboPreferences(mContext);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mContext);
  CameraManager manager=(CameraManager)mContext.getSystemService(Context.CAMERA_SERVICE);
  try {
    String[] cameraIdList=manager.getCameraIdList();
    for (int i=0; i < cameraIdList.length; i++) {
      String cameraId=cameraIdList[i];
      CameraCharacteristics characteristics=manager.getCameraCharacteristics(cameraId);
      Byte monoOnly=0;
      try {
        monoOnly=characteristics.get(CaptureModule.MetaDataMonoOnlyKey);
      }
 catch (      Exception e) {
      }
      if (monoOnly == 1) {
        CaptureModule.MONO_ID=i;
        mIsMonoCameraPresent=true;
      }
      int facing=characteristics.get(CameraCharacteristics.LENS_FACING);
      if (facing == CameraCharacteristics.LENS_FACING_FRONT) {
        CaptureModule.FRONT_ID=i;
        mIsFrontCameraPresent=true;
      }
      mCharacteristics.add(i,characteristics);
    }
  }
 catch (  CameraAccessException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
private SettingsManager(Context context){
  mListeners=new ArrayList<>();
  mCharacteristics=new ArrayList<>();
  mContext=context;
  mPreferences=ComboPreferences.get(mContext);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mContext);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mContext);
  CameraManager manager=(CameraManager)mContext.getSystemService(Context.CAMERA_SERVICE);
  try {
    String[] cameraIdList=manager.getCameraIdList();
    for (int i=0; i < cameraIdList.length; i++) {
      String cameraId=cameraIdList[i];
      CameraCharacteristics characteristics=manager.getCameraCharacteristics(cameraId);
      Byte monoOnly=0;
      try {
        monoOnly=characteristics.get(CaptureModule.MetaDataMonoOnlyKey);
      }
 catch (      Exception e) {
      }
      if (monoOnly == 1) {
        CaptureModule.MONO_ID=i;
        mIsMonoCameraPresent=true;
      }
      int facing=characteristics.get(CameraCharacteristics.LENS_FACING);
      if (facing == CameraCharacteristics.LENS_FACING_FRONT) {
        CaptureModule.FRONT_ID=i;
        mIsFrontCameraPresent=true;
      }
      mCharacteristics.add(i,characteristics);
    }
  }
 catch (  CameraAccessException e) {
    e.printStackTrace();
  }
}
Program: 38180
Project: 38180
Buggy source:
@Override public void init(CameraActivity activity,View root){
  mActivity=activity;
  mUI=new VideoUI(activity,this,root);
  mPreferences=new ComboPreferences(mActivity);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),activity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
  mOrientationManager=new OrientationManager(mActivity);
  CameraOpenThread cameraOpenThread=new CameraOpenThread();
  cameraOpenThread.start();
  mContentResolver=mActivity.getContentResolver();
  Storage.setSaveSDCard(mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH,"String_Node_Str").equals("String_Node_Str"));
  mSaveToSDCard=Storage.isSaveSDCard();
  mIsVideoCaptureIntent=isVideoCaptureIntent();
  initializeSurfaceView();
  try {
    cameraOpenThread.join();
    if (mCameraDevice == null) {
      return;
    }
  }
 catch (  InterruptedException ex) {
  }
  readVideoPreferences();
  mUI.setPrefChangedListener(this);
  mQuickCapture=mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE,false);
  mLocationManager=new LocationManager(mActivity,null);
  mUI.setOrientationIndicator(0,false);
  setDisplayOrientation();
  mUI.showTimeLapseUI(mCaptureTimeLapse);
  initializeVideoSnapshot();
  resizeForPreviewAspectRatio();
  initializeVideoControl();
  mPendingSwitchCameraId=-1;
}

Fixed version (ground truth):
@Override public void init(CameraActivity activity,View root){
  mActivity=activity;
  mUI=new VideoUI(activity,this,root);
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),activity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
  mOrientationManager=new OrientationManager(mActivity);
  CameraOpenThread cameraOpenThread=new CameraOpenThread();
  cameraOpenThread.start();
  mContentResolver=mActivity.getContentResolver();
  Storage.setSaveSDCard(mPreferences.getString(CameraSettings.KEY_CAMERA_SAVEPATH,"String_Node_Str").equals("String_Node_Str"));
  mSaveToSDCard=Storage.isSaveSDCard();
  mIsVideoCaptureIntent=isVideoCaptureIntent();
  initializeSurfaceView();
  try {
    cameraOpenThread.join();
    if (mCameraDevice == null) {
      return;
    }
  }
 catch (  InterruptedException ex) {
  }
  readVideoPreferences();
  mUI.setPrefChangedListener(this);
  mQuickCapture=mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE,false);
  mLocationManager=new LocationManager(mActivity,null);
  mUI.setOrientationIndicator(0,false);
  setDisplayOrientation();
  mUI.showTimeLapseUI(mCaptureTimeLapse);
  initializeVideoSnapshot();
  resizeForPreviewAspectRatio();
  initializeVideoControl();
  mPendingSwitchCameraId=-1;
}
Program: 38181
Project: 38181
Buggy source:
public void reinit(){
  mPreferences=new ComboPreferences(mActivity);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}

Fixed version (ground truth):
public void reinit(){
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mCameraId=getPreferredCameraId(mPreferences);
  mPreferences.setLocalId(mActivity,mCameraId);
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}
Program: 38183
Project: 38183
Buggy source:
@Override public void onResumeBeforeSuper(){
  mPaused=false;
  mPreferences=new ComboPreferences(mActivity);
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mPreferences.setLocalId(mActivity,getPreferredCameraId(mPreferences));
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}

Fixed version (ground truth):
@Override public void onResumeBeforeSuper(){
  mPaused=false;
  mPreferences=ComboPreferences.get(mActivity);
  if (mPreferences == null) {
    mPreferences=new ComboPreferences(mActivity);
  }
  CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal(),mActivity);
  mPreferences.setLocalId(mActivity,getPreferredCameraId(mPreferences));
  CameraSettings.upgradeLocalPreferences(mPreferences.getLocal());
}