public static void setFocus(Camera.Parameters parameters,
								CameraSettings.FocusMode focusModeSetting,
                                boolean safeMode) {
        List<String> supportedFocusModes = parameters.getSupportedFocusModes();
        String focusMode = null;

		if (safeMode || focusModeSetting == CameraSettings.FocusMode.AUTO) {
			focusMode = findSettableValue("focus mode",
					supportedFocusModes,
					Camera.Parameters.FOCUS_MODE_AUTO);
		} else if (focusModeSetting == CameraSettings.FocusMode.CONTINUOUS) {
			focusMode = findSettableValue("focus mode",
					supportedFocusModes,
					Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE,
					Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO,
					Camera.Parameters.FOCUS_MODE_AUTO);
		} else if (focusModeSetting == CameraSettings.FocusMode.INFINITY) {
			focusMode = findSettableValue("focus mode",
					supportedFocusModes,
					Camera.Parameters.FOCUS_MODE_INFINITY);
		} else if (focusModeSetting == CameraSettings.FocusMode.MACRO) {
			focusMode = findSettableValue("focus mode",
					supportedFocusModes,
					Camera.Parameters.FOCUS_MODE_MACRO);
		}

        // Maybe selected auto-focus but not available, so fall through here:
        if (!safeMode && focusMode == null) {
            focusMode = findSettableValue("focus mode",
                    supportedFocusModes,
                    Camera.Parameters.FOCUS_MODE_MACRO,
                    Camera.Parameters.FOCUS_MODE_EDOF);
        }
        if (focusMode != null) {
            if (focusMode.equals(parameters.getFocusMode())) {
                Log.i(TAG, "Focus mode already set to " + focusMode);
            } else {
                parameters.setFocusMode(focusMode);
            }
        }
    }
Utility methods for configuring the Android camera.

@author Sean Owen
zxing-android-embedded/src/com/journeyapps/barcodescanner/camera/CameraConfigurationUtils.java