nus-yam/ex-repair huggingface dataset:
Program: 184411
Project: 184411
Buggy source:
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || allEntries.length <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}

Fixed version (ground truth):
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || supported.size() <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}
Program: 184412
Project: 184412
Buggy source:
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || allEntries.length <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}

Fixed version (ground truth):
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || supported.size() <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}
Program: 184413
Project: 184413
Buggy source:
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || allEntries.length <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}

Fixed version (ground truth):
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || supported.size() <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}
Program: 184416
Project: 184416
Buggy source:
private Size getOptimalPreviewSize(List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.05;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  int targetHeight=mSurfaceView.getHeight();
  if (targetHeight <= 0) {
    WindowManager windowManager=(WindowManager)getSystemService(Context.WINDOW_SERVICE);
    targetHeight=windowManager.getDefaultDisplay().getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.v(TAG,"String_Node_Str");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  Log.v(TAG,String.format("String_Node_Str",optimalSize.width,optimalSize.height));
  return optimalSize;
}

Fixed version (ground truth):
private Size getOptimalPreviewSize(List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.05;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  Display display=getWindowManager().getDefaultDisplay();
  int targetHeight=Math.min(display.getHeight(),display.getWidth());
  if (targetHeight <= 0) {
    WindowManager windowManager=(WindowManager)getSystemService(Context.WINDOW_SERVICE);
    targetHeight=windowManager.getDefaultDisplay().getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.v(TAG,"String_Node_Str");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  Log.v(TAG,String.format("String_Node_Str",optimalSize.width,optimalSize.height));
  return optimalSize;
}
Program: 184417
Project: 184417
Buggy source:
private Size getOptimalPreviewSize(List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.05;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  int targetHeight=mSurfaceView.getHeight();
  if (targetHeight <= 0) {
    WindowManager windowManager=(WindowManager)getSystemService(Context.WINDOW_SERVICE);
    targetHeight=windowManager.getDefaultDisplay().getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.v(TAG,"String_Node_Str");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  Log.v(TAG,String.format("String_Node_Str",optimalSize.width,optimalSize.height));
  return optimalSize;
}

Fixed version (ground truth):
private Size getOptimalPreviewSize(List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.05;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  Display display=getWindowManager().getDefaultDisplay();
  int targetHeight=Math.min(display.getHeight(),display.getWidth());
  if (targetHeight <= 0) {
    WindowManager windowManager=(WindowManager)getSystemService(Context.WINDOW_SERVICE);
    targetHeight=windowManager.getDefaultDisplay().getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.v(TAG,"String_Node_Str");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  Log.v(TAG,String.format("String_Node_Str",optimalSize.width,optimalSize.height));
  return optimalSize;
}
Program: 184420
Project: 184420
Buggy source:
private Size getOptimalPreviewSize(List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.05;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  int targetHeight=mSurfaceView.getHeight();
  if (targetHeight <= 0) {
    WindowManager windowManager=(WindowManager)getSystemService(Context.WINDOW_SERVICE);
    targetHeight=windowManager.getDefaultDisplay().getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.v(TAG,"String_Node_Str");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  Log.v(TAG,String.format("String_Node_Str",optimalSize.width,optimalSize.height));
  return optimalSize;
}

Fixed version (ground truth):
private Size getOptimalPreviewSize(List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.05;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  Display display=getWindowManager().getDefaultDisplay();
  int targetHeight=Math.min(display.getHeight(),display.getWidth());
  if (targetHeight <= 0) {
    WindowManager windowManager=(WindowManager)getSystemService(Context.WINDOW_SERVICE);
    targetHeight=windowManager.getDefaultDisplay().getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.v(TAG,"String_Node_Str");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  Log.v(TAG,String.format("String_Node_Str",optimalSize.width,optimalSize.height));
  return optimalSize;
}
Program: 184422
Project: 184422
Buggy source:
private Size getOptimalPreviewSize(List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.05;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  int targetHeight=mSurfaceView.getHeight();
  if (targetHeight <= 0) {
    WindowManager windowManager=(WindowManager)getSystemService(Context.WINDOW_SERVICE);
    targetHeight=windowManager.getDefaultDisplay().getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.v(TAG,"String_Node_Str");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  Log.v(TAG,String.format("String_Node_Str",optimalSize.width,optimalSize.height));
  return optimalSize;
}

Fixed version (ground truth):
private Size getOptimalPreviewSize(List<Size> sizes,double targetRatio){
  final double ASPECT_TOLERANCE=0.05;
  if (sizes == null)   return null;
  Size optimalSize=null;
  double minDiff=Double.MAX_VALUE;
  Display display=getWindowManager().getDefaultDisplay();
  int targetHeight=Math.min(display.getHeight(),display.getWidth());
  if (targetHeight <= 0) {
    WindowManager windowManager=(WindowManager)getSystemService(Context.WINDOW_SERVICE);
    targetHeight=windowManager.getDefaultDisplay().getHeight();
  }
  for (  Size size : sizes) {
    double ratio=(double)size.width / size.height;
    if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE)     continue;
    if (Math.abs(size.height - targetHeight) < minDiff) {
      optimalSize=size;
      minDiff=Math.abs(size.height - targetHeight);
    }
  }
  if (optimalSize == null) {
    Log.v(TAG,"String_Node_Str");
    minDiff=Double.MAX_VALUE;
    for (    Size size : sizes) {
      if (Math.abs(size.height - targetHeight) < minDiff) {
        optimalSize=size;
        minDiff=Math.abs(size.height - targetHeight);
      }
    }
  }
  Log.v(TAG,String.format("String_Node_Str",optimalSize.width,optimalSize.height));
  return optimalSize;
}
Program: 184424
Project: 184424
Buggy source:
private void showOnScreenSettings(){
  if (mSettings == null) {
    mSettings=new OnScreenSettings(findViewById(R.id.camera_preview));
    CameraSettings helper=new CameraSettings(this,mParameters);
    mSettings.setPreferenceScreen(helper.getPreferenceScreen(R.xml.camera_preferences));
    mSettings.setOnVisibilityChangedListener(this);
    String sceneMode=mParameters.getSceneMode();
    boolean autoSceneMode=sceneMode == null || Parameters.SCENE_MODE_AUTO.equals(sceneMode);
    mScreenComplete=autoSceneMode;
    if (autoSceneMode) {
      mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE,null);
      mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE,null);
      mSettings.overrideSettings(CameraSettings.KEY_WHITE_BALANCE,null);
    }
 else {
      mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE,mParameters.getFlashMode());
      mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE,mParameters.getFocusMode());
      mSettings.overrideSettings(CameraSettings.KEY_WHITE_BALANCE,mParameters.getWhiteBalance());
    }
  }
  mSettings.setVisible(true);
}

Fixed version (ground truth):
private void showOnScreenSettings(){
  if (mSettings == null) {
    mSettings=new OnScreenSettings(findViewById(R.id.camera_preview));
    CameraSettings helper=new CameraSettings(this,mInitialParameters);
    mSettings.setPreferenceScreen(helper.getPreferenceScreen(R.xml.camera_preferences));
    mSettings.setOnVisibilityChangedListener(this);
    String sceneMode=mParameters.getSceneMode();
    if (sceneMode == null || Parameters.SCENE_MODE_AUTO.equals(sceneMode)) {
      mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE,null);
      mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE,null);
      mSettings.overrideSettings(CameraSettings.KEY_WHITE_BALANCE,null);
    }
 else {
      mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE,mParameters.getFlashMode());
      mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE,mParameters.getFocusMode());
      mSettings.overrideSettings(CameraSettings.KEY_WHITE_BALANCE,mParameters.getWhiteBalance());
    }
  }
  mSettings.setVisible(true);
}
Program: 184425
Project: 184425
Buggy source:
private void ensureCameraDevice() throws CameraHardwareException {
  if (mCameraDevice == null) {
    mCameraDevice=CameraHolder.instance().open();
  }
}

