Pebble 2/Duo: Fix random crash on disconnect.

This commit is contained in:
Andreas Shimokawa
2025-11-02 07:57:08 +01:00
parent d5d21f531c
commit d0c9878934
@@ -218,10 +218,14 @@ public class PebbleLESupport {
int bytesRead;
while (true) {
try {
// this code is very similar to iothread, that is bad
// this code is very similar to IOThread, that is bad
// because we are the ones who prepared the buffer, there should be no
// need to do crazy stuff just to find out the PP boundaries again.
bytesRead = mPipedInputStream.read(buf, 0, 4);
if (bytesRead < 0) {
LOG.info("It seams the InputStream is closed, will shut down the PipeReader.");
break;
}
while (bytesRead < 4) {
bytesRead += mPipedInputStream.read(buf, bytesRead, 4 - bytesRead);
}