#721 fail fast instead of letting ExifInterface corrupt some WEBP

This commit is contained in:
Thibault Deckers 2023-08-22 00:38:41 +02:00
parent 246dbd6de4
commit 8d441d29ea
3 changed files with 16 additions and 2 deletions

View file

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
## <a id="unreleased"></a>[Unreleased]
### Fixed
- editing some WEBP corrupting them (by failing instead)
## <a id="v1.9.0"></a>[v1.9.0] - 2023-08-21
### Added
@ -24,6 +28,7 @@ All notable changes to this project will be documented in this file.
### Fixed
- flickering when starting videos
- editing fragmented MP4 corrupting them (by failing instead)
## <a id="v1.8.9"></a>[v1.8.9] - 2023-06-04

View file

@ -6,6 +6,7 @@ import android.content.ContextWrapper
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.ImageDecoder
import android.net.Uri
import android.os.Binder
import android.os.Build
@ -684,6 +685,14 @@ abstract class ImageProvider {
throw Exception("editing Exif changes mimeType=$mimeType -> $editedMimeType for uri=$uri path=$path")
}
if (mimeType == MimeTypes.WEBP && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// as of androidx.exifinterface:exifinterface:1.3.6, editing some specific WEBP
// makes them undecodable by some decoders (including Android's and Chrome's)
// even though `BitmapFactory` successfully decodes their bounds,
// so we check whether decoding it throws an exception
ImageDecoder.decodeBitmap(ImageDecoder.createSource(editableFile))
}
if (videoBytes != null) {
// append trailer video, if any
editableFile.appendBytes(videoBytes!!)

View file

@ -3,7 +3,7 @@ buildscript {
kotlin_version = '1.8.21'
ksp_version = "$kotlin_version-1.0.11"
agp_version = '7.4.2'
glide_version = '4.15.1'
glide_version = '4.16.0'
// AppGallery Connect plugin versions: https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-sdk-changenotes-0000001058732550
huawei_agconnect_version = '1.9.1.300'
abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4]
@ -28,7 +28,7 @@ buildscript {
if (useCrashlytics) {
// GMS & Firebase Crashlytics (used by some flavors only)
classpath 'com.google.gms:google-services:4.3.15'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.4'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.8'
}
if (useHms) {