diff options
author | Likai Ding <likaid@codeaurora.org> | 2014-09-29 11:32:02 +0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-11-11 07:18:20 -0800 |
commit | 291c0f59bd170836c502a8c5c8d0aaf2b2dd2f82 (patch) | |
tree | 6d532843046f0d99330d33fb748b3e072e2e7bea /src/com/android/camera/Storage.java | |
parent | 52f4cda298a5d53395fc46959c88f94b2d3fe921 (diff) | |
download | android_packages_apps_Snap-291c0f59bd170836c502a8c5c8d0aaf2b2dd2f82.tar.gz android_packages_apps_Snap-291c0f59bd170836c502a8c5c8d0aaf2b2dd2f82.tar.bz2 android_packages_apps_Snap-291c0f59bd170836c502a8c5c8d0aaf2b2dd2f82.zip |
Camera2: correct image size recorded in media provider db
Photos taken in camcorder can't be previewed on PC via MTP mode. The
root cause is that, the actual image file size does not always match
the _size column in media provider database. During the saving process,
EXIF data are rewritten, but the size sent to media provider is not
updated accordingly.
Record bytes written in ExifOutputStream and OrderedDataOutputStream so
that after rewritting, the correct image size could be sent to media
provider.
Change-Id: I74d91e86d712c121eb50daecaf879ab4f5be97fc
CRs-Fixed: 711522
Diffstat (limited to 'src/com/android/camera/Storage.java')
-rw-r--r-- | src/com/android/camera/Storage.java | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/com/android/camera/Storage.java b/src/com/android/camera/Storage.java index 53950f2f2..ab2f818ab 100644 --- a/src/com/android/camera/Storage.java +++ b/src/com/android/camera/Storage.java @@ -74,12 +74,12 @@ public class Storage { } } - public static void writeFile(String path, byte[] jpeg, ExifInterface exif, + public static int writeFile(String path, byte[] jpeg, ExifInterface exif, String mimeType) { if (exif != null && (mimeType == null || mimeType.equalsIgnoreCase("jpeg"))) { try { - exif.writeExif(jpeg, path); + return exif.writeExif(jpeg, path); } catch (Exception e) { Log.e(TAG, "Failed to write data", e); } @@ -89,7 +89,9 @@ public class Storage { dir.mkdirs(); } writeFile(path, jpeg); + return jpeg.length; } + return 0; } public static void writeFile(String path, byte[] data) { @@ -114,9 +116,9 @@ public class Storage { int height, String mimeType) { String path = generateFilepath(title, mimeType); - writeFile(path, jpeg, exif, mimeType); + int size = writeFile(path, jpeg, exif, mimeType); return addImage(resolver, title, date, location, orientation, - jpeg.length, path, width, height, mimeType); + size, path, width, height, mimeType); } // Get a ContentValues object for the given photo data |