The test implementation of BluetoothSocket::GetInputStream() would crash if
the socket was closed. That's not ideal because the caller can't verify if the
socket is open or closed.
New test verifies that GetOutputStream() and GetInputStream() always return a
valid reference.
PiperOrigin-RevId: 518722540
Previously reading from an empty, closed Pipe returned:
* IO exception if there were no writes to the pipe,
* Empty byte array if there were writes to the pipe.
With this change, we return an empty byte array on both paths.
This also fixes a subtle race condition in the following flow:
1. Pipe is empty
2. Thread A is reading from the pipe (blocking call).
3. Thread B writes to the pipe and immediately closes it.
4. Thread A is unblocked and returns IO error. The data written by thread B is
ignored!
The new test in bluetooth_classic_test triggered that defect consistently.
PiperOrigin-RevId: 518107700
MediumEnvironment's initial state will now match the state after calling `Stop()`.
Cleaned up tests that were calling Stop() before test start.
PiperOrigin-RevId: 486277290