From 851320e6bd2bbe4a66c7d754be9e819416142a5f Mon Sep 17 00:00:00 2001 From: Bart Sopers Date: Sat, 26 Dec 2020 20:40:52 +0100 Subject: [PATCH] Handle empty RileyLink name correctly --- .../pump/common/hw/rileylink/ble/RileyLinkBLE.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java index 05744e1845..e922bd990c 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RileyLinkBLE.java @@ -396,10 +396,16 @@ public class RileyLinkBLE { } rileyLinkServiceData.rileyLinkAddress = bluetoothConnectionGatt.getDevice().getAddress(); - rileyLinkServiceData.rileyLinkName = bluetoothConnectionGatt.getDevice().getName(); - // Update stored name upon connecting (also for backwards compatibility for device where a name was not yet stored) - sp.putString(RileyLinkConst.Prefs.RileyLinkName, rileyLinkServiceData.rileyLinkName); + String deviceName = bluetoothConnectionGatt.getDevice().getName(); + if (StringUtils.isNotEmpty(deviceName)) { + // Update stored name upon connecting (also for backwards compatibility for device where a name was not yet stored) + sp.putString(RileyLinkConst.Prefs.RileyLinkName, rileyLinkServiceData.rileyLinkName); + rileyLinkServiceData.rileyLinkName = deviceName; + } else { + sp.remove(RileyLinkConst.Prefs.RileyLinkName); + rileyLinkServiceData.rileyLinkName = null; + } } }