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

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

Change-Id: Ibf961c109e95504081ca0b6aa925b4cfd6beabee
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Ray Essick
2023-03-21 00:54:12 +00:00
committed by Automerger Merge Worker

View File

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