Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8f240961 authored by Emilian Peev's avatar Emilian Peev
Browse files

Camera2: Correct EXIF GPS timestamp

 GPS 'Location' expects timestamps in milliseconds
 however the camera metadata uses seconds for it.
 An additional conversion is needed to take care
 of this mismatch.

BUG: 32593275
Change-Id: I636060aac2177ae9818af32d677292f1eb76d97e
parent 0ae1a7d9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -792,7 +792,8 @@ public class CameraMetadataNative implements Parcelable {
    private Location getGpsLocation() {
        String processingMethod = get(CaptureResult.JPEG_GPS_PROCESSING_METHOD);
        double[] coords = get(CaptureResult.JPEG_GPS_COORDINATES);
        Long timeStamp = get(CaptureResult.JPEG_GPS_TIMESTAMP);
        // Location expects timestamp in [ms.]
        Long timeStamp = get(CaptureResult.JPEG_GPS_TIMESTAMP) * 1000;

        if (areValuesAllNull(processingMethod, coords, timeStamp)) {
            return null;
@@ -823,7 +824,8 @@ public class CameraMetadataNative implements Parcelable {

        double[] coords = { l.getLatitude(), l.getLongitude(), l.getAltitude() };
        String processMethod = translateLocationProviderToProcess(l.getProvider());
        long timestamp = l.getTime();
        //JPEG_GPS_TIMESTAMP expects sec. instead of msec.
        long timestamp = l.getTime() / 1000;

        set(CaptureRequest.JPEG_GPS_TIMESTAMP, timestamp);
        set(CaptureRequest.JPEG_GPS_COORDINATES, coords);