From 0d2e75f2a2515151a963cb98d1ece62d8eadc4a0 Mon Sep 17 00:00:00 2001 From: Janusz Sobczak Date: Wed, 12 Jul 2023 12:01:16 -0700 Subject: [PATCH] Call pairing result in background This prevents calling the callback twice and out of order. PiperOrigin-RevId: 547562324 --- fastpair/internal/fast_pair_seeker_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastpair/internal/fast_pair_seeker_impl.cc b/fastpair/internal/fast_pair_seeker_impl.cc index 7f90ec77..c59ac65d 100644 --- a/fastpair/internal/fast_pair_seeker_impl.cc +++ b/fastpair/internal/fast_pair_seeker_impl.cc @@ -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(); }); });