Fixed version (ground truth):
private void ensureCameraDevice() throws CameraHardwareException {
  if (mCameraDevice == null) {
    mCameraDevice=CameraHolder.instance().open();
    mInitialParameters=mCameraDevice.getParameters();
  }
}
Program: 184426
Project: 184426
Buggy source:
private void initPreference(PreferenceScreen screen){
  ListPreference videoDuration=(ListPreference)screen.findPreference(KEY_VIDEO_DURATION);
  ListPreference pictureSize=(ListPreference)screen.findPreference(KEY_PICTURE_SIZE);
  ListPreference whiteBalance=(ListPreference)screen.findPreference(KEY_WHITE_BALANCE);
  ListPreference colorEffect=(ListPreference)screen.findPreference(KEY_COLOR_EFFECT);
  ListPreference sceneMode=(ListPreference)screen.findPreference(KEY_SCENE_MODE);
  ListPreference flashMode=(ListPreference)screen.findPreference(KEY_FLASH_MODE);
  if (videoDuration != null) {
    CharSequence[] entries=videoDuration.getEntries();
    entries[0]=String.format(entries[0].toString(),MMS_VIDEO_DURATION);
  }
  if (pictureSize != null) {
    filterUnsupportedOptions(screen,pictureSize,sizeListToStringList(mParameters.getSupportedPictureSizes()));
  }
  if (whiteBalance != null) {
    filterUnsupportedOptions(screen,whiteBalance,mParameters.getSupportedWhiteBalance());
  }
  if (colorEffect != null) {
    filterUnsupportedOptions(screen,colorEffect,mParameters.getSupportedColorEffects());
  }
  if (sceneMode != null) {
    filterUnsupportedOptions(screen,sceneMode,mParameters.getSupportedSceneModes());
  }
  if (flashMode != null) {
    filterUnsupportedOptions(screen,flashMode,mParameters.getSupportedFlashModes());
  }
}

