From e53b8b6b325a455bb12d89649663025b2f7e8994 Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Sun, 4 Dec 2016 21:04:30 +0100 Subject: [PATCH] Liveview: ignore the SocketTimeoutException, disconnect in any other case --- .../devices/liveview/LiveviewIoThread.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/liveview/LiveviewIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/liveview/LiveviewIoThread.java index 9f6c2c75..f257cf84 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/liveview/LiveviewIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/liveview/LiveviewIoThread.java @@ -13,6 +13,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.net.SocketTimeoutException; import java.nio.ByteBuffer; import java.util.UUID; @@ -97,18 +98,16 @@ public class LiveviewIoThread extends GBDeviceIoThread { mLiveviewSupport.evaluateGBDeviceEvent(deviceEvent); } } - + } catch (SocketTimeoutException ignore) { + LOG.debug("socket timeout, we can't help but ignore this"); } catch (IOException e) { - - if (e.getMessage() != null && e.getMessage().contains("socket closed")) { //FIXME: this does not feel right - LOG.info(e.getMessage()); - mIsConnected = false; - mBtSocket = null; - mInStream = null; - mOutStream = null; - LOG.info("Bluetooth socket closed, will quit IO Thread"); - break; - } + LOG.info(e.getMessage()); + mIsConnected = false; + mBtSocket = null; + mInStream = null; + mOutStream = null; + LOG.info("Bluetooth socket closed, will quit IO Thread"); + break; } }