mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Add startscanning to fast pair mediator
PiperOrigin-RevId: 522114963
This commit is contained in:
committed by
Copybara-Service
parent
0705059e94
commit
0a89c8a499
@@ -27,10 +27,6 @@ Mediator::Mediator(std::unique_ptr<ScannerBroker> 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
|
||||
|
||||
@@ -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<ScannerBroker> scanner_broker_;
|
||||
std::unique_ptr<FastPairRepository> fast_pair_repository_;
|
||||
|
||||
@@ -60,6 +60,7 @@ TEST_F(MediatorTest, SannerBrokerCallStartScanning) {
|
||||
mediator_ = std::make_unique<Mediator>(
|
||||
std::move(scanner_broker_),
|
||||
std::move(fast_pair_repository_));
|
||||
mediator_->StartScanning();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user