diff options
| author | Jaikumar Ganesh <jaikumarg@android.com> | 2011-05-20 10:23:48 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2011-05-20 10:23:48 -0700 |
| commit | 0c2d82c6f28ab6ec73d66fcc1f62e067829df426 (patch) | |
| tree | 58f492a559790c6d66cba8d797c93d03ff5d0b96 | |
| parent | 2433c443bb5fe96d9a39b59e10e3c03d791e2278 (diff) | |
| parent | 848a1e3d8522129c8a39d198a10b134926d71bd2 (diff) | |
| download | frameworks_base-0c2d82c6f28ab6ec73d66fcc1f62e067829df426.zip frameworks_base-0c2d82c6f28ab6ec73d66fcc1f62e067829df426.tar.gz frameworks_base-0c2d82c6f28ab6ec73d66fcc1f62e067829df426.tar.bz2 | |
am 848a1e3d: Merge "OBEX: Fix PrivateOutputStream small write problem"
* commit '848a1e3d8522129c8a39d198a10b134926d71bd2':
OBEX: Fix PrivateOutputStream small write problem
| -rw-r--r-- | obex/javax/obex/PrivateOutputStream.java | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/obex/javax/obex/PrivateOutputStream.java b/obex/javax/obex/PrivateOutputStream.java index ca420af..713f4ae 100644 --- a/obex/javax/obex/PrivateOutputStream.java +++ b/obex/javax/obex/PrivateOutputStream.java @@ -107,18 +107,15 @@ public final class PrivateOutputStream extends OutputStream { 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); } } |
