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

Commit 9574e580 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala Committed by Gerrit Code Review
Browse files

Merge "Don't use timestamps with all zero"

parents 887d348d 43b0a458
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package android.media;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -128,6 +130,9 @@ public class ExifInterface {
    // use sLock to serialize the accesses.
    private static final Object sLock = new Object();

    // Pattern to check non zero timestamp
    private static final Pattern sNonZeroTimePattern = Pattern.compile(".*[1-9].*");

    /**
     * Reads Exif tags from the specified JPEG file.
     */
@@ -367,7 +372,8 @@ public class ExifInterface {
     */
    public long getDateTime() {
        String dateTimeString = mAttributes.get(TAG_DATETIME);
        if (dateTimeString == null) return -1;
        if (dateTimeString == null
                || !sNonZeroTimePattern.matcher(dateTimeString).matches()) return -1;

        ParsePosition pos = new ParsePosition(0);
        try {
@@ -402,7 +408,9 @@ public class ExifInterface {
    public long getGpsDateTime() {
        String date = mAttributes.get(TAG_GPS_DATESTAMP);
        String time = mAttributes.get(TAG_GPS_TIMESTAMP);
        if (date == null || time == null) return -1;
        if (date == null || time == null
                || (!sNonZeroTimePattern.matcher(date).matches()
                && !sNonZeroTimePattern.matcher(time).matches())) return -1;

        String dateTimeString = date + ' ' + time;