Merge changes from topic "dynamic_system.data_transfer.shared_memory.size" am: f76e45bf6f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2033045 Change-Id: Ibb3a2a8904f2f1ef76e9136961c37512a77b406d
This commit is contained in:
@@ -133,36 +133,32 @@ public class SparseInputStream extends InputStream {
|
|||||||
return mLeft == 0;
|
return mLeft == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* It overrides the InputStream.read(byte[] buf)
|
public int read(byte[] buf, int off, int len) throws IOException {
|
||||||
*/
|
|
||||||
public int read(byte[] buf) throws IOException {
|
|
||||||
if (!mIsSparse) {
|
if (!mIsSparse) {
|
||||||
return mIn.read(buf);
|
return mIn.read(buf, off, len);
|
||||||
}
|
}
|
||||||
if (prepareChunk()) return -1;
|
if (prepareChunk()) return -1;
|
||||||
int n = -1;
|
int n = -1;
|
||||||
switch (mCur.mChunkType) {
|
switch (mCur.mChunkType) {
|
||||||
case SparseChunk.RAW:
|
case SparseChunk.RAW:
|
||||||
n = mIn.read(buf, 0, (int) min(mLeft, buf.length));
|
n = mIn.read(buf, off, (int) min(mLeft, len));
|
||||||
mLeft -= n;
|
mLeft -= n;
|
||||||
return n;
|
return n;
|
||||||
case SparseChunk.DONTCARE:
|
case SparseChunk.DONTCARE:
|
||||||
n = (int) min(mLeft, buf.length);
|
n = (int) min(mLeft, len);
|
||||||
Arrays.fill(buf, 0, n - 1, (byte) 0);
|
Arrays.fill(buf, off, off + n, (byte) 0);
|
||||||
mLeft -= n;
|
mLeft -= n;
|
||||||
return n;
|
return n;
|
||||||
case SparseChunk.FILL:
|
case SparseChunk.FILL:
|
||||||
// The FILL type is rarely used, so use a simple implmentation.
|
// The FILL type is rarely used, so use a simple implmentation.
|
||||||
return super.read(buf);
|
return super.read(buf, off, len);
|
||||||
default:
|
default:
|
||||||
throw new IOException("Unsupported Chunk:" + mCur.toString());
|
throw new IOException("Unsupported Chunk:" + mCur.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* It overrides the InputStream.read()
|
|
||||||
*/
|
|
||||||
public int read() throws IOException {
|
public int read() throws IOException {
|
||||||
if (!mIsSparse) {
|
if (!mIsSparse) {
|
||||||
return mIn.read();
|
return mIn.read();
|
||||||
|
|||||||
Reference in New Issue
Block a user