1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-20 20:10:15 +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 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 final ScanCallback bleScanCallback = new BleScanCallback();

View File

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