mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-23 11:15:44 +00:00
Fix crash when saving media with octet stream content type.
This commit is contained in:
@@ -314,6 +314,10 @@ public class MediaUtil {
|
||||
return isImageType(contentType) || isVideoType(contentType);
|
||||
}
|
||||
|
||||
public static boolean isImageVideoOrAudioType(String contentType) {
|
||||
return isImageOrVideoType(contentType) || isAudioType(contentType);
|
||||
}
|
||||
|
||||
public static boolean isImageAndNotGif(@NonNull String contentType) {
|
||||
return isImageType(contentType) && !isGif(contentType);
|
||||
}
|
||||
|
||||
@@ -184,6 +184,11 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
|
||||
String extension = fileParts[1];
|
||||
String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
|
||||
|
||||
if (MediaUtil.isOctetStream(mimeType) && MediaUtil.isImageVideoOrAudioType(contentType)) {
|
||||
Log.d(TAG, "MimeTypeMap returned octet stream for media, changing to provided content type [" + contentType + "] instead.");
|
||||
mimeType = contentType;
|
||||
}
|
||||
|
||||
ContentValues contentValues = new ContentValues();
|
||||
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, fileName);
|
||||
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, mimeType);
|
||||
|
||||
Reference in New Issue
Block a user