diff options
| author | 2016-09-09 22:46:44 +0000 | |
|---|---|---|
| committer | 2016-09-09 22:46:44 +0000 | |
| commit | 8d3e6bd3efe62581fd2def53b892ad76e7c76eae (patch) | |
| tree | 84bc5b8fc01a87d91d35111b2b6001deeb5bb5f3 | |
| parent | 9a409265fc47964c09b0d2f937c1c918823f8985 (diff) | |
| parent | 659275dc30f6f5eaf243eec065d0a3e1fe29f166 (diff) | |
DO NOT MERGE) ExifInterface: Make saveAttributes throw an exception before change
am: 659275dc30
Change-Id: I385c86e9753f1c99201a4f32b3c8b840da51376e
| -rw-r--r-- | media/java/android/media/ExifInterface.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/media/java/android/media/ExifInterface.java b/media/java/android/media/ExifInterface.java index 654a08a47395..d51dbda38dec 100644 --- a/media/java/android/media/ExifInterface.java +++ b/media/java/android/media/ExifInterface.java @@ -1034,6 +1034,7 @@ public class ExifInterface { private int mThumbnailOffset; private int mThumbnailLength; private byte[] mThumbnailBytes; + private boolean mIsSupportedFile; // Pattern to check non zero timestamp private static final Pattern sNonZeroTimePattern = Pattern.compile(".*[1-9].*"); @@ -1332,9 +1333,11 @@ public class ExifInterface { try { InputStream in = new FileInputStream(mFilename); getJpegAttributes(in); + mIsSupportedFile = true; } catch (IOException e) { // Ignore exceptions in order to keep the compatibility with the old versions of // ExifInterface. + mIsSupportedFile = false; Log.w(TAG, "Invalid image.", e); } finally { addDefaultValuesForCompatibility(); @@ -1363,6 +1366,10 @@ public class ExifInterface { * and make a single call rather than multiple calls for each attribute. */ public void saveAttributes() throws IOException { + if (!mIsSupportedFile) { + throw new UnsupportedOperationException( + "ExifInterface only supports saving attributes on JPEG formats."); + } // Keep the thumbnail in memory mThumbnailBytes = getThumbnail(); |