Merge "Use a ExifInterface ctor with a file descriptor as a parameter" am: f715c61542

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2485757

Change-Id: I8c2482febe7e289f51a1f122e4148b8443e41a8d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Ray Essick
2023-03-20 23:33:41 +00:00
committed by Automerger Merge Worker

View File

@@ -49,6 +49,7 @@ import com.android.internal.util.ArrayUtils;
import libcore.io.IoUtils; import libcore.io.IoUtils;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
@@ -255,17 +256,19 @@ public class ThumbnailUtils {
// get orientation // get orientation
if (MediaFile.isExifMimeType(mimeType)) { if (MediaFile.isExifMimeType(mimeType)) {
exif = new ExifInterface(file); try (FileInputStream is = new FileInputStream(file)) {
switch (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0)) { exif = new ExifInterface(is.getFD());
case ExifInterface.ORIENTATION_ROTATE_90: switch (exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0)) {
orientation = 90; case ExifInterface.ORIENTATION_ROTATE_90:
break; orientation = 90;
case ExifInterface.ORIENTATION_ROTATE_180: break;
orientation = 180; case ExifInterface.ORIENTATION_ROTATE_180:
break; orientation = 180;
case ExifInterface.ORIENTATION_ROTATE_270: break;
orientation = 270; case ExifInterface.ORIENTATION_ROTATE_270:
break; orientation = 270;
break;
}
} }
} }