Merge "Rename TiffInputStream to CountedDataInputStream" into gb-ub-photos-arches
diff --git a/src/com/android/gallery3d/exif/TiffInputStream.java b/src/com/android/gallery3d/exif/CountedDataInputStream.java
similarity index 91%
rename from src/com/android/gallery3d/exif/TiffInputStream.java
rename to src/com/android/gallery3d/exif/CountedDataInputStream.java
index 2b0054c..dfd4a1a 100644
--- a/src/com/android/gallery3d/exif/TiffInputStream.java
+++ b/src/com/android/gallery3d/exif/CountedDataInputStream.java
@@ -24,7 +24,7 @@
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 @@
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 @@
@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 4249a72..bd8a97d 100644
--- a/src/com/android/gallery3d/exif/ExifParser.java
+++ b/src/com/android/gallery3d/exif/ExifParser.java
@@ -137,7 +137,7 @@
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 @@
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();