OSDN Git Service

ExifInterface: Prevent DATETIME value from being set unproperly
authorHyundo Moon <hdmoon@google.com>
Mon, 12 Jun 2017 11:47:50 +0000 (20:47 +0900)
committerHyundo Moon <hdmoon@google.com>
Tue, 13 Jun 2017 02:37:20 +0000 (02:37 +0000)
Although the DATETIME and DATETIME_ORIGINAL tags are for different
purposes, the DATETIME value is set to the same value as
DATETIME_ORIGINAL tag's when loading the attributes of an image.
This CL prevents the problem by setting the value of DATETIME tag only
when it does not exist.

Bug: 62137632
Test: Passed ExifInterface CTS
Change-Id: Ic5c43c53cb363a782bcac20915d74ea534ec70e4

media/java/android/media/ExifInterface.java

index 0a61148..6677178 100644 (file)
@@ -2661,9 +2661,9 @@ public class ExifInterface {
     }
 
     private void addDefaultValuesForCompatibility() {
-        // The value of DATETIME tag has the same value of DATETIME_ORIGINAL tag.
+        // If DATETIME tag has no value, then set the value to DATETIME_ORIGINAL tag's.
         String valueOfDateTimeOriginal = getAttribute(TAG_DATETIME_ORIGINAL);
-        if (valueOfDateTimeOriginal != null) {
+        if (valueOfDateTimeOriginal != null && getAttribute(TAG_DATETIME) == null) {
             mAttributes[IFD_TYPE_PRIMARY].put(TAG_DATETIME,
                     ExifAttribute.createString(valueOfDateTimeOriginal));
         }