mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Initialize metadata repository
Make sure that FastPairRepository is initalized. FastPairRepository is required to fetch metadata information PiperOrigin-RevId: 542906473
This commit is contained in:
committed by
Copybara-Service
parent
d91f7e6f44
commit
36132890cd
@@ -98,6 +98,7 @@ cc_library(
|
||||
":fast_pair_seeker",
|
||||
"//fastpair/internal",
|
||||
"//fastpair/repository:device_repository",
|
||||
"//fastpair/server_access",
|
||||
"//internal/flags:nearby_flags",
|
||||
"//internal/platform:types",
|
||||
"//internal/platform/flags:platform_flags",
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "fastpair/fast_pair_plugin.h"
|
||||
#include "fastpair/internal/fast_pair_seeker_impl.h"
|
||||
#include "fastpair/server_access/fast_pair_repository_impl.h"
|
||||
#include "internal/flags/nearby_flags.h"
|
||||
#include "internal/platform/flags/nearby_platform_feature_flags.h"
|
||||
#include "internal/platform/logging.h"
|
||||
@@ -34,12 +35,15 @@ namespace {
|
||||
constexpr absl::Duration kTimeout = absl::Seconds(3);
|
||||
}
|
||||
|
||||
FastPairService::FastPairService() {
|
||||
FastPairService::FastPairService()
|
||||
: FastPairService(std::make_unique<FastPairRepositoryImpl>()) {}
|
||||
|
||||
FastPairService::FastPairService(std::unique_ptr<FastPairRepository> repository)
|
||||
: fast_pair_repository_(std::move(repository)) {
|
||||
NearbyFlags::GetInstance().OverrideBoolFlagValue(
|
||||
platform::config_package_nearby::nearby_platform_feature::
|
||||
kEnableBleV2Gatt,
|
||||
true);
|
||||
|
||||
seeker_ = std::make_unique<FastPairSeekerImpl>(
|
||||
FastPairSeekerImpl::ServiceCallbacks{
|
||||
.on_initial_discovery =
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "fastpair/fast_pair_plugin.h"
|
||||
#include "fastpair/fast_pair_seeker.h"
|
||||
#include "fastpair/repository/fast_pair_device_repository.h"
|
||||
#include "fastpair/server_access/fast_pair_repository.h"
|
||||
#include "internal/platform/single_thread_executor.h"
|
||||
|
||||
namespace nearby {
|
||||
@@ -36,6 +37,9 @@ namespace fastpair {
|
||||
class FastPairService {
|
||||
public:
|
||||
FastPairService();
|
||||
// Constructor for tests. Allows us to inject a serverless metadata
|
||||
// repository.
|
||||
explicit FastPairService(std::unique_ptr<FastPairRepository> repository);
|
||||
~FastPairService();
|
||||
|
||||
// Registers a plugin provider. `name` must be a unique.
|
||||
@@ -66,6 +70,7 @@ class FastPairService {
|
||||
absl::flat_hash_map<std::string, std::unique_ptr<FastPairPluginProvider>>
|
||||
providers_;
|
||||
FastPairDeviceRepository devices_{&executor_};
|
||||
std::unique_ptr<FastPairRepository> fast_pair_repository_;
|
||||
};
|
||||
|
||||
} // namespace fastpair
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
@@ -75,7 +76,7 @@ TEST(FastPairService, InitialDiscoveryEvent) {
|
||||
constexpr absl::string_view kPluginName = "my plugin";
|
||||
auto repository = FakeFastPairRepository::Create(kModelId, kPublicAntiSpoof);
|
||||
FakeProvider provider;
|
||||
FastPairService service;
|
||||
FastPairService service(std::move(repository));
|
||||
CountDownLatch latch(1);
|
||||
auto plugin_provider = std::make_unique<FakeFastPairPluginProvider>();
|
||||
plugin_provider->on_initial_discovery_event_ =
|
||||
|
||||
Reference in New Issue
Block a user