From f57fec25f84ededd4f619a439dfb78a96b75a4a7 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Mon, 10 Oct 2016 20:50:50 +0200 Subject: [PATCH] Remove the coordinator instance #323 For now, always iterate over the available coordinators instead. Should fix MiBandSupport occasionally being used in place of MiBand2Support. --- .../gadgetbridge/util/DeviceHelper.java | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java index fbd49f51b..a14aff808 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java @@ -46,13 +46,8 @@ public class DeviceHelper { // lazily created private List coordinators; - // the current single coordinator (typically there's just one device connected - private DeviceCoordinator coordinator; public boolean isSupported(GBDeviceCandidate candidate) { - if (coordinator != null && coordinator.supports(candidate)) { - return true; - } for (DeviceCoordinator coordinator : getAllCoordinators()) { if (coordinator.supports(candidate)) { return true; @@ -62,9 +57,6 @@ public class DeviceHelper { } public boolean isSupported(GBDevice device) { - if (coordinator != null && coordinator.supports(device)) { - return true; - } for (DeviceCoordinator coordinator : getAllCoordinators()) { if (coordinator.supports(device)) { return true; @@ -130,9 +122,6 @@ public class DeviceHelper { public GBDevice toSupportedDevice(BluetoothDevice device) { GBDeviceCandidate candidate = new GBDeviceCandidate(device, GBDevice.RSSI_UNKNOWN); - if (coordinator != null && coordinator.supports(candidate)) { - return coordinator.createDevice(candidate); - } for (DeviceCoordinator coordinator : getAllCoordinators()) { if (coordinator.supports(candidate)) { return coordinator.createDevice(candidate); @@ -142,14 +131,10 @@ public class DeviceHelper { } public DeviceCoordinator getCoordinator(GBDeviceCandidate device) { - if (coordinator != null && coordinator.supports(device)) { - return coordinator; - } synchronized (this) { for (DeviceCoordinator coord : getAllCoordinators()) { if (coord.supports(device)) { - coordinator = coord; - return coordinator; + return coord; } } } @@ -157,14 +142,10 @@ public class DeviceHelper { } public DeviceCoordinator getCoordinator(GBDevice device) { - if (coordinator != null && coordinator.supports(device)) { - return coordinator; - } synchronized (this) { for (DeviceCoordinator coord : getAllCoordinators()) { if (coord.supports(device)) { - coordinator = coord; - return coordinator; + return coord; } } }