Skip to content

Commit

Permalink
Merge "OBEX: Fix PrivateOutputStream small write problem"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaikumar Ganesh authored and Android Code Review committed May 20, 2011
2 parents 6c42761 + a9c4c59 commit 848a1e3
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions obex/javax/obex/PrivateOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,15 @@ public synchronized void write(byte[] buffer, int offset, int count) throws IOEx

ensureOpen();
mParent.ensureNotDone();
if (count < mMaxPacketSize) {
mArray.write(buffer, offset, count);
} else {
while (remainLength >= mMaxPacketSize) {
mArray.write(buffer, offset1, mMaxPacketSize);
offset1 += mMaxPacketSize;
remainLength = count - offset1;
mParent.continueOperation(true, false);
}
if (remainLength > 0) {
mArray.write(buffer, offset1, remainLength);
}
while ((mArray.size() + remainLength) >= mMaxPacketSize) {
int bufferLeft = mMaxPacketSize - mArray.size();
mArray.write(buffer, offset1, bufferLeft);
offset1 += bufferLeft;
remainLength -= bufferLeft;
mParent.continueOperation(true, false);
}
if (remainLength > 0) {
mArray.write(buffer, offset1, remainLength);
}
}

Expand Down

0 comments on commit 848a1e3

Please sign in to comment.