diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2015-08-31 20:19:26 +0200 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2015-08-31 20:19:26 +0200 |
commit | aaf3ecaf4146e35ee4b7f3d2c04c6b83a781fc93 (patch) | |
tree | 59570d33839c66918f03b0287c923a7404ef6996 | |
parent | ca262d352374622145056b3d3dea99484e035594 (diff) |
made useImageAsIs determination a bit more foolproof (samsung)
-rw-r--r-- | src/main/java/eu/siacs/conversations/persistance/FileBackend.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index d5e4645e..817f1c51 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -131,11 +131,16 @@ public class FileBackend { if (path == null) { return false; } + File file = new File(path); + long size = file.length(); + if (size == 0 || size >= 524288 ) { + return false; + } BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; try { BitmapFactory.decodeStream(mXmppConnectionService.getContentResolver().openInputStream(uri), null, options); - if (options == null || options.outMimeType == null) { + if (options == null || options.outMimeType == null || options.outHeight <= 0 || options.outWidth <= 0) { return false; } return (options.outWidth <= Config.IMAGE_SIZE && options.outHeight <= Config.IMAGE_SIZE && options.outMimeType.contains(Config.IMAGE_FORMAT.name().toLowerCase())); |