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

Commit f0851b27 authored by Jin Seok Park's avatar Jin Seok Park
Browse files

Add API to check if specified mime type is supported

Bug: 138845596
Test: N/A
Change-Id: I082f1d63b85a786214316fa00fa14522fc822b20
parent 47fc7357
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23923,6 +23923,7 @@ package android.media {
    method @Nullable public long[] getThumbnailRange();
    method public boolean hasAttribute(@NonNull String);
    method public boolean hasThumbnail();
    method public static boolean isSupportedMimeType(@NonNull String);
    method public boolean isThumbnailCompressed();
    method public void saveAttributes() throws java.io.IOException;
    method public void setAttribute(@NonNull String, @Nullable String);
+32 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
@@ -1450,6 +1451,37 @@ public class ExifInterface {
        loadAttributes(inputStream);
    }

    /**
     * Returns whether ExifInterface currently supports parsing data from the specified mime type
     * or not.
     *
     * @param mimeType the string value of mime type
     */
    public static boolean isSupportedMimeType(@NonNull String mimeType) {
        if (mimeType == null) {
            throw new NullPointerException("mimeType shouldn't be null");
        }

        switch (mimeType.toLowerCase(Locale.ROOT)) {
            case "image/jpeg":
            case "image/x-adobe-dng":
            case "image/x-canon-cr2":
            case "image/x-nikon-nef":
            case "image/x-nikon-nrw":
            case "image/x-sony-arw":
            case "image/x-panasonic-rw2":
            case "image/x-olympus-orf":
            case "image/x-pentax-pef":
            case "image/x-samsung-srw":
            case "image/x-fuji-raf":
            case "image/heic":
            case "image/heif":
                return true;
            default:
                return false;
        }
    }

    /**
     * Returns the EXIF attribute of the specified tag or {@code null} if there is no such tag in
     * the image file.