diff --git a/fastpair/keyed_service/fast_pair_mediator.cc b/fastpair/keyed_service/fast_pair_mediator.cc index 97111344..d72d01c1 100644 --- a/fastpair/keyed_service/fast_pair_mediator.cc +++ b/fastpair/keyed_service/fast_pair_mediator.cc @@ -27,10 +27,6 @@ Mediator::Mediator(std::unique_ptr scanner_broker, : scanner_broker_(std::move(scanner_broker)), fast_pair_repository_(std::move(fast_pair_repository)) { scanner_broker_->AddObserver(this); - - // TODO(b/275452353): Add feature_status_tracker IsFastPairEnabled() - // Currently default to true. - SetFastPairState(true); } void Mediator::OnDeviceFound(const FastPairDevice& device) { @@ -42,16 +38,19 @@ void Mediator::OnDeviceLost(const FastPairDevice& device) { NEARBY_LOGS(INFO) << __func__ << ": " << device; } -void Mediator::SetFastPairState(bool is_enabled) { - NEARBY_LOGS(VERBOSE) << __func__ << ": " << is_enabled; - - if (is_enabled) { +void Mediator::StartScanning() { + if (IsFastPairEnabled()) { scanner_broker_->StartScanning(Protocol::kFastPairInitialPairing); return; } - scanner_broker_->StopScanning(Protocol::kFastPairInitialPairing); } +bool Mediator::IsFastPairEnabled() { + // TODO(b/275452353): Add feature_status_tracker IsFastPairEnabled() + // Currently default to true. + NEARBY_LOGS(VERBOSE) << __func__ << ": " << true; + return true; +} } // namespace fastpair } // namespace nearby diff --git a/fastpair/keyed_service/fast_pair_mediator.h b/fastpair/keyed_service/fast_pair_mediator.h index 42c03c77..c59857a1 100644 --- a/fastpair/keyed_service/fast_pair_mediator.h +++ b/fastpair/keyed_service/fast_pair_mediator.h @@ -36,8 +36,10 @@ class Mediator final : public ScannerBroker::Observer { void OnDeviceFound(const FastPairDevice& device) override; void OnDeviceLost(const FastPairDevice& device) override; + void StartScanning(); + private: - void SetFastPairState(bool is_enabled); + bool IsFastPairEnabled(); std::unique_ptr scanner_broker_; std::unique_ptr fast_pair_repository_; diff --git a/fastpair/keyed_service/fast_pair_mediator_test.cc b/fastpair/keyed_service/fast_pair_mediator_test.cc index be454a9c..40944a49 100644 --- a/fastpair/keyed_service/fast_pair_mediator_test.cc +++ b/fastpair/keyed_service/fast_pair_mediator_test.cc @@ -60,6 +60,7 @@ TEST_F(MediatorTest, SannerBrokerCallStartScanning) { mediator_ = std::make_unique( std::move(scanner_broker_), std::move(fast_pair_repository_)); + mediator_->StartScanning(); } } // namespace