Call pairing result in background

This prevents calling the callback twice and out of order.

PiperOrigin-RevId: 547562324
This commit is contained in:
Janusz Sobczak
2023-07-12 12:02:28 -07:00
committed by Copybara-Service
parent ffdd25a194
commit 0d2e75f2a2
+1 -1
View File
@@ -52,10 +52,10 @@ FastPairSeekerImpl::~FastPairSeekerImpl() {
NEARBY_LOGS(INFO) << "~FastPairSeekerImpl start";
pairer_broker_->RemoveObserver(this);
mediums_.GetBluetoothClassic().RemoveObserver(this);
FinishPairing(absl::AbortedError("Pairing terminated"));
auto unused = StopFastPairScan();
CountDownLatch latch(1);
executor_->Execute("~FastPairSeekerImpl", [this, latch]() mutable {
FinishPairing(absl::AbortedError("Pairing terminated"));
pairer_broker_.reset();
executor_->Execute("sync", [latch]() mutable { latch.CountDown(); });
});