Program: 184423
Project: 184423
Buggy source:
private void setCameraParameters(){
  mParameters=mCameraDevice.getParameters();
  List<Integer> frameRates=mParameters.getSupportedPreviewFrameRates();
  if (frameRates != null) {
    Integer max=Collections.max(frameRates);
    mParameters.setPreviewFrameRate(max);
  }
  String pictureSize=mPreferences.getString(CameraSettings.KEY_PICTURE_SIZE,null);
  if (pictureSize == null) {
    CameraSettings.initialCameraPictureSize(this,mParameters);
  }
 else {
    List<Size> supported=mParameters.getSupportedPictureSizes();
    CameraSettings.setCameraPictureSize(pictureSize,supported,mParameters);
  }
  Size size=mParameters.getPictureSize();
  PreviewFrameLayout frameLayout=(PreviewFrameLayout)findViewById(R.id.frame_layout);
  frameLayout.setAspectRatio((double)size.width / size.height);
  List<Size> sizes=mParameters.getSupportedPreviewSizes();
  Size optimalSize=getOptimalPreviewSize(sizes,(double)size.width / size.height);
  if (optimalSize != null) {
    mParameters.setPreviewSize(optimalSize.width,optimalSize.height);
  }
  String jpegQuality=mPreferences.getString(CameraSettings.KEY_JPEG_QUALITY,getString(R.string.pref_camera_jpegquality_default));
  mParameters.setJpegQuality(Integer.parseInt(jpegQuality));
  String colorEffect=mPreferences.getString(CameraSettings.KEY_COLOR_EFFECT,getString(R.string.pref_camera_coloreffect_default));
  if (isSupported(colorEffect,mParameters.getSupportedColorEffects())) {
    mParameters.setColorEffect(colorEffect);
  }
  String sceneMode=mPreferences.getString(CameraSettings.KEY_SCENE_MODE,getString(R.string.pref_camera_scenemode_default));
  if (isSupported(sceneMode,mParameters.getSupportedSceneModes())) {
    mParameters.setSceneMode(sceneMode);
  }
 else {
    sceneMode=mParameters.getSceneMode();
    if (sceneMode == null) {
      sceneMode=Parameters.SCENE_MODE_AUTO;
    }
  }
  String flashMode;
  String whiteBalance;
  if (!Parameters.SCENE_MODE_AUTO.equals(sceneMode)) {
    mCameraDevice.setParameters(mParameters);
    mParameters=mCameraDevice.getParameters();
    flashMode=mParameters.getFlashMode();
    whiteBalance=mParameters.getWhiteBalance();
    mFocusMode=mParameters.getFocusMode();
    if (mSettings != null) {
      mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE,flashMode);
      mSettings.overrideSettings(CameraSettings.KEY_WHITE_BALANCE,whiteBalance);
      mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE,mFocusMode);
    }
  }
 else {
    if (mSettings != null) {
      mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE,null);
      mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE,null);
      mSettings.overrideSettings(CameraSettings.KEY_WHITE_BALANCE,null);
    }
    flashMode=mPreferences.getString(CameraSettings.KEY_FLASH_MODE,getString(R.string.pref_camera_flashmode_default));
    List<String> supportedFlash=mParameters.getSupportedFlashModes();
    if (isSupported(flashMode,supportedFlash)) {
      mParameters.setFlashMode(flashMode);
    }
 else {
      flashMode=mParameters.getFlashMode();
      if (flashMode == null) {
        flashMode=Parameters.FLASH_MODE_OFF;
      }
    }
    whiteBalance=mPreferences.getString(CameraSettings.KEY_WHITE_BALANCE,getString(R.string.pref_camera_whitebalance_default));
    if (isSupported(whiteBalance,mParameters.getSupportedWhiteBalance())) {
      mParameters.setWhiteBalance(whiteBalance);
    }
 else {
      whiteBalance=mParameters.getWhiteBalance();
      if (whiteBalance == null) {
        whiteBalance=Parameters.WHITE_BALANCE_AUTO;
      }
    }
    mFocusMode=mPreferences.getString(CameraSettings.KEY_FOCUS_MODE,getString(R.string.pref_camera_focusmode_default));
    if (isSupported(mFocusMode,mParameters.getSupportedFocusModes())) {
      mParameters.setFocusMode(mFocusMode);
    }
 else {
      mFocusMode=mParameters.getFocusMode();
      if (mFocusMode == null) {
        mFocusMode=Parameters.FOCUS_MODE_AUTO;
      }
    }
    mCameraDevice.setParameters(mParameters);
    if (!mScreenComplete && mSettings != null) {
      mScreenComplete=true;
      mParameters=mCameraDevice.getParameters();
      CameraSettings helper=new CameraSettings(this,mParameters);
      mSettings.setPreferenceScreen(helper.getPreferenceScreen(R.xml.camera_preferences));
    }
  }
  final String finalWhiteBalance=whiteBalance;
  final String finalFlashMode=flashMode;
  final String finalSceneMode=Parameters.SCENE_MODE_AUTO.equals(sceneMode) ? SCENE_MODE_OFF : SCENE_MODE_ON;
  mHandler.post(new Runnable(){
    public void run(){
      mFocusIndicator.setMode(mFocusMode);
      mWhitebalanceIndicator.setMode(finalWhiteBalance);
      mSceneModeIndicator.setMode(finalSceneMode);
      mFlashIndicator.setMode(finalFlashMode);
    }
  }
);
}