Fixed version (ground truth):
private void initPreference(PreferenceScreen screen){
  ListPreference videoDuration=(ListPreference)screen.findPreference(KEY_VIDEO_DURATION);
  ListPreference pictureSize=(ListPreference)screen.findPreference(KEY_PICTURE_SIZE);
  ListPreference whiteBalance=(ListPreference)screen.findPreference(KEY_WHITE_BALANCE);
  ListPreference colorEffect=(ListPreference)screen.findPreference(KEY_COLOR_EFFECT);
  ListPreference sceneMode=(ListPreference)screen.findPreference(KEY_SCENE_MODE);
  ListPreference flashMode=(ListPreference)screen.findPreference(KEY_FLASH_MODE);
  ListPreference focusMode=(ListPreference)screen.findPreference(KEY_FOCUS_MODE);
  if (videoDuration != null) {
    CharSequence[] entries=videoDuration.getEntries();
    entries[0]=String.format(entries[0].toString(),MMS_VIDEO_DURATION);
  }
  if (pictureSize != null) {
    filterUnsupportedOptions(screen,pictureSize,sizeListToStringList(mParameters.getSupportedPictureSizes()));
  }
  if (whiteBalance != null) {
    filterUnsupportedOptions(screen,whiteBalance,mParameters.getSupportedWhiteBalance());
  }
  if (colorEffect != null) {
    filterUnsupportedOptions(screen,colorEffect,mParameters.getSupportedColorEffects());
  }
  if (sceneMode != null) {
    filterUnsupportedOptions(screen,sceneMode,mParameters.getSupportedSceneModes());
  }
  if (flashMode != null) {
    filterUnsupportedOptions(screen,flashMode,mParameters.getSupportedFlashModes());
  }
  if (focusMode != null) {
    filterUnsupportedOptions(screen,focusMode,mParameters.getSupportedFocusModes());
  }
}
Program: 184427
Project: 184427
Buggy source:
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  if (supported == null) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntries=pref.getEntries();
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}

Fixed version (ground truth):
private void filterUnsupportedOptions(PreferenceScreen screen,ListPreference pref,List<String> supported){
  CharSequence[] allEntries=pref.getEntries();
  if (supported == null || allEntries.length <= 1) {
    removePreference(screen,pref);
    return;
  }
  CharSequence[] allEntryValues=pref.getEntryValues();
  Drawable[] allIcons=(pref instanceof IconListPreference) ? ((IconListPreference)pref).getIcons() : null;
  ArrayList<CharSequence> entries=new ArrayList<CharSequence>();
  ArrayList<CharSequence> entryValues=new ArrayList<CharSequence>();
  ArrayList<Drawable> icons=allIcons == null ? null : new ArrayList<Drawable>();
  for (int i=0, len=allEntryValues.length; i < len; i++) {
    if (supported.indexOf(allEntryValues[i].toString()) != NOT_FOUND) {
      entries.add(allEntries[i]);
      entryValues.add(allEntryValues[i]);
      if (allIcons != null)       icons.add(allIcons[i]);
    }
  }
  int size=entries.size();
  pref.setEntries(entries.toArray(new CharSequence[size]));
  pref.setEntryValues(entryValues.toArray(new CharSequence[size]));
  if (allIcons != null) {
    ((IconListPreference)pref).setIcons(icons.toArray(new Drawable[size]));
  }
  String value=pref.getValue();
  if (pref.findIndexOfValue(value) == NOT_FOUND) {
    pref.setValueIndex(0);
  }
}
Program: 184428
Project: 184428
Buggy source:
public static Uri addImage(ContentResolver cr,String title,long dateTaken,Location location,int orientation,String directory,String filename,Bitmap source,byte[] jpegData){
  OutputStream outputStream=null;
  File file=new File(directory,filename);
  try {
    file.mkdirs();
    outputStream=new FileOutputStream(file);
    if (source != null) {
      source.compress(CompressFormat.JPEG,75,outputStream);
    }
 else {
      outputStream.write(jpegData);
    }
  }
 catch (  FileNotFoundException ex) {
    Log.w(TAG,ex);
    return null;
  }
catch (  IOException ex) {
    Log.w(TAG,ex);
    return null;
  }
 finally {
    Util.closeSilently(outputStream);
  }
  ContentValues values=new ContentValues(7);
  values.put(Images.Media.TITLE,title);
  values.put(Images.Media.DISPLAY_NAME,filename);
  values.put(Images.Media.DATE_TAKEN,dateTaken);
  values.put(Images.Media.MIME_TYPE,"String_Node_Str");
  values.put(Images.Media.ORIENTATION,orientation);
  values.put(Images.Media.DATA,directory + "String_Node_Str" + filename);
  if (location != null) {
    values.put(Images.Media.LATITUDE,location.getLatitude());
    values.put(Images.Media.LONGITUDE,location.getLongitude());
  }
  return cr.insert(STORAGE_URI,values);
}

