Commit 3da53601 authored by Adam Langley's avatar Adam Langley Committed by Commit Bot

device/fido: fix discovery when only caBLE v2 pairings are known.

If FidoCableDiscovery was only provided with v2 pairing information then
it wouldn't send any advertisements, but also wouldn't signal that it
was ready.

BUG=1002262

Change-Id: I0e15d0017ec97891316c0fe1ea83761384676e52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857298Reviewed-by: default avatarMartin Kreichgauer <martinkr@google.com>
Commit-Queue: Adam Langley <agl@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705272}
parent c4cccc8f
......@@ -428,19 +428,16 @@ void FidoCableDiscovery::OnStartDiscoverySessionWithFilter(
void FidoCableDiscovery::StartAdvertisement() {
DCHECK(adapter());
if (discovery_data_.empty() && qr_generator_key_.has_value()) {
// If no caBLE extension was provided then there are no BLE advertisements
// and discovery starts immediately on the assumption that the user will
// scan a QR-code with their phone.
NotifyDiscoveryStarted(true);
return;
}
FIDO_LOG(DEBUG) << "Starting to advertise clientEID.";
bool advertisements_pending = false;
for (const auto& data : discovery_data_) {
if (data.version != CableDiscoveryData::Version::V1) {
continue;
}
if (!advertisements_pending) {
FIDO_LOG(DEBUG) << "Starting to advertise clientEIDs.";
advertisements_pending = true;
}
adapter()->RegisterAdvertisement(
ConstructAdvertisementData(data.v1->client_eid),
base::AdaptCallbackForRepeating(
......@@ -450,6 +447,13 @@ void FidoCableDiscovery::StartAdvertisement() {
base::BindOnce(&FidoCableDiscovery::OnAdvertisementRegisterError,
weak_factory_.GetWeakPtr())));
}
if (!advertisements_pending) {
// If no V1 extensions were provided then this discovery is ready
// immediately. Otherwise |NotifyDiscoveryStarted| will be called once
// all the advertising requests have been resolved.
NotifyDiscoveryStarted(true);
}
}
void FidoCableDiscovery::StopAdvertisements(base::OnceClosure callback) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment