From 9db7d13a94edb8c5b6f1dba9bab63e825ce7a4d1 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sun, 4 Oct 2015 00:00:53 +0200 Subject: [PATCH] Log any exceptions during ble callbacks, if any #91 --- .../gadgetbridge/service/btle/BtLEQueue.java | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java index 65632d9c9..6ac159c16 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java @@ -365,7 +365,11 @@ public final class BtLEQueue { return; } if (getCallbackToUse() != null) { - getCallbackToUse().onCharacteristicRead(gatt, characteristic, status); + try { + getCallbackToUse().onCharacteristicRead(gatt, characteristic, status); + } catch (Throwable ex) { + LOG.error("onCharaceristicRead: " + ex.getMessage(), ex); + } } checkWaitingCharacteristic(characteristic, status); } @@ -377,7 +381,11 @@ public final class BtLEQueue { return; } if (getCallbackToUse() != null) { - getCallbackToUse().onDescriptorRead(gatt, descriptor, status); + try { + getCallbackToUse().onDescriptorRead(gatt, descriptor, status); + } catch (Throwable ex) { + LOG.error("onDescriptorRead: " + ex.getMessage(), ex); + } } checkWaitingCharacteristic(descriptor.getCharacteristic(), status); } @@ -389,7 +397,11 @@ public final class BtLEQueue { return; } if (getCallbackToUse() != null) { - getCallbackToUse().onDescriptorWrite(gatt, descriptor, status); + try { + getCallbackToUse().onDescriptorWrite(gatt, descriptor, status); + } catch (Throwable ex) { + LOG.error("onDescriptorWrite: " + ex.getMessage(), ex); + } } checkWaitingCharacteristic(descriptor.getCharacteristic(), status); } @@ -402,7 +414,11 @@ public final class BtLEQueue { return; } if (getCallbackToUse() != null) { - getCallbackToUse().onCharacteristicChanged(gatt, characteristic); + try { + getCallbackToUse().onCharacteristicChanged(gatt, characteristic); + } catch (Throwable ex) { + LOG.error("onCharaceristicChanged: " + ex.getMessage(), ex); + } } else { LOG.info("No gattcallback registered, ignoring characteristic change"); } @@ -415,7 +431,11 @@ public final class BtLEQueue { return; } if (getCallbackToUse() != null) { - getCallbackToUse().onReadRemoteRssi(gatt, rssi, status); + try { + getCallbackToUse().onReadRemoteRssi(gatt, rssi, status); + } catch (Throwable ex) { + LOG.error("onReadRemoteRssi: " + ex.getMessage(), ex); + } } } @@ -446,6 +466,4 @@ public final class BtLEQueue { mTransactionGattCallback = null; } } - - ; }