Loading media/java/android/media/ExifInterface.java +56 −49 Original line number Diff line number Diff line Loading @@ -1566,7 +1566,7 @@ public class ExifInterface { FileInputStream in = null; try { in = new FileInputStream(fileDescriptor); loadAttributes(in); loadAttributes(in, fileDescriptor); } finally { closeQuietly(in); if (isFdDuped) { Loading Loading @@ -1637,7 +1637,7 @@ public class ExifInterface { mSeekableFileDescriptor = null; } } loadAttributes(inputStream); loadAttributes(inputStream, null); } /** Loading Loading @@ -1963,7 +1963,7 @@ public class ExifInterface { * This function decides which parser to read the image data according to the given input stream * type and the content of the input stream. */ private void loadAttributes(@NonNull InputStream in) { private void loadAttributes(@NonNull InputStream in, @Nullable FileDescriptor fd) { if (in == null) { throw new NullPointerException("inputstream shouldn't be null"); } Loading Loading @@ -1993,7 +1993,7 @@ public class ExifInterface { break; } case IMAGE_TYPE_HEIF: { getHeifAttributes(inputStream); getHeifAttributes(inputStream, fd); break; } case IMAGE_TYPE_ORF: { Loading Loading @@ -2580,7 +2580,7 @@ public class ExifInterface { } else if (isSeekableFD(in.getFD())) { mSeekableFileDescriptor = in.getFD(); } loadAttributes(in); loadAttributes(in, null); } finally { closeQuietly(in); if (modernFd != null) { Loading Loading @@ -3068,9 +3068,13 @@ public class ExifInterface { } } private void getHeifAttributes(ByteOrderedDataInputStream in) throws IOException { private void getHeifAttributes(ByteOrderedDataInputStream in, @Nullable FileDescriptor fd) throws IOException { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { if (fd != null) { retriever.setDataSource(fd); } else { retriever.setDataSource(new MediaDataSource() { long mPosition; Loading Loading @@ -3111,7 +3115,9 @@ public class ExifInterface { mPosition += bytesRead; return bytesRead; } } catch (IOException e) {} } catch (IOException e) { // absorb the exception and fall through to the 'failed read' path below } mPosition = -1; // need to seek on next read return -1; } Loading @@ -3121,6 +3127,7 @@ public class ExifInterface { return -1; } }); } String exifOffsetStr = retriever.extractMetadata( MediaMetadataRetriever.METADATA_KEY_EXIF_OFFSET); Loading Loading
media/java/android/media/ExifInterface.java +56 −49 Original line number Diff line number Diff line Loading @@ -1566,7 +1566,7 @@ public class ExifInterface { FileInputStream in = null; try { in = new FileInputStream(fileDescriptor); loadAttributes(in); loadAttributes(in, fileDescriptor); } finally { closeQuietly(in); if (isFdDuped) { Loading Loading @@ -1637,7 +1637,7 @@ public class ExifInterface { mSeekableFileDescriptor = null; } } loadAttributes(inputStream); loadAttributes(inputStream, null); } /** Loading Loading @@ -1963,7 +1963,7 @@ public class ExifInterface { * This function decides which parser to read the image data according to the given input stream * type and the content of the input stream. */ private void loadAttributes(@NonNull InputStream in) { private void loadAttributes(@NonNull InputStream in, @Nullable FileDescriptor fd) { if (in == null) { throw new NullPointerException("inputstream shouldn't be null"); } Loading Loading @@ -1993,7 +1993,7 @@ public class ExifInterface { break; } case IMAGE_TYPE_HEIF: { getHeifAttributes(inputStream); getHeifAttributes(inputStream, fd); break; } case IMAGE_TYPE_ORF: { Loading Loading @@ -2580,7 +2580,7 @@ public class ExifInterface { } else if (isSeekableFD(in.getFD())) { mSeekableFileDescriptor = in.getFD(); } loadAttributes(in); loadAttributes(in, null); } finally { closeQuietly(in); if (modernFd != null) { Loading Loading @@ -3068,9 +3068,13 @@ public class ExifInterface { } } private void getHeifAttributes(ByteOrderedDataInputStream in) throws IOException { private void getHeifAttributes(ByteOrderedDataInputStream in, @Nullable FileDescriptor fd) throws IOException { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { if (fd != null) { retriever.setDataSource(fd); } else { retriever.setDataSource(new MediaDataSource() { long mPosition; Loading Loading @@ -3111,7 +3115,9 @@ public class ExifInterface { mPosition += bytesRead; return bytesRead; } } catch (IOException e) {} } catch (IOException e) { // absorb the exception and fall through to the 'failed read' path below } mPosition = -1; // need to seek on next read return -1; } Loading @@ -3121,6 +3127,7 @@ public class ExifInterface { return -1; } }); } String exifOffsetStr = retriever.extractMetadata( MediaMetadataRetriever.METADATA_KEY_EXIF_OFFSET); Loading