Skip to content

Commit

Permalink
[Fast Pair] Write account key after pairing change
Browse files Browse the repository at this point in the history
Currently Fast Pair attempts to write the account key before
DevicePairedChanged() is called. This flow can cause GATT failures for
some devices (Pixel Buds Pros). This change moves the writing of the
account key into DevicePairedChanged(). DevicePairedChanged() uses the additional data in the Fast Pair Device object to differentiate between V1 and V2 fast pair devices.

unit tests

Tested: Tested manually DUT with allegro and other devices. Updated
Change-Id: I04024f2c5be4b37e221984de215983ccb16e1714
Fixed: b/244337054 b/234166201
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3961635
Reviewed-by: Juliet Lévesque <julietlevesque@google.com>
Reviewed-by: Ryan Hansberry <hansberry@chromium.org>
Commit-Queue: Alex Kingsborough <akingsb@google.com>
Cr-Commit-Position: refs/heads/main@{#1069037}
  • Loading branch information
Alex Kingsborough authored and Chromium LUCI CQ committed Nov 9, 2022
1 parent 42b34bb commit 2ce8d6d
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 296 deletions.
22 changes: 15 additions & 7 deletions ash/quick_pair/pairing/fast_pair/fast_pair_pairer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,8 @@ void FastPairPairerImpl::OnParseDecryptedPasskey(

QP_LOG(INFO) << __func__ << ": Passkeys match, confirming pairing";
pairing_device->ConfirmPairing();
std::move(paired_callback_).Run(device_);
adapter_->RemovePairingDelegate(this);
AttemptSendAccountKey();
// DevicePairedChanged() is expected to be called following pairing
// confirmation.
}

void FastPairPairerImpl::AttemptSendAccountKey() {
Expand Down Expand Up @@ -628,14 +627,23 @@ void FastPairPairerImpl::DevicePairedChanged(device::BluetoothAdapter* adapter,
if (!new_paired_status || !paired_callback_)
return;

// This covers the case where we are pairing a v1 device and are using the
// Bluetooth pairing dialog to do it.
if (device->GetAddress() == device_->ble_address ||
device->GetAddress() == device_->classic_address()) {
QP_LOG(INFO) << __func__ << ": Completing pairing procedure";
QP_LOG(INFO) << __func__ << ": Completing pairing procedure " << device_;
std::move(paired_callback_).Run(device_);

if (pairing_procedure_complete_) {
// For V2 devices we still need to remove the Pairing Delegate and write the
// account key. `AttemptSendAccountKey()` will call
// |pairing_procedure_complete_| whereas V1 devices need to run the callback
// in this function since they don't write account keys, and their pairing
// procedure is not complete at this point.
if (device_->version().has_value() &&
device_->version().value() == DeviceFastPairVersion::kHigherThanV1) {
adapter_->RemovePairingDelegate(this);
AttemptSendAccountKey();
} else if (pairing_procedure_complete_) {
// This covers the case where we are pairing a v1 device and are using the
// Bluetooth pairing dialog to do it.
std::move(pairing_procedure_complete_).Run(device_);
}
}
Expand Down

0 comments on commit 2ce8d6d

Please sign in to comment.