From ad214b3f5616f6ab8d21b0b6503d2ceeee3dceab Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Sun, 17 Nov 2024 18:15:53 +0100 Subject: [PATCH] ExifInterface upgrade --- android/app/build.gradle | 8 +- android/exifinterface/build.gradle | 3 +- .../src/main/AndroidManifest.xml | 4 +- .../media/ExifInterfaceFork.java | 837 +++++++++++------- .../media/ExifInterfaceUtilsFork.java | 46 +- 5 files changed, 542 insertions(+), 356 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index eb8171a4a..2eade1cc3 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -154,12 +154,12 @@ dependencies { implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1' implementation "androidx.appcompat:appcompat:1.7.0" - implementation 'androidx.core:core-ktx:1.13.1' - implementation 'androidx.lifecycle:lifecycle-process:2.8.6' + implementation 'androidx.core:core-ktx:1.15.0' + implementation 'androidx.lifecycle:lifecycle-process:2.8.7' implementation 'androidx.media:media:1.7.0' implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.security:security-crypto:1.1.0-alpha06' - implementation 'androidx.work:work-runtime-ktx:2.9.1' + implementation 'androidx.work:work-runtime-ktx:2.10.0' implementation 'com.caverock:androidsvg-aar:1.4' implementation 'com.commonsware.cwac:document:0.5.0' @@ -181,7 +181,7 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.3' - kapt 'androidx.annotation:annotation:1.8.2' + kapt 'androidx.annotation:annotation:1.9.1' ksp "com.github.bumptech.glide:ksp:$glide_version" compileOnly rootProject.findProject(':streams_channel') diff --git a/android/exifinterface/build.gradle b/android/exifinterface/build.gradle index 46bfa54d8..7d83b50a2 100644 --- a/android/exifinterface/build.gradle +++ b/android/exifinterface/build.gradle @@ -26,5 +26,6 @@ android { } dependencies { - implementation 'androidx.annotation:annotation:1.8.2' + implementation 'androidx.annotation:annotation:1.9.1' + implementation 'org.jspecify:jspecify:1.0.0' } \ No newline at end of file diff --git a/android/exifinterface/src/main/AndroidManifest.xml b/android/exifinterface/src/main/AndroidManifest.xml index a5918e68a..568741e54 100644 --- a/android/exifinterface/src/main/AndroidManifest.xml +++ b/android/exifinterface/src/main/AndroidManifest.xml @@ -1,4 +1,2 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/android/exifinterface/src/main/java/androidx/exifinterface/media/ExifInterfaceFork.java b/android/exifinterface/src/main/java/androidx/exifinterface/media/ExifInterfaceFork.java index 934ee16b5..07bab0f4c 100644 --- a/android/exifinterface/src/main/java/androidx/exifinterface/media/ExifInterfaceFork.java +++ b/android/exifinterface/src/main/java/androidx/exifinterface/media/ExifInterfaceFork.java @@ -22,6 +22,8 @@ import static androidx.exifinterface.media.ExifInterfaceUtilsFork.convertToLongA import static androidx.exifinterface.media.ExifInterfaceUtilsFork.copy; import static androidx.exifinterface.media.ExifInterfaceUtilsFork.parseSubSeconds; import static androidx.exifinterface.media.ExifInterfaceUtilsFork.startsWith; + +import static java.lang.annotation.ElementType.TYPE_USE; import static java.nio.ByteOrder.BIG_ENDIAN; import static java.nio.ByteOrder.LITTLE_ENDIAN; @@ -33,17 +35,19 @@ import android.location.Location; import android.media.MediaDataSource; import android.media.MediaMetadataRetriever; import android.os.Build; +import android.system.Os; import android.system.OsConstants; import android.util.Log; import android.util.Pair; import androidx.annotation.IntDef; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.annotation.RestrictTo; -import androidx.exifinterface.media.ExifInterfaceUtilsFork.Api21Impl; +import androidx.annotation.VisibleForTesting; import androidx.exifinterface.media.ExifInterfaceUtilsFork.Api23Impl; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; + import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.ByteArrayInputStream; @@ -62,12 +66,14 @@ import java.io.InputStream; import java.io.OutputStream; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.charset.Charset; import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Arrays; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.HashSet; @@ -83,20 +89,48 @@ import java.util.regex.Pattern; import java.util.zip.CRC32; /* - * Forked from 'androidx.exifinterface:exifinterface:1.3.7' on 2024/02/21 + * Forked from 'androidx.exifinterface:exifinterface:1.4.0-alpha01' on 2024/11/17 * Named differently to let ExifInterface be loaded as subdependency. + * cf https://github.com/androidx/androidx/tree/androidx-main/exifinterface/exifinterface/src/main/java/androidx/exifinterface/media */ /** * This is a class for reading and writing Exif tags in various image file formats. + * + *

Supported for reading: JPEG, PNG, WebP, HEIC, DNG, CR2, NEF, NRW, ARW, RW2, ORF, PEF, SRW, + * RAF, AVIF (on API 31+). + * + *

Supported for writing: JPEG, PNG, WebP. + * *

- * Supported for reading: JPEG, PNG, WebP, HEIF, DNG, CR2, NEF, NRW, ARW, RW2, ORF, PEF, SRW, RAF. + * + *

XMP Support

*

- * Supported for writing: JPEG, PNG, WebP. - *

- * Note: JPEG and HEIF files may contain XMP data either inside the Exif data chunk or outside of - * it. This class will search both locations for XMP data, but if XMP data exist both inside and - * outside Exif, will favor the XMP data inside Exif over the one outside. + * This class can read raw XMP data from the supported image file formats. + * + *

XMP data can be stored within Exif data (under tag 700), but many of the formats also define a + * separate storage location for XMP. ExifInterface handles this ambiguity as follows: + * + *

*/ public class ExifInterfaceFork { // TLAD threshold for safer Exif attribute parsing @@ -882,29 +916,43 @@ public class ExifInterfaceFork { // G. Tags related to picture-taking condition /** - *

Exposure time, given in seconds.

+ * Exposure time, given in seconds. + * + *

Note: For backwards compatibility this attribute is returned from {@link + * #getAttribute(String)} in decimal form (i.e. the format produced by {@link + * Double#toString(double)}). It is accepted into {@link #setAttribute(String, String)} in both + * rational (e.g. {@code "1/3"}) and decimal forms. The decimal format is anything accepted by + * {@link Double#parseDouble(String)}, e.g. {@code "0.125"}. * *

*/ public static final String TAG_EXPOSURE_TIME = "ExposureTime"; + /** - *

The F number.

+ * The F number. + * + *

Note: For backwards compatibility this attribute is returned from {@link + * #getAttribute(String)} in decimal form (i.e. the format produced by {@link + * Double#toString(double)}). It is accepted into {@link #setAttribute(String, String)} in both + * rational (e.g. {@code "1/3"}) and decimal forms. The decimal format is anything accepted by + * {@link Double#parseDouble(String)}, e.g. {@code "0.125"}. * *

*/ public static final String TAG_F_NUMBER = "FNumber"; + /** - *

TThe class of the program used by the camera to set exposure when the picture is taken. + *

The class of the program used by the camera to set exposure when the picture is taken. * The tag values are as follows.

* * */ public static final String TAG_MAX_APERTURE_VALUE = "MaxApertureValue"; + /** - *

The distance to the subject, given in meters. Note that if the numerator of the recorded - * value is 0xFFFFFFFF, Infinity shall be indicated; and if the numerator is 0, Distance - * unknown shall be indicated.

+ * The distance to the subject, given in meters. + * + *

Note that if the numerator of the recorded value is 0xFFFFFFFF, Infinity shall be + * indicated; and if the numerator is 0, Distance unknown shall be indicated. + * + *

Note: For backwards compatibility this attribute is returned from {@link + * #getAttribute(String)} in decimal form (i.e. the format produced by {@link + * Double#toString(double)}). It is accepted into {@link #setAttribute(String, String)} in both + * rational (e.g. {@code "1/3"}) and decimal forms. The decimal format is anything accepted by + * {@link Double#parseDouble(String)}, e.g. {@code "0.125"}. * *

*/ public static final String TAG_SUBJECT_DISTANCE = "SubjectDistance"; + /** *

The metering mode.

* @@ -1451,18 +1508,26 @@ public class ExifInterfaceFork { * @see #WHITEBALANCE_MANUAL */ public static final String TAG_WHITE_BALANCE = "WhiteBalance"; + /** - *

This tag indicates the digital zoom ratio when the image was shot. If the numerator of - * the recorded value is 0, this indicates that digital zoom was not used.

+ * This tag indicates the digital zoom ratio when the image was shot. If the numerator of the + * recorded value is 0, this indicates that digital zoom was not used. + * + *

Note: For backwards compatibility this attribute is returned from {@link + * #getAttribute(String)} in decimal form (i.e. the format produced by {@link + * Double#toString(double)}). It is accepted into {@link #setAttribute(String, String)} in both + * rational (e.g. {@code "1/3"}) and decimal forms. The decimal format is anything accepted by + * {@link Double#parseDouble(String)}, e.g. {@code "0.125"}. * *

*/ public static final String TAG_DIGITAL_ZOOM_RATIO = "DigitalZoomRatio"; + /** *

This tag indicates the equivalent focal length assuming a 35mm film camera, in mm. * A value of 0 means the focal length is unknown. Note that this tag differs from @@ -1792,18 +1857,24 @@ public class ExifInterfaceFork { * */ public static final String TAG_GPS_ALTITUDE = "GPSAltitude"; + /** - *

Indicates the time as UTC (Coordinated Universal Time). TimeStamp is expressed as three - * unsigned rational values giving the hour, minute, and second.

+ * Indicates the time as UTC (Coordinated Universal Time). TimeStamp is expressed as three + * unsigned rational values giving the hour, minute, and second. + * + *

Note: This attribute is returned from {@link #getAttribute(String)} and accepted into + * {@link #setAttribute(String, String)} as 3 colon-separated integers, e.g. {@code "11:05:32"}. + * Decimal or rational hours, minutes or seconds parts are not supported. * *

*/ public static final String TAG_GPS_TIMESTAMP = "GPSTimeStamp"; + /** *

Indicates the GPS satellites used for measurements. This tag may be used to describe * the number of satellites, their ID number, angle of elevation, azimuth, SNR and other @@ -1876,7 +1947,8 @@ public class ExifInterfaceFork { */ public static final String TAG_GPS_SPEED_REF = "GPSSpeedRef"; /** - *

Indicates the speed of GPS receiver movement.

+ * Indicates the speed of GPS receiver movement. The units are indicated by {@link + * #TAG_GPS_SPEED_REF}. * *