Fixed version (ground truth):
public static Uri addImage(ContentResolver cr,String title,long dateTaken,Location location,int orientation,String directory,String filename,Bitmap source,byte[] jpegData){
  OutputStream outputStream=null;
  String filePath=directory + "String_Node_Str" + filename;
  try {
    File dir=new File(directory);
    if (!dir.exists())     dir.mkdirs();
    File file=new File(directory,filename);
    outputStream=new FileOutputStream(file);
    if (source != null) {
      source.compress(CompressFormat.JPEG,75,outputStream);
    }
 else {
      outputStream.write(jpegData);
    }
  }
 catch (  FileNotFoundException ex) {
    Log.w(TAG,ex);
    return null;
  }
catch (  IOException ex) {
    Log.w(TAG,ex);
    return null;
  }
 finally {
    Util.closeSilently(outputStream);
  }
  ContentValues values=new ContentValues(7);
  values.put(Images.Media.TITLE,title);
  values.put(Images.Media.DISPLAY_NAME,filename);
  values.put(Images.Media.DATE_TAKEN,dateTaken);
  values.put(Images.Media.MIME_TYPE,"String_Node_Str");
  values.put(Images.Media.ORIENTATION,orientation);
  values.put(Images.Media.DATA,filePath);
  if (location != null) {
    values.put(Images.Media.LATITUDE,location.getLatitude());
    values.put(Images.Media.LONGITUDE,location.getLongitude());
  }
  return cr.insert(STORAGE_URI,values);
}
Program: 184429
Project: 184429
Buggy source:
public static Uri addImage(ContentResolver cr,String title,long dateTaken,Location location,int orientation,String directory,String filename,Bitmap source,byte[] jpegData){
  OutputStream outputStream=null;
  File file=new File(directory,filename);
  try {
    file.mkdirs();
    outputStream=new FileOutputStream(file);
    if (source != null) {
      source.compress(CompressFormat.JPEG,75,outputStream);
    }
 else {
      outputStream.write(jpegData);
    }
  }
 catch (  FileNotFoundException ex) {
    Log.w(TAG,ex);
    return null;
  }
catch (  IOException ex) {
    Log.w(TAG,ex);
    return null;
  }
 finally {
    Util.closeSilently(outputStream);
  }
  ContentValues values=new ContentValues(7);
  values.put(Images.Media.TITLE,title);
  values.put(Images.Media.DISPLAY_NAME,filename);
  values.put(Images.Media.DATE_TAKEN,dateTaken);
  values.put(Images.Media.MIME_TYPE,"String_Node_Str");
  values.put(Images.Media.ORIENTATION,orientation);
  values.put(Images.Media.DATA,directory + "String_Node_Str" + filename);
  if (location != null) {
    values.put(Images.Media.LATITUDE,location.getLatitude());
    values.put(Images.Media.LONGITUDE,location.getLongitude());
  }
  return cr.insert(STORAGE_URI,values);
}

Fixed version (ground truth):
public static Uri addImage(ContentResolver cr,String title,long dateTaken,Location location,int orientation,String directory,String filename,Bitmap source,byte[] jpegData){
  OutputStream outputStream=null;
  String filePath=directory + "String_Node_Str" + filename;
  try {
    File dir=new File(directory);
    if (!dir.exists())     dir.mkdirs();
    File file=new File(directory,filename);
    outputStream=new FileOutputStream(file);
    if (source != null) {
      source.compress(CompressFormat.JPEG,75,outputStream);
    }
 else {
      outputStream.write(jpegData);
    }
  }
 catch (  FileNotFoundException ex) {
    Log.w(TAG,ex);
    return null;
  }
catch (  IOException ex) {
    Log.w(TAG,ex);
    return null;
  }
 finally {
    Util.closeSilently(outputStream);
  }
  ContentValues values=new ContentValues(7);
  values.put(Images.Media.TITLE,title);
  values.put(Images.Media.DISPLAY_NAME,filename);
  values.put(Images.Media.DATE_TAKEN,dateTaken);
  values.put(Images.Media.MIME_TYPE,"String_Node_Str");
  values.put(Images.Media.ORIENTATION,orientation);
  values.put(Images.Media.DATA,filePath);
  if (location != null) {
    values.put(Images.Media.LATITUDE,location.getLatitude());
    values.put(Images.Media.LONGITUDE,location.getLongitude());
  }
  return cr.insert(STORAGE_URI,values);
}
Program: 184430
Project: 184430
Buggy source:
public static Uri addImage(ContentResolver cr,String title,long dateTaken,Location location,int orientation,String directory,String filename,Bitmap source,byte[] jpegData){
  OutputStream outputStream=null;
  File file=new File(directory,filename);
  try {
    file.mkdirs();
    outputStream=new FileOutputStream(file);
    if (source != null) {
      source.compress(CompressFormat.JPEG,75,outputStream);
    }
 else {
      outputStream.write(jpegData);
    }
  }
 catch (  FileNotFoundException ex) {
    Log.w(TAG,ex);
    return null;
  }
catch (  IOException ex) {
    Log.w(TAG,ex);
    return null;
  }
 finally {
    Util.closeSilently(outputStream);
  }
  ContentValues values=new ContentValues(7);
  values.put(Images.Media.TITLE,title);
  values.put(Images.Media.DISPLAY_NAME,filename);
  values.put(Images.Media.DATE_TAKEN,dateTaken);
  values.put(Images.Media.MIME_TYPE,"String_Node_Str");
  values.put(Images.Media.ORIENTATION,orientation);
  values.put(Images.Media.DATA,directory + "String_Node_Str" + filename);
  if (location != null) {
    values.put(Images.Media.LATITUDE,location.getLatitude());
    values.put(Images.Media.LONGITUDE,location.getLongitude());
  }
  return cr.insert(STORAGE_URI,values);
}

