From d0c987893428d6a701e121e6122f30a8fdfbf8d5 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Sun, 2 Nov 2025 07:57:08 +0100 Subject: [PATCH] Pebble 2/Duo: Fix random crash on disconnect. --- .../service/devices/pebble/ble/PebbleLESupport.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleLESupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleLESupport.java index b9ea6152a1..ae6127a160 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleLESupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleLESupport.java @@ -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); }