Fix build for EXIF processing on 64-bit platforms
64-bit builds do not have time64_t since time_t itself is 64-bit, make
sure the EXIF code that processes GPS timestamps uses a 64-bit version
of time_t that exists on the current platform.
Test: ran camera CTS tests
Change-Id: Ia32ad546c57e685ec9dfdf47c65aa10fe5b5a120
(cherry picked from commit 5f9bf798dfb618fc204dfa422e89e75bbd5a7abd)
diff --git a/camera/Exif.cpp b/camera/Exif.cpp
index 06364d6..22d5cea 100644
--- a/camera/Exif.cpp
+++ b/camera/Exif.cpp
@@ -23,7 +23,6 @@
#include <inttypes.h>
#include <math.h>
#include <stdint.h>
-#include <time64.h>
#include <camera/CameraParameters.h>
#include <libexif/exif-data.h>
@@ -34,6 +33,18 @@
#include <string>
#include <vector>
+// For GPS timestamping we want to ensure we use a 64-bit time_t, 32-bit
+// platforms have time64_t but 64-bit platforms do not.
+#if defined(__LP64__)
+#include <time.h>
+using Timestamp = time_t;
+#define TIMESTAMP_TO_TM(timestamp, tm) gmtime_r(timestamp, tm)
+#else
+#include <time64.h>
+using Timestamp = time64_t;
+#define TIMESTAMP_TO_TM(timestamp, tm) gmtime64_r(timestamp, tm)
+#endif
+
namespace android {
// A prefix that is used for tags with the "undefined" format to indicate that
@@ -206,9 +217,9 @@
static bool convertTimestampToTimeAndDate(int64_t timestamp,
float (*timeValues)[3],
std::string* date) {
- time64_t time = timestamp;
+ Timestamp time = timestamp;
struct tm utcTime;
- if (gmtime64_r(&time, &utcTime) == nullptr) {
+ if (TIMESTAMP_TO_TM(&time, &utcTime) == nullptr) {
ALOGE("Could not decompose timestamp into components");
return false;
}