Fixed version (ground truth):
private void setCameraParameters(){
  mParameters=mCameraDevice.getParameters();
  List<Integer> frameRates=mParameters.getSupportedPreviewFrameRates();
  if (frameRates != null) {
    Integer max=Collections.max(frameRates);
    mParameters.setPreviewFrameRate(max);
  }
  String pictureSize=mPreferences.getString(CameraSettings.KEY_PICTURE_SIZE,null);
  if (pictureSize == null) {
    CameraSettings.initialCameraPictureSize(this,mParameters);
  }
 else {
    List<Size> supported=mParameters.getSupportedPictureSizes();
    CameraSettings.setCameraPictureSize(pictureSize,supported,mParameters);
  }
  Size size=mParameters.getPictureSize();
  PreviewFrameLayout frameLayout=(PreviewFrameLayout)findViewById(R.id.frame_layout);
  frameLayout.setAspectRatio((double)size.width / size.height);
  List<Size> sizes=mParameters.getSupportedPreviewSizes();
  Size optimalSize=getOptimalPreviewSize(sizes,(double)size.width / size.height);
  if (optimalSize != null) {
    mParameters.setPreviewSize(optimalSize.width,optimalSize.height);
  }
  String jpegQuality=mPreferences.getString(CameraSettings.KEY_JPEG_QUALITY,getString(R.string.pref_camera_jpegquality_default));
  mParameters.setJpegQuality(Integer.parseInt(jpegQuality));
  String colorEffect=mPreferences.getString(CameraSettings.KEY_COLOR_EFFECT,getString(R.string.pref_camera_coloreffect_default));
  if (isSupported(colorEffect,mParameters.getSupportedColorEffects())) {
    mParameters.setColorEffect(colorEffect);
  }
  String sceneMode=mPreferences.getString(CameraSettings.KEY_SCENE_MODE,getString(R.string.pref_camera_scenemode_default));
  if (isSupported(sceneMode,mParameters.getSupportedSceneModes())) {
    mParameters.setSceneMode(sceneMode);
  }
 else {
    sceneMode=mParameters.getSceneMode();
    if (sceneMode == null) {
      sceneMode=Parameters.SCENE_MODE_AUTO;
    }
  }
  String flashMode;
  String whiteBalance;
  if (!Parameters.SCENE_MODE_AUTO.equals(sceneMode)) {
    mCameraDevice.setParameters(mParameters);
    mParameters=mCameraDevice.getParameters();
    flashMode=mParameters.getFlashMode();
    whiteBalance=mParameters.getWhiteBalance();
    mFocusMode=mParameters.getFocusMode();
    if (mSettings != null) {
      mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE,flashMode);
      mSettings.overrideSettings(CameraSettings.KEY_WHITE_BALANCE,whiteBalance);
      mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE,mFocusMode);
    }
  }
 else {
    if (mSettings != null) {
      mSettings.overrideSettings(CameraSettings.KEY_FLASH_MODE,null);
      mSettings.overrideSettings(CameraSettings.KEY_FOCUS_MODE,null);
      mSettings.overrideSettings(CameraSettings.KEY_WHITE_BALANCE,null);
    }
    flashMode=mPreferences.getString(CameraSettings.KEY_FLASH_MODE,getString(R.string.pref_camera_flashmode_default));
    List<String> supportedFlash=mParameters.getSupportedFlashModes();
    if (isSupported(flashMode,supportedFlash)) {
      mParameters.setFlashMode(flashMode);
    }
 else {
      flashMode=mParameters.getFlashMode();
      if (flashMode == null) {
        flashMode=Parameters.FLASH_MODE_OFF;
      }
    }
    whiteBalance=mPreferences.getString(CameraSettings.KEY_WHITE_BALANCE,getString(R.string.pref_camera_whitebalance_default));
    if (isSupported(whiteBalance,mParameters.getSupportedWhiteBalance())) {
      mParameters.setWhiteBalance(whiteBalance);
    }
 else {
      whiteBalance=mParameters.getWhiteBalance();
      if (whiteBalance == null) {
        whiteBalance=Parameters.WHITE_BALANCE_AUTO;
      }
    }
    mFocusMode=mPreferences.getString(CameraSettings.KEY_FOCUS_MODE,getString(R.string.pref_camera_focusmode_default));
    if (isSupported(mFocusMode,mParameters.getSupportedFocusModes())) {
      mParameters.setFocusMode(mFocusMode);
    }
 else {
      mFocusMode=mParameters.getFocusMode();
      if (mFocusMode == null) {
        mFocusMode=Parameters.FOCUS_MODE_AUTO;
      }
    }
    mCameraDevice.setParameters(mParameters);
  }
  final String finalWhiteBalance=whiteBalance;
  final String finalFlashMode=flashMode;
  final String finalSceneMode=Parameters.SCENE_MODE_AUTO.equals(sceneMode) ? SCENE_MODE_OFF : SCENE_MODE_ON;
  mHandler.post(new Runnable(){
    public void run(){
      mFocusIndicator.setMode(mFocusMode);
      mWhitebalanceIndicator.setMode(finalWhiteBalance);
      mSceneModeIndicator.setMode(finalSceneMode);
      mFlashIndicator.setMode(finalFlashMode);
    }
  }
);
}