Unhide exposure compensation API.
bug:2375993
diff --git a/api/current.xml b/api/current.xml
index e688ab4..8a9a77a 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -71453,6 +71453,28 @@
visibility="public"
>
</method>
+<method name="getExposureCompensation"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getExposureCompensationStep"
+ return="float"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getFlashMode"
return="java.lang.String"
abstract="false"
@@ -71543,6 +71565,28 @@
visibility="public"
>
</method>
+<method name="getMaxExposureCompensation"
+ 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"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getPictureFormat"
return="int"
abstract="false"
@@ -71843,6 +71887,19 @@
<parameter name="value" type="java.lang.String">
</parameter>
</method>
+<method name="setExposureCompensation"
+ 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="setFlashMode"
return="void"
abstract="false"
diff --git a/core/java/android/hardware/Camera.java b/core/java/android/hardware/Camera.java
index 6dba94d..08e5e8d 100644
--- a/core/java/android/hardware/Camera.java
+++ b/core/java/android/hardware/Camera.java
@@ -724,6 +724,9 @@
private static final String KEY_HORIZONTAL_VIEW_ANGLE = "horizontal-view-angle";
private static final String KEY_VERTICAL_VIEW_ANGLE = "vertical-view-angle";
private static final String KEY_EXPOSURE_COMPENSATION = "exposure-compensation";
+ 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";
// Parameter key suffix for supported values.
private static final String SUPPORTED_VALUES_SUFFIX = "-values";
@@ -1543,38 +1546,63 @@
}
/**
- * Gets the current exposure compensation setting.
+ * Gets the current exposure compensation index.
*
- * @return the current exposure compensation value multiplied by 100.
- * null if exposure compensation is not supported. Ex: -100
- * means -1 EV. 130 means +1.3 EV.
- * @hide
+ * @return current exposure compensation index. The range is {@link
+ * #getMinExposureCompensation} to {@link
+ * #getMaxExposureCompensation}. 0 means exposure is not
+ * adjusted.
*/
public int getExposureCompensation() {
- return getInt(KEY_EXPOSURE_COMPENSATION);
+ return getInt(KEY_EXPOSURE_COMPENSATION, 0);
}
/**
- * Sets the exposure compensation.
+ * Sets the exposure compensation index.
*
- * @param value exposure compensation multiplied by 100. Ex: -100 means
- * -1 EV. 130 means +1.3 EV.
- * @hide
+ * @param value. The valid value range is from {@link
+ * #getMinExposureCompensation} (inclusive) to {@link
+ * #getMaxExposureCompensation} (inclusive). 0 means exposure is
+ * not adjusted. Application should call
+ * getMinExposureCompensation and getMaxExposureCompensation to
+ * know if exposure compensation is supported.
*/
public void setExposureCompensation(int value) {
set(KEY_EXPOSURE_COMPENSATION, value);
}
/**
- * Gets the supported exposure compensation.
+ * Gets the maximum exposure compensation index.
*
- * @return a List of Integer constants. null if exposure compensation is
- * not supported. The list is sorted from small to large. Ex:
- * -100, -66, -33, 0, 33, 66, 100.
- * @hide
+ * @return maximum exposure compensation index (>=0). If both this
+ * method and {@link #getMinExposureCompensation} return 0,
+ * exposure compensation is not supported.
*/
- public List<Integer> getSupportedExposureCompensation() {
- return splitInt(get(KEY_EXPOSURE_COMPENSATION + SUPPORTED_VALUES_SUFFIX));
+ public int getMaxExposureCompensation() {
+ return getInt(KEY_MAX_EXPOSURE_COMPENSATION, 0);
+ }
+
+ /**
+ * Gets the minimum exposure compensation index.
+ *
+ * @return minimum exposure compensation index (<=0). If both this
+ * method and {@link #getMaxExposureCompensation} return 0,
+ * exposure compensation is not supported.
+ */
+ public int getMinExposureCompensation() {
+ return getInt(KEY_MIN_EXPOSURE_COMPENSATION, 0);
+ }
+
+ /**
+ * Gets the exposure compensation step.
+ *
+ * @return exposure compensation step. Applications can get EV by
+ * multiplying the exposure compensation index and step. Ex: if
+ * exposure compensation index is -6 and step is 0.333333333, EV
+ * is -2.
+ */
+ public float getExposureCompensationStep() {
+ return getFloat(KEY_EXPOSURE_COMPENSATION_STEP, 0);
}
/**
@@ -1680,6 +1708,24 @@
return substrings;
}
+ // Returns the value of a float parameter.
+ private float getFloat(String key, float defaultValue) {
+ try {
+ return Float.parseFloat(mMap.get(key));
+ } catch (NumberFormatException ex) {
+ return defaultValue;
+ }
+ }
+
+ // Returns the value of a integer parameter.
+ private int getInt(String key, int defaultValue) {
+ try {
+ return Integer.parseInt(mMap.get(key));
+ } catch (NumberFormatException ex) {
+ return defaultValue;
+ }
+ }
+
// Splits a comma delimited string to an ArrayList of Size.
// Return null if the passing string is null or the size is 0.
private ArrayList<Size> splitSize(String str) {
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index e328f33..9df2695 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -187,16 +187,23 @@
// Vertical angle of view in degrees.
// Example value: "42.5". Read only.
static const char KEY_VERTICAL_VIEW_ANGLE[];
- // Exposure compensation. The value is multiplied by 100. -100 means -1 EV.
- // 130 means +1.3 EV.
- // Example value: "0" or "133". Read/write.
+ // Exposure compensation index. 0 means exposure is not adjusted.
+ // Example value: "0" or "5". Read/write.
static const char KEY_EXPOSURE_COMPENSATION[];
- // Supported exposure compensation.
- // Example value: "-100,-66,-33,0,33,66,100". Read only.
- static const char KEY_SUPPORTED_EXPOSURE_COMPENSATION[];
+ // The maximum exposure compensation index (>=0).
+ // Example value: "6". Read only.
+ static const char KEY_MAX_EXPOSURE_COMPENSATION[];
+ // The minimum exposure compensation index (<=0).
+ // Example value: "-6". Read only.
+ static const char KEY_MIN_EXPOSURE_COMPENSATION[];
+ // The exposure compensation step. Exposure compensation index multiply by
+ // step eqals to EV. Ex: if exposure compensation index is 6 and step is
+ // 0.3333, EV is -2.
+ // Example value: "0.333333333" or "0.5". Read only.
+ static const char KEY_EXPOSURE_COMPENSATION_STEP[];
- // Values for white balance settings.
+ // Values for white balance settings.
static const char WHITE_BALANCE_AUTO[];
static const char WHITE_BALANCE_INCANDESCENT[];
static const char WHITE_BALANCE_FLUORESCENT[];
diff --git a/libs/camera/CameraParameters.cpp b/libs/camera/CameraParameters.cpp
index 1bf1759..8439e2b 100644
--- a/libs/camera/CameraParameters.cpp
+++ b/libs/camera/CameraParameters.cpp
@@ -60,7 +60,9 @@
const char CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE[] = "horizontal-view-angle";
const char CameraParameters::KEY_VERTICAL_VIEW_ANGLE[] = "vertical-view-angle";
const char CameraParameters::KEY_EXPOSURE_COMPENSATION[] = "exposure-compensation";
-const char CameraParameters::KEY_SUPPORTED_EXPOSURE_COMPENSATION[] = "exposure-compensation-values";
+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";
// Values for white balance settings.
const char CameraParameters::WHITE_BALANCE_AUTO[] = "auto";