summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/gallery3d/exif/CountedDataInputStream.java (renamed from src/com/android/gallery3d/exif/TiffInputStream.java)14
-rw-r--r--src/com/android/gallery3d/exif/ExifParser.java4
2 files changed, 10 insertions, 8 deletions
diff --git a/src/com/android/gallery3d/exif/TiffInputStream.java b/src/com/android/gallery3d/exif/CountedDataInputStream.java
index 2b0054c46..dfd4a1a10 100644
--- a/src/com/android/gallery3d/exif/TiffInputStream.java
+++ b/src/com/android/gallery3d/exif/CountedDataInputStream.java
@@ -24,7 +24,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;
-class TiffInputStream extends FilterInputStream {
+class CountedDataInputStream extends FilterInputStream {
private int mCount = 0;
@@ -32,7 +32,7 @@ class TiffInputStream extends FilterInputStream {
private final byte mByteArray[] = new byte[8];
private final ByteBuffer mByteBuffer = ByteBuffer.wrap(mByteArray);
- protected TiffInputStream(InputStream in) {
+ protected CountedDataInputStream(InputStream in) {
super(in);
}
@@ -42,26 +42,28 @@ class TiffInputStream extends FilterInputStream {
@Override
public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
+ int r = in.read(b);
+ mCount += (r >= 0) ? r : 0;
+ return r;
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
- int r = super.read(b, off, len);
+ int r = in.read(b, off, len);
mCount += (r >= 0) ? r : 0;
return r;
}
@Override
public int read() throws IOException {
- int r = super.read();
+ int r = in.read();
mCount += (r >= 0) ? 1 : 0;
return r;
}
@Override
public long skip(long length) throws IOException {
- long skip = super.skip(length);
+ long skip = in.skip(length);
mCount += skip;
return skip;
}
diff --git a/src/com/android/gallery3d/exif/ExifParser.java b/src/com/android/gallery3d/exif/ExifParser.java
index 4249a7241..bd8a97dac 100644
--- a/src/com/android/gallery3d/exif/ExifParser.java
+++ b/src/com/android/gallery3d/exif/ExifParser.java
@@ -137,7 +137,7 @@ public class ExifParser {
private static final int TAG_SIZE = 12;
private static final int OFFSET_SIZE = 2;
- private final TiffInputStream mTiffStream;
+ private final CountedDataInputStream mTiffStream;
private final int mOptions;
private int mIfdStartOffset = 0;
private int mNumOfTagInIfd = 0;
@@ -174,7 +174,7 @@ public class ExifParser {
private ExifParser(InputStream inputStream, int options)
throws IOException, ExifInvalidFormatException {
seekTiffData(inputStream);
- mTiffStream = new TiffInputStream(inputStream);
+ mTiffStream = new CountedDataInputStream(inputStream);
mOptions = options;
if (mTiffStream.getReadByteCount() == 0) {
parseTiffHeader();