Program: 38275
Project: 38275
Buggy source:
private boolean updateCameraParametersPreference(){
  setAutoExposureLockIfSupported();
  setAutoWhiteBalanceLockIfSupported();
  setFocusAreasIfSupported();
  setMeteringAreasIfSupported();
  String pictureSize=mPreferences.getString(CameraSettings.KEY_PICTURE_SIZE,null);
  if (pictureSize == null) {
    CameraSettings.initialCameraPictureSize(mActivity,mParameters);
  }
 else {
    Size old_size=mParameters.getPictureSize();
    Log.v(TAG,"String_Node_Str" + old_size.width + "String_Node_Str"+ old_size.height);
    List<Size> supported=mParameters.getSupportedPictureSizes();
    CameraSettings.setCameraPictureSize(pictureSize,supported,mParameters);
    Size size=mParameters.getPictureSize();
    Log.v(TAG,"String_Node_Str" + size.width + "String_Node_Str"+ size.height);
    if (old_size != null && size != null) {
      if (!size.equals(old_size) && mCameraState != PREVIEW_STOPPED) {
        Log.v(TAG,"String_Node_Str");
        mRestartPreview=true;
      }
    }
  }
  Size size=mParameters.getPictureSize();
  List<Size> sizes=mParameters.getSupportedPreviewSizes();
  Size optimalSize=CameraUtil.getOptimalPreviewSize(mActivity,sizes,(double)size.width / size.height);
  Size original=mParameters.getPreviewSize();
  if (!original.equals(optimalSize)) {
    mParameters.setPreviewSize(optimalSize.width,optimalSize.height);
    if (mHandler.getLooper() == Looper.myLooper()) {
      setupPreview();
    }
 else {
      mCameraDevice.setParameters(mParameters);
    }
    mParameters=mCameraDevice.getParameters();
    Log.v(TAG,"String_Node_Str");
    mRestartPreview=true;
  }
  Log.v(TAG,"String_Node_Str" + optimalSize.width + "String_Node_Str"+ optimalSize.height);
  String onValue=mActivity.getString(R.string.setting_on_value);
  String hdr=mPreferences.getString(CameraSettings.KEY_CAMERA_HDR,mActivity.getString(R.string.pref_camera_hdr_default));
  String hdrPlus=mPreferences.getString(CameraSettings.KEY_CAMERA_HDR_PLUS,mActivity.getString(R.string.pref_camera_hdr_plus_default));
  boolean hdrOn=onValue.equals(hdr);
  boolean hdrPlusOn=onValue.equals(hdrPlus);
  boolean doGcamModeSwitch=false;
  if (hdrPlusOn && GcamHelper.hasGcamCapture()) {
    doGcamModeSwitch=true;
  }
 else {
    if (hdrOn) {
      mSceneMode=CameraUtil.SCENE_MODE_HDR;
      if (!(Parameters.SCENE_MODE_AUTO).equals(mParameters.getSceneMode())) {
        mParameters.setSceneMode(Parameters.SCENE_MODE_AUTO);
        mCameraDevice.setParameters(mParameters);
        mParameters=mCameraDevice.getParameters();
      }
    }
 else {
      mSceneMode=mPreferences.getString(CameraSettings.KEY_SCENE_MODE,mActivity.getString(R.string.pref_camera_scenemode_default));
    }
  }
  if (CameraUtil.isSupported(mSceneMode,mParameters.getSupportedSceneModes())) {
    if (!mParameters.getSceneMode().equals(mSceneMode)) {
      mParameters.setSceneMode(mSceneMode);
      mCameraDevice.setParameters(mParameters);
      mParameters=mCameraDevice.getParameters();
    }
  }
 else {
    mSceneMode=mParameters.getSceneMode();
    if (mSceneMode == null) {
      mSceneMode=Parameters.SCENE_MODE_AUTO;
    }
  }
  int jpegQuality=CameraProfile.getJpegEncodingQualityParameter(mCameraId,CameraProfile.QUALITY_HIGH);
  mParameters.setJpegQuality(jpegQuality);
  int value=CameraSettings.readExposure(mPreferences);
  int max=mParameters.getMaxExposureCompensation();
  int min=mParameters.getMinExposureCompensation();
  if (value >= min && value <= max) {
    mParameters.setExposureCompensation(value);
  }
 else {
    Log.w(TAG,"String_Node_Str" + value);
  }
  if (Parameters.SCENE_MODE_AUTO.equals(mSceneMode)) {
    String flashMode=mPreferences.getString(CameraSettings.KEY_FLASH_MODE,mActivity.getString(R.string.pref_camera_flashmode_default));
    List<String> supportedFlash=mParameters.getSupportedFlashModes();
    if (CameraUtil.isSupported(flashMode,supportedFlash)) {
      mParameters.setFlashMode(flashMode);
    }
 else {
      flashMode=mParameters.getFlashMode();
      if (flashMode == null) {
        flashMode=mActivity.getString(R.string.pref_camera_flashmode_no_flash);
      }
    }
    String whiteBalance=mPreferences.getString(CameraSettings.KEY_WHITE_BALANCE,mActivity.getString(R.string.pref_camera_whitebalance_default));
    if (CameraUtil.isSupported(whiteBalance,mParameters.getSupportedWhiteBalance())) {
      mParameters.setWhiteBalance(whiteBalance);
    }
 else {
      whiteBalance=mParameters.getWhiteBalance();
      if (whiteBalance == null) {
        whiteBalance=Parameters.WHITE_BALANCE_AUTO;
      }
    }
    mFocusManager.overrideFocusMode(null);
    mParameters.setFocusMode(mFocusManager.getFocusMode());
  }
 else {
    mFocusManager.overrideFocusMode(mParameters.getFocusMode());
    if (hdrOn)     mParameters.setFlashMode(Parameters.FLASH_MODE_OFF);
  }
  if (mContinuousFocusSupported && ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK) {
    updateAutoFocusMoveCallback();
  }
  qcomUpdateCameraParametersPreference();
  return doGcamModeSwitch;
}