Fixed version (ground truth):
public static Uri addImage(ContentResolver cr,String title,long dateTaken,Location location,int orientation,String directory,String filename,Bitmap source,byte[] jpegData){
  OutputStream outputStream=null;
  String filePath=directory + "String_Node_Str" + filename;
  try {
    File dir=new File(directory);
    if (!dir.exists())     dir.mkdirs();
    File file=new File(directory,filename);
    outputStream=new FileOutputStream(file);
    if (source != null) {
      source.compress(CompressFormat.JPEG,75,outputStream);
    }
 else {
      outputStream.write(jpegData);
    }
  }
 catch (  FileNotFoundException ex) {
    Log.w(TAG,ex);
    return null;
  }
catch (  IOException ex) {
    Log.w(TAG,ex);
    return null;
  }
 finally {
    Util.closeSilently(outputStream);
  }
  ContentValues values=new ContentValues(7);
  values.put(Images.Media.TITLE,title);
  values.put(Images.Media.DISPLAY_NAME,filename);
  values.put(Images.Media.DATE_TAKEN,dateTaken);
  values.put(Images.Media.MIME_TYPE,"String_Node_Str");
  values.put(Images.Media.ORIENTATION,orientation);
  values.put(Images.Media.DATA,filePath);
  if (location != null) {
    values.put(Images.Media.LATITUDE,location.getLatitude());
    values.put(Images.Media.LONGITUDE,location.getLongitude());
  }
  return cr.insert(STORAGE_URI,values);
}
Program: 184431
Project: 184431
Buggy source:
private void initPreference(PreferenceScreen screen){
  ListPreference videoDuration=(ListPreference)screen.findPreference(KEY_VIDEO_DURATION);
  ListPreference pictureSize=(ListPreference)screen.findPreference(KEY_PICTURE_SIZE);
  ListPreference whiteBalance=(ListPreference)screen.findPreference(KEY_WHITE_BALANCE);
  ListPreference colorEffect=(ListPreference)screen.findPreference(KEY_COLOR_EFFECT);
  ListPreference sceneMode=(ListPreference)screen.findPreference(KEY_SCENE_MODE);
  if (videoDuration != null) {
    CharSequence[] entries=videoDuration.getEntries();
    entries[0]=String.format(entries[0].toString(),MMS_VIDEO_DURATION);
  }
  if (pictureSize != null) {
    filterUnsupportedOptions(screen,pictureSize,sizeListToStringList(mParameters.getSupportedPictureSizes()));
  }
  if (whiteBalance != null) {
    filterUnsupportedOptions(screen,whiteBalance,mParameters.getSupportedWhiteBalance());
  }
  if (colorEffect != null) {
    filterUnsupportedOptions(screen,colorEffect,mParameters.getSupportedColorEffects());
  }
  if (sceneMode != null) {
    filterUnsupportedOptions(screen,sceneMode,mParameters.getSupportedSceneModes());
  }
}

