From 5bce94d8ee3bd6ccd67f26c12942ee8706464e09 Mon Sep 17 00:00:00 2001 From: Qin Wang Date: Thu, 6 Jul 2023 12:09:47 -0700 Subject: [PATCH] Move fast_pair_repository to third_party/nearby/fastpair/repository and remove all deprecated files PiperOrigin-RevId: 546057062 --- fastpair/BUILD | 4 +- fastpair/fast_pair_controller.cc | 2 +- fastpair/fast_pair_service.cc | 2 +- fastpair/fast_pair_service.h | 2 +- fastpair/handshake/BUILD | 5 +- .../fast_pair_data_encryptor_impl.cc | 2 +- .../fast_pair_handshake_impl_test.cc | 2 +- fastpair/internal/BUILD | 2 +- .../internal/fast_pair_seeker_impl_test.cc | 2 +- fastpair/keyed_service/BUILD | 3 +- fastpair/keyed_service/fast_pair_mediator.cc | 2 +- fastpair/keyed_service/fast_pair_mediator.h | 2 +- .../keyed_service/fast_pair_mediator_test.cc | 9 - fastpair/pairing/BUILD | 2 +- fastpair/pairing/fastpair/BUILD | 2 +- .../fastpair/fast_pair_pairer_impl_test.cc | 2 +- fastpair/pairing/pairer_broker_impl_test.cc | 2 +- fastpair/proto/BUILD | 2 +- fastpair/proto/proto_builder.cc | 2 +- fastpair/repository/BUILD | 125 ++++++++---- .../fake_fast_pair_metadata_repository.h | 82 -------- .../fake_fast_pair_repository.cc | 2 +- .../fake_fast_pair_repository.h | 8 +- .../repository/fast_pair_metadata_fetcher.h | 60 ------ .../fast_pair_metadata_fetcher_impl.cc | 113 ----------- .../fast_pair_metadata_fetcher_impl.h | 84 -------- .../fast_pair_metadata_fetcher_impl_test.cc | 184 ------------------ .../fast_pair_metadata_repository.h | 60 ------ .../fast_pair_metadata_repository_impl.cc | 140 ------------- .../fast_pair_metadata_repository_impl.h | 89 --------- ...fast_pair_metadata_repository_impl_test.cc | 156 --------------- .../fast_pair_repository.cc | 2 +- .../fast_pair_repository.h | 6 +- .../fast_pair_repository_impl.cc | 2 +- .../fast_pair_repository_impl.h | 8 +- .../fast_pair_repository_impl_test.cc | 2 +- .../fast_pair_repository_test.cc | 2 +- .../mock_fast_pair_repository.h | 8 +- fastpair/retroactive/BUILD | 2 +- fastpair/retroactive/retroactive_test.cc | 2 +- fastpair/scanning/BUILD | 2 +- fastpair/scanning/fastpair/BUILD | 3 +- .../fast_pair_discoverable_scanner_impl.cc | 2 +- ...ast_pair_discoverable_scanner_impl_test.cc | 2 +- fastpair/scanning/scanner_broker_impl_test.cc | 2 +- fastpair/server_access/BUILD | 92 --------- .../fast_pair_metadata_downloader.cc | 59 ------ .../fast_pair_metadata_downloader.h | 58 ------ .../fast_pair_metadata_downloader_impl.cc | 122 ------------ .../fast_pair_metadata_downloader_impl.h | 75 ------- ...fast_pair_metadata_downloader_impl_test.cc | 126 ------------ fastpair/ui/BUILD | 1 - .../ui/fast_pair/fast_pair_presenter_impl.cc | 2 +- 53 files changed, 142 insertions(+), 1592 deletions(-) delete mode 100644 fastpair/repository/fake_fast_pair_metadata_repository.h rename fastpair/{server_access => repository}/fake_fast_pair_repository.cc (97%) rename fastpair/{server_access => repository}/fake_fast_pair_repository.h (86%) delete mode 100644 fastpair/repository/fast_pair_metadata_fetcher.h delete mode 100644 fastpair/repository/fast_pair_metadata_fetcher_impl.cc delete mode 100644 fastpair/repository/fast_pair_metadata_fetcher_impl.h delete mode 100644 fastpair/repository/fast_pair_metadata_fetcher_impl_test.cc delete mode 100644 fastpair/repository/fast_pair_metadata_repository.h delete mode 100644 fastpair/repository/fast_pair_metadata_repository_impl.cc delete mode 100644 fastpair/repository/fast_pair_metadata_repository_impl.h delete mode 100644 fastpair/repository/fast_pair_metadata_repository_impl_test.cc rename fastpair/{server_access => repository}/fast_pair_repository.cc (97%) rename fastpair/{server_access => repository}/fast_pair_repository.h (88%) rename fastpair/{server_access => repository}/fast_pair_repository_impl.cc (97%) rename fastpair/{server_access => repository}/fast_pair_repository_impl.h (84%) rename fastpair/{server_access => repository}/fast_pair_repository_impl_test.cc (97%) rename fastpair/{server_access => repository}/fast_pair_repository_test.cc (96%) rename fastpair/{server_access => repository}/mock_fast_pair_repository.h (77%) delete mode 100644 fastpair/server_access/fast_pair_metadata_downloader.cc delete mode 100644 fastpair/server_access/fast_pair_metadata_downloader.h delete mode 100644 fastpair/server_access/fast_pair_metadata_downloader_impl.cc delete mode 100644 fastpair/server_access/fast_pair_metadata_downloader_impl.h delete mode 100644 fastpair/server_access/fast_pair_metadata_downloader_impl_test.cc diff --git a/fastpair/BUILD b/fastpair/BUILD index 3387cb3d..ec101847 100644 --- a/fastpair/BUILD +++ b/fastpair/BUILD @@ -28,7 +28,7 @@ cc_library( "//fastpair/common", "//fastpair/handshake", "//fastpair/message_stream", - "//fastpair/server_access", + "//fastpair/repository", "//internal/base", "//internal/platform:comm", "//internal/platform:types", @@ -99,7 +99,9 @@ cc_library( ":fast_pair_seeker", "//fastpair/common", "//fastpair/internal", + "//fastpair/repository", "//fastpair/repository:device_repository", + "//fastpair/repository:repository_impl", "//fastpair/server_access", "//internal/account", "//internal/auth:oauth_lib", diff --git a/fastpair/fast_pair_controller.cc b/fastpair/fast_pair_controller.cc index ab3aed9d..9d1ad89f 100644 --- a/fastpair/fast_pair_controller.cc +++ b/fastpair/fast_pair_controller.cc @@ -25,7 +25,7 @@ #include "fastpair/common/protocol.h" #include "fastpair/handshake/fast_pair_data_encryptor_impl.h" #include "fastpair/message_stream/message_stream.h" -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include "internal/platform/bluetooth_adapter.h" #include "internal/platform/bluetooth_classic.h" #include "internal/platform/single_thread_executor.h" diff --git a/fastpair/fast_pair_service.cc b/fastpair/fast_pair_service.cc index 42275e22..f57eabd5 100644 --- a/fastpair/fast_pair_service.cc +++ b/fastpair/fast_pair_service.cc @@ -25,7 +25,7 @@ #include "fastpair/internal/fast_pair_seeker_impl.h" #include "fastpair/server_access/fast_pair_client_impl.h" #include "fastpair/server_access/fast_pair_http_notifier.h" -#include "fastpair/server_access/fast_pair_repository_impl.h" +#include "fastpair/repository/fast_pair_repository_impl.h" #include "internal/account/account_manager_impl.h" #include "internal/auth/authentication_manager_impl.h" #include "internal/flags/nearby_flags.h" diff --git a/fastpair/fast_pair_service.h b/fastpair/fast_pair_service.h index 68428400..7443d625 100644 --- a/fastpair/fast_pair_service.h +++ b/fastpair/fast_pair_service.h @@ -26,7 +26,7 @@ #include "fastpair/repository/fast_pair_device_repository.h" #include "fastpair/server_access/fast_pair_client.h" #include "fastpair/server_access/fast_pair_http_notifier.h" -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include "internal/account/account_manager.h" #include "internal/auth/authentication_manager.h" #include "internal/network/http_client.h" diff --git a/fastpair/handshake/BUILD b/fastpair/handshake/BUILD index bedd516a..31bdfddd 100644 --- a/fastpair/handshake/BUILD +++ b/fastpair/handshake/BUILD @@ -41,7 +41,6 @@ cc_library( "//fastpair/dataparser", "//fastpair/internal/mediums", "//fastpair/repository", - "//fastpair/server_access", "//internal/base:bluetooth_address", "//internal/platform:comm", "//internal/platform:logging", @@ -88,7 +87,7 @@ cc_test( "//fastpair/crypto", "//fastpair/dataparser", "//fastpair/internal/mediums", - "//fastpair/server_access:test_support", + "//fastpair/repository:test_support", "//fastpair/testing", "//internal/platform:logging", "//internal/platform:types", @@ -140,7 +139,7 @@ cc_test( ":handshake", "//fastpair/common", "//fastpair/proto:fastpair_cc_proto", - "//fastpair/server_access:test_support", + "//fastpair/repository:test_support", "//internal/platform:base", "//internal/platform:test_util", "//internal/platform:types", diff --git a/fastpair/handshake/fast_pair_data_encryptor_impl.cc b/fastpair/handshake/fast_pair_data_encryptor_impl.cc index a65cee5e..1d20a593 100644 --- a/fastpair/handshake/fast_pair_data_encryptor_impl.cc +++ b/fastpair/handshake/fast_pair_data_encryptor_impl.cc @@ -37,7 +37,7 @@ #include "fastpair/crypto/fast_pair_key_pair.h" #include "fastpair/dataparser/fast_pair_data_parser.h" #include "fastpair/handshake/fast_pair_data_encryptor.h" -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include "internal/platform/logging.h" namespace nearby { diff --git a/fastpair/handshake/fast_pair_handshake_impl_test.cc b/fastpair/handshake/fast_pair_handshake_impl_test.cc index b605e5d8..192af794 100644 --- a/fastpair/handshake/fast_pair_handshake_impl_test.cc +++ b/fastpair/handshake/fast_pair_handshake_impl_test.cc @@ -34,7 +34,7 @@ #include "fastpair/common/protocol.h" #include "fastpair/handshake/fast_pair_gatt_service_client_impl.h" #include "fastpair/proto/fastpair_rpcs.proto.h" -#include "fastpair/server_access/fake_fast_pair_repository.h" +#include "fastpair/repository/fake_fast_pair_repository.h" #include "internal/platform/byte_array.h" #include "internal/platform/count_down_latch.h" #include "internal/platform/medium_environment.h" diff --git a/fastpair/internal/BUILD b/fastpair/internal/BUILD index 72516d51..45fbbb91 100644 --- a/fastpair/internal/BUILD +++ b/fastpair/internal/BUILD @@ -36,7 +36,7 @@ cc_test( "//fastpair:fast_pair_events", "//fastpair/message_stream:fake_gatt_callbacks", "//fastpair/message_stream:fake_provider", - "//fastpair/server_access:test_support", + "//fastpair/repository:test_support", "//internal/platform:test_util", "//internal/platform:types", "//internal/platform/implementation/g3", # build_cleaner: keep diff --git a/fastpair/internal/fast_pair_seeker_impl_test.cc b/fastpair/internal/fast_pair_seeker_impl_test.cc index 28f22ced..75d6628c 100644 --- a/fastpair/internal/fast_pair_seeker_impl_test.cc +++ b/fastpair/internal/fast_pair_seeker_impl_test.cc @@ -27,7 +27,7 @@ #include "fastpair/fast_pair_events.h" #include "fastpair/message_stream/fake_gatt_callbacks.h" #include "fastpair/message_stream/fake_provider.h" -#include "fastpair/server_access/fake_fast_pair_repository.h" +#include "fastpair/repository/fake_fast_pair_repository.h" #include "internal/platform/count_down_latch.h" #include "internal/platform/medium_environment.h" diff --git a/fastpair/keyed_service/BUILD b/fastpair/keyed_service/BUILD index 5b2d5324..b5046e28 100644 --- a/fastpair/keyed_service/BUILD +++ b/fastpair/keyed_service/BUILD @@ -31,7 +31,9 @@ cc_library( "//fastpair/common", "//fastpair/internal/mediums", "//fastpair/pairing", + "//fastpair/repository", "//fastpair/repository:device_repository", + "//fastpair/repository:repository_impl", "//fastpair/scanning:scanner", "//fastpair/server_access", "//fastpair/ui:fast_pair_ui", @@ -60,7 +62,6 @@ cc_test( shard_count = 16, deps = [ ":keyed_service", - "//fastpair/server_access:test_support", "//fastpair/testing", "//fastpair/ui:fast_pair_ui", "//fastpair/ui:mock_fast_pair_ui", diff --git a/fastpair/keyed_service/fast_pair_mediator.cc b/fastpair/keyed_service/fast_pair_mediator.cc index 19faffd9..da17b826 100644 --- a/fastpair/keyed_service/fast_pair_mediator.cc +++ b/fastpair/keyed_service/fast_pair_mediator.cc @@ -28,7 +28,7 @@ #include "fastpair/repository/fast_pair_device_repository.h" #include "fastpair/scanning/scanner_broker_impl.h" #include "fastpair/server_access/fast_pair_client_impl.h" -#include "fastpair/server_access/fast_pair_repository_impl.h" +#include "fastpair/repository/fast_pair_repository_impl.h" #include "fastpair/ui/actions.h" #include "fastpair/ui/fast_pair/fast_pair_notification_controller.h" #include "fastpair/ui/ui_broker_impl.h" diff --git a/fastpair/keyed_service/fast_pair_mediator.h b/fastpair/keyed_service/fast_pair_mediator.h index 69dce3e3..0265efcb 100644 --- a/fastpair/keyed_service/fast_pair_mediator.h +++ b/fastpair/keyed_service/fast_pair_mediator.h @@ -26,7 +26,7 @@ #include "fastpair/scanning/scanner_broker.h" #include "fastpair/server_access/fast_pair_client.h" #include "fastpair/server_access/fast_pair_http_notifier.h" -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include "fastpair/ui/fast_pair/fast_pair_notification_controller.h" #include "fastpair/ui/ui_broker.h" #include "internal/account/account_manager.h" diff --git a/fastpair/keyed_service/fast_pair_mediator_test.cc b/fastpair/keyed_service/fast_pair_mediator_test.cc index a9d50dbd..bd832bb7 100644 --- a/fastpair/keyed_service/fast_pair_mediator_test.cc +++ b/fastpair/keyed_service/fast_pair_mediator_test.cc @@ -24,7 +24,6 @@ #include "gtest/gtest.h" #include "absl/strings/escaping.h" #include "absl/strings/string_view.h" -#include "fastpair/server_access/fake_fast_pair_repository.h" #include "fastpair/testing/fast_pair_service_data_creator.h" #include "fastpair/ui/actions.h" #include "fastpair/ui/fast_pair/fast_pair_notification_controller.h" @@ -47,9 +46,6 @@ constexpr absl::string_view kModelId = "718c17"; constexpr absl::string_view kServiceID = "Fast Pair"; constexpr absl::string_view kFastPairServiceUuid = "0000FE2C-0000-1000-8000-00805F9B34FB"; -constexpr absl::string_view kPublicAntiSpoof = - "Wuyr48lD3txnUhGiMF1IfzlTwRxxe+wMB1HLzP+" - "0wVcljfT3XPoiy1fntlneziyLD5knDVAJSE+RM/zlPRP/Jg=="; constexpr int kNotDiscoverableAdvHeader = 0b00000110; constexpr int kAccountKeyFilterHeader = 0b01100000; constexpr int kSaltHeader = 0b00010001; @@ -57,9 +53,6 @@ constexpr absl::string_view kAccountKeyFilter("112233445566"); constexpr absl::string_view kSalt("01"); constexpr absl::string_view kModelId2 = "9adb11"; -constexpr absl::string_view kPublicAntiSpoof2 = - "z+grhW8lWVA34JUQhXOxMrk1WqVy+VpEDd2K+01ZJvS6KdV0OUg7FRMzq+" - "ITuOqKO/2TIRKEAEfMKdyk2Ob1Vw=="; constexpr absl::string_view kAddress = "74:74:46:01:6C:21"; class MediatorTest : public testing::Test { @@ -88,7 +81,6 @@ class MediatorTest : public testing::Test { void TearDown() override { executor_.reset(); mediums_.reset(); - repository_.reset(); ui_broker_.reset(); mock_ui_broker_ = nullptr; notification_controller_.reset(); @@ -120,7 +112,6 @@ class MediatorTest : public testing::Test { protected: MediumEnvironment& env_{MediumEnvironment::Instance()}; std::unique_ptr mediums_; - std::unique_ptr repository_; std::unique_ptr ui_broker_; std::unique_ptr notification_controller_; std::unique_ptr executor_; diff --git a/fastpair/pairing/BUILD b/fastpair/pairing/BUILD index 5129a003..9fa08255 100644 --- a/fastpair/pairing/BUILD +++ b/fastpair/pairing/BUILD @@ -54,7 +54,7 @@ cc_test( "//fastpair/handshake", "//fastpair/internal/mediums", "//fastpair/pairing/fastpair:pairing", - "//fastpair/server_access:test_support", + "//fastpair/repository:test_support", "//internal/base:bluetooth_address", "//internal/platform:comm", "//internal/platform:test_util", diff --git a/fastpair/pairing/fastpair/BUILD b/fastpair/pairing/fastpair/BUILD index 4434ba89..7bdf5090 100644 --- a/fastpair/pairing/fastpair/BUILD +++ b/fastpair/pairing/fastpair/BUILD @@ -51,7 +51,7 @@ cc_test( ":pairing", "//fastpair/common", "//fastpair/handshake", - "//fastpair/server_access:test_support", + "//fastpair/repository:test_support", "//internal/base:bluetooth_address", "//internal/platform:comm", "//internal/platform:test_util", diff --git a/fastpair/pairing/fastpair/fast_pair_pairer_impl_test.cc b/fastpair/pairing/fastpair/fast_pair_pairer_impl_test.cc index 3c7bbe66..bb421585 100644 --- a/fastpair/pairing/fastpair/fast_pair_pairer_impl_test.cc +++ b/fastpair/pairing/fastpair/fast_pair_pairer_impl_test.cc @@ -42,7 +42,7 @@ #include "fastpair/handshake/fast_pair_data_encryptor_impl.h" #include "fastpair/handshake/fast_pair_handshake_impl.h" #include "fastpair/pairing/fastpair/fast_pair_pairer.h" -#include "fastpair/server_access/fake_fast_pair_repository.h" +#include "fastpair/repository/fake_fast_pair_repository.h" #include "internal/base/bluetooth_address.h" #include "internal/platform/ble_v2.h" #include "internal/platform/bluetooth_adapter.h" diff --git a/fastpair/pairing/pairer_broker_impl_test.cc b/fastpair/pairing/pairer_broker_impl_test.cc index a2a82582..1e7c352a 100644 --- a/fastpair/pairing/pairer_broker_impl_test.cc +++ b/fastpair/pairing/pairer_broker_impl_test.cc @@ -33,7 +33,7 @@ #include "fastpair/handshake/fast_pair_handshake_lookup.h" #include "fastpair/internal/mediums/mediums.h" #include "fastpair/pairing/fastpair/fast_pair_pairer.h" -#include "fastpair/server_access/fake_fast_pair_repository.h" +#include "fastpair/repository/fake_fast_pair_repository.h" #include "internal/base/bluetooth_address.h" #include "internal/platform/ble_v2.h" #include "internal/platform/count_down_latch.h" diff --git a/fastpair/proto/BUILD b/fastpair/proto/BUILD index 9615f9a7..ea2c5e6c 100644 --- a/fastpair/proto/BUILD +++ b/fastpair/proto/BUILD @@ -56,7 +56,7 @@ cc_library( deps = [ ":fastpair_cc_proto", "//fastpair/common", - "//fastpair/server_access", + "//fastpair/repository", "//internal/platform:logging", "@com_google_absl//absl/time", ], diff --git a/fastpair/proto/proto_builder.cc b/fastpair/proto/proto_builder.cc index 6f3d4b3c..e4f6078d 100644 --- a/fastpair/proto/proto_builder.cc +++ b/fastpair/proto/proto_builder.cc @@ -25,7 +25,7 @@ #include "fastpair/proto/enum.proto.h" #include "fastpair/proto/fast_pair_string.proto.h" #include "fastpair/proto/fastpair_rpcs.proto.h" -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include "internal/platform/logging.h" namespace nearby { diff --git a/fastpair/repository/BUILD b/fastpair/repository/BUILD index 8e78b378..6047ea14 100644 --- a/fastpair/repository/BUILD +++ b/fastpair/repository/BUILD @@ -3,14 +3,10 @@ licenses(["notice"]) cc_library( name = "repository", srcs = [ - "fast_pair_metadata_fetcher_impl.cc", - "fast_pair_metadata_repository_impl.cc", + "fast_pair_repository.cc", ], hdrs = [ - "fast_pair_metadata_fetcher.h", - "fast_pair_metadata_fetcher_impl.h", - "fast_pair_metadata_repository.h", - "fast_pair_metadata_repository_impl.h", + "fast_pair_repository.h", ], copts = [ "-Ithird_party", @@ -18,16 +14,42 @@ cc_library( visibility = ["//fastpair:__subpackages__"], deps = [ "//fastpair/common", - "//fastpair/proto:fastpair_cc_proto", - "//internal/network:types", - "//internal/platform:logging", - "//internal/platform/implementation:types", - "@com_google_absl//absl/container:flat_hash_map", - "@com_google_absl//absl/status:statusor", + "//internal/base:bluetooth_address", + "//internal/crypto", + "@com_google_absl//absl/functional:any_invocable", "@com_google_absl//absl/strings", ], ) +cc_library( + name = "repository_impl", + srcs = [ + "fast_pair_repository_impl.cc", + ], + hdrs = [ + "fast_pair_repository_impl.h", + ], + compatible_with = ["//buildenv/target:non_prod"], + copts = [ + "-Ithird_party", + ], + visibility = ["//fastpair:__subpackages__"], + deps = [ + ":repository", + "//fastpair/common", + "//fastpair/proto:fastpair_cc_proto", + "//fastpair/proto:proto_builder", + "//fastpair/server_access", + "//internal/base:bluetooth_address", + "//internal/crypto", + "//internal/platform:logging", + "//internal/platform:types", + "@com_google_absl//absl/functional:any_invocable", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/time", + ], +) + cc_library( name = "device_repository", srcs = [ @@ -47,6 +69,41 @@ cc_library( ], ) +cc_library( + name = "test_support", + srcs = ["fake_fast_pair_repository.cc"], + hdrs = [ + "fake_fast_pair_repository.h", + ], + visibility = [ + "//fastpair:__subpackages__", + ], + deps = [ + ":repository", + "//fastpair/common", + "//fastpair/proto:fastpair_cc_proto", + "//internal/platform:types", + "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/strings", + ], +) + +cc_library( + name = "mocks", + testonly = 1, + hdrs = [ + "mock_fast_pair_repository.h", + ], + visibility = [ + "//fastpair:__subpackages__", + ], + deps = [ + ":repository", + "@com_google_absl//absl/strings", + "@com_google_googletest//:gtest_for_library_testonly", + ], +) + cc_test( name = "device_repository_test", srcs = [ @@ -62,24 +119,10 @@ cc_test( ], ) -cc_library( - name = "fake_fast_pair_metadata_repository", - hdrs = ["fake_fast_pair_metadata_repository.h"], - copts = [ - "-Ithird_party", - ], - visibility = ["//visibility:public"], - deps = [ - ":repository", - "//fastpair/proto:fastpair_cc_proto", - ], -) - cc_test( - name = "repository_test", + name = "fast_pair_repository_test", srcs = [ - "fast_pair_metadata_fetcher_impl_test.cc", - "fast_pair_metadata_repository_impl_test.cc", + "fast_pair_repository_test.cc", ], copts = [ "-Ithird_party", @@ -87,14 +130,30 @@ cc_test( deps = [ ":repository", "//fastpair/common", - "//fastpair/internal/test:nearby_fastpair_test", - "//fastpair/proto:fastpair_cc_proto", - "//internal/network:types", "//internal/platform/implementation/g3", # build_cleaner: keep "@com_github_protobuf_matchers//protobuf-matchers", - "@com_google_absl//absl/container:flat_hash_map", - "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", "@com_google_googletest//:gtest_main", ], ) + +cc_test( + name = "fast_pair_repository_impl_test", + srcs = [ + "fast_pair_repository_impl_test.cc", + ], + copts = [ + "-Ithird_party", + ], + deps = [ + ":repository", + ":repository_impl", + ":test_support", + "//fastpair/common", + "//fastpair/server_access:test_support", + "//internal/platform:types", + "//internal/platform/implementation/g3", # build_cleaner: keep + "@com_github_protobuf_matchers//protobuf-matchers", + "@com_google_googletest//:gtest_main", + ], +) diff --git a/fastpair/repository/fake_fast_pair_metadata_repository.h b/fastpair/repository/fake_fast_pair_metadata_repository.h deleted file mode 100644 index db0219d2..00000000 --- a/fastpair/repository/fake_fast_pair_metadata_repository.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAKE_FAST_PAIR_METADATA_REPOSITORY_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAKE_FAST_PAIR_METADATA_REPOSITORY_H_ - -#include -#include - -#include "fastpair/repository/fast_pair_metadata_repository.h" -#include "fastpair/proto/fastpair_rpcs.proto.h" - - -namespace nearby { -namespace fastpair { -class FakeFastPairMetadataRepository : public FastPairMetadataRepository { - public: - struct GetObservedDeviceRequest { - GetObservedDeviceRequest(const proto::GetObservedDeviceRequest& request, - ObservedDeviceCallback callback, - ErrorCallback error_callback) - : request(request), - callback(std::move(callback)), - error_callback(std::move(error_callback)) {} - - GetObservedDeviceRequest(GetObservedDeviceRequest&& request) = default; - ~GetObservedDeviceRequest() = default; - - proto::GetObservedDeviceRequest request; - ObservedDeviceCallback callback; - ErrorCallback error_callback; - }; - - FakeFastPairMetadataRepository() = default; - ~FakeFastPairMetadataRepository() override = default; - - std::unique_ptr& get_observed_device_request() { - return get_observed_device_request_; - } - - private: - void GetObservedDevice(const proto::GetObservedDeviceRequest& request, - ObservedDeviceCallback response_callback, - ErrorCallback error_callback) override { - get_observed_device_request_ = std::make_unique( - request, std::move(response_callback), std::move(error_callback)); - } - - std::unique_ptr get_observed_device_request_; -}; - -class FakeFastPairMetadataRepositoryFactory - : public FastPairMetadataRepositoryFactory { - public: - FakeFastPairMetadataRepositoryFactory() = default; - ~FakeFastPairMetadataRepositoryFactory() override = default; - - FakeFastPairMetadataRepository* fake_repository() { return fake_repository_; } - - private: - std::unique_ptr CreateInstance() override { - auto fake_repository = std::make_unique(); - fake_repository_ = fake_repository.get(); - return fake_repository; - } - FakeFastPairMetadataRepository* fake_repository_; -}; -} // namespace fastpair -} // namespace nearby - -#endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAKE_FAST_PAIR_METADATA_REPOSITORY_H_ diff --git a/fastpair/server_access/fake_fast_pair_repository.cc b/fastpair/repository/fake_fast_pair_repository.cc similarity index 97% rename from fastpair/server_access/fake_fast_pair_repository.cc rename to fastpair/repository/fake_fast_pair_repository.cc index beba4385..eafe6696 100644 --- a/fastpair/server_access/fake_fast_pair_repository.cc +++ b/fastpair/repository/fake_fast_pair_repository.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/server_access/fake_fast_pair_repository.h" +#include "fastpair/repository/fake_fast_pair_repository.h" #include #include diff --git a/fastpair/server_access/fake_fast_pair_repository.h b/fastpair/repository/fake_fast_pair_repository.h similarity index 86% rename from fastpair/server_access/fake_fast_pair_repository.h rename to fastpair/repository/fake_fast_pair_repository.h index d0006802..19d4b187 100644 --- a/fastpair/server_access/fake_fast_pair_repository.h +++ b/fastpair/repository/fake_fast_pair_repository.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAKE_FAST_PAIR_REPOSITORY_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAKE_FAST_PAIR_REPOSITORY_H_ +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAKE_FAST_PAIR_REPOSITORY_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAKE_FAST_PAIR_REPOSITORY_H_ #include #include @@ -21,7 +21,7 @@ #include "absl/container/flat_hash_map.h" #include "absl/strings/string_view.h" #include "fastpair/common/device_metadata.h" -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include "internal/platform/single_thread_executor.h" namespace nearby { @@ -49,4 +49,4 @@ class FakeFastPairRepository : public FastPairRepository { } // namespace fastpair } // namespace nearby -#endif // THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAKE_FAST_PAIR_REPOSITORY_H_ +#endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAKE_FAST_PAIR_REPOSITORY_H_ diff --git a/fastpair/repository/fast_pair_metadata_fetcher.h b/fastpair/repository/fast_pair_metadata_fetcher.h deleted file mode 100644 index ea00e902..00000000 --- a/fastpair/repository/fast_pair_metadata_fetcher.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_FETCHER_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_FETCHER_H_ - -#include -#include -#include -#include - -#include "absl/container/flat_hash_map.h" -#include "absl/strings/string_view.h" -#include "fastpair/common/fast_pair_http_result.h" -#include "internal/network/http_client.h" -#include "internal/network/url.h" - -namespace nearby { -namespace fastpair { - -class FastPairMetadataFetcher { - public: - using ResultCallback = std::function; - using ErrorCallback = std::function; - using QueryParameters = std::vector>; - - FastPairMetadataFetcher() = default; - virtual ~FastPairMetadataFetcher() = default; - - // Starts the API GET request call. - // |request_url|: The URL endpoint of the API request. - // |request_as_query_parameters|: The request proto represented as key-value - // pairs to be sent as query parameters. - // Note: A key can have multiple values. - // |http_client|: The HTTP client is used to access backend APIs. - // |result_callback|: Called when the flow completes successfully - // with a serialized response proto. - // |error_callback|: Called when the flow completes with an error. - virtual void StartGetUnauthRequest( - const network::Url& request_url, - const QueryParameters& request_as_query_parameters, - network::HttpClient* http_client, ResultCallback result_callback, - ErrorCallback error_callback) = 0; -}; - -} // namespace fastpair -} // namespace nearby - -#endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_FETCHER_H_ diff --git a/fastpair/repository/fast_pair_metadata_fetcher_impl.cc b/fastpair/repository/fast_pair_metadata_fetcher_impl.cc deleted file mode 100644 index c70a1e05..00000000 --- a/fastpair/repository/fast_pair_metadata_fetcher_impl.cc +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "fastpair/repository/fast_pair_metadata_fetcher_impl.h" - -#include -#include - -#include "absl/strings/string_view.h" -#include "fastpair/common/fast_pair_http_result.h" -#include "internal/platform/implementation/device_info.h" -#include "internal/platform/logging.h" - -namespace nearby { -namespace fastpair { - -namespace { - -const char kQueryParameterAlternateOutputKey[] = "alt"; -const char kQueryParameterAlternateOutputProto[] = "proto"; -const char kPlatformTypeHeaderName[] = "X-Sharing-Platform-Type"; - -absl::string_view GetPlatformTypeString(api::DeviceInfo::OsType os_type) { - switch (os_type) { - case api::DeviceInfo::OsType::kAndroid: - return "OSType.ANDROID"; - case api::DeviceInfo::OsType::kChromeOs: - return "OSType.CHROME_OS"; - case api::DeviceInfo::OsType::kIos: - return "OSType.IOS"; - case api::DeviceInfo::OsType::kWindows: - return "OSType.WINDOWS"; - default: - return "OSType.UNKNOWN"; - } -} - -} // namespace - -void FastPairMetadataFetcherImpl::StartGetUnauthRequest( - const network::Url& request_url, - const QueryParameters& request_as_query_parameters, - network::HttpClient* http_client, ResultCallback result_callback, - ErrorCallback error_callback) { - request_url_ = request_url; - request_as_query_parameters_ = request_as_query_parameters; - http_client_ = http_client; - result_callback_ = result_callback; - error_callback_ = error_callback; - Execute(); -} - -void FastPairMetadataFetcherImpl::ProcessApiCallSuccess( - const network::HttpResponse* response) { - network::HttpResponseBody response_body = response->GetBody(); - result_callback_(response_body.GetRawData()); -} - -void FastPairMetadataFetcherImpl::ProcessApiCallFailure(absl::Status status) { - std::optional error; - std::string error_message; - error = FastPairHttpErrorForHttpResponseCode(status); - - NEARBY_LOGS(ERROR) << "Fetcher failed: " - << FastPairHttpStatus(status).ToString(); - if (status.code() == absl::StatusCode::kFailedPrecondition) { - error = FastPairHttpError::kHttpErrorOffline; - } - - error_callback_(*error); -} - -void FastPairMetadataFetcherImpl::Execute() { - network::HttpRequest request{request_url_}; - request.AddQueryParameter(kQueryParameterAlternateOutputKey, - kQueryParameterAlternateOutputProto); - if (request_as_query_parameters_) { - for (const auto& key_value_pair : *request_as_query_parameters_) { - request.AddQueryParameter(key_value_pair.first, key_value_pair.second); - } - } - - request.AddHeader(kPlatformTypeHeaderName, GetPlatformTypeString(os_type_)); - request.AddHeader("Content-Type", std::string()); - - // Handle request body - request.SetBody(std::string()); - - http_client_->StartRequest( - request, [&](const absl::StatusOr& response) { - response_ = response; - if (response_.ok()) { - body_string_ = std::string(response_->GetBody().GetRawData()); - ProcessApiCallSuccess(&response_.value()); - } else { - ProcessApiCallFailure(response.status()); - } - }); -} - -} // namespace fastpair -} // namespace nearby diff --git a/fastpair/repository/fast_pair_metadata_fetcher_impl.h b/fastpair/repository/fast_pair_metadata_fetcher_impl.h deleted file mode 100644 index e7599999..00000000 --- a/fastpair/repository/fast_pair_metadata_fetcher_impl.h +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_FETCHER_IMPL_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_FETCHER_IMPL_H_ - -#include -#include -#include -#include - -#include "absl/container/flat_hash_map.h" -#include "absl/status/statusor.h" -#include "fastpair/repository/fast_pair_metadata_fetcher.h" -#include "internal/network/http_client.h" -#include "internal/network/url.h" -#include "internal/platform/implementation/device_info.h" - -namespace nearby { -namespace fastpair { - -class FastPairMetadataFetcherImpl : public FastPairMetadataFetcher { - public: - explicit FastPairMetadataFetcherImpl(api::DeviceInfo::OsType os_type) - : os_type_(os_type) {} - ~FastPairMetadataFetcherImpl() override = default; - FastPairMetadataFetcherImpl(const FastPairMetadataFetcherImpl&) = delete; - FastPairMetadataFetcherImpl& operator=(const FastPairMetadataFetcherImpl&) = - delete; - // FastPairApiCallFlow - void StartGetUnauthRequest(const network::Url& request_url, - const QueryParameters& request_as_query_parameters, - network::HttpClient* http_client, - ResultCallback result_callback, - ErrorCallback error_callback) override; - - protected: - network::HttpRequestMethod GetRequestMethod() const; - void ProcessApiCallSuccess(const network::HttpResponse* response); - void ProcessApiCallFailure(absl::Status status); - void Execute(); - - private: - // The URL of the endpoint serving the request. - network::Url request_url_; - - // The request message proto represented as key-value pairs that will be sent - // as query parameters in the API GET request. Note: A key can have multiple - // values. - std::optional request_as_query_parameters_; - - // Callback invoked with the serialized response message proto when the flow - // completes successfully. - ResultCallback result_callback_; - - // Callback invoked with an error message when the flow fails. - ErrorCallback error_callback_; - - // Http client to execute request - network::HttpClient* http_client_ = nullptr; - - // Store a copy of HTTP response - absl::StatusOr response_; - std::string body_string_; - - // Used to indicate the OS type. - const api::DeviceInfo::OsType os_type_; -}; - -} // namespace fastpair -} // namespace nearby - -#endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_FETCHER_IMPL_H_ diff --git a/fastpair/repository/fast_pair_metadata_fetcher_impl_test.cc b/fastpair/repository/fast_pair_metadata_fetcher_impl_test.cc deleted file mode 100644 index 43e0381b..00000000 --- a/fastpair/repository/fast_pair_metadata_fetcher_impl_test.cc +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "fastpair/repository/fast_pair_metadata_fetcher_impl.h" - -#include -#include -#include -#include -#include -#include - -#include "gtest/gtest.h" -#include "absl/container/flat_hash_map.h" -#include "absl/status/statusor.h" -#include "absl/strings/string_view.h" -#include "fastpair/internal/test/fast_pair_fake_http_client.h" - -namespace nearby { -namespace fastpair { -namespace { - -using ::nearby::network::FastPairFakeHttpClient; -using ::nearby::network::Url; -using OsType = ::nearby::api::DeviceInfo::OsType; - -constexpr char kResponseProto[] = "result_proto"; -constexpr char kRequestUrl[] = "https://googleapis.com/nearbysharing/test"; -constexpr char kQueryParameterAlternateOutputKey[] = "alt"; -constexpr char kQueryParameterAlternateOutputProto[] = "proto"; - -const FastPairMetadataFetcher::QueryParameters& -GetTestRequestProtoAsQueryParameters() { - static const FastPairMetadataFetcher::QueryParameters* - request_as_query_parameters = - new FastPairMetadataFetcher::QueryParameters( - {{"key1", "value1_1"}, {"key1", "value1_2"}, {"key2", "value2"}}); - return *request_as_query_parameters; -} - -// Adds the key-value pairs of |request_as_query_parameters| as query -// parameters.|request_as_query_parameters| is only non-null. -Url UrlWithQueryParameters( - absl::string_view url, - const std::optional& - request_as_query_parameters) { - auto url_with_qp = Url::Create(url); - EXPECT_TRUE(url_with_qp.ok()); - - url_with_qp->AddQueryParameter(kQueryParameterAlternateOutputKey, - kQueryParameterAlternateOutputProto); - - if (request_as_query_parameters) { - for (const auto& key_value : *request_as_query_parameters) { - url_with_qp->AddQueryParameter(key_value.first, key_value.second); - } - } - - return url_with_qp.value(); -} - -class FastPairMetadataFetcherImplTest : public ::testing::Test { - protected: - FastPairMetadataFetcherImplTest() { - http_client_ = std::make_unique(); - } - void SetUp() override { - result_ = nullptr; - network_error_ = nullptr; - } - void StartGetUnauthRequest() { - StartGetUnauthRequestWithRequestAsQueryParameters( - GetTestRequestProtoAsQueryParameters()); - } - void OnResult(absl::string_view result) { - EXPECT_FALSE(result_ || network_error_); - result_ = std::make_unique(result); - } - - void OnError(FastPairHttpError network_error) { - EXPECT_FALSE(result_ || network_error_); - network_error_ = std::make_unique(network_error); - } - void StartGetUnauthRequestWithRequestAsQueryParameters( - const FastPairMetadataFetcher::QueryParameters& - request_as_query_parameters) { - auto url = Url::Create(kRequestUrl); - ASSERT_TRUE(url.ok()); - flow_.StartGetUnauthRequest( - url.value(), request_as_query_parameters, http_client_.get(), - [&](absl::string_view response) { OnResult(response); }, - [&](FastPairHttpError error) { OnError(error); }); - - CheckFastPairRepositoryGetUnauthRequest(request_as_query_parameters); - } - void CheckPlatformTypeHeader( - const absl::flat_hash_map>& - headers) { - auto platform_type = - GetHeaderFirstValue("X-Sharing-Platform-Type", headers); - EXPECT_EQ("OSType.CHROME_OS", platform_type); - } - std::string GetHeaderFirstValue( - absl::string_view key, - const absl::flat_hash_map>& - headers) { - auto it = headers.find(key); - while (it != headers.end()) { - return it->second[0]; - } - return ""; - } - void CheckFastPairRepositoryGetUnauthRequest( - const FastPairMetadataFetcher::QueryParameters& - request_as_query_parameters) { - EXPECT_EQ(http_client_->GetPendingRequest().size(), 1); - const network::HttpRequest& request = - http_client_->GetPendingRequest()[0].request; - - CheckPlatformTypeHeader(request.GetAllHeaders()); - - EXPECT_EQ(UrlWithQueryParameters(kRequestUrl, request_as_query_parameters), - request.GetUrl()); - - EXPECT_EQ("GET", request.GetMethodString()); - - // Expect no body. - auto body = request.GetBody(); - EXPECT_TRUE(body.empty()); - auto content_type = - GetHeaderFirstValue("Content-Type", request.GetAllHeaders()); - EXPECT_EQ("", content_type); - } - void CompleteGetUnauthRequest( - int error, - std::optional response_code = std::nullopt, - const std::optional& response_string = std::nullopt) { - http_client_->CompleteRequest(error, response_code, response_string); - EXPECT_TRUE(result_ || network_error_); - } - std::unique_ptr result_; - std::unique_ptr network_error_; - - private: - std::unique_ptr http_client_; - FastPairMetadataFetcherImpl flow_{api::DeviceInfo::OsType::kChromeOs}; -}; - -TEST_F(FastPairMetadataFetcherImplTest, GetUnauthRequestSuccess) { - StartGetUnauthRequest(); - CompleteGetUnauthRequest(0, network::HttpStatusCode::kHttpOk, kResponseProto); - EXPECT_EQ(*result_, kResponseProto); - EXPECT_FALSE(network_error_); -} - -TEST_F(FastPairMetadataFetcherImplTest, GetUnauthRequestFailure) { - StartGetUnauthRequest(); - CompleteGetUnauthRequest(0xff00); - EXPECT_FALSE(result_); - EXPECT_EQ(*network_error_, FastPairHttpError::kHttpErrorOffline); -} - -TEST_F(FastPairMetadataFetcherImplTest, GetUnauthRequestStatus500) { - StartGetUnauthRequest(); - CompleteGetUnauthRequest(0, network::HttpStatusCode::kHttpInternalServerError, - "Fast Pair Meltdown."); - EXPECT_FALSE(result_); - EXPECT_EQ(*network_error_, FastPairHttpError::kHttpErrorInternal); -} - -} // namespace -} // namespace fastpair -} // namespace nearby diff --git a/fastpair/repository/fast_pair_metadata_repository.h b/fastpair/repository/fast_pair_metadata_repository.h deleted file mode 100644 index b5cee2a7..00000000 --- a/fastpair/repository/fast_pair_metadata_repository.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_REPOSITORY_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_REPOSITORY_H_ - -#include -#include - -#include "absl/strings/string_view.h" -#include "fastpair/common/fast_pair_http_result.h" - -namespace nearby { -namespace fastpair { - -namespace proto { - -class GetObservedDeviceRequest; -class GetObservedDeviceResponse; - -} // namespace proto - -class FastPairMetadataRepository { - public: - using ErrorCallback = std::function; - using ObservedDeviceCallback = - std::function; - FastPairMetadataRepository() = default; - virtual ~FastPairMetadataRepository() = default; - - virtual void GetObservedDevice(const proto::GetObservedDeviceRequest& request, - ObservedDeviceCallback callback, - ErrorCallback error_callback) = 0; -}; - -// Interface for creating FastPairMetadataRepository instances to increase the -// flexibility -class FastPairMetadataRepositoryFactory { - public: - FastPairMetadataRepositoryFactory() = default; - virtual ~FastPairMetadataRepositoryFactory() = default; - - virtual std::unique_ptr CreateInstance() = 0; -}; - -} // namespace fastpair -} // namespace nearby - -#endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_REPOSITORY_H_ diff --git a/fastpair/repository/fast_pair_metadata_repository_impl.cc b/fastpair/repository/fast_pair_metadata_repository_impl.cc deleted file mode 100644 index c0de0260..00000000 --- a/fastpair/repository/fast_pair_metadata_repository_impl.cc +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "fastpair/repository/fast_pair_metadata_repository_impl.h" - -#include -#include -#include -#include -#include - -#include "absl/strings/str_cat.h" -#include "absl/strings/string_view.h" -#include "fastpair/common/fast_pair_http_result.h" -#include "fastpair/proto/fastpair_rpcs.proto.h" -#include "fastpair/repository/fast_pair_metadata_fetcher.h" -#include "fastpair/repository/fast_pair_metadata_fetcher_impl.h" -#include "fastpair/repository/fast_pair_metadata_repository.h" -#include "internal/network/http_client.h" -#include "internal/network/http_client_factory.h" -#include "internal/network/url.h" -#include "internal/platform/implementation/device_info.h" -#include "internal/platform/logging.h" - -namespace nearby { -namespace fastpair { - -const char kDefaultNearbyDeviceV1HTTPHost[] = - "https://nearbydevices-pa.googleapis.com"; - -const char kNearbyShareV1Path[] = "v1"; -const char kListDevicePath[] = "device"; -const char kClientId[] = "AIzaSyBv7ZrOlX5oIJLVQrZh-WkZFKm5L6FlStQ"; -const char kMode[] = "mode"; -const char* GetObservedDeviceMode[3] = {"MODE_UNKNOWN", "MODE_RELEASE", - "MODE_DEBUG"}; -FastPairMetadataRepositoryImpl::FastPairMetadataRepositoryImpl( - std::unique_ptr fetcher, - std::unique_ptr http_client) - : fetcher_(std::move(fetcher)), http_client_(std::move(http_client)) {} - -FastPairMetadataRepositoryImpl::~FastPairMetadataRepositoryImpl() = default; - -// Create full fastpair v1 URL -nearby::network::Url CreateV1DeviceRequestUrlPath( - const proto::GetObservedDeviceRequest& request) { - std::string path = absl::StrFormat( - "%s/%s/%s/%s", kDefaultNearbyDeviceV1HTTPHost, kNearbyShareV1Path, - kListDevicePath, std::to_string(request.device_id())); - return nearby::network::Url::Create(path).value(); -} - -FastPairMetadataFetcher::QueryParameters -GetObservedDeviceRequestToQueryParameters( - const proto::GetObservedDeviceRequest& request) { - FastPairMetadataFetcher::QueryParameters params; - params.push_back({"key", kClientId}); - params.push_back({kMode, GetObservedDeviceMode[request.mode()]}); - - return params; -} - -void FastPairMetadataRepositoryImpl::GetObservedDevice( - const proto::GetObservedDeviceRequest& request, - ObservedDeviceCallback callback, ErrorCallback error_callback) { - ObservedDeviceCallback new_callback = - [=](const proto::GetObservedDeviceResponse& response) { - callback(response); - }; - ErrorCallback new_error_callback = [=](FastPairHttpError error) { - error_callback(error); - }; - - MakeUnauthFetcher(CreateV1DeviceRequestUrlPath(request), - GetObservedDeviceRequestToQueryParameters(request), - new_callback, new_error_callback); -} - -void FastPairMetadataRepositoryImpl::MakeUnauthFetcher( - const nearby::network::Url& request_url, - const std::optional& - request_as_query_parameters, - ObservedDeviceCallback response_callback, ErrorCallback error_callback) { - has_call_started_ = true; - request_url_ = request_url; - error_callback_ = std::move(error_callback); - fetcher_->StartGetUnauthRequest( - request_url_, *request_as_query_parameters, http_client_.get(), - [&, response_callback = - std::move(response_callback)](absl::string_view result_response) { - OnFetcherSuccess(response_callback, result_response); - }, - [&](FastPairHttpError error) { OnFetcherFailed(error); }); -} - -void FastPairMetadataRepositoryImpl::OnFetcherSuccess( - ObservedDeviceCallback callback, absl::string_view result_response) { - proto::GetObservedDeviceResponse response; - if (!response.ParseFromString(result_response)) { - OnFetcherFailed(FastPairHttpError::kHttpErrorOtherFailure); - return; - } - callback(response); -} - -void FastPairMetadataRepositoryImpl::OnFetcherFailed(FastPairHttpError error) { - NEARBY_LOGS(ERROR) - << "Fast pair server accessing RPC call failed with error. " << error; - error_callback_(error); -} - -FastPairMetadataRepositoryFactoryImpl::FastPairMetadataRepositoryFactoryImpl( - network::HttpClientFactory* http_client_factory) - : http_client_factory_(http_client_factory) {} - -FastPairMetadataRepositoryFactoryImpl:: - ~FastPairMetadataRepositoryFactoryImpl() = default; - -std::unique_ptr -FastPairMetadataRepositoryFactoryImpl::CreateInstance() { - NEARBY_LOGS(VERBOSE) << "Device Type is hardcode to kWindows."; - return std::make_unique( - std::make_unique( - api::DeviceInfo::OsType::kWindows), - http_client_factory_->CreateInstance()); -} - -} // namespace fastpair -} // namespace nearby diff --git a/fastpair/repository/fast_pair_metadata_repository_impl.h b/fastpair/repository/fast_pair_metadata_repository_impl.h deleted file mode 100644 index 502fc8aa..00000000 --- a/fastpair/repository/fast_pair_metadata_repository_impl.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_REPOSITORY_IMPL_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_REPOSITORY_IMPL_H_ - -#include -#include -#include -#include - -#include "absl/container/flat_hash_map.h" -#include "absl/strings/string_view.h" -#include "fastpair/repository/fast_pair_metadata_fetcher.h" -#include "fastpair/repository/fast_pair_metadata_repository.h" -#include "internal/network/http_client.h" -#include "internal/network/http_client_factory.h" - -namespace nearby { -namespace fastpair { - -class FastPairMetadataRepositoryImpl : public FastPairMetadataRepository { - public: - FastPairMetadataRepositoryImpl( - std::unique_ptr fetcher, - std::unique_ptr http_client); - ~FastPairMetadataRepositoryImpl() override; - - FastPairMetadataRepositoryImpl(FastPairMetadataRepositoryImpl&) = delete; - FastPairMetadataRepositoryImpl& operator=(FastPairMetadataRepositoryImpl&) = - delete; - void GetObservedDevice(const proto::GetObservedDeviceRequest& request, - ObservedDeviceCallback response_callback, - ErrorCallback error_callback) override; - - private: - void MakeUnauthFetcher( - const nearby::network::Url& request_url, - const std::optional& - request_as_query_parameters, - ObservedDeviceCallback response_callback, ErrorCallback error_callback); - - // Called when the fetcher success fails at any step. - void OnFetcherSuccess(ObservedDeviceCallback callback, - absl::string_view result_response); - - // Called when the fetcher fails at any step. - void OnFetcherFailed(FastPairHttpError error); - - bool has_call_started_; - std::unique_ptr fetcher_; - std::unique_ptr http_client_; - nearby::network::Url request_url_; - ErrorCallback error_callback_; -}; - -class FastPairMetadataRepositoryFactoryImpl - : public FastPairMetadataRepositoryFactory { - public: - explicit FastPairMetadataRepositoryFactoryImpl( - network::HttpClientFactory* http_client_factory); - ~FastPairMetadataRepositoryFactoryImpl() override; - - FastPairMetadataRepositoryFactoryImpl( - FastPairMetadataRepositoryFactoryImpl&) = delete; - FastPairMetadataRepositoryFactoryImpl& operator=( - FastPairMetadataRepositoryFactoryImpl&) = delete; - - std::unique_ptr CreateInstance() override; - - private: - network::HttpClientFactory* http_client_factory_; -}; - -} // namespace fastpair -} // namespace nearby - -#endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_METADATA_REPOSITORY_IMPL_H_ diff --git a/fastpair/repository/fast_pair_metadata_repository_impl_test.cc b/fastpair/repository/fast_pair_metadata_repository_impl_test.cc deleted file mode 100644 index be8acc6b..00000000 --- a/fastpair/repository/fast_pair_metadata_repository_impl_test.cc +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "fastpair/repository/fast_pair_metadata_repository_impl.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "gmock/gmock.h" -#include "protobuf-matchers/protocol-buffer-matchers.h" -#include "gtest/gtest.h" -#include "fastpair/common/fast_pair_http_result.h" -#include "fastpair/internal/test/fast_pair_fake_http_client.h" -#include "fastpair/proto/fastpair_rpcs.proto.h" -#include "fastpair/repository/fast_pair_metadata_fetcher.h" -#include "fastpair/repository/fast_pair_metadata_repository.h" -#include "internal/network/url.h" - -namespace nearby { -namespace fastpair { - -using ::nearby::network::HttpClient; -using ::nearby::network::Url; - -const char kImageUrl[] = "https://example.com/image.jpg"; -const char kListDevicePath[] = "device/"; -const char kClientId[] = "AIzaSyBv7ZrOlX5oIJLVQrZh-WkZFKm5L6FlStQ"; -const char kTestGoogleApisUrl[] = "https://nearbydevices-pa.googleapis.com"; -constexpr int64_t kDeviceId = 10148625; -const char kDeviceName[] = "devicename"; - -class FakeFastPairMetadataFetcher : public FastPairMetadataFetcher { - public: - FakeFastPairMetadataFetcher() = default; - ~FakeFastPairMetadataFetcher() override = default; - FakeFastPairMetadataFetcher(const FakeFastPairMetadataFetcher&) = delete; - FakeFastPairMetadataFetcher& operator=(const FakeFastPairMetadataFetcher&) = - delete; - - void StartGetUnauthRequest(const Url& request_url, - const QueryParameters& request_as_query_parameters, - HttpClient* http_client, - ResultCallback result_callback, - ErrorCallback error_callback) override { - request_url_ = request_url; - request_as_query_parameters_ = request_as_query_parameters; - http_client_ = http_client; - result_callback_ = result_callback; - error_callback_ = error_callback; - } - Url request_url_; - QueryParameters request_as_query_parameters_; - HttpClient* http_client_; - ResultCallback result_callback_; - ErrorCallback error_callback_; -}; -std::vector ExpectQueryStringValues( - const FastPairMetadataFetcher::QueryParameters& query_parameters, - absl::string_view key) { - std::vector values; - for (const auto& pair : query_parameters) { - const auto& query_key = pair.first; - const auto& query_value = pair.second; - if (query_key == key) { - values.push_back(query_value); - } - } - EXPECT_GT(values.size(), 0); - return values; -} -class FastPairMetadataRepositoryImplTest : public ::testing::Test { - protected: - FastPairMetadataRepositoryImplTest() = default; - - void SetUp() override { - http_client_ = std::make_unique(); - - auto fetcher = std::make_unique(); - fetcher_ = fetcher.get(); - - repository_ = std::make_unique( - std::move(fetcher), std::move(http_client_)); - } - - const FastPairMetadataFetcher::QueryParameters& - request_as_query_parameters() { - return fetcher_->request_as_query_parameters_; - } - - const Url& request_url() { return fetcher_->request_url_; } - - Url GetUrl(absl::string_view path) { - return Url::Create( - absl::StrCat(kTestGoogleApisUrl, "/v1/", kListDevicePath, path)) - .value(); - } - - FakeFastPairMetadataFetcher* fetcher_; - std::unique_ptr http_client_; - std::unique_ptr repository_; - - Url request_url_; - FastPairMetadataFetcher::QueryParameters request_as_query_parameters_; - FastPairMetadataFetcher::ResultCallback result_callback_; - FastPairMetadataFetcher::ErrorCallback error_callback_; -}; - -TEST_F(FastPairMetadataRepositoryImplTest, GetObservedDeviceSuccess) { - proto::GetObservedDeviceRequest request; - proto::GetObservedDeviceResponse result; - - request.set_device_id(kDeviceId); - request.set_mode(proto::GetObservedDeviceRequest::MODE_RELEASE); - - repository_->GetObservedDevice( - request, - [&result](const proto::GetObservedDeviceResponse& response) { - result = response; - }, - [&](FastPairHttpError error) {}); - - EXPECT_EQ(request_url(), GetUrl(std::to_string(request.device_id()))); - EXPECT_EQ(std::vector{"MODE_RELEASE"}, - ExpectQueryStringValues(request_as_query_parameters(), "mode")); - EXPECT_EQ(std::vector{kClientId}, - ExpectQueryStringValues(request_as_query_parameters(), "key")); - - proto::GetObservedDeviceResponse test_response; - test_response.mutable_device()->set_id(kDeviceId); - test_response.mutable_device()->set_name(kDeviceName); - test_response.mutable_device()->set_image_url(kImageUrl); - - EXPECT_EQ(test_response.device().id(), kDeviceId); - EXPECT_EQ(test_response.device().name(), kDeviceName); - EXPECT_EQ(test_response.device().image_url(), kImageUrl); -} - -} // namespace fastpair -} // namespace nearby diff --git a/fastpair/server_access/fast_pair_repository.cc b/fastpair/repository/fast_pair_repository.cc similarity index 97% rename from fastpair/server_access/fast_pair_repository.cc rename to fastpair/repository/fast_pair_repository.cc index faf7ac92..25becf6e 100644 --- a/fastpair/server_access/fast_pair_repository.cc +++ b/fastpair/repository/fast_pair_repository.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include #include diff --git a/fastpair/server_access/fast_pair_repository.h b/fastpair/repository/fast_pair_repository.h similarity index 88% rename from fastpair/server_access/fast_pair_repository.h rename to fastpair/repository/fast_pair_repository.h index 46d76a86..d7703d4b 100644 --- a/fastpair/server_access/fast_pair_repository.h +++ b/fastpair/repository/fast_pair_repository.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_REPOSITORY_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_REPOSITORY_H_ +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_REPOSITORY_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_REPOSITORY_H_ #include #include @@ -49,4 +49,4 @@ class FastPairRepository { } // namespace fastpair } // namespace nearby -#endif // THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_REPOSITORY_H_ +#endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_REPOSITORY_H_ diff --git a/fastpair/server_access/fast_pair_repository_impl.cc b/fastpair/repository/fast_pair_repository_impl.cc similarity index 97% rename from fastpair/server_access/fast_pair_repository_impl.cc rename to fastpair/repository/fast_pair_repository_impl.cc index 65ee5ca1..135349b5 100644 --- a/fastpair/server_access/fast_pair_repository_impl.cc +++ b/fastpair/repository/fast_pair_repository_impl.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/server_access/fast_pair_repository_impl.h" +#include "fastpair/repository/fast_pair_repository_impl.h" #include #include diff --git a/fastpair/server_access/fast_pair_repository_impl.h b/fastpair/repository/fast_pair_repository_impl.h similarity index 84% rename from fastpair/server_access/fast_pair_repository_impl.h rename to fastpair/repository/fast_pair_repository_impl.h index 9a12c222..90c4fe4b 100644 --- a/fastpair/server_access/fast_pair_repository_impl.h +++ b/fastpair/repository/fast_pair_repository_impl.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_REPOSITORY_IMPL_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_REPOSITORY_IMPL_H_ +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_REPOSITORY_IMPL_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_REPOSITORY_IMPL_H_ #include #include @@ -21,7 +21,7 @@ #include "absl/strings/string_view.h" #include "fastpair/common/device_metadata.h" #include "fastpair/server_access/fast_pair_client.h" -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include "internal/platform/single_thread_executor.h" namespace nearby { @@ -48,4 +48,4 @@ class FastPairRepositoryImpl : public FastPairRepository { } // namespace fastpair } // namespace nearby -#endif // THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_REPOSITORY_IMPL_H_ +#endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_FAST_PAIR_REPOSITORY_IMPL_H_ diff --git a/fastpair/server_access/fast_pair_repository_impl_test.cc b/fastpair/repository/fast_pair_repository_impl_test.cc similarity index 97% rename from fastpair/server_access/fast_pair_repository_impl_test.cc rename to fastpair/repository/fast_pair_repository_impl_test.cc index c6c658a6..afad5015 100644 --- a/fastpair/server_access/fast_pair_repository_impl_test.cc +++ b/fastpair/repository/fast_pair_repository_impl_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/server_access/fast_pair_repository_impl.h" +#include "fastpair/repository/fast_pair_repository_impl.h" #include #include diff --git a/fastpair/server_access/fast_pair_repository_test.cc b/fastpair/repository/fast_pair_repository_test.cc similarity index 96% rename from fastpair/server_access/fast_pair_repository_test.cc rename to fastpair/repository/fast_pair_repository_test.cc index fcd7901a..2153fdc8 100644 --- a/fastpair/server_access/fast_pair_repository_test.cc +++ b/fastpair/repository/fast_pair_repository_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include "gtest/gtest.h" #include "absl/strings/escaping.h" diff --git a/fastpair/server_access/mock_fast_pair_repository.h b/fastpair/repository/mock_fast_pair_repository.h similarity index 77% rename from fastpair/server_access/mock_fast_pair_repository.h rename to fastpair/repository/mock_fast_pair_repository.h index d18ca94c..8057b6a4 100644 --- a/fastpair/server_access/mock_fast_pair_repository.h +++ b/fastpair/repository/mock_fast_pair_repository.h @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_MOCK_FAST_PAIR_REPOSITORY_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_MOCK_FAST_PAIR_REPOSITORY_H_ +#ifndef THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_MOCK_FAST_PAIR_REPOSITORY_H_ +#define THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_MOCK_FAST_PAIR_REPOSITORY_H_ #include "gmock/gmock.h" #include "absl/strings/string_view.h" -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" namespace nearby { namespace fastpair { @@ -33,4 +33,4 @@ class MockFastPairRepository : public FastPairRepository { } // namespace nearby -#endif // THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_MOCK_FAST_PAIR_REPOSITORY_H_ +#endif // THIRD_PARTY_NEARBY_FASTPAIR_REPOSITORY_MOCK_FAST_PAIR_REPOSITORY_H_ diff --git a/fastpair/retroactive/BUILD b/fastpair/retroactive/BUILD index ff25a0c0..ec1f012c 100644 --- a/fastpair/retroactive/BUILD +++ b/fastpair/retroactive/BUILD @@ -59,7 +59,7 @@ cc_test( "//fastpair/message_stream:fake_gatt_callbacks", "//fastpair/message_stream:fake_provider", "//fastpair/proto:fastpair_cc_proto", - "//fastpair/server_access:test_support", + "//fastpair/repository:test_support", "//internal/base:bluetooth_address", "//internal/platform:base", "//internal/platform:comm", diff --git a/fastpair/retroactive/retroactive_test.cc b/fastpair/retroactive/retroactive_test.cc index 477ec90f..0172f6b5 100644 --- a/fastpair/retroactive/retroactive_test.cc +++ b/fastpair/retroactive/retroactive_test.cc @@ -26,7 +26,7 @@ #include "fastpair/message_stream/fake_gatt_callbacks.h" #include "fastpair/message_stream/fake_provider.h" #include "fastpair/proto/fastpair_rpcs.proto.h" -#include "fastpair/server_access/fake_fast_pair_repository.h" +#include "fastpair/repository/fake_fast_pair_repository.h" #include "internal/base/bluetooth_address.h" #include "internal/platform/bluetooth_classic.h" #include "internal/platform/byte_array.h" diff --git a/fastpair/scanning/BUILD b/fastpair/scanning/BUILD index 5b1b0158..4b665194 100644 --- a/fastpair/scanning/BUILD +++ b/fastpair/scanning/BUILD @@ -68,7 +68,7 @@ cc_test( "//fastpair/common", "//fastpair/internal/mediums", "//fastpair/proto:fastpair_cc_proto", - "//fastpair/server_access:test_support", + "//fastpair/repository:test_support", "//internal/platform:base", "//internal/platform:test_util", "//internal/platform:types", diff --git a/fastpair/scanning/fastpair/BUILD b/fastpair/scanning/fastpair/BUILD index dc01f55a..5c5bc293 100644 --- a/fastpair/scanning/fastpair/BUILD +++ b/fastpair/scanning/fastpair/BUILD @@ -37,7 +37,6 @@ cc_library( "//fastpair/proto:fastpair_cc_proto", "//fastpair/repository", "//fastpair/repository:device_repository", - "//fastpair/server_access", "//internal/base", "//internal/platform:base", "//internal/platform:comm", @@ -104,7 +103,7 @@ cc_test( ":scanning", ":test_support", "//fastpair/repository:device_repository", - "//fastpair/server_access:test_support", + "//fastpair/repository:test_support", "//fastpair/testing", "//internal/platform:comm", "//internal/platform/implementation/g3", # build_cleaner: keep diff --git a/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl.cc b/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl.cc index dac16eaf..936050ef 100644 --- a/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl.cc +++ b/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl.cc @@ -30,7 +30,7 @@ #include "fastpair/common/protocol.h" #include "fastpair/dataparser/fast_pair_data_parser.h" #include "fastpair/proto/fastpair_rpcs.pb.h" -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include "internal/platform/byte_array.h" #include "internal/platform/logging.h" diff --git a/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl_test.cc b/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl_test.cc index 2d213fb3..35dcb83e 100644 --- a/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl_test.cc +++ b/fastpair/scanning/fastpair/fast_pair_discoverable_scanner_impl_test.cc @@ -22,7 +22,7 @@ #include "absl/synchronization/notification.h" #include "fastpair/repository/fast_pair_device_repository.h" #include "fastpair/scanning/fastpair/fake_fast_pair_scanner.h" -#include "fastpair/server_access/fake_fast_pair_repository.h" +#include "fastpair/repository/fake_fast_pair_repository.h" #include "fastpair/testing/fast_pair_service_data_creator.h" #include "internal/platform/bluetooth_adapter.h" diff --git a/fastpair/scanning/scanner_broker_impl_test.cc b/fastpair/scanning/scanner_broker_impl_test.cc index 418462f9..379c4816 100644 --- a/fastpair/scanning/scanner_broker_impl_test.cc +++ b/fastpair/scanning/scanner_broker_impl_test.cc @@ -25,7 +25,7 @@ #include "fastpair/internal/mediums/mediums.h" #include "fastpair/proto/fastpair_rpcs.proto.h" #include "fastpair/scanning/scanner_broker.h" -#include "fastpair/server_access/fake_fast_pair_repository.h" +#include "fastpair/repository/fake_fast_pair_repository.h" #include "internal/platform/byte_array.h" #include "internal/platform/count_down_latch.h" #include "internal/platform/medium_environment.h" diff --git a/fastpair/server_access/BUILD b/fastpair/server_access/BUILD index 320ab3f4..6aeffa98 100644 --- a/fastpair/server_access/BUILD +++ b/fastpair/server_access/BUILD @@ -19,19 +19,11 @@ cc_library( srcs = [ "fast_pair_client_impl.cc", "fast_pair_http_notifier.cc", - "fast_pair_metadata_downloader.cc", - "fast_pair_metadata_downloader_impl.cc", - "fast_pair_repository.cc", - "fast_pair_repository_impl.cc", ], hdrs = [ "fast_pair_client.h", "fast_pair_client_impl.h", "fast_pair_http_notifier.h", - "fast_pair_metadata_downloader.h", - "fast_pair_metadata_downloader_impl.h", - "fast_pair_repository.h", - "fast_pair_repository_impl.h", ], visibility = [ "//fastpair:__subpackages__", @@ -40,17 +32,12 @@ cc_library( "//fastpair/common", "//fastpair/proto:fastpair_cc_proto", "//fastpair/proto:proto_to_json", - "//fastpair/repository", "//internal/account", "//internal/auth:types", "//internal/base", - "//internal/base:bluetooth_address", - "//internal/crypto", - "//internal/network:nearby_http_client", "//internal/network:types", "//internal/platform:logging", "//internal/platform:types", - "@com_google_absl//absl/functional:any_invocable", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:str_format", @@ -61,76 +48,15 @@ cc_library( cc_library( name = "test_support", - srcs = ["fake_fast_pair_repository.cc"], hdrs = [ "fake_fast_pair_client.h", - "fake_fast_pair_repository.h", ], visibility = [ "//fastpair:__subpackages__", ], deps = [ ":server_access", - "//fastpair/common", "//fastpair/proto:fastpair_cc_proto", - "//internal/platform:types", - "@com_google_absl//absl/container:flat_hash_map", - "@com_google_absl//absl/strings", - ], -) - -cc_library( - name = "mocks", - testonly = 1, - hdrs = [ - "mock_fast_pair_repository.h", - ], - visibility = [ - "//fastpair:__subpackages__", - ], - deps = [ - ":server_access", - "@com_google_absl//absl/strings", - "@com_google_googletest//:gtest_for_library_testonly", - ], -) - -cc_test( - name = "fast_pair_metadata_downloader_impl_test", - srcs = [ - "fast_pair_metadata_downloader_impl_test.cc", - ], - copts = [ - "-Ithird_party", - ], - deps = [ - ":server_access", - "//fastpair/common", - "//fastpair/proto:fastpair_cc_proto", - "//fastpair/repository:fake_fast_pair_metadata_repository", - "//internal/platform/implementation/g3", - "@com_github_protobuf_matchers//protobuf-matchers", - "@com_google_absl//absl/strings", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "fast_pair_repository_impl_test", - srcs = [ - "fast_pair_repository_impl_test.cc", - ], - copts = [ - "-Ithird_party", - ], - deps = [ - ":server_access", - ":test_support", - "//fastpair/common", - "//internal/platform:types", - "//internal/platform/implementation/g3", # build_cleaner: keep - "@com_github_protobuf_matchers//protobuf-matchers", - "@com_google_googletest//:gtest_main", ], ) @@ -151,24 +77,6 @@ cc_test( ], ) -cc_test( - name = "fast_pair_repository_test", - srcs = [ - "fast_pair_repository_test.cc", - ], - copts = [ - "-Ithird_party", - ], - deps = [ - ":server_access", - "//fastpair/common", - "//internal/platform/implementation/g3", # build_cleaner: keep - "@com_github_protobuf_matchers//protobuf-matchers", - "@com_google_absl//absl/strings", - "@com_google_googletest//:gtest_main", - ], -) - cc_test( name = "fast_pair_client_impl_test", srcs = [ diff --git a/fastpair/server_access/fast_pair_metadata_downloader.cc b/fastpair/server_access/fast_pair_metadata_downloader.cc deleted file mode 100644 index b5b11018..00000000 --- a/fastpair/server_access/fast_pair_metadata_downloader.cc +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "fastpair/server_access/fast_pair_metadata_downloader.h" - -#include -#include -#include - -#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 { -FastPairMetadataDownloader::FastPairMetadataDownloader( - absl::string_view model_id, SuccessCallback success_callback, - FailureCallback failure_callback) - : model_id_(model_id), - success_callback_(std::move(success_callback)), - failure_callback_(std::move(failure_callback)) {} - -FastPairMetadataDownloader::~FastPairMetadataDownloader() = default; - -void FastPairMetadataDownloader::Run() { - DCHECK(!was_run_); - was_run_ = true; - OnRun(); -} - -void FastPairMetadataDownloader::Succeed(DeviceMetadata& device_metadata) { - DCHECK(was_run_); - DCHECK(success_callback_); - NEARBY_LOGS(INFO) << __func__ << ": Fast Pair download of " - << device_metadata.GetDetails().name() << " succeeded."; - std::move(success_callback_)(device_metadata); -} - -void FastPairMetadataDownloader::Fail() { - DCHECK(was_run_); - DCHECK(failure_callback_); - - std::move(failure_callback_)(); -} - -} // namespace fastpair -} // namespace nearby diff --git a/fastpair/server_access/fast_pair_metadata_downloader.h b/fastpair/server_access/fast_pair_metadata_downloader.h deleted file mode 100644 index 5225cc14..00000000 --- a/fastpair/server_access/fast_pair_metadata_downloader.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_METADATA_DOWNLOADER_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_METADATA_DOWNLOADER_H_ - -#include -#include -#include - -#include "absl/functional/any_invocable.h" -#include "absl/strings/string_view.h" -#include "fastpair/common/device_metadata.h" - -namespace nearby { -namespace fastpair { - -class FastPairMetadataDownloader { - public: - using SuccessCallback = absl::AnyInvocable; - using FailureCallback = absl::AnyInvocable; - - FastPairMetadataDownloader(absl::string_view model_id, - SuccessCallback success_callback, - FailureCallback failure_callback); - virtual ~FastPairMetadataDownloader(); - - // Starts downloading the device information - void Run(); - - protected: - absl::string_view model_id() const { return model_id_; } - virtual void OnRun() = 0; - void Succeed(DeviceMetadata& device_metadata); - void Fail(); - - private: - absl::string_view model_id_; - SuccessCallback success_callback_; - FailureCallback failure_callback_; - bool was_run_ = false; -}; - -} // namespace fastpair -} // namespace nearby - -#endif // THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_METADATA_DOWNLOADER_H_ diff --git a/fastpair/server_access/fast_pair_metadata_downloader_impl.cc b/fastpair/server_access/fast_pair_metadata_downloader_impl.cc deleted file mode 100644 index 7f268ec2..00000000 --- a/fastpair/server_access/fast_pair_metadata_downloader_impl.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "fastpair/server_access/fast_pair_metadata_downloader_impl.h" - -#include -#include -#include -#include -#include -#include - -#include "absl/strings/numbers.h" -#include "absl/strings/string_view.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" - -namespace nearby { -namespace fastpair { - -FastPairMetadataDownloaderImpl::Factory* - FastPairMetadataDownloaderImpl::Factory::test_factory_ = nullptr; - -std::unique_ptr -FastPairMetadataDownloaderImpl::Factory::Create( - absl::string_view model_id, - FastPairMetadataRepositoryFactory* repository_factory, - SuccessCallback success_callback, FailureCallback failure_callback) { - if (test_factory_) { - return test_factory_->CreateInstance(model_id, repository_factory, - std::move(success_callback), - std::move(failure_callback)); - } - return absl::WrapUnique(new FastPairMetadataDownloaderImpl( - model_id, repository_factory, std::move(success_callback), - std::move(failure_callback))); -} - -// static -void FastPairMetadataDownloaderImpl::Factory::SetFactoryForTesting( - Factory* test_factory) { - test_factory_ = test_factory; -} - -FastPairMetadataDownloaderImpl::Factory::~Factory() = default; - -FastPairMetadataDownloaderImpl::~FastPairMetadataDownloaderImpl() = default; - -FastPairMetadataDownloaderImpl::FastPairMetadataDownloaderImpl( - absl::string_view model_id, - FastPairMetadataRepositoryFactory* repository_factory, - SuccessCallback success_callback, FailureCallback failure_callback) - : FastPairMetadataDownloader(model_id, std::move(success_callback), - std::move(failure_callback)), - repository_factory_(repository_factory) {} - -void FastPairMetadataDownloaderImpl::OnRun() { - NEARBY_LOGS(VERBOSE) << __func__ << " : Starting metadata downloading."; - CallAccessServer(model_id()); -} - -void FastPairMetadataDownloaderImpl::CallAccessServer( - absl::string_view model_id) { - NEARBY_LOGS(VERBOSE) << __func__ - << ": Making server accessing RPC call to fetch device " - "information with model ID: " - << model_id; - - proto::GetObservedDeviceRequest request; - int64_t device_id; - CHECK(absl::SimpleHexAtoi(model_id, &device_id)); - request.set_device_id(device_id); - request.set_mode(proto::GetObservedDeviceRequest::MODE_RELEASE); - - repository_ = repository_factory_->CreateInstance(); - - repository_->GetObservedDevice( - request, - [&](const proto::GetObservedDeviceResponse& response) { - NEARBY_LOGS(INFO) << __func__ << "Name: " << response.device().name(); - NEARBY_LOGS(INFO) << __func__ - << "Image URL: " << response.device().image_url(); - - NEARBY_LOGS(INFO) - << __func__ << "StringNotification: " - << response.strings().initial_notification_description(); - OnAccessServerSuccess(response); - }, - [&](FastPairHttpError error) { OnAccessServerFailure(error); }); -} - -void FastPairMetadataDownloaderImpl::OnAccessServerFailure( - FastPairHttpError error) { - NEARBY_LOGS(ERROR) << __func__ - << ": Server accessing RPC call failed with error " - << error; - Fail(); -} -void FastPairMetadataDownloaderImpl::OnAccessServerSuccess( - const proto::GetObservedDeviceResponse& response) { - DeviceMetadata device_metadata(response); - - NEARBY_LOGS(VERBOSE) << __func__ << ": Download " - << device_metadata.GetDetails().name() << " succeeded."; - Succeed(device_metadata); -} - -} // namespace fastpair -} // namespace nearby diff --git a/fastpair/server_access/fast_pair_metadata_downloader_impl.h b/fastpair/server_access/fast_pair_metadata_downloader_impl.h deleted file mode 100644 index df45c053..00000000 --- a/fastpair/server_access/fast_pair_metadata_downloader_impl.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_METADATA_DOWNLOADER_IMPL_H_ -#define THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_METADATA_DOWNLOADER_IMPL_H_ - -#include -#include -#include - -#include "absl/strings/string_view.h" -#include "fastpair/common/fast_pair_http_result.h" -#include "fastpair/proto/fastpair_rpcs.pb.h" -#include "fastpair/repository/fast_pair_metadata_repository.h" -#include "fastpair/server_access/fast_pair_metadata_downloader.h" - -namespace nearby { -namespace fastpair { - -class FastPairMetadataRepository; - -class FastPairMetadataDownloaderImpl : public FastPairMetadataDownloader { - public: - class Factory { - public: - static std::unique_ptr Create( - absl::string_view model_id, - FastPairMetadataRepositoryFactory* repository_factory, - SuccessCallback success_callback, FailureCallback failure_callback); - - static void SetFactoryForTesting(Factory* test_factory); - - protected: - virtual ~Factory(); - virtual std::unique_ptr CreateInstance( - absl::string_view model_id, - FastPairMetadataRepositoryFactory* repository_factory, - SuccessCallback success_callback, FailureCallback failure_callback) = 0; - - private: - static Factory* test_factory_; - }; - - ~FastPairMetadataDownloaderImpl() override; - - private: - FastPairMetadataDownloaderImpl( - absl::string_view model_id, - FastPairMetadataRepositoryFactory* repository_factory, - SuccessCallback success_callback, FailureCallback failure_callback); - - void OnRun() override; - void CallAccessServer(absl::string_view model_id); - void OnAccessServerSuccess(const proto::GetObservedDeviceResponse& response); - void OnAccessServerFailure(FastPairHttpError error); - - std::unique_ptr repository_; - FastPairMetadataRepositoryFactory* repository_factory_ = nullptr; -}; - -} // namespace fastpair -} // namespace nearby - -#endif // THIRD_PARTY_NEARBY_FASTPAIR_SERVER_ACCESS_FAST_PAIR_METADATA_DOWNLOADER_IMPL_H_ diff --git a/fastpair/server_access/fast_pair_metadata_downloader_impl_test.cc b/fastpair/server_access/fast_pair_metadata_downloader_impl_test.cc deleted file mode 100644 index bbf1f093..00000000 --- a/fastpair/server_access/fast_pair_metadata_downloader_impl_test.cc +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2022 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "fastpair/server_access/fast_pair_metadata_downloader_impl.h" - -#include -#include -#include -#include -#include - -#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/fake_fast_pair_metadata_repository.h" -#include "fastpair/server_access/fast_pair_metadata_downloader.h" - -namespace nearby { -namespace fastpair { -namespace { - -const int64_t kDeviceId = 10148625; -const char kModelId[] = "9adb11"; -const char kDeviceName[] = "Pixel Buds Pro"; - -class FastPairMetadataDownloaderImplTest : public ::testing::Test { - protected: - struct Result { - bool success; - std::optional device; - }; - - FastPairMetadataDownloaderImplTest() = default; - ~FastPairMetadataDownloaderImplTest() override = default; - - void VerifyRequest() { - ASSERT_TRUE(fake_repository_factory_.fake_repository() != nullptr); - FakeFastPairMetadataRepository* repository = - fake_repository_factory_.fake_repository(); - const proto::GetObservedDeviceRequest& request = - repository->get_observed_device_request()->request; - EXPECT_EQ(request.device_id(), kDeviceId); - } - - void GetObservedDataRequestSuccess( - const proto::GetObservedDeviceResponse& response) { - VerifyRequest(); - FakeFastPairMetadataRepository* repository = - fake_repository_factory_.fake_repository(); - std::move(repository->get_observed_device_request()->callback)(response); - } - - void GetObservedDataRequestFailure( - const proto::GetObservedDeviceResponse& response) { - VerifyRequest(); - FakeFastPairMetadataRepository* repository = - fake_repository_factory_.fake_repository(); - std::move(repository->get_observed_device_request()->error_callback)( - FastPairHttpError::kHttpErrorInvalidArgument); - } - - // The callbacks passed into NearbyShareContactDownloader ctor. - void OnSuccess(DeviceMetadata& device_metadata) { - const proto::Device device = device_metadata.GetDetails(); - result_ = Result(); - result_->success = true; - result_->device = std::move(device); - } - void OnFailure() { - result_ = Result(); - result_->success = false; - result_->device.reset(); - } - - std::optional result_; - FakeFastPairMetadataRepositoryFactory fake_repository_factory_; - std::unique_ptr downloader_; -}; - -TEST_F(FastPairMetadataDownloaderImplTest, GetObservedDeviceDownloadSuccess) { - downloader_ = FastPairMetadataDownloaderImpl::Factory::Create( - kModelId, &fake_repository_factory_, - [&](DeviceMetadata& device_metadata) { OnSuccess(device_metadata); }, - [&]() { OnFailure(); }); - downloader_->Run(); - proto::GetObservedDeviceResponse response; - response.mutable_device()->set_id(kDeviceId); - response.mutable_device()->set_name(kDeviceName); - GetObservedDataRequestSuccess(response); - ASSERT_TRUE(result_); - EXPECT_TRUE(result_->success); - ASSERT_TRUE(result_->device); - EXPECT_EQ(result_->device->name(), kDeviceName); - EXPECT_EQ(result_->device->id(), kDeviceId); -} - -TEST_F(FastPairMetadataDownloaderImplTest, GetObservedDeviceDownloadFailure) { - downloader_ = FastPairMetadataDownloaderImpl::Factory::Create( - kModelId, &fake_repository_factory_, - [&](DeviceMetadata& device_metadata) { OnSuccess(device_metadata); }, - [&]() { OnFailure(); }); - downloader_->Run(); - proto::GetObservedDeviceResponse response; - response.mutable_device()->set_id(kDeviceId); - response.mutable_device()->set_name(kDeviceName); - GetObservedDataRequestFailure(response); - ASSERT_TRUE(result_); - EXPECT_FALSE(result_->success); - EXPECT_FALSE(result_->device); -} -} // namespace -} // namespace fastpair -} // namespace nearby diff --git a/fastpair/ui/BUILD b/fastpair/ui/BUILD index 763ee129..52fef3f8 100644 --- a/fastpair/ui/BUILD +++ b/fastpair/ui/BUILD @@ -36,7 +36,6 @@ cc_library( deps = [ "//fastpair/common", "//fastpair/repository", - "//fastpair/server_access", "//internal/base", "//internal/platform:logging", "@com_google_absl//absl/functional:any_invocable", diff --git a/fastpair/ui/fast_pair/fast_pair_presenter_impl.cc b/fastpair/ui/fast_pair/fast_pair_presenter_impl.cc index b6cc5250..d242096c 100644 --- a/fastpair/ui/fast_pair/fast_pair_presenter_impl.cc +++ b/fastpair/ui/fast_pair/fast_pair_presenter_impl.cc @@ -20,7 +20,7 @@ #include "fastpair/common/device_metadata.h" #include "fastpair/common/fast_pair_device.h" -#include "fastpair/server_access/fast_pair_repository.h" +#include "fastpair/repository/fast_pair_repository.h" #include "fastpair/ui/fast_pair/fast_pair_notification_controller.h" #include "internal/platform/logging.h"