Fix coordinators not recognitzing devices by name

Do not ask a device candidate for its name , ask the underlying BluetoothDevice
The candidate uses the device alias - not good for matching
This commit is contained in:
Andreas Shimokawa 2016-07-09 23:10:21 +02:00
parent f54163faeb
commit 340a0f4a66
2 changed files with 2 additions and 4 deletions

View File

@ -10,7 +10,6 @@ import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity; import nodomain.freeyourgadget.gadgetbridge.activities.charts.ChartsActivity;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
@ -18,7 +17,6 @@ import nodomain.freeyourgadget.gadgetbridge.entities.AbstractActivitySample;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser; import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
@ -42,7 +40,7 @@ public class MiBandCoordinator extends AbstractDeviceCoordinator {
// and a heuristic // and a heuristic
try { try {
if (isHealthWearable(candidate.getDevice())) { if (isHealthWearable(candidate.getDevice())) {
return candidate.getName().toUpperCase().startsWith(MiBandConst.MI_GENERAL_NAME_PREFIX.toUpperCase()); return candidate.getDevice().getName().toUpperCase().startsWith(MiBandConst.MI_GENERAL_NAME_PREFIX.toUpperCase());
} }
} catch (Exception ex) { } catch (Exception ex) {
LOG.error("unable to check device support", ex); LOG.error("unable to check device support", ex);

View File

@ -23,7 +23,7 @@ public class PebbleCoordinator extends AbstractDeviceCoordinator {
@Override @Override
public boolean supports(GBDeviceCandidate candidate) { public boolean supports(GBDeviceCandidate candidate) {
return candidate.getName().startsWith("Pebble"); return candidate.getDevice().getName().startsWith("Pebble");
} }
@Override @Override