diff --git a/imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatChecker.kt b/imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatChecker.kt index e30f670711..4bbb246d71 100644 --- a/imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatChecker.kt +++ b/imagepipeline-base/src/main/java/com/facebook/imageformat/ImageFormatChecker.kt @@ -21,6 +21,7 @@ class ImageFormatChecker private constructor() { private var maxHeaderLength = 0 private var customImageFormatCheckers: List? = null private val defaultFormatChecker = DefaultImageFormatChecker() + private var binaryXmlEnabled = false init { updateMaxHeaderLength() @@ -31,11 +32,22 @@ class ImageFormatChecker private constructor() { updateMaxHeaderLength() } + fun setBinaryXmlEnabled(binaryXmlEnabled: Boolean) { + this.binaryXmlEnabled = binaryXmlEnabled + } + @Throws(IOException::class) fun determineImageFormat(`is`: InputStream): ImageFormat { val imageHeaderBytes = ByteArray(maxHeaderLength) val headerSize = readHeaderFromStream(maxHeaderLength, `is`, imageHeaderBytes) val format = defaultFormatChecker.determineFormat(imageHeaderBytes, headerSize) + if (format == DefaultImageFormats.BINARY_XML) { + return if (binaryXmlEnabled) { + ImageFormat.BINARY_XML + } else { + ImageFormat.UNKNOWN + } + } if (format !== ImageFormat.UNKNOWN) { return format }