Use a ExifInterface ctor with a file descriptor as a parameter
To avoid a binder circular dependency, ExifInterface is changed to use a file descriptor for getting HEIF attributes (when available). Bug: 199822700 Test: manual Change-Id: I1b0762fd91f89bfb739b47467a685149309dd157
This commit is contained in:
parent
627b64593d
commit
e106aa909b
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user