mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
Remove the coordinator instance #323
For now, always iterate over the available coordinators instead. Should fix MiBandSupport occasionally being used in place of MiBand2Support.
This commit is contained in:
parent
db034a246c
commit
f57fec25f8
@ -46,13 +46,8 @@ public class DeviceHelper {
|
||||
|
||||
// lazily created
|
||||
private List<DeviceCoordinator> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user