Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45e14ffe authored by Sungsoo's avatar Sungsoo Committed by android-build-merger
Browse files

DO NOT MERGE) ExifInterface: Make saveAttributes throw an exception before change am: 2ee53c82

am: 865bf888

Change-Id: I1a59ad0872c98a416efa7bfc8800d65c01cea3f8
parents bd6a29cd 865bf888
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -1039,6 +1039,7 @@ public class ExifInterface {
    private int mThumbnailOffset;
    private int mThumbnailOffset;
    private int mThumbnailLength;
    private int mThumbnailLength;
    private byte[] mThumbnailBytes;
    private byte[] mThumbnailBytes;
    private boolean mIsSupportedFile;


    // Pattern to check non zero timestamp
    // Pattern to check non zero timestamp
    private static final Pattern sNonZeroTimePattern = Pattern.compile(".*[1-9].*");
    private static final Pattern sNonZeroTimePattern = Pattern.compile(".*[1-9].*");
@@ -1337,9 +1338,11 @@ public class ExifInterface {
        try {
        try {
            InputStream in = new FileInputStream(mFilename);
            InputStream in = new FileInputStream(mFilename);
            getJpegAttributes(in);
            getJpegAttributes(in);
            mIsSupportedFile = true;
        } catch (IOException e) {
        } catch (IOException e) {
            // Ignore exceptions in order to keep the compatibility with the old versions of
            // Ignore exceptions in order to keep the compatibility with the old versions of
            // ExifInterface.
            // ExifInterface.
            mIsSupportedFile = false;
            Log.w(TAG, "Invalid image.", e);
            Log.w(TAG, "Invalid image.", e);
        } finally {
        } finally {
            addDefaultValuesForCompatibility();
            addDefaultValuesForCompatibility();
@@ -1368,6 +1371,10 @@ public class ExifInterface {
     * and make a single call rather than multiple calls for each attribute.
     * and make a single call rather than multiple calls for each attribute.
     */
     */
    public void saveAttributes() throws IOException {
    public void saveAttributes() throws IOException {
        if (!mIsSupportedFile) {
            throw new UnsupportedOperationException(
                    "ExifInterface only supports saving attributes on JPEG formats.");
        }
        // Keep the thumbnail in memory
        // Keep the thumbnail in memory
        mThumbnailBytes = getThumbnail();
        mThumbnailBytes = getThumbnail();