Fixed version (ground truth):
private boolean updateCameraParametersPreference(){
  setAutoExposureLockIfSupported();
  setAutoWhiteBalanceLockIfSupported();
  setFocusAreasIfSupported();
  setMeteringAreasIfSupported();
  String pictureSize=mPreferences.getString(CameraSettings.KEY_PICTURE_SIZE,null);
  if (pictureSize == null) {
    CameraSettings.initialCameraPictureSize(mActivity,mParameters);
  }
 else {
    Size old_size=mParameters.getPictureSize();
    Log.v(TAG,"String_Node_Str" + old_size.width + "String_Node_Str"+ old_size.height);
    List<Size> supported=mParameters.getSupportedPictureSizes();
    CameraSettings.setCameraPictureSize(pictureSize,supported,mParameters);
    Size size=mParameters.getPictureSize();
    Log.v(TAG,"String_Node_Str" + size.width + "String_Node_Str"+ size.height);
    if (old_size != null && size != null) {
      if (!size.equals(old_size) && mCameraState != PREVIEW_STOPPED) {
        Log.v(TAG,"String_Node_Str");
        mRestartPreview=true;
      }
    }
  }
  Size size=mParameters.getPictureSize();
  List<Size> sizes=mParameters.getSupportedPreviewSizes();
  Size optimalSize=CameraUtil.getOptimalPreviewSize(mActivity,sizes,(double)size.width / size.height);
  Size original=mParameters.getPreviewSize();
  if (!original.equals(optimalSize)) {
    mParameters.setPreviewSize(optimalSize.width,optimalSize.height);
    if (mHandler.getLooper() == Looper.myLooper()) {
      setupPreview();
    }
 else {
      mCameraDevice.setParameters(mParameters);
    }
    mParameters=mCameraDevice.getParameters();
    Log.v(TAG,"String_Node_Str");
    mRestartPreview=true;
  }
  Log.v(TAG,"String_Node_Str" + optimalSize.width + "String_Node_Str"+ optimalSize.height);
  String onValue=mActivity.getString(R.string.setting_on_value);
  String hdr=mPreferences.getString(CameraSettings.KEY_CAMERA_HDR,mActivity.getString(R.string.pref_camera_hdr_default));
  String hdrPlus=mPreferences.getString(CameraSettings.KEY_CAMERA_HDR_PLUS,mActivity.getString(R.string.pref_camera_hdr_plus_default));
  boolean hdrOn=onValue.equals(hdr);
  boolean hdrPlusOn=onValue.equals(hdrPlus);
  boolean doGcamModeSwitch=false;
  if (hdrPlusOn && GcamHelper.hasGcamCapture()) {
    doGcamModeSwitch=true;
  }
 else {
    if (hdrOn) {
      mSceneMode=CameraUtil.SCENE_MODE_HDR;
      if (!(Parameters.SCENE_MODE_AUTO).equals(mParameters.getSceneMode()) && !(Parameters.SCENE_MODE_HDR).equals(mParameters.getSceneMode())) {
        mParameters.setSceneMode(Parameters.SCENE_MODE_AUTO);
        mCameraDevice.setParameters(mParameters);
        mParameters=mCameraDevice.getParameters();
      }
    }
 else {
      mSceneMode=mPreferences.getString(CameraSettings.KEY_SCENE_MODE,mActivity.getString(R.string.pref_camera_scenemode_default));
    }
  }
  if (CameraUtil.isSupported(mSceneMode,mParameters.getSupportedSceneModes())) {
    if (!mParameters.getSceneMode().equals(mSceneMode)) {
      mParameters.setSceneMode(mSceneMode);
      mCameraDevice.setParameters(mParameters);
      mParameters=mCameraDevice.getParameters();
    }
  }
 else {
    mSceneMode=mParameters.getSceneMode();
    if (mSceneMode == null) {
      mSceneMode=Parameters.SCENE_MODE_AUTO;
    }
  }
  int jpegQuality=CameraProfile.getJpegEncodingQualityParameter(mCameraId,CameraProfile.QUALITY_HIGH);
  mParameters.setJpegQuality(jpegQuality);
  int value=CameraSettings.readExposure(mPreferences);
  int max=mParameters.getMaxExposureCompensation();
  int min=mParameters.getMinExposureCompensation();
  if (value >= min && value <= max) {
    mParameters.setExposureCompensation(value);
  }
 else {
    Log.w(TAG,"String_Node_Str" + value);
  }
  if (Parameters.SCENE_MODE_AUTO.equals(mSceneMode)) {
    String flashMode=mPreferences.getString(CameraSettings.KEY_FLASH_MODE,mActivity.getString(R.string.pref_camera_flashmode_default));
    List<String> supportedFlash=mParameters.getSupportedFlashModes();
    if (CameraUtil.isSupported(flashMode,supportedFlash)) {
      mParameters.setFlashMode(flashMode);
    }
 else {
      flashMode=mParameters.getFlashMode();
      if (flashMode == null) {
        flashMode=mActivity.getString(R.string.pref_camera_flashmode_no_flash);
      }
    }
    String whiteBalance=mPreferences.getString(CameraSettings.KEY_WHITE_BALANCE,mActivity.getString(R.string.pref_camera_whitebalance_default));
    if (CameraUtil.isSupported(whiteBalance,mParameters.getSupportedWhiteBalance())) {
      mParameters.setWhiteBalance(whiteBalance);
    }
 else {
      whiteBalance=mParameters.getWhiteBalance();
      if (whiteBalance == null) {
        whiteBalance=Parameters.WHITE_BALANCE_AUTO;
      }
    }
    mFocusManager.overrideFocusMode(null);
    mParameters.setFocusMode(mFocusManager.getFocusMode());
  }
 else {
    mFocusManager.overrideFocusMode(mParameters.getFocusMode());
    if (hdrOn)     mParameters.setFlashMode(Parameters.FLASH_MODE_OFF);
  }
  if (mContinuousFocusSupported && ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK) {
    updateAutoFocusMoveCallback();
  }
  qcomUpdateCameraParametersPreference();
  return doGcamModeSwitch;
}