Skip to content
Browse files

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

* commit '848a1e3d8522129c8a39d198a10b134926d71bd2':
  OBEX: Fix PrivateOutputStream small write problem
  • Loading branch information...
2 parents 2433c44 + 848a1e3 commit 0c2d82c6f28ab6ec73d66fcc1f62e067829df426 Jaikumar Ganesh committed with Android Git Automerger May 20, 2011
Showing with 9 additions and 12 deletions.
  1. +9 −12 obex/javax/obex/PrivateOutputStream.java
View
21 obex/javax/obex/PrivateOutputStream.java
@@ -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);
}
}

0 comments on commit 0c2d82c

Please sign in to comment.
Something went wrong with that request. Please try again.