Unhide camera focus area and metering area API.
These API are for touch focus.
bug:3475893
Change-Id: I1e213c0bed0c6fe18dcbfb0457c51c52e7cfae30
diff --git a/api/current.txt b/api/current.txt
index 0c3a0c4a..5c2ed4b 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -8624,6 +8624,12 @@
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 @@
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 @@
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 @@
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 @@
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 77c2d1b..49db72b 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -1088,7 +1088,6 @@
*
* @see #setFocusAreas(List)
* @see #getFocusAreas()
- * @hide
*/
public static class Area {
/**
@@ -1521,24 +1520,28 @@
}
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 @@
*
* @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 @@
* 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 @@
* {@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 @@
*
* @param focusAreas the focus areas
* @see #getFocusAreas()
- * @hide
*/
public void setFocusAreas(List<Area> focusAreas) {
set(KEY_FOCUS_AREAS, focusAreas);
@@ -2647,7 +2647,6 @@
*
* @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 @@
* 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 @@
* 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 @@
*
* @param meteringAreas the metering areas
* @see #getMeteringAreas()
- * @hide
*/
public void setMeteringAreas(List<Area> meteringAreas) {
set(KEY_METERING_AREAS, meteringAreas);
@@ -2837,7 +2834,7 @@
// 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 @@
} 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;
}
};