am 848a1e3d: Merge "OBEX: Fix PrivateOutputStream small write problem"

* commit '848a1e3d8522129c8a39d198a10b134926d71bd2':
  OBEX: Fix PrivateOutputStream small write problem
This commit is contained in:
Jaikumar Ganesh
2011-05-20 10:23:48 -07:00
committed by Android Git Automerger

View File

@@ -107,20 +107,17 @@ public final class PrivateOutputStream extends OutputStream {
ensureOpen(); ensureOpen();
mParent.ensureNotDone(); mParent.ensureNotDone();
if (count < mMaxPacketSize) { while ((mArray.size() + remainLength) >= mMaxPacketSize) {
mArray.write(buffer, offset, count); int bufferLeft = mMaxPacketSize - mArray.size();
} else { mArray.write(buffer, offset1, bufferLeft);
while (remainLength >= mMaxPacketSize) { offset1 += bufferLeft;
mArray.write(buffer, offset1, mMaxPacketSize); remainLength -= bufferLeft;
offset1 += mMaxPacketSize;
remainLength = count - offset1;
mParent.continueOperation(true, false); mParent.continueOperation(true, false);
} }
if (remainLength > 0) { if (remainLength > 0) {
mArray.write(buffer, offset1, remainLength); mArray.write(buffer, offset1, remainLength);
} }
} }
}
/** /**
* Reads the bytes that have been written to this stream. * Reads the bytes that have been written to this stream.