Fixed version (ground truth):
private void initPreference(PreferenceScreen screen){
  ListPreference videoDuration=(ListPreference)screen.findPreference(KEY_VIDEO_DURATION);
  ListPreference pictureSize=(ListPreference)screen.findPreference(KEY_PICTURE_SIZE);
  ListPreference whiteBalance=(ListPreference)screen.findPreference(KEY_WHITE_BALANCE);
  ListPreference colorEffect=(ListPreference)screen.findPreference(KEY_COLOR_EFFECT);
  ListPreference sceneMode=(ListPreference)screen.findPreference(KEY_SCENE_MODE);
  ListPreference flashMode=(ListPreference)screen.findPreference(KEY_FLASH_MODE);
  if (videoDuration != null) {
    CharSequence[] entries=videoDuration.getEntries();
    entries[0]=String.format(entries[0].toString(),MMS_VIDEO_DURATION);
  }
  if (pictureSize != null) {
    filterUnsupportedOptions(screen,pictureSize,sizeListToStringList(mParameters.getSupportedPictureSizes()));
  }
  if (whiteBalance != null) {
    filterUnsupportedOptions(screen,whiteBalance,mParameters.getSupportedWhiteBalance());
  }
  if (colorEffect != null) {
    filterUnsupportedOptions(screen,colorEffect,mParameters.getSupportedColorEffects());
  }
  if (sceneMode != null) {
    filterUnsupportedOptions(screen,sceneMode,mParameters.getSupportedSceneModes());
  }
  if (flashMode != null) {
    filterUnsupportedOptions(screen,flashMode,mParameters.getSupportedFlashModes());
  }
}
Program: 184432
Project: 184432
Buggy source:
private void initPreference(PreferenceScreen screen){
  ListPreference videoDuration=(ListPreference)screen.findPreference(KEY_VIDEO_DURATION);
  ListPreference pictureSize=(ListPreference)screen.findPreference(KEY_PICTURE_SIZE);
  ListPreference whiteBalance=(ListPreference)screen.findPreference(KEY_WHITE_BALANCE);
  ListPreference colorEffect=(ListPreference)screen.findPreference(KEY_COLOR_EFFECT);
  ListPreference sceneMode=(ListPreference)screen.findPreference(KEY_SCENE_MODE);
  if (videoDuration != null) {
    CharSequence[] entries=videoDuration.getEntries();
    entries[0]=String.format(entries[0].toString(),MMS_VIDEO_DURATION);
  }
  if (pictureSize != null) {
    filterUnsupportedOptions(screen,pictureSize,sizeListToStringList(mParameters.getSupportedPictureSizes()));
  }
  if (whiteBalance != null) {
    filterUnsupportedOptions(screen,whiteBalance,mParameters.getSupportedWhiteBalance());
  }
  if (colorEffect != null) {
    filterUnsupportedOptions(screen,colorEffect,mParameters.getSupportedColorEffects());
  }
  if (sceneMode != null) {
    filterUnsupportedOptions(screen,sceneMode,mParameters.getSupportedSceneModes());
  }
}

Fixed version (ground truth):
private void initPreference(PreferenceScreen screen){
  ListPreference videoDuration=(ListPreference)screen.findPreference(KEY_VIDEO_DURATION);
  ListPreference pictureSize=(ListPreference)screen.findPreference(KEY_PICTURE_SIZE);
  ListPreference whiteBalance=(ListPreference)screen.findPreference(KEY_WHITE_BALANCE);
  ListPreference colorEffect=(ListPreference)screen.findPreference(KEY_COLOR_EFFECT);
  ListPreference sceneMode=(ListPreference)screen.findPreference(KEY_SCENE_MODE);
  ListPreference flashMode=(ListPreference)screen.findPreference(KEY_FLASH_MODE);
  if (videoDuration != null) {
    CharSequence[] entries=videoDuration.getEntries();
    entries[0]=String.format(entries[0].toString(),MMS_VIDEO_DURATION);
  }
  if (pictureSize != null) {
    filterUnsupportedOptions(screen,pictureSize,sizeListToStringList(mParameters.getSupportedPictureSizes()));
  }
  if (whiteBalance != null) {
    filterUnsupportedOptions(screen,whiteBalance,mParameters.getSupportedWhiteBalance());
  }
  if (colorEffect != null) {
    filterUnsupportedOptions(screen,colorEffect,mParameters.getSupportedColorEffects());
  }
  if (sceneMode != null) {
    filterUnsupportedOptions(screen,sceneMode,mParameters.getSupportedSceneModes());
  }
  if (flashMode != null) {
    filterUnsupportedOptions(screen,flashMode,mParameters.getSupportedFlashModes());
  }
}
Program: 184433
Project: 184433
Buggy source:
private void initPreference(PreferenceScreen screen){
  ListPreference videoDuration=(ListPreference)screen.findPreference(KEY_VIDEO_DURATION);
  ListPreference pictureSize=(ListPreference)screen.findPreference(KEY_PICTURE_SIZE);
  ListPreference whiteBalance=(ListPreference)screen.findPreference(KEY_WHITE_BALANCE);
  ListPreference colorEffect=(ListPreference)screen.findPreference(KEY_COLOR_EFFECT);
  ListPreference sceneMode=(ListPreference)screen.findPreference(KEY_SCENE_MODE);
  if (videoDuration != null) {
    CharSequence[] entries=videoDuration.getEntries();
    entries[0]=String.format(entries[0].toString(),MMS_VIDEO_DURATION);
  }
  if (pictureSize != null) {
    filterUnsupportedOptions(screen,pictureSize,sizeListToStringList(mParameters.getSupportedPictureSizes()));
  }
  if (whiteBalance != null) {
    filterUnsupportedOptions(screen,whiteBalance,mParameters.getSupportedWhiteBalance());
  }
  if (colorEffect != null) {
    filterUnsupportedOptions(screen,colorEffect,mParameters.getSupportedColorEffects());
  }
  if (sceneMode != null) {
    filterUnsupportedOptions(screen,sceneMode,mParameters.getSupportedSceneModes());
  }
}

