summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-12-11 15:08:12 -0800
committerMark Wei <markwei@google.com>2013-12-11 15:14:46 -0800
commitc7ad691a967e860a93d76bedb7c5d207dd083591 (patch)
tree9c48d9bc5bd06840e7ae038a6ca82fbede2fcb30
parentb6ec2afe9710112214d79b36b2233fef6a52845a (diff)
downloadbitmap-c7ad691a967e860a93d76bedb7c5d207dd083591.tar.gz
We expect the BitmapRegionDecoder to fail on a GIF. We need to reset the
InputStream so the BitmapFactory decoder doesn't choke on a consumed InputStream. Bug: 12099499 Change-Id: Ie066e04f369cc51b783e2ce95ca4be5e5f8e8871
-rw-r--r--src/com/android/bitmap/DecodeTask.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/com/android/bitmap/DecodeTask.java b/src/com/android/bitmap/DecodeTask.java
index 0d814c4..03b8445 100644
--- a/src/com/android/bitmap/DecodeTask.java
+++ b/src/com/android/bitmap/DecodeTask.java
@@ -348,6 +348,16 @@ public class DecodeTask extends AsyncTask<Void, Void, ReusableBitmap> {
decodeResult = bitmap;
} catch (IOException e) {
// fall through to below and try again with the non-cropping decoder
+ if (fd == null) {
+ in = reset(in);
+ if (in == null) {
+ return null;
+ }
+ if (isCancelled()) {
+ return null;
+ }
+ }
+
e.printStackTrace();
} finally {
Trace.endSection();