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
|
// lazily created
|
||||||
private List<DeviceCoordinator> coordinators;
|
private List<DeviceCoordinator> coordinators;
|
||||||
// the current single coordinator (typically there's just one device connected
|
|
||||||
private DeviceCoordinator coordinator;
|
|
||||||
|
|
||||||
public boolean isSupported(GBDeviceCandidate candidate) {
|
public boolean isSupported(GBDeviceCandidate candidate) {
|
||||||
if (coordinator != null && coordinator.supports(candidate)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (DeviceCoordinator coordinator : getAllCoordinators()) {
|
for (DeviceCoordinator coordinator : getAllCoordinators()) {
|
||||||
if (coordinator.supports(candidate)) {
|
if (coordinator.supports(candidate)) {
|
||||||
return true;
|
return true;
|
||||||
@ -62,9 +57,6 @@ public class DeviceHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSupported(GBDevice device) {
|
public boolean isSupported(GBDevice device) {
|
||||||
if (coordinator != null && coordinator.supports(device)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
for (DeviceCoordinator coordinator : getAllCoordinators()) {
|
for (DeviceCoordinator coordinator : getAllCoordinators()) {
|
||||||
if (coordinator.supports(device)) {
|
if (coordinator.supports(device)) {
|
||||||
return true;
|
return true;
|
||||||
@ -130,9 +122,6 @@ public class DeviceHelper {
|
|||||||
public GBDevice toSupportedDevice(BluetoothDevice device) {
|
public GBDevice toSupportedDevice(BluetoothDevice device) {
|
||||||
GBDeviceCandidate candidate = new GBDeviceCandidate(device, GBDevice.RSSI_UNKNOWN);
|
GBDeviceCandidate candidate = new GBDeviceCandidate(device, GBDevice.RSSI_UNKNOWN);
|
||||||
|
|
||||||
if (coordinator != null && coordinator.supports(candidate)) {
|
|
||||||
return coordinator.createDevice(candidate);
|
|
||||||
}
|
|
||||||
for (DeviceCoordinator coordinator : getAllCoordinators()) {
|
for (DeviceCoordinator coordinator : getAllCoordinators()) {
|
||||||
if (coordinator.supports(candidate)) {
|
if (coordinator.supports(candidate)) {
|
||||||
return coordinator.createDevice(candidate);
|
return coordinator.createDevice(candidate);
|
||||||
@ -142,14 +131,10 @@ public class DeviceHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DeviceCoordinator getCoordinator(GBDeviceCandidate device) {
|
public DeviceCoordinator getCoordinator(GBDeviceCandidate device) {
|
||||||
if (coordinator != null && coordinator.supports(device)) {
|
|
||||||
return coordinator;
|
|
||||||
}
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (DeviceCoordinator coord : getAllCoordinators()) {
|
for (DeviceCoordinator coord : getAllCoordinators()) {
|
||||||
if (coord.supports(device)) {
|
if (coord.supports(device)) {
|
||||||
coordinator = coord;
|
return coord;
|
||||||
return coordinator;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,14 +142,10 @@ public class DeviceHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DeviceCoordinator getCoordinator(GBDevice device) {
|
public DeviceCoordinator getCoordinator(GBDevice device) {
|
||||||
if (coordinator != null && coordinator.supports(device)) {
|
|
||||||
return coordinator;
|
|
||||||
}
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (DeviceCoordinator coord : getAllCoordinators()) {
|
for (DeviceCoordinator coord : getAllCoordinators()) {
|
||||||
if (coord.supports(device)) {
|
if (coord.supports(device)) {
|
||||||
coordinator = coord;
|
return coord;
|
||||||
return coordinator;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user