Fixed version (ground truth):
private void initPreference(PreferenceScreen screen){
  ListPreference videoDuration=(ListPreference)screen.findPreference(KEY_VIDEO_DURATION);
  ListPreference pictureSize=(ListPreference)screen.findPreference(KEY_PICTURE_SIZE);
  ListPreference whiteBalance=(ListPreference)screen.findPreference(KEY_WHITE_BALANCE);
  ListPreference colorEffect=(ListPreference)screen.findPreference(KEY_COLOR_EFFECT);
  ListPreference sceneMode=(ListPreference)screen.findPreference(KEY_SCENE_MODE);
  ListPreference flashMode=(ListPreference)screen.findPreference(KEY_FLASH_MODE);
  if (videoDuration != null) {
    CharSequence[] entries=videoDuration.getEntries();
    entries[0]=String.format(entries[0].toString(),MMS_VIDEO_DURATION);
  }
  if (pictureSize != null) {
    filterUnsupportedOptions(screen,pictureSize,sizeListToStringList(mParameters.getSupportedPictureSizes()));
  }
  if (whiteBalance != null) {
    filterUnsupportedOptions(screen,whiteBalance,mParameters.getSupportedWhiteBalance());
  }
  if (colorEffect != null) {
    filterUnsupportedOptions(screen,colorEffect,mParameters.getSupportedColorEffects());
  }
  if (sceneMode != null) {
    filterUnsupportedOptions(screen,sceneMode,mParameters.getSupportedSceneModes());
  }
  if (flashMode != null) {
    filterUnsupportedOptions(screen,flashMode,mParameters.getSupportedFlashModes());
  }
}
Program: 184434
Project: 184434
Buggy source:
private void startPreview() throws CameraHardwareException {
  if (mPausing || isFinishing())   return;
  ensureCameraDevice();
  if (mPreviewing)   stopPreview();
  setPreviewDisplay(mSurfaceHolder);
  setCameraParameter();
  final long wallTimeStart=SystemClock.elapsedRealtime();
  final long threadTimeStart=Debug.threadCpuTimeNanos();
  mCameraDevice.setOneShotPreviewCallback(mOneShotPreviewCallback);
  mCameraDevice.setErrorCallback(mErrorCallback);
  try {
    Log.v(TAG,"String_Node_Str");
    mCameraDevice.startPreview();
  }
 catch (  Throwable ex) {
    closeCamera();
    throw new RuntimeException("String_Node_Str",ex);
  }
  mPreviewing=true;
  mStatus=IDLE;
  long threadTimeEnd=Debug.threadCpuTimeNanos();
  long wallTimeEnd=SystemClock.elapsedRealtime();
  if ((wallTimeEnd - wallTimeStart) > 3000) {
    Log.w(TAG,"String_Node_Str" + (wallTimeEnd - wallTimeStart) + "String_Node_Str"+ (threadTimeEnd - threadTimeStart) / 1000000 + "String_Node_Str");
  }
}

Fixed version (ground truth):
private void startPreview() throws CameraHardwareException {
  if (mPausing || isFinishing())   return;
  ensureCameraDevice();
  if (mPreviewing)   stopPreview();
  setPreviewDisplay(mSurfaceHolder);
  setCameraParameters();
  final long wallTimeStart=SystemClock.elapsedRealtime();
  final long threadTimeStart=Debug.threadCpuTimeNanos();
  mCameraDevice.setOneShotPreviewCallback(mOneShotPreviewCallback);
  mCameraDevice.setErrorCallback(mErrorCallback);
  try {
    Log.v(TAG,"String_Node_Str");
    mCameraDevice.startPreview();
  }
 catch (  Throwable ex) {
    closeCamera();
    throw new RuntimeException("String_Node_Str",ex);
  }
  mPreviewing=true;
  mStatus=IDLE;
  long threadTimeEnd=Debug.threadCpuTimeNanos();
  long wallTimeEnd=SystemClock.elapsedRealtime();
  if ((wallTimeEnd - wallTimeStart) > 3000) {
    Log.w(TAG,"String_Node_Str" + (wallTimeEnd - wallTimeStart) + "String_Node_Str"+ (threadTimeEnd - threadTimeStart) / 1000000 + "String_Node_Str");
  }
}
Program: 184435
Project: 184435
Buggy source:
public void onZoomUpdate(int zoomLevel,android.hardware.Camera camera){
  mZoomValue=(double)zoomLevel / 1000;
  mZooming=false;
}

Fixed version (ground truth):
public void onZoomUpdate(int zoomLevel,android.hardware.Camera camera){
  mZoomValue=(double)zoomLevel / 1000;
  Log.v(TAG,"String_Node_Str" + zoomLevel);
  updateZoomButtonsEnabled();
}
Program: 184436
Project: 184436
Buggy source:
private void initializeZoom(){
  String zoomState=mParameters.get(PARM_ZOOM_STATE);
  if (zoomState == null)   return;
  mZoomValue=Double.parseDouble(mParameters.get(PARM_ZOOM_TO_LEVEL));
  mZoomMax=Double.parseDouble(mParameters.get(PARM_ZOOM_MAX));
  mZoomStep=Double.parseDouble(mParameters.get(PARM_ZOOM_STEP));
  mParameters.set(PARM_ZOOM_SPEED,ZOOM_SPEED);
  mCameraDevice.setParameters(mParameters);
  mGestureDetector=new GestureDetector(this,new ZoomGestureListener());
  mCameraDevice.setZoomCallback(mZoomCallback);
  mZoomButtons=new ZoomButtonsController(mSurfaceView);
  mZoomButtons.setAutoDismissed(true);
  mZoomButtons.setZoomSpeed(100);
  mZoomButtons.setOnZoomListener(new ZoomButtonsController.OnZoomListener(){
    public void onVisibilityChanged(    boolean visible){
      if (visible) {
        updateZoomButtonsEnabled();
      }
    }
    public void onZoom(    boolean zoomIn){
      if (mZooming)       return;
      if (zoomIn) {
        if (mZoomValue < mZoomMax) {
          mZoomValue+=mZoomStep;
          zoomToLevel(ZOOM_CONTINUOUS);
        }
      }
 else {
        if (mZoomValue > ZOOM_MIN) {
          mZoomValue-=mZoomStep;
          zoomToLevel(ZOOM_CONTINUOUS);
        }
      }
      updateZoomButtonsEnabled();
    }
  }
);
}

