Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge "OBEX: Fix PrivateOutputStream small write problem"

  • Loading branch information...
commit 848a1e3d8522129c8a39d198a10b134926d71bd2 2 parents 6c42761 + a9c4c59
Jaikumar Ganesh authored Android Code Review committed
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);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.