diff options
-rw-r--r-- | api/current.xml | 130 | ||||
-rw-r--r-- | core/java/android/hardware/Camera.java | 85 | ||||
-rw-r--r-- | include/camera/CameraParameters.h | 24 | ||||
-rw-r--r-- | libs/camera/CameraParameters.cpp | 5 |
4 files changed, 206 insertions, 38 deletions
diff --git a/api/current.xml b/api/current.xml index 6cec09a..189835e 100644 --- a/api/current.xml +++ b/api/current.xml @@ -71441,6 +71441,19 @@ <exception name="IOException" type="java.io.IOException"> </exception> </method> +<method name="setZoomCallback" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="true" + deprecated="not deprecated" + visibility="public" +> +<parameter name="cb" type="android.hardware.Camera.ZoomCallback"> +</parameter> +</method> <method name="startPreview" return="void" abstract="false" @@ -71452,6 +71465,19 @@ visibility="public" > </method> +<method name="startSmoothZoom" + return="void" + abstract="false" + native="true" + synchronized="false" + static="false" + final="true" + deprecated="not deprecated" + visibility="public" +> +<parameter name="value" type="int"> +</parameter> +</method> <method name="stopPreview" return="void" abstract="false" @@ -71463,6 +71489,17 @@ visibility="public" > </method> +<method name="stopSmoothZoom" + return="void" + abstract="false" + native="true" + synchronized="false" + static="false" + final="true" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="takePicture" return="void" abstract="false" @@ -71756,6 +71793,17 @@ visibility="public" > </method> +<method name="getMaxZoom" + return="int" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="getMinExposureCompensation" return="int" abstract="false" @@ -71987,6 +72035,50 @@ visibility="public" > </method> +<method name="getZoom" + return="int" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="getZoomRatios" + return="java.util.List<java.lang.Integer>" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="isSmoothZoomSupported" + return="boolean" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> +<method name="isZoomSupported" + return="boolean" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +</method> <method name="remove" return="void" abstract="false" @@ -72307,6 +72399,19 @@ <parameter name="value" type="java.lang.String"> </parameter> </method> +<method name="setZoom" + return="void" + abstract="false" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="value" type="int"> +</parameter> +</method> <method name="unflatten" return="void" abstract="false" @@ -72922,6 +73027,31 @@ > </field> </class> +<interface name="Camera.ZoomCallback" + abstract="true" + static="true" + final="false" + deprecated="not deprecated" + visibility="public" +> +<method name="onZoomUpdate" + return="void" + abstract="true" + native="false" + synchronized="false" + static="false" + final="false" + deprecated="not deprecated" + visibility="public" +> +<parameter name="zoomValue" type="int"> +</parameter> +<parameter name="stopped" type="boolean"> +</parameter> +<parameter name="camera" type="android.hardware.Camera"> +</parameter> +</method> +</interface> <class name="GeomagneticField" extends="java.lang.Object" abstract="false" diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index da5fa49..cddbec9 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -524,21 +524,24 @@ public class Camera { /** * Zooms to the requested value smoothly. Driver will generate {@link - * #ZoomCallback} for the current zoom value and whether zoom is stopped. - * The applications can call {@link #stopSmoothZoom} to stop the zoom - * earlier. The applications should not call startSmoothZoom again or {@link - * android.hardware.Camera.Parameters#setZoom(int)} before the zoom stops. + * ZoomCallback} for the zoom value and whether zoom is stopped at the + * time. For example, suppose the current zoom is 0 and startSmoothZoom is + * called with value 3. Three ZoomCallback will be generated with zoom value + * 1, 2, and 3. The applications can call {@link #stopSmoothZoom} to stop + * the zoom earlier. The applications should not call startSmoothZoom again + * or change the zoom value before zoom stops. This method is supported if + * {@link android.hardware.Camera.Parameters#isSmoothZoomSupported} is true. * * @param value zoom value. The valid range is 0 to {@link * android.hardware.Camera.Parameters#getMaxZoom}. - * @hide */ public native final void startSmoothZoom(int value); /** * Stops the smooth zoom. The applications should wait for the {@link - * #ZoomCallback} to know when the zoom is actually stopped. - * @hide + * ZoomCallback} to know when the zoom is actually stopped. This method is + * supported if {@link + * android.hardware.Camera.Parameters#isSmoothZoomSupported} is true. */ public native final void stopSmoothZoom(); @@ -560,7 +563,6 @@ public class Camera { /** * Handles the zoom callback. * - * @hide */ public interface ZoomCallback { @@ -573,7 +575,7 @@ public class Camera { * this is the last zoom update for the application. * * @param camera the Camera service object - * @see android.hardware.Camera.Parameters#startSmoothZoom + * @see #startSmoothZoom(int) */ void onZoomUpdate(int zoomValue, boolean stopped, Camera camera); }; @@ -581,8 +583,9 @@ public class Camera { /** * Registers a callback to be invoked when the zoom value is updated by the * camera driver during smooth zoom. + * * @param cb the callback to run - * @hide + * @see #startSmoothZoom(int) */ public final void setZoomCallback(ZoomCallback cb) { @@ -727,9 +730,16 @@ public class Camera { private static final String KEY_MAX_EXPOSURE_COMPENSATION = "max-exposure-compensation"; private static final String KEY_MIN_EXPOSURE_COMPENSATION = "min-exposure-compensation"; private static final String KEY_EXPOSURE_COMPENSATION_STEP = "exposure-compensation-step"; + private static final String KEY_ZOOM = "zoom"; + private static final String KEY_MAX_ZOOM = "max-zoom"; + private static final String KEY_ZOOM_RATIOS = "zoom-ratios"; + private static final String KEY_ZOOM_SUPPORTED = "zoom-supported"; + private static final String KEY_SMOOTH_ZOOM_SUPPORTED = "smooth-zoom-supported"; // Parameter key suffix for supported values. private static final String SUPPORTED_VALUES_SUFFIX = "-values"; + private static final String TRUE = "true"; + // Values for white balance settings. public static final String WHITE_BALANCE_AUTO = "auto"; public static final String WHITE_BALANCE_INCANDESCENT = "incandescent"; @@ -1607,26 +1617,28 @@ public class Camera { /** * Gets current zoom value. This also works when smooth zoom is in - * progress. + * progress. Applications should check {@link #isZoomSupported} before + * using this method. * * @return the current zoom value. The range is 0 to {@link - * #getMaxZoom}. - * @hide + * #getMaxZoom}. 0 means the camera is not zoomed. */ public int getZoom() { - return getInt("zoom"); + return getInt(KEY_ZOOM, 0); } /** - * Sets current zoom value. If {@link #startSmoothZoom(int)} has been - * called and zoom is not stopped yet, applications should not call this - * method. + * Sets current zoom value. If the camera is zoomed (value > 0), the + * actual picture size may be smaller than picture size setting. + * Applications can check the actual picture size after picture is + * returned from {@link PictureCallback}. The preview size remains the + * same in zoom. Applications should check {@link #isZoomSupported} + * before using this method. * * @param value zoom value. The valid range is 0 to {@link #getMaxZoom}. - * @hide */ public void setZoom(int value) { - set("zoom", value); + set(KEY_ZOOM, value); } /** @@ -1634,37 +1646,37 @@ public class Camera { * before using other zoom methods. * * @return true if zoom is supported. - * @hide */ public boolean isZoomSupported() { - String str = get("zoom-supported"); - return "true".equals(str); + String str = get(KEY_ZOOM_SUPPORTED); + return TRUE.equals(str); } /** * Gets the maximum zoom value allowed for snapshot. This is the maximum * value that applications can set to {@link #setZoom(int)}. + * Applications should call {@link #isZoomSupported} before using this + * method. This value may change in different preview size. Applications + * should call this again after setting preview size. * * @return the maximum zoom value supported by the camera. - * @hide */ public int getMaxZoom() { - return getInt("max-zoom"); + return getInt(KEY_MAX_ZOOM, 0); } /** - * Gets the zoom factors of all zoom values. + * Gets the zoom ratios of all zoom values. Applications should check + * {@link #isZoomSupported} before using this method. * - * @return the zoom factors in 1/100 increments. Ex: a zoom of 3.2x is - * returned as 320. Accuracy of the value is dependent on the - * hardware implementation. The first element of the list is the - * zoom factor of first zoom value. If the first zoom value is - * 0, the zoom factor should be 100. The last element is the - * zoom factor of zoom value {@link #getMaxZoom}. - * @hide + * @return the zoom ratios in 1/100 increments. Ex: a zoom of 3.2x is + * returned as 320. The number of elements is {@link + * #getMaxZoom} + 1. The list is sorted from small to large. The + * first element is always 100. The last element is the zoom + * ratio of the maximum zoom value. */ - public List<Integer> getZoomFactors() { - return splitInt(get("zoom-factors")); + public List<Integer> getZoomRatios() { + return splitInt(get(KEY_ZOOM_RATIOS)); } /** @@ -1672,11 +1684,10 @@ public class Camera { * this before using other smooth zoom methods. * * @return true if smooth zoom is supported. - * @hide */ public boolean isSmoothZoomSupported() { - String str = get("smooth-zoom-supported"); - return "true".equals(str); + String str = get(KEY_SMOOTH_ZOOM_SUPPORTED); + return TRUE.equals(str); } // Splits a comma delimited string to an ArrayList of String. diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h index 9df2695..752afc2 100644 --- a/include/camera/CameraParameters.h +++ b/include/camera/CameraParameters.h @@ -201,7 +201,29 @@ public: // 0.3333, EV is -2. // Example value: "0.333333333" or "0.5". Read only. static const char KEY_EXPOSURE_COMPENSATION_STEP[]; - + // Current zoom value. + // Example value: "0" or "6". Read/write. + static const char KEY_ZOOM[]; + // Maximum zoom value. + // Example value: "6". Read only. + static const char KEY_MAX_ZOOM[]; + // The zoom ratios of all zoom values. The zoom ratio is in 1/100 + // increments. Ex: a zoom of 3.2x is returned as 320. The number of list + // elements is KEY_MAX_ZOOM + 1. The first element is always 100. The last + // element is the zoom ratio of zoom value KEY_MAX_ZOOM. + // Example value: "100,150,200,250,300,350,400". Read only. + static const char KEY_ZOOM_RATIOS[]; + // Whether zoom is supported. Zoom is supported if the value is "true". Zoom + // is not supported if the value is not "true" or the key does not exist. + // Example value: "true". Read only. + static const char KEY_ZOOM_SUPPORTED[]; + // Whether if smooth zoom is supported. Smooth zoom is supported if the + // value is "true". It is not supported if the value is not "true" or the + // key does not exist. + // See CAMERA_CMD_START_SMOOTH_ZOOM, CAMERA_CMD_STOP_SMOOTH_ZOOM, and + // CAMERA_MSG_ZOOM in frameworks/base/include/camera/Camera.h. + // Example value: "true". Read only. + static const char KEY_SMOOTH_ZOOM_SUPPORTED[]; // Values for white balance settings. static const char WHITE_BALANCE_AUTO[]; diff --git a/libs/camera/CameraParameters.cpp b/libs/camera/CameraParameters.cpp index 8439e2b..cf4cbfa 100644 --- a/libs/camera/CameraParameters.cpp +++ b/libs/camera/CameraParameters.cpp @@ -63,6 +63,11 @@ const char CameraParameters::KEY_EXPOSURE_COMPENSATION[] = "exposure-compensatio const char CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION[] = "max-exposure-compensation"; const char CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION[] = "min-exposure-compensation"; const char CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP[] = "exposure-compensation-step"; +const char CameraParameters::KEY_ZOOM[] = "zoom"; +const char CameraParameters::KEY_MAX_ZOOM[] = "max-zoom"; +const char CameraParameters::KEY_ZOOM_RATIOS[] = "zoom-ratios"; +const char CameraParameters::KEY_ZOOM_SUPPORTED[] = "zoom-supported"; +const char CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED[] = "smooth-zoom-supported"; // Values for white balance settings. const char CameraParameters::WHITE_BALANCE_AUTO[] = "auto"; |