From be227f8466bf187191990d38e6454faed081c93b Mon Sep 17 00:00:00 2001 From: Lasan Mahaliyana Date: Fri, 19 Jun 2026 04:43:29 +0530 Subject: [PATCH] added top level stubs to match upstream --- .../analytics/analytics_recorder_impl.cc | 16 ++ .../analytics/analytics_recorder_impl.h | 150 +++++++++++++ google/nearby/identity/v1/BUILD | 18 ++ google/nearby/identity/v1/resources.pb.h | 21 ++ google/nearby/identity/v1/rpcs.pb.h | 21 ++ google/protobuf/BUILD | 10 + location/nearby/analytics/cpp/logging/BUILD | 10 + .../analytics/cpp/logging/event_logger.h | 41 ++++ location/nearby/analytics/cpp/proto/BUILD | 16 ++ .../analytics/cpp/proto/connections_log.pb.h | 30 +++ .../analytics/cpp/proto/sharing_log.pb.h | 30 +++ location/nearby/sharing/lib/account/BUILD | 16 ++ .../sharing/lib/account/account_manager.h | 85 +++++++ location/nearby/sharing/lib/rpc/BUILD | 31 +++ .../lib/rpc/grpc_async_client_factory.h | 101 +++++++++ .../sharing/lib/rpc/identity_rpc_types.h | 208 +++++++++++++++++ .../sharing/lib/rpc/sharing_rpc_client.h | 76 +++++++ location/nearby/sharing/lib/sync/BUILD | 27 +++ .../sharing/lib/sync/sync_binding_prefs.pb.h | 212 ++++++++++++++++++ .../nearby/sharing/lib/sync/sync_manager.h | 126 +++++++++++ util/hash/BUILD | 11 + util/hash/highway_fingerprint.h | 31 +++ 22 files changed, 1287 insertions(+) create mode 100644 connections/implementation/analytics/analytics_recorder_impl.cc create mode 100644 connections/implementation/analytics/analytics_recorder_impl.h create mode 100644 google/nearby/identity/v1/BUILD create mode 100644 google/nearby/identity/v1/resources.pb.h create mode 100644 google/nearby/identity/v1/rpcs.pb.h create mode 100644 google/protobuf/BUILD create mode 100644 location/nearby/analytics/cpp/logging/BUILD create mode 100644 location/nearby/analytics/cpp/logging/event_logger.h create mode 100644 location/nearby/analytics/cpp/proto/BUILD create mode 100644 location/nearby/analytics/cpp/proto/connections_log.pb.h create mode 100644 location/nearby/analytics/cpp/proto/sharing_log.pb.h create mode 100644 location/nearby/sharing/lib/account/BUILD create mode 100644 location/nearby/sharing/lib/account/account_manager.h create mode 100644 location/nearby/sharing/lib/rpc/BUILD create mode 100644 location/nearby/sharing/lib/rpc/grpc_async_client_factory.h create mode 100644 location/nearby/sharing/lib/rpc/identity_rpc_types.h create mode 100644 location/nearby/sharing/lib/rpc/sharing_rpc_client.h create mode 100644 location/nearby/sharing/lib/sync/BUILD create mode 100644 location/nearby/sharing/lib/sync/sync_binding_prefs.pb.h create mode 100644 location/nearby/sharing/lib/sync/sync_manager.h create mode 100644 util/hash/BUILD create mode 100644 util/hash/highway_fingerprint.h diff --git a/connections/implementation/analytics/analytics_recorder_impl.cc b/connections/implementation/analytics/analytics_recorder_impl.cc new file mode 100644 index 00000000..75d155a9 --- /dev/null +++ b/connections/implementation/analytics/analytics_recorder_impl.cc @@ -0,0 +1,16 @@ +// Copyright 2026 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 "connections/implementation/analytics/analytics_recorder_impl.h" + diff --git a/connections/implementation/analytics/analytics_recorder_impl.h b/connections/implementation/analytics/analytics_recorder_impl.h new file mode 100644 index 00000000..b26ffb01 --- /dev/null +++ b/connections/implementation/analytics/analytics_recorder_impl.h @@ -0,0 +1,150 @@ +// Copyright 2026 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 CONNECTIONS_IMPLEMENTATION_ANALYTICS_ANALYTICS_RECORDER_IMPL_H_ +#define CONNECTIONS_IMPLEMENTATION_ANALYTICS_ANALYTICS_RECORDER_IMPL_H_ + +#include +#include +#include + +#include "absl/time/time.h" +#include "connections/implementation/analytics/analytics_recorder.h" +#include "location/nearby/analytics/cpp/logging/event_logger.h" +#include "proto/connections_enums.pb.h" + +namespace nearby::analytics { + +class AnalyticsRecorderImpl : public AnalyticsRecorder { + public: + explicit AnalyticsRecorderImpl(EventLogger* event_logger = nullptr) + : event_logger_(event_logger) {} + ~AnalyticsRecorderImpl() override = default; + + void OnStartAdvertising( + connections::Strategy strategy, + const std::vector& mediums, + AdvertisingMetadataParams* advertising_metadata_params) override {} + void OnStopAdvertising() override {} + int GetNextAdvertisingUpdateIndex() override { return 0; } + void OnStartedIncomingConnectionListening( + connections::Strategy strategy) override {} + void OnStoppedIncomingConnectionListening() override {} + void OnStartDiscovery( + connections::Strategy strategy, + const std::vector& mediums, + DiscoveryMetadataParams* discovery_metadata_params) override {} + void OnStopDiscovery() override {} + int GetNextDiscoveryUpdateIndex() override { return 0; } + void OnEndpointFound( + location::nearby::proto::connections::Medium medium) override {} + void OnRequestConnection(const connections::Strategy& strategy, + const std::string& endpoint_id) override {} + void OnConnectionRequestReceived( + const std::string& remote_endpoint_id) override {} + void OnConnectionRequestSent(const std::string& remote_endpoint_id) override {} + void OnRemoteEndpointAccepted( + const std::string& remote_endpoint_id) override {} + void OnLocalEndpointAccepted( + const std::string& remote_endpoint_id) override {} + void OnRemoteEndpointRejected( + const std::string& remote_endpoint_id) override {} + void OnLocalEndpointRejected( + const std::string& remote_endpoint_id) override {} + void OnIncomingConnectionAttempt( + location::nearby::proto::connections::ConnectionAttemptType type, + location::nearby::proto::connections::Medium medium, + location::nearby::proto::connections::ConnectionAttemptResult result, + absl::Duration duration, const std::string& connection_token, + ConnectionAttemptMetadataParams* connection_attempt_metadata_params) + override {} + void OnOutgoingConnectionAttempt( + const std::string& remote_endpoint_id, + location::nearby::proto::connections::ConnectionAttemptType type, + location::nearby::proto::connections::Medium medium, + location::nearby::proto::connections::ConnectionAttemptResult result, + absl::Duration duration, const std::string& connection_token, + ConnectionAttemptMetadataParams* connection_attempt_metadata_params) + override {} + void OnConnectionEstablished( + const std::string& endpoint_id, + location::nearby::proto::connections::Medium medium, + const std::string& connection_token) override {} + void OnConnectionClosed( + const std::string& endpoint_id, + location::nearby::proto::connections::Medium medium, + location::nearby::proto::connections::DisconnectionReason reason, + SafeDisconnectionResult result) override {} + void OnIncomingPayloadStarted(const std::string& endpoint_id, + std::int64_t payload_id, + connections::PayloadType type, + std::int64_t total_size_bytes) override {} + void OnPayloadChunkReceived(const std::string& endpoint_id, + std::int64_t payload_id, + std::int64_t chunk_size_bytes) override {} + void OnIncomingPayloadDone( + const std::string& endpoint_id, std::int64_t payload_id, + location::nearby::proto::connections::PayloadStatus status, + location::nearby::proto::connections::OperationResultCode + operation_result_code) override {} + void OnOutgoingPayloadStarted(const std::vector& endpoint_ids, + std::int64_t payload_id, + connections::PayloadType type, + std::int64_t total_size_bytes) override {} + void OnPayloadChunkSent(const std::string& endpoint_id, + std::int64_t payload_id, + std::int64_t chunk_size_bytes) override {} + void OnOutgoingPayloadDone( + const std::string& endpoint_id, std::int64_t payload_id, + location::nearby::proto::connections::PayloadStatus status, + location::nearby::proto::connections::OperationResultCode + operation_result_code) override {} + void OnBandwidthUpgradeStarted( + const std::string& endpoint_id, + location::nearby::proto::connections::Medium from_medium, + location::nearby::proto::connections::Medium to_medium, + location::nearby::proto::connections::ConnectionAttemptDirection + direction, + const std::string& connection_token) override {} + void UpdateBwUpgradeNetworkInfo(const std::string& endpoint_id, + int num_interfaces, + int num_ipv6_only_interfaces) override {} + void OnBandwidthUpgradeError( + const std::string& endpoint_id, + location::nearby::proto::connections::BandwidthUpgradeResult result, + location::nearby::proto::connections::BandwidthUpgradeErrorStage + error_stage, + location::nearby::proto::connections::OperationResultCode + operation_result_code) override {} + void OnBandwidthUpgradeSuccess(const std::string& endpoint_id) override {} + void OnErrorCode(const ErrorCodeParams& params) override {} + void LogStartSession() override {} + void LogSession() override {} + bool IsSessionLogged() override { return false; } + location::nearby::proto::connections::OperationResultCategory + GetOperationResultCategory( + location::nearby::proto::connections::OperationResultCode result_code) + override { + return location::nearby::proto::connections::CATEGORY_UNKNOWN; + } + void Sync() override {} + + private: + EventLogger* event_logger_; +}; + +} // namespace nearby::analytics + +#endif // CONNECTIONS_IMPLEMENTATION_ANALYTICS_ANALYTICS_RECORDER_IMPL_H_ + diff --git a/google/nearby/identity/v1/BUILD b/google/nearby/identity/v1/BUILD new file mode 100644 index 00000000..5baf6b00 --- /dev/null +++ b/google/nearby/identity/v1/BUILD @@ -0,0 +1,18 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +licenses(["notice"]) + +cc_library( + name = "resources_cc_proto", + hdrs = ["resources.pb.h"], + visibility = ["//visibility:public"], + deps = ["//location/nearby/sharing/lib/rpc:sharing_rpc_client"], +) + +cc_library( + name = "rpcs_cc_proto", + hdrs = ["rpcs.pb.h"], + visibility = ["//visibility:public"], + deps = [":resources_cc_proto"], +) + diff --git a/google/nearby/identity/v1/resources.pb.h b/google/nearby/identity/v1/resources.pb.h new file mode 100644 index 00000000..a356b034 --- /dev/null +++ b/google/nearby/identity/v1/resources.pb.h @@ -0,0 +1,21 @@ +// Copyright 2026 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 GOOGLE_NEARBY_IDENTITY_V1_RESOURCES_PB_H_ +#define GOOGLE_NEARBY_IDENTITY_V1_RESOURCES_PB_H_ + +#include "location/nearby/sharing/lib/rpc/identity_rpc_types.h" + +#endif // GOOGLE_NEARBY_IDENTITY_V1_RESOURCES_PB_H_ + diff --git a/google/nearby/identity/v1/rpcs.pb.h b/google/nearby/identity/v1/rpcs.pb.h new file mode 100644 index 00000000..ae0d8f22 --- /dev/null +++ b/google/nearby/identity/v1/rpcs.pb.h @@ -0,0 +1,21 @@ +// Copyright 2026 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 GOOGLE_NEARBY_IDENTITY_V1_RPCS_PB_H_ +#define GOOGLE_NEARBY_IDENTITY_V1_RPCS_PB_H_ + +#include "google/nearby/identity/v1/resources.pb.h" + +#endif // GOOGLE_NEARBY_IDENTITY_V1_RPCS_PB_H_ + diff --git a/google/protobuf/BUILD b/google/protobuf/BUILD new file mode 100644 index 00000000..c92897a9 --- /dev/null +++ b/google/protobuf/BUILD @@ -0,0 +1,10 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +licenses(["notice"]) + +cc_library( + name = "timestamp_cc_proto", + visibility = ["//visibility:public"], + deps = ["@com_google_protobuf//:protobuf"], +) + diff --git a/location/nearby/analytics/cpp/logging/BUILD b/location/nearby/analytics/cpp/logging/BUILD new file mode 100644 index 00000000..f9fa2f06 --- /dev/null +++ b/location/nearby/analytics/cpp/logging/BUILD @@ -0,0 +1,10 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +licenses(["notice"]) + +cc_library( + name = "event_logger", + hdrs = ["event_logger.h"], + visibility = ["//visibility:public"], +) + diff --git a/location/nearby/analytics/cpp/logging/event_logger.h b/location/nearby/analytics/cpp/logging/event_logger.h new file mode 100644 index 00000000..018fafb4 --- /dev/null +++ b/location/nearby/analytics/cpp/logging/event_logger.h @@ -0,0 +1,41 @@ +// Copyright 2026 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 LOCATION_NEARBY_ANALYTICS_CPP_LOGGING_EVENT_LOGGER_H_ +#define LOCATION_NEARBY_ANALYTICS_CPP_LOGGING_EVENT_LOGGER_H_ + +namespace location::nearby::analytics::proto { +class ConnectionsLog; +} // namespace location::nearby::analytics::proto + +namespace nearby::sharing::analytics::proto { +class SharingLog; +} // namespace nearby::sharing::analytics::proto + +namespace nearby::analytics { + +class EventLogger { + public: + virtual ~EventLogger() = default; + + virtual void Log( + const location::nearby::analytics::proto::ConnectionsLog& message) = 0; + virtual void Log( + const nearby::sharing::analytics::proto::SharingLog& message) = 0; +}; + +} // namespace nearby::analytics + +#endif // LOCATION_NEARBY_ANALYTICS_CPP_LOGGING_EVENT_LOGGER_H_ + diff --git a/location/nearby/analytics/cpp/proto/BUILD b/location/nearby/analytics/cpp/proto/BUILD new file mode 100644 index 00000000..fe716469 --- /dev/null +++ b/location/nearby/analytics/cpp/proto/BUILD @@ -0,0 +1,16 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +licenses(["notice"]) + +cc_library( + name = "connections_log_cc_proto", + hdrs = ["connections_log.pb.h"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "sharing_log_cc_proto", + hdrs = ["sharing_log.pb.h"], + visibility = ["//visibility:public"], +) + diff --git a/location/nearby/analytics/cpp/proto/connections_log.pb.h b/location/nearby/analytics/cpp/proto/connections_log.pb.h new file mode 100644 index 00000000..b17fb8a4 --- /dev/null +++ b/location/nearby/analytics/cpp/proto/connections_log.pb.h @@ -0,0 +1,30 @@ +// Copyright 2026 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 LOCATION_NEARBY_ANALYTICS_CPP_PROTO_CONNECTIONS_LOG_PB_H_ +#define LOCATION_NEARBY_ANALYTICS_CPP_PROTO_CONNECTIONS_LOG_PB_H_ + +#include + +namespace location::nearby::analytics::proto { + +class ConnectionsLog { + public: + std::string SerializeAsString() const { return {}; } +}; + +} // namespace location::nearby::analytics::proto + +#endif // LOCATION_NEARBY_ANALYTICS_CPP_PROTO_CONNECTIONS_LOG_PB_H_ + diff --git a/location/nearby/analytics/cpp/proto/sharing_log.pb.h b/location/nearby/analytics/cpp/proto/sharing_log.pb.h new file mode 100644 index 00000000..e25e2dad --- /dev/null +++ b/location/nearby/analytics/cpp/proto/sharing_log.pb.h @@ -0,0 +1,30 @@ +// Copyright 2026 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 LOCATION_NEARBY_ANALYTICS_CPP_PROTO_SHARING_LOG_PB_H_ +#define LOCATION_NEARBY_ANALYTICS_CPP_PROTO_SHARING_LOG_PB_H_ + +#include + +namespace nearby::sharing::analytics::proto { + +class SharingLog { + public: + std::string SerializeAsString() const { return {}; } +}; + +} // namespace nearby::sharing::analytics::proto + +#endif // LOCATION_NEARBY_ANALYTICS_CPP_PROTO_SHARING_LOG_PB_H_ + diff --git a/location/nearby/sharing/lib/account/BUILD b/location/nearby/sharing/lib/account/BUILD new file mode 100644 index 00000000..53237a05 --- /dev/null +++ b/location/nearby/sharing/lib/account/BUILD @@ -0,0 +1,16 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +licenses(["notice"]) + +cc_library( + name = "account_manager", + hdrs = ["account_manager.h"], + visibility = ["//visibility:public"], + deps = [ + "@com_google_absl//absl/functional:any_invocable", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings:string_view", + ], +) + diff --git a/location/nearby/sharing/lib/account/account_manager.h b/location/nearby/sharing/lib/account/account_manager.h new file mode 100644 index 00000000..33b8a5e7 --- /dev/null +++ b/location/nearby/sharing/lib/account/account_manager.h @@ -0,0 +1,85 @@ +// Copyright 2026 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 LOCATION_NEARBY_SHARING_LIB_ACCOUNT_ACCOUNT_MANAGER_H_ +#define LOCATION_NEARBY_SHARING_LIB_ACCOUNT_ACCOUNT_MANAGER_H_ + +#include +#include +#include +#include + +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" + +namespace nearby::sharing { + +struct AccountInfo { + std::string id; + std::string email; + std::string display_name; + std::string given_name; + std::string picture_url; +}; + +enum AuthStatus { + SUCCESS = 0, + ERROR = 1, + UNSUPPORTED = 2, +}; + +class SigninAttempt { + public: + virtual ~SigninAttempt() = default; + + virtual std::string Start( + absl::AnyInvocable + callback) = 0; + virtual void Close() = 0; +}; + +class AccountManager { + public: + using Account = AccountInfo; + + class Observer { + public: + virtual ~Observer() = default; + virtual void OnLoginSucceeded(absl::string_view account_id) {} + virtual void OnLogoutSucceeded(absl::string_view account_id, + bool credential_error) {} + }; + + virtual ~AccountManager() = default; + + virtual std::optional GetCurrentAccount() = 0; + virtual std::unique_ptr Login(absl::string_view client_id, + absl::string_view client_secret) = 0; + virtual void Logout(absl::AnyInvocable logout_callback) = 0; + virtual bool GetAccessToken( + absl::AnyInvocable)> callback) = 0; + virtual std::pair GetOAuthClientCredential() = 0; + virtual void AddObserver(Observer* observer) = 0; + virtual void RemoveObserver(Observer* observer) = 0; + virtual void SaveAccountPrefs(absl::string_view user_id, + absl::string_view client_id, + absl::string_view client_secret) = 0; +}; + +} // namespace nearby::sharing + +#endif // LOCATION_NEARBY_SHARING_LIB_ACCOUNT_ACCOUNT_MANAGER_H_ diff --git a/location/nearby/sharing/lib/rpc/BUILD b/location/nearby/sharing/lib/rpc/BUILD new file mode 100644 index 00000000..65e3cd62 --- /dev/null +++ b/location/nearby/sharing/lib/rpc/BUILD @@ -0,0 +1,31 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +licenses(["notice"]) + +cc_library( + name = "sharing_rpc_client", + hdrs = [ + "identity_rpc_types.h", + "sharing_rpc_client.h", + ], + visibility = ["//visibility:public"], + deps = [ + "//sharing/proto:share_cc_proto", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/time", + "@com_google_protobuf//:protobuf", + ], +) + +cc_library( + name = "grpc_async_client_factory", + hdrs = ["grpc_async_client_factory.h"], + visibility = ["//visibility:public"], + deps = [ + ":sharing_rpc_client", + "//location/nearby/sharing/lib/account:account_manager", + "//sharing/analytics", + "@com_google_absl//absl/status", + ], +) + diff --git a/location/nearby/sharing/lib/rpc/grpc_async_client_factory.h b/location/nearby/sharing/lib/rpc/grpc_async_client_factory.h new file mode 100644 index 00000000..996cffc0 --- /dev/null +++ b/location/nearby/sharing/lib/rpc/grpc_async_client_factory.h @@ -0,0 +1,101 @@ +// Copyright 2026 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 LOCATION_NEARBY_SHARING_LIB_RPC_GRPC_ASYNC_CLIENT_FACTORY_H_ +#define LOCATION_NEARBY_SHARING_LIB_RPC_GRPC_ASYNC_CLIENT_FACTORY_H_ + +#include + +#include "absl/status/status.h" +#include "internal/platform/clock.h" +#include "location/nearby/sharing/lib/account/account_manager.h" +#include "location/nearby/sharing/lib/rpc/sharing_rpc_client.h" +#include "sharing/analytics/analytics_recorder.h" + +namespace nearby::sharing::platform::common { +namespace internal { + +class NoOpSharingRpcClient : public nearby::sharing::api::SharingRpcClient { + public: + void ListContactPeople( + nearby::sharing::proto::ListContactPeopleRequest request, + ListContactPeopleCallback callback) override { + static_cast(request); + callback(nearby::sharing::proto::ListContactPeopleResponse()); + } +}; + +class NoOpIdentityRpcClient : public nearby::sharing::api::IdentityRpcClient { + public: + void QuerySharedCredentials( + google::nearby::identity::v1::QuerySharedCredentialsRequest request, + absl::Duration timeout, QuerySharedCredentialsCallback callback) override { + static_cast(request); + static_cast(timeout); + callback(google::nearby::identity::v1::QuerySharedCredentialsResponse()); + } + + void QuerySharedCredentialsWithBindingIds( + google::nearby::identity::v1::QuerySharedCredentialsWithBindingIdsRequest + request, + absl::Duration timeout, + QuerySharedCredentialsWithBindingIdsCallback callback) override { + static_cast(request); + static_cast(timeout); + callback(google::nearby::identity::v1:: + QuerySharedCredentialsWithBindingIdsResponse()); + } + + void PublishDevice( + google::nearby::identity::v1::PublishDeviceRequest request, + absl::Duration timeout, PublishDeviceCallback callback) override { + static_cast(request); + static_cast(timeout); + callback(google::nearby::identity::v1::PublishDeviceResponse()); + } + + void GetAccountInfo( + google::nearby::identity::v1::GetAccountInfoRequest request, + absl::Duration timeout, GetAccountInfoCallback callback) override { + static_cast(request); + static_cast(timeout); + callback(google::nearby::identity::v1::GetAccountInfoResponse()); + } +}; + +} // namespace internal + +class GrpcAsyncClientFactory { + public: + GrpcAsyncClientFactory(AccountManager* account_manager, Clock* clock, + analytics::AnalyticsRecorder* analytics_recorder) { + static_cast(account_manager); + static_cast(clock); + static_cast(analytics_recorder); + } + + std::unique_ptr CreateInstance() { + return std::make_unique(); + } + + std::unique_ptr + CreateIdentityInstance() { + return std::make_unique(); + } +}; + +} // namespace nearby::sharing::platform::common + +#endif // LOCATION_NEARBY_SHARING_LIB_RPC_GRPC_ASYNC_CLIENT_FACTORY_H_ + diff --git a/location/nearby/sharing/lib/rpc/identity_rpc_types.h b/location/nearby/sharing/lib/rpc/identity_rpc_types.h new file mode 100644 index 00000000..93392219 --- /dev/null +++ b/location/nearby/sharing/lib/rpc/identity_rpc_types.h @@ -0,0 +1,208 @@ +// Copyright 2026 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 LOCATION_NEARBY_SHARING_LIB_RPC_IDENTITY_RPC_TYPES_H_ +#define LOCATION_NEARBY_SHARING_LIB_RPC_IDENTITY_RPC_TYPES_H_ + +#include + +#include +#include +#include + +#include "google/protobuf/timestamp.pb.h" + +namespace google::nearby::identity::v1 { + +class SharedCredential { + public: + enum DataType { + DATA_TYPE_UNKNOWN = 0, + DATA_TYPE_PUBLIC_CERTIFICATE = 1, + }; + + void set_id(uint64_t id) { id_ = id; } + uint64_t id() const { return id_; } + void set_data(std::string data) { data_ = std::move(data); } + const std::string& data() const { return data_; } + void set_data_type(DataType data_type) { data_type_ = data_type; } + DataType data_type() const { return data_type_; } + google::protobuf::Timestamp* mutable_expiration_time() { + return &expiration_time_; + } + const google::protobuf::Timestamp& expiration_time() const { + return expiration_time_; + } + + private: + uint64_t id_ = 0; + std::string data_; + DataType data_type_ = DATA_TYPE_UNKNOWN; + google::protobuf::Timestamp expiration_time_; +}; + +class PerVisibilitySharedCredentials { + public: + enum Visibility { + VISIBILITY_UNKNOWN = 0, + VISIBILITY_SELF = 1, + VISIBILITY_CONTACTS = 2, + }; + + void set_visibility(Visibility visibility) { visibility_ = visibility; } + Visibility visibility() const { return visibility_; } + SharedCredential* add_shared_credentials() { + shared_credentials_.emplace_back(); + return &shared_credentials_.back(); + } + const std::vector& shared_credentials() const { + return shared_credentials_; + } + + private: + Visibility visibility_ = VISIBILITY_UNKNOWN; + std::vector shared_credentials_; +}; + +class Device { + public: + enum Contact { + CONTACT_UNKNOWN = 0, + CONTACT_GOOGLE_CONTACT = 1, + CONTACT_GOOGLE_CONTACT_LATEST = 2, + }; + + void set_name(std::string name) { name_ = std::move(name); } + const std::string& name() const { return name_; } + void set_display_name(std::string display_name) { + display_name_ = std::move(display_name); + } + const std::string& display_name() const { return display_name_; } + void set_contact(Contact contact) { contact_ = contact; } + Contact contact() const { return contact_; } + PerVisibilitySharedCredentials* add_per_visibility_shared_credentials() { + per_visibility_shared_credentials_.emplace_back(); + return &per_visibility_shared_credentials_.back(); + } + const std::vector& + per_visibility_shared_credentials() const { + return per_visibility_shared_credentials_; + } + + private: + std::string name_; + std::string display_name_; + Contact contact_ = CONTACT_UNKNOWN; + std::vector per_visibility_shared_credentials_; +}; + +class QuerySharedCredentialsRequest { + public: + void set_name(std::string name) { name_ = std::move(name); } + const std::string& name() const { return name_; } + void set_page_token(std::string page_token) { + page_token_ = std::move(page_token); + } + const std::string& page_token() const { return page_token_; } + + private: + std::string name_; + std::string page_token_; +}; + +class QuerySharedCredentialsResponse { + public: + SharedCredential* add_shared_credentials() { + shared_credentials_.emplace_back(); + return &shared_credentials_.back(); + } + const std::vector& shared_credentials() const { + return shared_credentials_; + } + void set_next_page_token(std::string next_page_token) { + next_page_token_ = std::move(next_page_token); + } + const std::string& next_page_token() const { return next_page_token_; } + + private: + std::vector shared_credentials_; + std::string next_page_token_; +}; + +class QuerySharedCredentialsWithBindingIdsRequest + : public QuerySharedCredentialsRequest {}; + +class QuerySharedCredentialsWithBindingIdsResponse + : public QuerySharedCredentialsResponse {}; + +class PublishDeviceRequest { + public: + Device* mutable_device() { return &device_; } + const Device& device() const { return device_; } + + private: + Device device_; +}; + +class PublishDeviceResponse { + public: + enum ContactUpdate { + CONTACT_UPDATE_UNKNOWN = 0, + CONTACT_UPDATE_REMOVED = 1, + CONTACT_UPDATE_ADDED = 2, + }; + + void add_contact_updates(ContactUpdate contact_update) { + contact_updates_.push_back(contact_update); + } + const std::vector& contact_updates() const { + return contact_updates_; + } + + private: + std::vector contact_updates_; +}; + +class GetAccountInfoRequest {}; + +class AccountInfo { + public: + enum Capability { + CAPABILITY_UNSPECIFIED = 0, + CAPABILITY_UNKNOWN = 0, + CAPABILITY_TITANIUM = 1, + }; + + void add_capabilities(Capability capability) { + capabilities_.push_back(capability); + } + const std::vector& capabilities() const { return capabilities_; } + + private: + std::vector capabilities_; +}; + +class GetAccountInfoResponse { + public: + AccountInfo* mutable_account_info() { return &account_info_; } + const AccountInfo& account_info() const { return account_info_; } + + private: + AccountInfo account_info_; +}; + +} // namespace google::nearby::identity::v1 + +#endif // LOCATION_NEARBY_SHARING_LIB_RPC_IDENTITY_RPC_TYPES_H_ + diff --git a/location/nearby/sharing/lib/rpc/sharing_rpc_client.h b/location/nearby/sharing/lib/rpc/sharing_rpc_client.h new file mode 100644 index 00000000..0509cd89 --- /dev/null +++ b/location/nearby/sharing/lib/rpc/sharing_rpc_client.h @@ -0,0 +1,76 @@ +// Copyright 2026 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 LOCATION_NEARBY_SHARING_LIB_RPC_SHARING_RPC_CLIENT_H_ +#define LOCATION_NEARBY_SHARING_LIB_RPC_SHARING_RPC_CLIENT_H_ + +#include + +#include "absl/status/statusor.h" +#include "absl/time/time.h" +#include "location/nearby/sharing/lib/rpc/identity_rpc_types.h" +#include "sharing/proto/contact_rpc.pb.h" + +namespace nearby::sharing::api { + +class SharingRpcClient { + public: + using ListContactPeopleCallback = std::function&)>; + + virtual ~SharingRpcClient() = default; + + virtual void ListContactPeople( + nearby::sharing::proto::ListContactPeopleRequest request, + ListContactPeopleCallback callback) = 0; +}; + +class IdentityRpcClient { + public: + static constexpr absl::Duration kTimeout = absl::Seconds(30); + + using QuerySharedCredentialsCallback = std::function&)>; + using QuerySharedCredentialsWithBindingIdsCallback = std::function&)>; + using PublishDeviceCallback = std::function&)>; + using GetAccountInfoCallback = std::function&)>; + + virtual ~IdentityRpcClient() = default; + + virtual void QuerySharedCredentials( + google::nearby::identity::v1::QuerySharedCredentialsRequest request, + absl::Duration timeout, QuerySharedCredentialsCallback callback) = 0; + virtual void QuerySharedCredentialsWithBindingIds( + google::nearby::identity::v1::QuerySharedCredentialsWithBindingIdsRequest + request, + absl::Duration timeout, + QuerySharedCredentialsWithBindingIdsCallback callback) = 0; + virtual void PublishDevice( + google::nearby::identity::v1::PublishDeviceRequest request, + absl::Duration timeout, PublishDeviceCallback callback) = 0; + virtual void GetAccountInfo( + google::nearby::identity::v1::GetAccountInfoRequest request, + absl::Duration timeout, GetAccountInfoCallback callback) = 0; +}; + +} // namespace nearby::sharing::api + +#endif // LOCATION_NEARBY_SHARING_LIB_RPC_SHARING_RPC_CLIENT_H_ + diff --git a/location/nearby/sharing/lib/sync/BUILD b/location/nearby/sharing/lib/sync/BUILD new file mode 100644 index 00000000..d3a0d730 --- /dev/null +++ b/location/nearby/sharing/lib/sync/BUILD @@ -0,0 +1,27 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +licenses(["notice"]) + +cc_library( + name = "sync_binding_prefs_cc_proto", + hdrs = ["sync_binding_prefs.pb.h"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "sync_manager", + hdrs = ["sync_manager.h"], + visibility = ["//visibility:public"], + deps = [ + ":sync_binding_prefs_cc_proto", + "//internal/base:file_path", + "//location/nearby/sharing/lib/rpc:sharing_rpc_client", + "//sharing/internal/api:platform", + "@com_google_absl//absl/functional:any_invocable", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/strings:string_view", + ], +) + diff --git a/location/nearby/sharing/lib/sync/sync_binding_prefs.pb.h b/location/nearby/sharing/lib/sync/sync_binding_prefs.pb.h new file mode 100644 index 00000000..06a1d283 --- /dev/null +++ b/location/nearby/sharing/lib/sync/sync_binding_prefs.pb.h @@ -0,0 +1,212 @@ +// Copyright 2026 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 LOCATION_NEARBY_SHARING_LIB_SYNC_SYNC_BINDING_PREFS_PB_H_ +#define LOCATION_NEARBY_SHARING_LIB_SYNC_SYNC_BINDING_PREFS_PB_H_ + +#include +#include +#include +#include + +namespace nearby::sharing::sync { + +class SyncBinding { + public: + enum SourceDeviceType { + SOURCE_DEVICE_TYPE_UNKNOWN = 0, + SOURCE_DEVICE_TYPE_PHONE = 1, + SOURCE_DEVICE_TYPE_TABLET = 2, + SOURCE_DEVICE_TYPE_LAPTOP = 3, + SOURCE_DEVICE_TYPE_CAR = 4, + SOURCE_DEVICE_TYPE_FOLDABLE = 5, + SOURCE_DEVICE_TYPE_XR = 6, + }; + + void set_binding_id(std::string binding_id) { + binding_id_ = std::move(binding_id); + } + void set_binding_id(std::string_view binding_id) { + binding_id_ = std::string(binding_id); + } + const std::string& binding_id() const { return binding_id_; } + void set_source_name(std::string source_name) { + source_name_ = std::move(source_name); + } + void set_source_name(std::string_view source_name) { + source_name_ = std::string(source_name); + } + const std::string& source_name() const { return source_name_; } + void set_destination_directory(std::string destination_directory) { + destination_directory_ = std::move(destination_directory); + } + void set_destination_directory(std::string_view destination_directory) { + destination_directory_ = std::string(destination_directory); + } + const std::string& destination_directory() const { + return destination_directory_; + } + void set_source_device_type(SourceDeviceType source_device_type) { + source_device_type_ = source_device_type; + } + SourceDeviceType source_device_type() const { return source_device_type_; } + + private: + std::string binding_id_; + std::string source_name_; + std::string destination_directory_; + SourceDeviceType source_device_type_ = SOURCE_DEVICE_TYPE_UNKNOWN; +}; + +class SyncBindingPrefs { + public: + static const SyncBindingPrefs& default_instance() { + static const SyncBindingPrefs* prefs = new SyncBindingPrefs(); + return *prefs; + } + + SyncBinding* add_sync_bindings() { + sync_bindings_.emplace_back(); + return &sync_bindings_.back(); + } + const std::vector& sync_bindings() const { + return sync_bindings_; + } + const SyncBinding& sync_bindings(int index) const { + return sync_bindings_.at(index); + } + int sync_bindings_size() const { + return static_cast(sync_bindings_.size()); + } + + bool SerializeToString(std::string* output) const { + if (output == nullptr) { + return false; + } + output->clear(); + for (const SyncBinding& binding : sync_bindings_) { + output->append(Escape(binding.binding_id())); + output->push_back('\t'); + output->append(Escape(binding.source_name())); + output->push_back('\t'); + output->append(Escape(binding.destination_directory())); + output->push_back('\t'); + output->append(std::to_string(static_cast(binding.source_device_type()))); + output->push_back('\n'); + } + return true; + } + + bool ParseFromString(const std::string& input) { + sync_bindings_.clear(); + size_t start = 0; + while (start < input.size()) { + size_t end = input.find('\n', start); + std::string line = input.substr(start, end == std::string::npos + ? std::string::npos + : end - start); + if (!line.empty()) { + std::vector fields; + size_t field_start = 0; + while (fields.size() < 4) { + size_t field_end = line.find('\t', field_start); + fields.push_back(Unescape(line.substr( + field_start, field_end == std::string::npos + ? std::string::npos + : field_end - field_start))); + if (field_end == std::string::npos) { + break; + } + field_start = field_end + 1; + } + if (fields.size() != 4) { + return false; + } + SyncBinding binding; + binding.set_binding_id(fields[0]); + binding.set_source_name(fields[1]); + binding.set_destination_directory(fields[2]); + binding.set_source_device_type( + static_cast(std::stoi(fields[3]))); + sync_bindings_.push_back(std::move(binding)); + } + if (end == std::string::npos) { + break; + } + start = end + 1; + } + return true; + } + + private: + static std::string Escape(const std::string& value) { + std::string escaped; + for (char c : value) { + if (c == '\\' || c == '\t' || c == '\n') { + escaped.push_back('\\'); + } + if (c == '\t') { + escaped.push_back('t'); + } else if (c == '\n') { + escaped.push_back('n'); + } else { + escaped.push_back(c); + } + } + return escaped; + } + + static std::string Unescape(const std::string& value) { + std::string unescaped; + bool escaping = false; + for (char c : value) { + if (escaping) { + if (c == 't') { + unescaped.push_back('\t'); + } else if (c == 'n') { + unescaped.push_back('\n'); + } else { + unescaped.push_back(c); + } + escaping = false; + } else if (c == '\\') { + escaping = true; + } else { + unescaped.push_back(c); + } + } + return unescaped; + } + + std::vector sync_bindings_; +}; + +class SyncConfigPrefs { + public: + bool SerializeToString(std::string* output) const { + if (output == nullptr) { + return false; + } + output->clear(); + return true; + } + + bool ParseFromString(const std::string& input) { + return input.empty(); + } +}; + +} // namespace nearby::sharing::sync + +#endif // LOCATION_NEARBY_SHARING_LIB_SYNC_SYNC_BINDING_PREFS_PB_H_ diff --git a/location/nearby/sharing/lib/sync/sync_manager.h b/location/nearby/sharing/lib/sync/sync_manager.h new file mode 100644 index 00000000..118f10df --- /dev/null +++ b/location/nearby/sharing/lib/sync/sync_manager.h @@ -0,0 +1,126 @@ +// Copyright 2026 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 LOCATION_NEARBY_SHARING_LIB_SYNC_SYNC_MANAGER_H_ +#define LOCATION_NEARBY_SHARING_LIB_SYNC_SYNC_MANAGER_H_ + +#include +#include +#include + +#include "absl/functional/any_invocable.h" +#include "absl/status/status.h" +#include "absl/status/statusor.h" +#include "absl/strings/str_cat.h" +#include "absl/strings/string_view.h" +#include "internal/base/file_path.h" +#include "location/nearby/sharing/lib/rpc/sharing_rpc_client.h" +#include "location/nearby/sharing/lib/sync/sync_binding_prefs.pb.h" +#include "sharing/internal/api/preference_manager.h" + +namespace nearby::sharing { + +class SyncManager { + public: + SyncManager(api::IdentityRpcClient* identity_client, + api::PreferenceManager* preference_manager) + : identity_client_(identity_client), preference_manager_(preference_manager) {} + + explicit SyncManager(api::PreferenceManager* preference_manager) + : SyncManager(nullptr, preference_manager) {} + + void AsyncInitiateSyncBinding( + absl::AnyInvocable)> callback) { + static_cast(identity_client_); + if (callback) { + std::move(callback)(absl::UnavailableError( + "Sync binding RPC is not available in this build")); + } + } + + void AddSyncBinding(const sync::SyncBinding& binding) { + if (preference_manager_ == nullptr) { + return; + } + sync::SyncBindingPrefs prefs = + preference_manager_->GetSyncBindingValue().value_or( + sync::SyncBindingPrefs()); + sync::SyncBinding* stored = prefs.add_sync_bindings(); + *stored = binding; + preference_manager_->SetSyncBindingValue(prefs); + } + + std::optional GetSyncBinding( + absl::string_view binding_id) const { + if (preference_manager_ == nullptr) { + return std::nullopt; + } + std::optional prefs = + preference_manager_->GetSyncBindingValue(); + if (!prefs.has_value()) { + return std::nullopt; + } + for (const sync::SyncBinding& binding : prefs->sync_bindings()) { + if (binding.binding_id() == binding_id) { + return binding; + } + } + return std::nullopt; + } + + bool IsFileSyncBinding(absl::string_view binding_id) const { + return GetSyncBinding(binding_id).has_value(); + } + + std::optional GetSyncConfig( + absl::string_view binding_id) const { + static_cast(binding_id); + return std::nullopt; + } + + absl::StatusOr UpdateSyncBindingDestinationDirectory( + absl::string_view binding_id, FilePath save_path) { + if (preference_manager_ == nullptr) { + return absl::FailedPreconditionError("Preference manager is unavailable"); + } + sync::SyncBindingPrefs prefs = + preference_manager_->GetSyncBindingValue().value_or( + sync::SyncBindingPrefs()); + std::optional original_path; + sync::SyncBindingPrefs updated_prefs; + for (const sync::SyncBinding& binding : prefs.sync_bindings()) { + sync::SyncBinding* updated_binding = updated_prefs.add_sync_bindings(); + *updated_binding = binding; + if (binding.binding_id() == binding_id) { + original_path = FilePath(binding.destination_directory()); + updated_binding->set_destination_directory(save_path.ToString()); + } + } + if (!original_path.has_value()) { + return absl::NotFoundError( + absl::StrCat("Sync binding not found: ", binding_id)); + } + preference_manager_->SetSyncBindingValue(updated_prefs); + return *original_path; + } + + private: + api::IdentityRpcClient* identity_client_; + api::PreferenceManager* preference_manager_; +}; + +} // namespace nearby::sharing + +#endif // LOCATION_NEARBY_SHARING_LIB_SYNC_SYNC_MANAGER_H_ + diff --git a/util/hash/BUILD b/util/hash/BUILD new file mode 100644 index 00000000..e92c3ccb --- /dev/null +++ b/util/hash/BUILD @@ -0,0 +1,11 @@ +load("@rules_cc//cc:cc_library.bzl", "cc_library") + +cc_library( + name = "highway_fingerprint", + hdrs = ["highway_fingerprint.h"], + visibility = ["//visibility:public"], + deps = [ + "@com_google_absl//absl/hash", + "@com_google_absl//absl/strings:string_view", + ], +) diff --git a/util/hash/highway_fingerprint.h b/util/hash/highway_fingerprint.h new file mode 100644 index 00000000..600b7642 --- /dev/null +++ b/util/hash/highway_fingerprint.h @@ -0,0 +1,31 @@ +// Copyright 2026 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_SHARING_LINUX_STUBS_HIGHWAY_FINGERPRINT_H_ +#define THIRD_PARTY_NEARBY_SHARING_LINUX_STUBS_HIGHWAY_FINGERPRINT_H_ + +#include + +#include "absl/hash/hash.h" +#include "absl/strings/string_view.h" + +namespace util_hash { + +inline uint64_t HighwayFingerprint64(absl::string_view input) { + return absl::Hash{}(input); +} + +} // namespace util_hash + +#endif // THIRD_PARTY_NEARBY_SHARING_LINUX_STUBS_HIGHWAY_FINGERPRINT_H_