mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Store metadata in FastPairDevice
Add DeviceMetadata to FastPairDevice after downloading it. It simplifies the code and prevents fetching the same metadata several times. FastPairDataEncryptorImpl does not download the metadata anymore. Metadata must have already been downloaded, otherwise we wouldn't know what FP protocol to use. PiperOrigin-RevId: 542490742
This commit is contained in:
committed by
Copybara-Service
parent
f9123d544b
commit
3cf20ee3bc
@@ -61,7 +61,6 @@ cc_library(
|
||||
":server_access",
|
||||
"//fastpair/common",
|
||||
"//fastpair/proto:fastpair_cc_proto",
|
||||
"//fastpair/repository",
|
||||
"//internal/platform:types",
|
||||
"@com_google_absl//absl/container:flat_hash_map",
|
||||
"@com_google_absl//absl/strings",
|
||||
@@ -97,7 +96,6 @@ cc_test(
|
||||
":server_access",
|
||||
"//fastpair/common",
|
||||
"//fastpair/proto:fastpair_cc_proto",
|
||||
"//fastpair/repository",
|
||||
"//fastpair/repository:fake_fast_pair_metadata_repository",
|
||||
"//internal/platform/implementation/g3",
|
||||
"@com_github_protobuf_matchers//protobuf-matchers",
|
||||
|
||||
@@ -18,7 +18,9 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/strings/escaping.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "fastpair/common/constant.h"
|
||||
#include "fastpair/proto/fastpair_rpcs.proto.h"
|
||||
|
||||
namespace nearby {
|
||||
@@ -48,7 +50,9 @@ std::unique_ptr<FakeFastPairRepository> FakeFastPairRepository::Create(
|
||||
absl::string_view model_id, absl::string_view public_anti_spoof_key) {
|
||||
proto::Device metadata;
|
||||
auto repository = std::make_unique<FakeFastPairRepository>();
|
||||
if (public_anti_spoof_key.length() == kPublicKeyByteSize) {
|
||||
if (public_anti_spoof_key.empty()) {
|
||||
// Missing ASK is fine for V1 devices.
|
||||
} else if (public_anti_spoof_key.length() == kPublicKeyByteSize) {
|
||||
metadata.mutable_anti_spoofing_key_pair()->set_public_key(
|
||||
public_anti_spoof_key);
|
||||
} else {
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "fastpair/repository/device_metadata.h"
|
||||
#include "fastpair/common/device_metadata.h"
|
||||
#include "fastpair/server_access/fast_pair_repository.h"
|
||||
#include "internal/platform/single_thread_executor.h"
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "fastpair/proto/fastpair_rpcs.pb.h"
|
||||
#include "fastpair/repository/device_metadata.h"
|
||||
#include "internal/platform/logging.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "fastpair/common/device_metadata.h"
|
||||
#include "fastpair/proto/fastpair_rpcs.pb.h"
|
||||
#include "internal/platform/logging.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace fastpair {
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "fastpair/repository/device_metadata.h"
|
||||
#include "fastpair/common/device_metadata.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace fastpair {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "absl/strings/numbers.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "fastpair/repository/device_metadata.h"
|
||||
#include "fastpair/common/device_metadata.h"
|
||||
#include "fastpair/repository/fast_pair_metadata_repository.h"
|
||||
#include "fastpair/server_access/fast_pair_metadata_downloader.h"
|
||||
#include "internal/platform/logging.h"
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "fastpair/common/device_metadata.h"
|
||||
#include "fastpair/common/fast_pair_http_result.h"
|
||||
#include "fastpair/proto/fastpair_rpcs.proto.h"
|
||||
#include "fastpair/repository/device_metadata.h"
|
||||
#include "fastpair/repository/fake_fast_pair_metadata_repository.h"
|
||||
#include "fastpair/server_access/fast_pair_metadata_downloader.h"
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "absl/functional/any_invocable.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "fastpair/repository/device_metadata.h"
|
||||
#include "fastpair/common/device_metadata.h"
|
||||
|
||||
namespace nearby {
|
||||
namespace fastpair {
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include "protobuf-matchers/protocol-buffer-matchers.h"
|
||||
#include "gtest/gtest.h"
|
||||
#include "fastpair/common/device_metadata.h"
|
||||
#include "fastpair/proto/fastpair_rpcs.proto.h"
|
||||
#include "fastpair/repository/device_metadata.h"
|
||||
#include "fastpair/repository/fake_fast_pair_metadata_repository.h"
|
||||
#include "fastpair/server_access/fast_pair_metadata_downloader.h"
|
||||
#include "fastpair/server_access/fast_pair_metadata_downloader_impl.h"
|
||||
@@ -53,7 +53,7 @@ class FastPairRepositoryImplTest : public ::testing::Test {
|
||||
void GetObservedDataRequestSuccess(
|
||||
const proto::GetObservedDeviceResponse& response) {
|
||||
FakeFastPairMetadataRepository* repository =
|
||||
fake_repository_factory_->fake_repository();
|
||||
fake_repository_factory_->fake_repository();
|
||||
std::move(repository->get_observed_device_request()->callback)(response);
|
||||
}
|
||||
|
||||
@@ -64,8 +64,7 @@ class FastPairRepositoryImplTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
std::optional<Result> result_;
|
||||
FakeFastPairMetadataRepositoryFactory*
|
||||
fake_repository_factory_;
|
||||
FakeFastPairMetadataRepositoryFactory* fake_repository_factory_;
|
||||
std::unique_ptr<FastPairRepositoryImpl> repository_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user