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

Commit 8dde3542 authored by Bhakthavatsala Raghavendra's avatar Bhakthavatsala Raghavendra
Browse files

Return -1 on socket read EOF

Return -1 instead of IOException on socket read EOF. This ensures
consistent behavior between RFCOMM, LE and L2CAP sockets and also
aligns with InputStream documentation

Bug: 383671392
Test: mmm packages/modules/Bluetooth
Flag: Exempt, minor change
Change-Id: I374b93d773bce73c37460a12c124ac49a9ab8b0e
parent 1b4b1a12
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -978,7 +978,7 @@ public final class BluetoothSocket implements Closeable {
            if (mL2capBuffer.remaining() == 0) {
                if (VDBG) Log.v(TAG, "l2cap buffer empty, refilling...");
                if (fillL2capRxBuffer() == -1) {
                    throw new IOException("bt socket closed, read return: " + ret);
                    return -1;
                }
            }
            if (bytesToRead > mL2capBuffer.remaining()) {
@@ -994,7 +994,7 @@ public final class BluetoothSocket implements Closeable {
            ret = mSocketIS.read(b, offset, length);
        }
        if (ret < 0) {
            throw new IOException("bt socket closed, read return: " + ret);
            return -1;
        }
        if (VDBG) Log.d(TAG, "read out:  " + mSocketIS + " ret: " + ret);
        return ret;