Fixed version (ground truth):
private void initializeZoom(){
  String zoomState=mParameters.get(PARM_ZOOM_STATE);
  if (zoomState == null)   return;
  mZoomValue=Double.parseDouble(mParameters.get(PARM_ZOOM_TO_LEVEL));
  mZoomMax=Double.parseDouble(mParameters.get(PARM_ZOOM_MAX));
  mZoomStep=Double.parseDouble(mParameters.get(PARM_ZOOM_STEP));
  mParameters.set(PARM_ZOOM_SPEED,ZOOM_SPEED);
  mCameraDevice.setParameters(mParameters);
  mGestureDetector=new GestureDetector(this,new ZoomGestureListener());
  mCameraDevice.setZoomCallback(mZoomCallback);
  mZoomButtons=new ZoomButtonsController(mSurfaceView);
  mZoomButtons.setAutoDismissed(true);
  mZoomButtons.setZoomSpeed(100);
  mZoomButtons.setOnZoomListener(new ZoomButtonsController.OnZoomListener(){
    public void onVisibilityChanged(    boolean visible){
      if (visible) {
        updateZoomButtonsEnabled();
      }
    }
    public void onZoom(    boolean zoomIn){
      if (isZooming())       return;
      if (zoomIn) {
        if (mZoomValue < mZoomMax) {
          zoomToLevel(ZOOM_CONTINUOUS,mZoomValue + mZoomStep);
        }
      }
 else {
        if (mZoomValue > ZOOM_MIN) {
          zoomToLevel(ZOOM_CONTINUOUS,mZoomValue - mZoomStep);
        }
      }
    }
  }
);
}
Program: 184437
Project: 184437
Buggy source:
private void initializeSecondTime(){
  mOrientationListener.enable();
  readPreference();
  if (mRecordLocation)   startReceivingLocationUpdates();
  installIntentFilter();
  initializeFocusTone();
  checkStorage();
  if (!mIsImageCaptureIntent) {
    updateThumbnailButton();
  }
}

Fixed version (ground truth):
private void initializeSecondTime(){
  mOrientationListener.enable();
  readPreference();
  if (mRecordLocation)   startReceivingLocationUpdates();
  installIntentFilter();
  initializeFocusTone();
  checkStorage();
  if (mZoomButtons != null) {
    mZoomValue=Double.parseDouble(mParameters.get(PARM_ZOOM_TO_LEVEL));
    mCameraDevice.setZoomCallback(mZoomCallback);
  }
  if (!mIsImageCaptureIntent) {
    updateThumbnailButton();
  }
}
Program: 184438
Project: 184438
Buggy source:
private void zoomToLevel(String type){
  if (type == null) {
    Log.e(TAG,"String_Node_Str");
    return;
  }
  if (mZoomValue > mZoomMax)   mZoomValue=mZoomMax;
  if (mZoomValue < ZOOM_MIN)   mZoomValue=ZOOM_MIN;
  mParameters.set(PARM_ZOOM_STATE,ZOOM_STOP);
  mCameraDevice.setParameters(mParameters);
  mParameters.set(PARM_ZOOM_TO_LEVEL,Double.toString(mZoomValue));
  mParameters.set(PARM_ZOOM_STATE,type);
  mCameraDevice.setParameters(mParameters);
  if (ZOOM_CONTINUOUS.equals(type))   mZooming=true;
}

Fixed version (ground truth):
private void zoomToLevel(String type,double zoomValue){
  if (zoomValue > mZoomMax)   zoomValue=mZoomMax;
  if (zoomValue < ZOOM_MIN)   zoomValue=ZOOM_MIN;
  mParameters.set(PARM_ZOOM_STATE,ZOOM_STOP);
  mCameraDevice.setParameters(mParameters);
  mParameters.set(PARM_ZOOM_TO_LEVEL,Double.toString(zoomValue));
  mParameters.set(PARM_ZOOM_STATE,type);
  mCameraDevice.setParameters(mParameters);
  if (ZOOM_IMMEDIATE.equals(type))   mZoomValue=zoomValue;
}