1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-24 05:50:47 +02:00

Display devices with unknown name during scan

This commit is contained in:
José Rebelo 2023-09-13 20:14:52 +01:00
parent e078ceff0a
commit 9230580a01
2 changed files with 17 additions and 15 deletions

View File

@ -104,7 +104,7 @@ public class DiscoveryActivityV2 extends AbstractGBActivity implements AdapterVi
private final Handler handler = new Handler(); private final Handler handler = new Handler();
private static final long SCAN_DURATION = 30000; // 30s private static final long SCAN_DURATION = 30000; // 30s
private static final long LIST_REFRESH_THRESHOLD_MS = 2500L; private static final long LIST_REFRESH_THRESHOLD_MS = 1000L;
private long lastListRefresh = System.currentTimeMillis(); private long lastListRefresh = System.currentTimeMillis();
private final ScanCallback bleScanCallback = new BleScanCallback(); private final ScanCallback bleScanCallback = new BleScanCallback();

View File

@ -217,10 +217,12 @@ public final class GBScanEventProcessor implements Runnable {
String previousName = null; String previousName = null;
ParcelUuid[] previousUuids = null; ParcelUuid[] previousUuids = null;
boolean firstTime = false;
if (candidate == null) { if (candidate == null) {
// First time we see this device // First time we see this device
LOG.debug("Found {} for the first time", address); LOG.debug("Found {} for the first time", address);
firstTime = true;
final GBScanEvent firstEvent = events.get(0); final GBScanEvent firstEvent = events.get(0);
events.remove(0); events.remove(0);
candidate = new GBDeviceCandidate(firstEvent.getDevice(), firstEvent.getRssi(), firstEvent.getServiceUuids()); candidate = new GBDeviceCandidate(firstEvent.getDevice(), firstEvent.getRssi(), firstEvent.getServiceUuids());
@ -248,22 +250,22 @@ public final class GBScanEventProcessor implements Runnable {
LOG.error("SecurityException on candidate.getDevice().getUuids()"); LOG.error("SecurityException on candidate.getDevice().getUuids()");
} }
if (Objects.equals(candidate.getName(), previousName) && Arrays.equals(candidate.getServiceUuids(), previousUuids)) { if (!firstTime) {
// Neither name nor uuids changed, do not reprocess if (Objects.equals(candidate.getName(), previousName) && Arrays.equals(candidate.getServiceUuids(), previousUuids)) {
LOG.trace("Not reprocessing {} due to no changes", address); // Neither name nor uuids changed, do not reprocess
return false; LOG.trace("Not reprocessing {} due to no changes", address);
return false;
}
} }
if (candidate.isNameKnown()) { if (processCandidate(candidate)) {
if (processCandidate(candidate)) { LOG.info(
LOG.info( "Device {} ({}) is supported as '{}' without scanning services",
"Device {} ({}) is supported as '{}' without scanning services", candidate.getDevice(),
candidate.getDevice(), candidate.getName(),
candidate.getName(), candidate.getDeviceType()
candidate.getDeviceType() );
); return true;
return true;
}
} }
if (candidate.getServiceUuids().length == 0 || (candidate.getServiceUuids().length == 1 && candidate.getServiceUuids()[0].equals(ZERO_UUID))) { if (candidate.getServiceUuids().length == 0 || (candidate.getServiceUuids().length == 1 && candidate.getServiceUuids()[0].equals(ZERO_UUID))) {