Permalink
Browse files

am 0c2d82c: am 848a1e3: Merge "OBEX: Fix PrivateOutputStream small wr…

…ite problem"

* commit '0c2d82c6f28ab6ec73d66fcc1f62e067829df426':
  OBEX: Fix PrivateOutputStream small write problem
  • Loading branch information...
2 parents 33bdc3c + 0c2d82c commit 3bec9cc27a4b87be644533d5fe44358dde399d49 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 3bec9cc

Please sign in to comment.