diff options
author | 2011-04-27 21:17:52 -0700 | |
---|---|---|
committer | 2011-04-27 21:17:52 -0700 | |
commit | 61773dbda321be54cce0ff4b8cfa993433c1543f (patch) | |
tree | 25ccd566a58afa3031cf4315ef4afb2baea058e9 | |
parent | 4135f45c87d9aedebd0f7999e76d1c53a5042ec2 (diff) | |
parent | f715bf95ded30821e81ba93bb48c08725e1c34aa (diff) |
Merge "Unhide camera focus area and metering area API."
-rw-r--r-- | api/current.txt | 12 | ||||
-rw-r--r-- | core/java/android/hardware/Camera.java | 75 |
2 files changed, 53 insertions, 34 deletions
diff --git a/api/current.txt b/api/current.txt index c76627f74aa3..4b3918e6adba 100644 --- a/api/current.txt +++ b/api/current.txt @@ -8624,6 +8624,12 @@ package android.hardware { field public static final int CAMERA_ERROR_UNKNOWN = 1; // 0x1 } + public static class Camera.Area { + ctor public Camera.Area(android.graphics.Rect, int); + field public android.graphics.Rect rect; + field public int weight; + } + public static abstract interface Camera.AutoFocusCallback { method public abstract void onAutoFocus(boolean, android.hardware.Camera); } @@ -8653,6 +8659,7 @@ package android.hardware { method public float getExposureCompensationStep(); method public java.lang.String getFlashMode(); method public float getFocalLength(); + method public java.util.List<android.hardware.Camera.Area> getFocusAreas(); method public void getFocusDistances(float[]); method public java.lang.String getFocusMode(); method public float getHorizontalViewAngle(); @@ -8661,7 +8668,10 @@ package android.hardware { method public int getJpegThumbnailQuality(); method public android.hardware.Camera.Size getJpegThumbnailSize(); method public int getMaxExposureCompensation(); + method public int getMaxNumFocusAreas(); + method public int getMaxNumMeteringAreas(); method public int getMaxZoom(); + method public java.util.List<android.hardware.Camera.Area> getMeteringAreas(); method public int getMinExposureCompensation(); method public int getPictureFormat(); method public android.hardware.Camera.Size getPictureSize(); @@ -8699,6 +8709,7 @@ package android.hardware { method public void setColorEffect(java.lang.String); method public void setExposureCompensation(int); method public void setFlashMode(java.lang.String); + method public void setFocusAreas(java.util.List<android.hardware.Camera.Area>); method public void setFocusMode(java.lang.String); method public void setGpsAltitude(double); method public void setGpsLatitude(double); @@ -8708,6 +8719,7 @@ package android.hardware { method public void setJpegQuality(int); method public void setJpegThumbnailQuality(int); method public void setJpegThumbnailSize(int, int); + method public void setMeteringAreas(java.util.List<android.hardware.Camera.Area>); method public void setPictureFormat(int); method public void setPictureSize(int, int); method public void setPreviewFormat(int); diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java index 77c2d1ba2cd2..49db72b40b41 100644 --- a/core/java/android/hardware/Camera.java +++ b/core/java/android/hardware/Camera.java @@ -1088,7 +1088,6 @@ public class Camera { * * @see #setFocusAreas(List) * @see #getFocusAreas() - * @hide */ public static class Area { /** @@ -1521,24 +1520,28 @@ public class Camera { } private void set(String key, List<Area> areas) { - StringBuilder buffer = new StringBuilder(); - for (int i = 0; i < areas.size(); i++) { - Area area = areas.get(i); - Rect rect = area.rect; - buffer.append('('); - buffer.append(rect.left); - buffer.append(','); - buffer.append(rect.top); - buffer.append(','); - buffer.append(rect.right); - buffer.append(','); - buffer.append(rect.bottom); - buffer.append(','); - buffer.append(area.weight); - buffer.append(')'); - if (i != areas.size() - 1) buffer.append(','); + if (areas == null) { + set(key, "(0,0,0,0,0)"); + } else { + StringBuilder buffer = new StringBuilder(); + for (int i = 0; i < areas.size(); i++) { + Area area = areas.get(i); + Rect rect = area.rect; + buffer.append('('); + buffer.append(rect.left); + buffer.append(','); + buffer.append(rect.top); + buffer.append(','); + buffer.append(rect.right); + buffer.append(','); + buffer.append(rect.bottom); + buffer.append(','); + buffer.append(area.weight); + buffer.append(')'); + if (i != areas.size() - 1) buffer.append(','); + } + set(key, buffer.toString()); } - set(key, buffer.toString()); } /** @@ -2578,7 +2581,6 @@ public class Camera { * * @return the maximum number of focus areas supported by the camera. * @see #getFocusAreas() - * @hide */ public int getMaxNumFocusAreas() { return getInt(KEY_MAX_NUM_FOCUS_AREAS, 0); @@ -2607,10 +2609,10 @@ public class Camera { * area. Focus areas can partially overlap and the driver will add the * weights in the overlap region. * - * A special case of all-zero single focus area means driver to decide - * the focus area. For example, the driver may use more signals to - * decide focus areas and change them dynamically. Apps can set all-zero - * if they want the driver to decide focus areas. + * A special case of null focus area means driver to decide the focus + * area. For example, the driver may use more signals to decide focus + * areas and change them dynamically. Apps can set all-zero if they want + * the driver to decide focus areas. * * Focus areas are relative to the current field of view * ({@link #getZoom()}). No matter what the zoom level is, (-1000,-1000) @@ -2623,10 +2625,9 @@ public class Camera { * {@link #FOCUS_MODE_CONTINUOUS_VIDEO}. * * @return a list of current focus areas - * @hide */ public List<Area> getFocusAreas() { - return splitArea(KEY_FOCUS_AREAS); + return splitArea(get(KEY_FOCUS_AREAS)); } /** @@ -2634,7 +2635,6 @@ public class Camera { * * @param focusAreas the focus areas * @see #getFocusAreas() - * @hide */ public void setFocusAreas(List<Area> focusAreas) { set(KEY_FOCUS_AREAS, focusAreas); @@ -2647,7 +2647,6 @@ public class Camera { * * @return the maximum number of metering areas supported by the camera. * @see #getMeteringAreas() - * @hide */ public int getMaxNumMeteringAreas() { return getInt(KEY_MAX_NUM_METERING_AREAS, 0); @@ -2676,10 +2675,10 @@ public class Camera { * metering result. Metering areas can partially overlap and the driver * will add the weights in the overlap region. * - * A special case of all-zero single metering area means driver to - * decide the metering area. For example, the driver may use more - * signals to decide metering areas and change them dynamically. Apps - * can set all-zero if they want the driver to decide metering areas. + * A special case of null metering area means driver to decide the + * metering area. For example, the driver may use more signals to decide + * metering areas and change them dynamically. Apps can set all-zero if + * they want the driver to decide metering areas. * * Metering areas are relative to the current field of view * ({@link #getZoom()}). No matter what the zoom level is, (-1000,-1000) @@ -2691,7 +2690,6 @@ public class Camera { * by {@link #setExposureCompensation(int)}. * * @return a list of current metering areas - * @hide */ public List<Area> getMeteringAreas() { return splitArea(KEY_METERING_AREAS); @@ -2703,7 +2701,6 @@ public class Camera { * * @param meteringAreas the metering areas * @see #getMeteringAreas() - * @hide */ public void setMeteringAreas(List<Area> meteringAreas) { set(KEY_METERING_AREAS, meteringAreas); @@ -2837,7 +2834,7 @@ public class Camera { // Splits a comma delimited string to an ArrayList of Area objects. // Example string: "(-10,-10,0,0,300),(0,0,10,10,700)". Return null if - // the passing string is null or the size is 0. + // the passing string is null or the size is 0 or (0,0,0,0,0). private ArrayList<Area> splitArea(String str) { if (str == null || str.charAt(0) != '(' || str.charAt(str.length() - 1) != ')') { @@ -2858,6 +2855,16 @@ public class Camera { } while (endIndex != str.length() - 1); if (result.size() == 0) return null; + + if (result.size() == 1) { + Area area = (Area) result.get(0); + Rect rect = area.rect; + if (rect.left == 0 && rect.top == 0 && rect.right == 0 + && rect.bottom == 0 && area.weight == 0) { + return null; + } + } + return result; } }; |