From 36322db5752c7ec196f59ba94abe5d5a63cc19f5 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Fri, 18 Sep 2009 18:59:21 +0800 Subject: [PATCH] Add focus API and FLASH_MODE_VIDEO_LIGHT. --- api/current.xml | 90 ++++++++++++++++++++++++++ core/java/android/hardware/Camera.java | 67 +++++++++++++++++-- 2 files changed, 153 insertions(+), 4 deletions(-) diff --git a/api/current.xml b/api/current.xml index efeecb6870bad..077b6ec5c372b 100644 --- a/api/current.xml +++ b/api/current.xml @@ -67644,6 +67644,17 @@ visibility="public" > + + + + + + + + + + + + + + + + + + If your application should not be installed * on devices without auto-focus, you must declare that your application * uses auto-focus with the @@ -598,6 +600,7 @@ public class Camera { private static final String KEY_ANTIBANDING = "antibanding"; private static final String KEY_SCENE_MODE = "scene-mode"; private static final String KEY_FLASH_MODE = "flash-mode"; + private static final String KEY_FOCUS_MODE = "focus-mode"; // Parameter key suffix for supported values. private static final String SUPPORTED_VALUES_SUFFIX = "-values"; @@ -646,6 +649,10 @@ public class Camera { * Flash will be fired in red-eye reduction mode. */ public static final String FLASH_MODE_RED_EYE = "red-eye"; + /** + * Constant emission of light. This can be used for video recording. + */ + public static final String FLASH_MODE_VIDEO_LIGHT = "video-light"; // Values for scene mode settings. public static final String SCENE_MODE_AUTO = "auto"; @@ -664,6 +671,25 @@ public class Camera { public static final String SCENE_MODE_PARTY = "party"; public static final String SCENE_MODE_CANDLELIGHT = "candlelight"; + // Values for focus mode settings. + /** + * Auto-focus mode. + */ + public static final String FOCUS_MODE_AUTO = "auto"; + /** + * Focus is set at infinity. Applications should not call + * {@link #autoFocus(AutoFocusCallback)} in this mode. + */ + public static final String FOCUS_MODE_INFINITY = "infinity"; + public static final String FOCUS_MODE_MACRO = "macro"; + /** + * Focus is fixed. The camera is always in this mode if the focus is not + * adjustable. If the camera has auto-focus, this mode can fix the + * focus, which is usually at hyperfocal distance. Applications should + * not call {@link #autoFocus(AutoFocusCallback)} in this mode. + */ + public static final String FOCUS_MODE_FIXED = "fixed"; + // Formats for setPreviewFormat and setPictureFormat. private static final String PIXEL_FORMAT_YUV422SP = "yuv422sp"; private static final String PIXEL_FORMAT_YUV420SP = "yuv420sp"; @@ -1295,6 +1321,39 @@ public class Camera { return split(str); } + /** + * Gets the current focus mode setting. + * + * @return one of FOCUS_MODE_XXX string constant. If the camera does not + * support auto-focus, this should return {@link + * #FOCUS_MODE_FIXED}. If the focus mode is not FOCUS_MODE_FIXED + * or {@link #FOCUS_MODE_INFINITY}, applications should call + * {@link #autoFocus(AutoFocusCallback)} to start the focus. + */ + public String getFocusMode() { + return get(KEY_FOCUS_MODE); + } + + /** + * Sets the focus mode. + * + * @param value FOCUS_MODE_XXX string constants. + */ + public void setFocusMode(String value) { + set(KEY_FOCUS_MODE, value); + } + + /** + * Gets the supported focus modes. + * + * @return a List of FOCUS_MODE_XXX string constants. null if focus mode + * setting is not supported. + */ + public List getSupportedFocusModes() { + String str = get(KEY_FOCUS_MODE + SUPPORTED_VALUES_SUFFIX); + return split(str); + } + // Splits a comma delimited string to an ArrayList of String. // Return null if the passing string is null or the size is 0. private ArrayList split(String str) {