diff options
author | Jeff Sharkey <jsharkey@android.com> | 2013-10-14 14:57:33 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2013-10-14 15:28:19 -0700 |
commit | c1c8f3f97d344a24bfddcb56a8be05e7e2fabe9e (patch) | |
tree | 378307092542fff53cc3ecd45dc404b5ace63afc /packages/ExternalStorageProvider/src/com | |
parent | b5da7b23df5278a5e722b601eb8ef7e98537a51e (diff) | |
download | frameworks_base-c1c8f3f97d344a24bfddcb56a8be05e7e2fabe9e.zip frameworks_base-c1c8f3f97d344a24bfddcb56a8be05e7e2fabe9e.tar.gz frameworks_base-c1c8f3f97d344a24bfddcb56a8be05e7e2fabe9e.tar.bz2 |
Add extras to AFD, send orientation metadata.
AssetFileDescriptor augments a ParcelFileDescriptor with details
about how it should be interpreted, so extend it to support a Bundle
of extras. Then use these extras to share thumbnail orientation
metadata.
The raw image data of EXIF thumbnails matches the orientation of
the enclosing image, but the thumbnail data doesn't repeat the EXIF
flags. This meant that receivers of openDocumentThumbnail() would
get an image that needed to be transformed, but without enough
context to actually transform it.
Instead of transforming and recompressing the image on the fly on
the provider side, send a transformation hint that the receiver
side can interpret.
Bug: 11205688
Change-Id: Ibc5a7ad002377a55e6ffcb5ac5c8829841002e06
Diffstat (limited to 'packages/ExternalStorageProvider/src/com')
-rw-r--r-- | packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java index 189e985..11ff2d8 100644 --- a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java +++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java @@ -27,6 +27,7 @@ import android.os.Environment; import android.os.ParcelFileDescriptor; import android.provider.DocumentsContract.Document; import android.provider.DocumentsContract.Root; +import android.provider.DocumentsContract; import android.provider.DocumentsProvider; import android.webkit.MimeTypeMap; @@ -313,19 +314,7 @@ public class ExternalStorageProvider extends DocumentsProvider { String documentId, Point sizeHint, CancellationSignal signal) throws FileNotFoundException { final File file = getFileForDocId(documentId); - final ParcelFileDescriptor pfd = ParcelFileDescriptor.open( - file, ParcelFileDescriptor.MODE_READ_ONLY); - - try { - final ExifInterface exif = new ExifInterface(file.getAbsolutePath()); - final long[] thumb = exif.getThumbnailRange(); - if (thumb != null) { - return new AssetFileDescriptor(pfd, thumb[0], thumb[1]); - } - } catch (IOException e) { - } - - return new AssetFileDescriptor(pfd, 0, AssetFileDescriptor.UNKNOWN_LENGTH); + return DocumentsContract.openImageThumbnail(file); } private static String getTypeForFile(File file) { |