Merge "Stop forwarding when BluetoothSocket read returns -1" into main
This commit is contained in:
commit
028d6681fb
1 changed files with 2 additions and 2 deletions
|
|
@ -109,10 +109,10 @@ public class L2capPacketForwarder {
|
|||
public int read(byte[] bytes, int off, int len) throws IOException {
|
||||
// Note: EINTR is handled internally and automatically triggers a retry loop.
|
||||
int bytesRead = mInputStream.read(bytes, off, len);
|
||||
if (bytesRead > MTU) {
|
||||
if (bytesRead < 0 || bytesRead > MTU) {
|
||||
// Don't try to recover, just trigger network teardown. This might indicate a bug in
|
||||
// the Bluetooth stack.
|
||||
throw new IOException("Packet exceeds MTU");
|
||||
throw new IOException("Packet exceeds MTU or reached EOF. Read: " + bytesRead);
|
||||
}
|
||||
return bytesRead;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue