Loading media/java/android/media/ExifInterface.java +12 −4 Original line number Diff line number Diff line Loading @@ -1876,11 +1876,16 @@ public class ExifInterface { } // Read the thumbnail. FileInputStream in = null; InputStream in = null; try { if (mAssetInputStream != null) { return nativeGetThumbnailFromAsset( mAssetInputStream.getNativeAsset(), mThumbnailOffset, mThumbnailLength); in = mAssetInputStream; if (in.markSupported()) { in.reset(); } else { Log.d(TAG, "Cannot read thumbnail from inputstream without mark/reset support"); return null; } } else if (mFilename != null) { in = new FileInputStream(mFilename); } else if (mSeekableFileDescriptor != null) { Loading @@ -1903,6 +1908,7 @@ public class ExifInterface { return buffer; } catch (IOException | ErrnoException e) { // Couldn't get a thumbnail image. Log.d(TAG, "Encountered exception while getting thumbnail", e); } finally { IoUtils.closeQuietly(in); } Loading Loading @@ -3052,7 +3058,8 @@ public class ExifInterface { thumbnailOffset += mOrfMakerNoteOffset; } if (DEBUG) { Log.d(TAG, "Setting thumbnail attributes with offset: " + thumbnailOffset); Log.d(TAG, "Setting thumbnail attributes with offset: " + thumbnailOffset + ", length: " + thumbnailLength); } if (thumbnailOffset > 0 && thumbnailLength > 0) { mHasThumbnail = true; Loading Loading @@ -3122,6 +3129,7 @@ public class ExifInterface { mHasThumbnail = true; mThumbnailBytes = totalStripBytes; mThumbnailLength = totalStripBytes.length; } } } else { Loading media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/ExifInterfaceTest.java +3 −4 Original line number Diff line number Diff line Loading @@ -196,11 +196,10 @@ public class ExifInterfaceTest extends AndroidTestCase { private void printExifTagsAndValues(String fileName, ExifInterface exifInterface) { // Prints thumbnail information. if (exifInterface.hasThumbnail()) { byte[] thumbnailBytes = exifInterface.getThumbnail(); byte[] thumbnailBytes = exifInterface.getThumbnailBytes(); if (thumbnailBytes != null) { Log.v(TAG, fileName + " Thumbnail size = " + thumbnailBytes.length); Bitmap bitmap = BitmapFactory.decodeByteArray( thumbnailBytes, 0, thumbnailBytes.length); Bitmap bitmap = exifInterface.getThumbnailBitmap(); if (bitmap == null) { Log.e(TAG, fileName + " Corrupted thumbnail!"); } else { Loading Loading @@ -265,7 +264,7 @@ public class ExifInterfaceTest extends AndroidTestCase { // Checks a thumbnail image. assertEquals(expectedValue.hasThumbnail, exifInterface.hasThumbnail()); if (expectedValue.hasThumbnail) { byte[] thumbnailBytes = exifInterface.getThumbnail(); byte[] thumbnailBytes = exifInterface.getThumbnailBytes(); assertNotNull(thumbnailBytes); Bitmap thumbnailBitmap = exifInterface.getThumbnailBitmap(); assertNotNull(thumbnailBitmap); Loading Loading
media/java/android/media/ExifInterface.java +12 −4 Original line number Diff line number Diff line Loading @@ -1876,11 +1876,16 @@ public class ExifInterface { } // Read the thumbnail. FileInputStream in = null; InputStream in = null; try { if (mAssetInputStream != null) { return nativeGetThumbnailFromAsset( mAssetInputStream.getNativeAsset(), mThumbnailOffset, mThumbnailLength); in = mAssetInputStream; if (in.markSupported()) { in.reset(); } else { Log.d(TAG, "Cannot read thumbnail from inputstream without mark/reset support"); return null; } } else if (mFilename != null) { in = new FileInputStream(mFilename); } else if (mSeekableFileDescriptor != null) { Loading @@ -1903,6 +1908,7 @@ public class ExifInterface { return buffer; } catch (IOException | ErrnoException e) { // Couldn't get a thumbnail image. Log.d(TAG, "Encountered exception while getting thumbnail", e); } finally { IoUtils.closeQuietly(in); } Loading Loading @@ -3052,7 +3058,8 @@ public class ExifInterface { thumbnailOffset += mOrfMakerNoteOffset; } if (DEBUG) { Log.d(TAG, "Setting thumbnail attributes with offset: " + thumbnailOffset); Log.d(TAG, "Setting thumbnail attributes with offset: " + thumbnailOffset + ", length: " + thumbnailLength); } if (thumbnailOffset > 0 && thumbnailLength > 0) { mHasThumbnail = true; Loading Loading @@ -3122,6 +3129,7 @@ public class ExifInterface { mHasThumbnail = true; mThumbnailBytes = totalStripBytes; mThumbnailLength = totalStripBytes.length; } } } else { Loading
media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/ExifInterfaceTest.java +3 −4 Original line number Diff line number Diff line Loading @@ -196,11 +196,10 @@ public class ExifInterfaceTest extends AndroidTestCase { private void printExifTagsAndValues(String fileName, ExifInterface exifInterface) { // Prints thumbnail information. if (exifInterface.hasThumbnail()) { byte[] thumbnailBytes = exifInterface.getThumbnail(); byte[] thumbnailBytes = exifInterface.getThumbnailBytes(); if (thumbnailBytes != null) { Log.v(TAG, fileName + " Thumbnail size = " + thumbnailBytes.length); Bitmap bitmap = BitmapFactory.decodeByteArray( thumbnailBytes, 0, thumbnailBytes.length); Bitmap bitmap = exifInterface.getThumbnailBitmap(); if (bitmap == null) { Log.e(TAG, fileName + " Corrupted thumbnail!"); } else { Loading Loading @@ -265,7 +264,7 @@ public class ExifInterfaceTest extends AndroidTestCase { // Checks a thumbnail image. assertEquals(expectedValue.hasThumbnail, exifInterface.hasThumbnail()); if (expectedValue.hasThumbnail) { byte[] thumbnailBytes = exifInterface.getThumbnail(); byte[] thumbnailBytes = exifInterface.getThumbnailBytes(); assertNotNull(thumbnailBytes); Bitmap thumbnailBitmap = exifInterface.getThumbnailBitmap(); assertNotNull(thumbnailBitmap); Loading