From a7bb6673a6a1d8048901bd5cc8ebf99cd25cfd5f Mon Sep 17 00:00:00 2001 From: Guogang Li Date: Fri, 21 Feb 2025 22:20:15 -0800 Subject: [PATCH] internal update PiperOrigin-RevId: 729773934 --- .../mediums/advertisements/advertisement_util.cc | 3 +++ sharing/advertisement.cc | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/connections/implementation/mediums/advertisements/advertisement_util.cc b/connections/implementation/mediums/advertisements/advertisement_util.cc index 122ea55b..c2bf0066 100644 --- a/connections/implementation/mediums/advertisements/advertisement_util.cc +++ b/connections/implementation/mediums/advertisements/advertisement_util.cc @@ -24,6 +24,8 @@ namespace nearby::connections::advertisements { std::optional ReadDeviceName(const ByteArray& endpoint_info) { + // Should always match the protocol implementation to read device name. + // LINT.IfChange StreamReader reader(endpoint_info); std::optional version = reader.ReadBits(3); if (!version.has_value() || *version != 1) { @@ -55,6 +57,7 @@ std::optional ReadDeviceName(const ByteArray& endpoint_info) { } return std::string(*device_name); + // LINT.ThenChange(//depot/google3/third_party/nearby/sharing/advertisement.cc) } } // namespace nearby::connections::advertisements diff --git a/sharing/advertisement.cc b/sharing/advertisement.cc index 8bc20948..2f3029c9 100644 --- a/sharing/advertisement.cc +++ b/sharing/advertisement.cc @@ -195,6 +195,9 @@ std::vector Advertisement::ToEndpointInfo() const { std::unique_ptr Advertisement::FromEndpointInfo( absl::Span endpoint_info) { + // Should always match the Nearby Connections implementation to read device + // name. + // LINT.IfChange if (endpoint_info.size() < kMinimumSize) { NL_LOG(ERROR) << "Failed to parse advertisement because it was too short."; return nullptr; @@ -271,6 +274,7 @@ std::unique_ptr Advertisement::FromEndpointInfo( return Advertisement::NewInstance( std::move(salt), std::move(encrypted_metadata_key), device_type, std::move(optional_device_name), vendor_id); + // LINT.ThenChange(//depot/google3/third_party/nearby/connections/implementation/mediums/advertisements/advertisement_util.cc) } bool Advertisement::operator==(const Advertisement& other) const {