Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 848a1e3d authored by Jaikumar Ganesh's avatar Jaikumar Ganesh Committed by Android Code Review
Browse files

Merge "OBEX: Fix PrivateOutputStream small write problem"

parents 6c427617 a9c4c594
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -107,20 +107,17 @@ 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;
        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);
        }
    }
    }

    /**
     * Reads the bytes that have been written to this stream.