>() {{ }});
/**
* Arrangement of color filters on sensor;
@@ -1353,8 +1353,8 @@ public final class CameraCharacteristics extends CameraMetadata SENSOR_INFO_EXPOSURE_TIME_RANGE =
- new Key("android.sensor.info.exposureTimeRange", long[].class);
+ public static final Key> SENSOR_INFO_EXPOSURE_TIME_RANGE =
+ new Key>("android.sensor.info.exposureTimeRange", new TypeReference>() {{ }});
/**
* Maximum possible frame duration (minimum frame
diff --git a/core/java/android/hardware/camera2/CameraManager.java b/core/java/android/hardware/camera2/CameraManager.java
index 03b342c03ff5..83db056dc771 100644
--- a/core/java/android/hardware/camera2/CameraManager.java
+++ b/core/java/android/hardware/camera2/CameraManager.java
@@ -220,6 +220,7 @@ public final class CameraManager {
private CameraDevice openCameraDeviceUserAsync(String cameraId,
CameraDevice.StateListener listener, Handler handler)
throws CameraAccessException {
+ CameraCharacteristics characteristics = getCameraCharacteristics(cameraId);
CameraDevice device = null;
try {
@@ -231,7 +232,8 @@ public final class CameraManager {
new android.hardware.camera2.impl.CameraDevice(
cameraId,
listener,
- handler);
+ handler,
+ characteristics);
BinderHolder holder = new BinderHolder();
diff --git a/core/java/android/hardware/camera2/CameraMetadata.java b/core/java/android/hardware/camera2/CameraMetadata.java
index 86c691f97855..27b4fb8ee6b1 100644
--- a/core/java/android/hardware/camera2/CameraMetadata.java
+++ b/core/java/android/hardware/camera2/CameraMetadata.java
@@ -290,8 +290,8 @@ public abstract class CameraMetadata {
*
*
* Lens shading map information
- * - {@link CaptureResult#STATISTICS_LENS_SHADING_MAP android.statistics.lensShadingMap}
- * - {@link CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE android.lens.info.shadingMapSize}
+ * - android.statistics.lensShadingMap
+ * - android.lens.info.shadingMapSize
*
*
*
@@ -302,8 +302,6 @@ public abstract class CameraMetadata {
*
* @see CaptureRequest#COLOR_CORRECTION_GAINS
* @see CaptureRequest#COLOR_CORRECTION_TRANSFORM
- * @see CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE
- * @see CaptureResult#STATISTICS_LENS_SHADING_MAP
* @see CaptureRequest#TONEMAP_CURVE
* @see CameraCharacteristics#TONEMAP_MAX_CURVE_POINTS
* @see CaptureRequest#TONEMAP_MODE
diff --git a/core/java/android/hardware/camera2/CaptureRequest.java b/core/java/android/hardware/camera2/CaptureRequest.java
index 9d490ca0d7f6..79659f1f5239 100644
--- a/core/java/android/hardware/camera2/CaptureRequest.java
+++ b/core/java/android/hardware/camera2/CaptureRequest.java
@@ -1051,9 +1051,16 @@ public final class CaptureRequest extends CameraMetadata>
public static final Key HOT_PIXEL_MODE =
new Key("android.hotPixel.mode", int.class);
+ /**
+ * A location object to use when generating image GPS metadata.
+ */
+ public static final Key JPEG_GPS_LOCATION =
+ new Key("android.jpeg.gpsLocation", android.location.Location.class);
+
/**
* GPS coordinates to include in output JPEG
* EXIF
+ * @hide
*/
public static final Key JPEG_GPS_COORDINATES =
new Key("android.jpeg.gpsCoordinates", double[].class);
@@ -1061,6 +1068,7 @@ public final class CaptureRequest extends CameraMetadata>
/**
* 32 characters describing GPS algorithm to
* include in EXIF
+ * @hide
*/
public static final Key JPEG_GPS_PROCESSING_METHOD =
new Key("android.jpeg.gpsProcessingMethod", String.class);
@@ -1068,6 +1076,7 @@ public final class CaptureRequest extends CameraMetadata>
/**
* Time GPS fix was made to include in
* EXIF
+ * @hide
*/
public static final Key JPEG_GPS_TIMESTAMP =
new Key("android.jpeg.gpsTimestamp", long.class);
@@ -1416,8 +1425,8 @@ public final class CaptureRequest extends CameraMetadata>
* When set to OFF mode, no lens shading correction will be applied by the
* camera device, and an identity lens shading map data will be provided
* if {@link CaptureRequest#STATISTICS_LENS_SHADING_MAP_MODE android.statistics.lensShadingMapMode} == ON. For example, for lens
- * shading map with size specified as {@link CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE android.lens.info.shadingMapSize} = [ 4, 3 ],
- * the output {@link CaptureResult#STATISTICS_LENS_SHADING_MAP android.statistics.lensShadingMap} for this case will be an identity map
+ * shading map with size specified as android.lens.info.shadingMapSize = [ 4, 3 ],
+ * the output android.statistics.lensShadingMap for this case will be an identity map
* shown below:
* [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
* 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
@@ -1429,8 +1438,8 @@ public final class CaptureRequest extends CameraMetadata>
* When set to other modes, lens shading correction will be applied by the
* camera device. Applications can request lens shading map data by setting
* {@link CaptureRequest#STATISTICS_LENS_SHADING_MAP_MODE android.statistics.lensShadingMapMode} to ON, and then the camera device will provide
- * lens shading map data in {@link CaptureResult#STATISTICS_LENS_SHADING_MAP android.statistics.lensShadingMap}, with size specified
- * by {@link CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE android.lens.info.shadingMapSize}; the returned shading map data will be the one
+ * lens shading map data in android.statistics.lensShadingMap, with size specified
+ * by android.lens.info.shadingMapSize; the returned shading map data will be the one
* applied by the camera device for this capture request.
* The shading map data may depend on the AE and AWB statistics, therefore the reliability
* of the map data may be affected by the AE and AWB algorithms. When AE and AWB are in
@@ -1440,8 +1449,6 @@ public final class CaptureRequest extends CameraMetadata>
*
* @see CaptureRequest#CONTROL_AE_MODE
* @see CaptureRequest#CONTROL_AWB_MODE
- * @see CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE
- * @see CaptureResult#STATISTICS_LENS_SHADING_MAP
* @see CaptureRequest#STATISTICS_LENS_SHADING_MAP_MODE
* @see #SHADING_MODE_OFF
* @see #SHADING_MODE_FAST
@@ -1482,10 +1489,8 @@ public final class CaptureRequest extends CameraMetadata>
* Whether the camera device will output the lens
* shading map in output result metadata.
* When set to ON,
- * {@link CaptureResult#STATISTICS_LENS_SHADING_MAP android.statistics.lensShadingMap} must be provided in
+ * android.statistics.lensShadingMap must be provided in
* the output result metadata.
- *
- * @see CaptureResult#STATISTICS_LENS_SHADING_MAP
* @see #STATISTICS_LENS_SHADING_MAP_MODE_OFF
* @see #STATISTICS_LENS_SHADING_MAP_MODE_ON
*/
diff --git a/core/java/android/hardware/camera2/CaptureResult.java b/core/java/android/hardware/camera2/CaptureResult.java
index 51180e8f2c62..aa202acc0512 100644
--- a/core/java/android/hardware/camera2/CaptureResult.java
+++ b/core/java/android/hardware/camera2/CaptureResult.java
@@ -1639,9 +1639,16 @@ public class CaptureResult extends CameraMetadata> {
public static final Key HOT_PIXEL_MODE =
new Key("android.hotPixel.mode", int.class);
+ /**
+ * A location object to use when generating image GPS metadata.
+ */
+ public static final Key JPEG_GPS_LOCATION =
+ new Key("android.jpeg.gpsLocation", android.location.Location.class);
+
/**
* GPS coordinates to include in output JPEG
* EXIF
+ * @hide
*/
public static final Key JPEG_GPS_COORDINATES =
new Key("android.jpeg.gpsCoordinates", double[].class);
@@ -1649,6 +1656,7 @@ public class CaptureResult extends CameraMetadata> {
/**
* 32 characters describing GPS algorithm to
* include in EXIF
+ * @hide
*/
public static final Key JPEG_GPS_PROCESSING_METHOD =
new Key("android.jpeg.gpsProcessingMethod", String.class);
@@ -1656,6 +1664,7 @@ public class CaptureResult extends CameraMetadata> {
/**
* Time GPS fix was made to include in
* EXIF
+ * @hide
*/
public static final Key JPEG_GPS_TIMESTAMP =
new Key("android.jpeg.gpsTimestamp", long.class);
@@ -2145,8 +2154,8 @@ public class CaptureResult extends CameraMetadata> {
* When set to OFF mode, no lens shading correction will be applied by the
* camera device, and an identity lens shading map data will be provided
* if {@link CaptureRequest#STATISTICS_LENS_SHADING_MAP_MODE android.statistics.lensShadingMapMode} == ON. For example, for lens
- * shading map with size specified as {@link CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE android.lens.info.shadingMapSize} = [ 4, 3 ],
- * the output {@link CaptureResult#STATISTICS_LENS_SHADING_MAP android.statistics.lensShadingMap} for this case will be an identity map
+ * shading map with size specified as android.lens.info.shadingMapSize = [ 4, 3 ],
+ * the output android.statistics.lensShadingMap for this case will be an identity map
* shown below:
* [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
* 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
@@ -2158,8 +2167,8 @@ public class CaptureResult extends CameraMetadata> {
* When set to other modes, lens shading correction will be applied by the
* camera device. Applications can request lens shading map data by setting
* {@link CaptureRequest#STATISTICS_LENS_SHADING_MAP_MODE android.statistics.lensShadingMapMode} to ON, and then the camera device will provide
- * lens shading map data in {@link CaptureResult#STATISTICS_LENS_SHADING_MAP android.statistics.lensShadingMap}, with size specified
- * by {@link CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE android.lens.info.shadingMapSize}; the returned shading map data will be the one
+ * lens shading map data in android.statistics.lensShadingMap, with size specified
+ * by android.lens.info.shadingMapSize; the returned shading map data will be the one
* applied by the camera device for this capture request.
* The shading map data may depend on the AE and AWB statistics, therefore the reliability
* of the map data may be affected by the AE and AWB algorithms. When AE and AWB are in
@@ -2169,8 +2178,6 @@ public class CaptureResult extends CameraMetadata> {
*
* @see CaptureRequest#CONTROL_AE_MODE
* @see CaptureRequest#CONTROL_AWB_MODE
- * @see CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE
- * @see CaptureResult#STATISTICS_LENS_SHADING_MAP
* @see CaptureRequest#STATISTICS_LENS_SHADING_MAP_MODE
* @see #SHADING_MODE_OFF
* @see #SHADING_MODE_FAST
@@ -2242,6 +2249,52 @@ public class CaptureResult extends CameraMetadata> {
public static final Key STATISTICS_FACES =
new Key("android.statistics.faces", android.hardware.camera2.params.Face[].class);
+ /**
+ * The shading map is a low-resolution floating-point map
+ * that lists the coefficients used to correct for vignetting, for each
+ * Bayer color channel.
+ * The least shaded section of the image should have a gain factor
+ * of 1; all other sections should have gains above 1.
+ * When {@link CaptureRequest#COLOR_CORRECTION_MODE android.colorCorrection.mode} = TRANSFORM_MATRIX, the map
+ * must take into account the colorCorrection settings.
+ * The shading map is for the entire active pixel array, and is not
+ * affected by the crop region specified in the request. Each shading map
+ * entry is the value of the shading compensation map over a specific
+ * pixel on the sensor. Specifically, with a (N x M) resolution shading
+ * map, and an active pixel array size (W x H), shading map entry
+ * (x,y) ϵ (0 ... N-1, 0 ... M-1) is the value of the shading map at
+ * pixel ( ((W-1)/(N-1)) * x, ((H-1)/(M-1)) * y) for the four color channels.
+ * The map is assumed to be bilinearly interpolated between the sample points.
+ * The channel order is [R, Geven, Godd, B], where Geven is the green
+ * channel for the even rows of a Bayer pattern, and Godd is the odd rows.
+ * The shading map is stored in a fully interleaved format.
+ * The shading map should have on the order of 30-40 rows and columns,
+ * and must be smaller than 64x64.
+ * As an example, given a very small map defined as:
+ * width,height = [ 4, 3 ]
+ * values =
+ * [ 1.3, 1.2, 1.15, 1.2, 1.2, 1.2, 1.15, 1.2,
+ * 1.1, 1.2, 1.2, 1.2, 1.3, 1.2, 1.3, 1.3,
+ * 1.2, 1.2, 1.25, 1.1, 1.1, 1.1, 1.1, 1.0,
+ * 1.0, 1.0, 1.0, 1.0, 1.2, 1.3, 1.25, 1.2,
+ * 1.3, 1.2, 1.2, 1.3, 1.2, 1.15, 1.1, 1.2,
+ * 1.2, 1.1, 1.0, 1.2, 1.3, 1.15, 1.2, 1.3 ]
+ *
+ * The low-resolution scaling map images for each channel are
+ * (displayed using nearest-neighbor interpolation):
+ *
+ *
+ *
+ * 
+ * As a visualization only, inverting the full-color map to recover an
+ * image of a gray wall (using bicubic interpolation for visual quality) as captured by the sensor gives:
+ * 
+ *
+ * @see CaptureRequest#COLOR_CORRECTION_MODE
+ */
+ public static final Key STATISTICS_LENS_SHADING_CORRECTION_MAP =
+ new Key("android.statistics.lensShadingCorrectionMap", android.hardware.camera2.params.LensShadingMap.class);
+
/**
* The shading map is a low-resolution floating-point map
* that lists the coefficients used to correct for vignetting, for each
@@ -2261,12 +2314,12 @@ public class CaptureResult extends CameraMetadata> {
* The channel order is [R, Geven, Godd, B], where Geven is the green
* channel for the even rows of a Bayer pattern, and Godd is the odd rows.
* The shading map is stored in a fully interleaved format, and its size
- * is provided in the camera static metadata by {@link CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE android.lens.info.shadingMapSize}.
+ * is provided in the camera static metadata by android.lens.info.shadingMapSize.
* The shading map should have on the order of 30-40 rows and columns,
* and must be smaller than 64x64.
* As an example, given a very small map defined as:
- * {@link CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE android.lens.info.shadingMapSize} = [ 4, 3 ]
- * {@link CaptureResult#STATISTICS_LENS_SHADING_MAP android.statistics.lensShadingMap} =
+ * android.lens.info.shadingMapSize = [ 4, 3 ]
+ * android.statistics.lensShadingMap =
* [ 1.3, 1.2, 1.15, 1.2, 1.2, 1.2, 1.15, 1.2,
* 1.1, 1.2, 1.2, 1.2, 1.3, 1.2, 1.3, 1.3,
* 1.2, 1.2, 1.25, 1.1, 1.1, 1.1, 1.1, 1.0,
@@ -2285,8 +2338,7 @@ public class CaptureResult extends CameraMetadata> {
* 
*
* @see CaptureRequest#COLOR_CORRECTION_MODE
- * @see CameraCharacteristics#LENS_INFO_SHADING_MAP_SIZE
- * @see CaptureResult#STATISTICS_LENS_SHADING_MAP
+ * @hide
*/
public static final Key STATISTICS_LENS_SHADING_MAP =
new Key("android.statistics.lensShadingMap", float[].class);
@@ -2393,10 +2445,8 @@ public class CaptureResult extends CameraMetadata> {
* Whether the camera device will output the lens
* shading map in output result metadata.
* When set to ON,
- * {@link CaptureResult#STATISTICS_LENS_SHADING_MAP android.statistics.lensShadingMap} must be provided in
+ * android.statistics.lensShadingMap must be provided in
* the output result metadata.
- *
- * @see CaptureResult#STATISTICS_LENS_SHADING_MAP
* @see #STATISTICS_LENS_SHADING_MAP_MODE_OFF
* @see #STATISTICS_LENS_SHADING_MAP_MODE_ON
*/
diff --git a/core/java/android/hardware/camera2/impl/CameraDevice.java b/core/java/android/hardware/camera2/impl/CameraDevice.java
index 7b249766a977..9a4c53155704 100644
--- a/core/java/android/hardware/camera2/impl/CameraDevice.java
+++ b/core/java/android/hardware/camera2/impl/CameraDevice.java
@@ -20,6 +20,8 @@ import static android.hardware.camera2.CameraAccessException.CAMERA_IN_USE;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCaptureSession;
+import android.hardware.camera2.CameraCharacteristics;
+import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.ICameraDeviceCallbacks;
@@ -73,6 +75,7 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice {
private final SparseArray mConfiguredOutputs = new SparseArray();
private final String mCameraId;
+ private final CameraCharacteristics mCharacteristics;
/**
* A list tracking request and its expected last frame.
@@ -151,13 +154,15 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice {
}
};
- public CameraDevice(String cameraId, StateListener listener, Handler handler) {
+ public CameraDevice(String cameraId, StateListener listener, Handler handler,
+ CameraCharacteristics characteristics) {
if (cameraId == null || listener == null || handler == null) {
throw new IllegalArgumentException("Null argument given");
}
mCameraId = cameraId;
mDeviceListener = listener;
mDeviceHandler = handler;
+ mCharacteristics = characteristics;
final int MAX_TAG_LEN = 23;
String tag = String.format("CameraDevice-JV-%s", mCameraId);
@@ -851,11 +856,18 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice {
@Override
public void onResultReceived(CameraMetadataNative result,
CaptureResultExtras resultExtras) throws RemoteException {
+
int requestId = resultExtras.getRequestId();
if (DEBUG) {
Log.v(TAG, "Received result frame " + resultExtras.getFrameNumber() + " for id "
+ requestId);
}
+
+
+ // TODO: Handle CameraCharacteristics access from CaptureResult correctly.
+ result.set(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE,
+ getCharacteristics().get(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE));
+
final CaptureListenerHolder holder;
synchronized (mLock) {
holder = CameraDevice.this.mCaptureListenerMap.get(requestId);
@@ -965,4 +977,8 @@ public class CameraDevice implements android.hardware.camera2.CameraDevice {
return (mRemoteDevice == null);
}
}
+
+ private CameraCharacteristics getCharacteristics() {
+ return mCharacteristics;
+ }
}
diff --git a/core/java/android/hardware/camera2/impl/CameraMetadataNative.java b/core/java/android/hardware/camera2/impl/CameraMetadataNative.java
index 12d8ddf36708..dc0c65250386 100644
--- a/core/java/android/hardware/camera2/impl/CameraMetadataNative.java
+++ b/core/java/android/hardware/camera2/impl/CameraMetadataNative.java
@@ -43,15 +43,19 @@ import android.hardware.camera2.marshal.impl.MarshalQueryableStreamConfiguration
import android.hardware.camera2.marshal.impl.MarshalQueryableStreamConfigurationDuration;
import android.hardware.camera2.marshal.impl.MarshalQueryableString;
import android.hardware.camera2.params.Face;
+import android.hardware.camera2.params.LensShadingMap;
import android.hardware.camera2.params.StreamConfiguration;
import android.hardware.camera2.params.StreamConfigurationDuration;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.hardware.camera2.params.TonemapCurve;
import android.hardware.camera2.utils.TypeReference;
+import android.location.Location;
+import android.location.LocationManager;
import android.os.Parcelable;
import android.os.Parcel;
import android.util.Log;
import android.util.Pair;
+import android.util.Size;
import com.android.internal.util.Preconditions;
@@ -59,6 +63,7 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.ArrayList;
+import java.util.HashMap;
/**
* Implementation of camera metadata marshal/unmarshal across Binder to
@@ -211,6 +216,37 @@ public class CameraMetadataNative implements Parcelable {
// this should be in sync with HAL_PIXEL_FORMAT_BLOB defined in graphics.h
public static final int NATIVE_JPEG_FORMAT = 0x21;
+ private static final String CELLID_PROCESS = "CELLID";
+ private static final String GPS_PROCESS = "GPS";
+
+ private static String translateLocationProviderToProcess(final String provider) {
+ if (provider == null) {
+ return null;
+ }
+ switch(provider) {
+ case LocationManager.GPS_PROVIDER:
+ return GPS_PROCESS;
+ case LocationManager.NETWORK_PROVIDER:
+ return CELLID_PROCESS;
+ default:
+ return null;
+ }
+ }
+
+ private static String translateProcessToLocationProvider(final String process) {
+ if (process == null) {
+ return null;
+ }
+ switch(process) {
+ case GPS_PROCESS:
+ return LocationManager.GPS_PROVIDER;
+ case CELLID_PROCESS:
+ return LocationManager.NETWORK_PROVIDER;
+ default:
+ return null;
+ }
+ }
+
public CameraMetadataNative() {
super();
mMetadataPtr = nativeAllocate();
@@ -411,7 +447,6 @@ public class CameraMetadataNative implements Parcelable {
ByteBuffer buffer = ByteBuffer.wrap(values).order(ByteOrder.nativeOrder());
return marshaler.unmarshal(buffer);
}
-
// Need overwrite some metadata that has different definitions between native
// and managed sides.
@SuppressWarnings("unchecked")
@@ -441,6 +476,10 @@ public class CameraMetadataNative implements Parcelable {
value = (T) getMaxNumOutputs(key);
} else if (key.equals(CaptureRequest.TONEMAP_CURVE)) {
value = (T) getTonemapCurve();
+ } else if (key.equals(CaptureResult.JPEG_GPS_LOCATION)) {
+ value = (T) getGpsLocation();
+ } else if (key.equals(CaptureResult.STATISTICS_LENS_SHADING_CORRECTION_MAP)) {
+ value = (T) getLensShadingMap();
} else {
override = false;
}
@@ -561,6 +600,62 @@ public class CameraMetadataNative implements Parcelable {
return fixedFaceRectangles;
}
+ private LensShadingMap getLensShadingMap() {
+ float[] lsmArray = getBase(CaptureResult.STATISTICS_LENS_SHADING_MAP);
+ if (lsmArray == null) {
+ Log.w(TAG, "getLensShadingMap - Lens shading map was null.");
+ return null;
+ }
+ Size s = get(CameraCharacteristics.LENS_INFO_SHADING_MAP_SIZE);
+ LensShadingMap map = new LensShadingMap(lsmArray, s.getHeight(), s.getWidth());
+ return map;
+ }
+
+ private Location getGpsLocation() {
+ String processingMethod = get(CaptureResult.JPEG_GPS_PROCESSING_METHOD);
+ Location l = new Location(translateProcessToLocationProvider(processingMethod));
+
+ double[] coords = get(CaptureResult.JPEG_GPS_COORDINATES);
+ Long timeStamp = get(CaptureResult.JPEG_GPS_TIMESTAMP);
+
+ if (timeStamp != null) {
+ l.setTime(timeStamp);
+ } else {
+ Log.w(TAG, "getGpsLocation - No timestamp for GPS location.");
+ }
+
+ if (coords != null) {
+ l.setLatitude(coords[0]);
+ l.setLongitude(coords[1]);
+ l.setAltitude(coords[2]);
+ } else {
+ Log.w(TAG, "getGpsLocation - No coordinates for GPS location");
+ }
+
+ return l;
+ }
+
+ private boolean setGpsLocation(Location l) {
+ if (l == null) {
+ return false;
+ }
+
+ double[] coords = { l.getLatitude(), l.getLongitude(), l.getAltitude() };
+ String processMethod = translateLocationProviderToProcess(l.getProvider());
+ long timestamp = l.getTime();
+
+ set(CaptureRequest.JPEG_GPS_TIMESTAMP, timestamp);
+ set(CaptureRequest.JPEG_GPS_COORDINATES, coords);
+
+ if (processMethod == null) {
+ Log.w(TAG, "setGpsLocation - No process method, Location is not from a GPS or NETWORK" +
+ "provider");
+ } else {
+ setBase(CaptureRequest.JPEG_GPS_PROCESSING_METHOD, processMethod);
+ }
+ return true;
+ }
+
private StreamConfigurationMap getStreamConfigurationMap() {
StreamConfiguration[] configurations = getBase(
CameraCharacteristics.SCALER_AVAILABLE_STREAM_CONFIGURATIONS);
@@ -670,6 +765,8 @@ public class CameraMetadataNative implements Parcelable {
return setFaceRectangles((Rect[]) value);
} else if (key.equals(CaptureRequest.TONEMAP_CURVE)) {
return setTonemapCurve((TonemapCurve) value);
+ } else if (key.equals(CaptureResult.JPEG_GPS_LOCATION)) {
+ return setGpsLocation((Location) value);
}
// For other keys, set() falls back to setBase().
return false;
diff --git a/core/java/android/hardware/camera2/params/LensShadingMap.java b/core/java/android/hardware/camera2/params/LensShadingMap.java
index b328f5786321..9bbc33a85f17 100644
--- a/core/java/android/hardware/camera2/params/LensShadingMap.java
+++ b/core/java/android/hardware/camera2/params/LensShadingMap.java
@@ -28,7 +28,7 @@ import java.util.Arrays;
/**
* Immutable class for describing a {@code 4 x N x M} lens shading map of floats.
*
- * @see CameraCharacteristics#LENS_SHADING_MAP
+ * @see CaptureResult#STATISTICS_LENS_SHADING_CORRECTION_MAP
*/
public final class LensShadingMap {
@@ -62,12 +62,12 @@ public final class LensShadingMap {
public LensShadingMap(final float[] elements, final int rows, final int columns) {
mRows = checkArgumentPositive(rows, "rows must be positive");
- mColumns = checkArgumentPositive(rows, "columns must be positive");
+ mColumns = checkArgumentPositive(columns, "columns must be positive");
mElements = checkNotNull(elements, "elements must not be null");
if (elements.length != getGainFactorCount()) {
throw new IllegalArgumentException("elements must be " + getGainFactorCount() +
- " length");
+ " length, received " + elements.length);
}
// Every element must be finite and >= 1.0f
@@ -242,4 +242,4 @@ public final class LensShadingMap {
private final int mRows;
private final int mColumns;
private final float[] mElements;
-};
+}
--
cgit v1.2.3-59-g8ed1b