From e99faba5fc8f94e48a34de010570b277ca349e81 Mon Sep 17 00:00:00 2001 From: Francis Tsui Date: Fri, 24 Oct 2025 11:37:01 -0700 Subject: [PATCH] Remove unused field from HotspotCredentials. PiperOrigin-RevId: 823606909 --- connections/implementation/mediums/wifi_hotspot.cc | 1 - internal/platform/medium_environment.cc | 2 +- internal/platform/wifi_credential.h | 11 +++-------- internal/platform/wifi_hotspot_test.cc | 4 ++-- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/connections/implementation/mediums/wifi_hotspot.cc b/connections/implementation/mediums/wifi_hotspot.cc index 8b5a987e..7eb64c86 100644 --- a/connections/implementation/mediums/wifi_hotspot.cc +++ b/connections/implementation/mediums/wifi_hotspot.cc @@ -135,7 +135,6 @@ HotspotCredentials* WifiHotspot::GetCredentials(absl::string_view service_id) { return crendential; } crendential->SetGateway(it->second.GetIPAddress()); - crendential->SetIPAddress(it->second.GetIPAddress()); crendential->SetPort(it->second.GetPort()); return crendential; diff --git a/internal/platform/medium_environment.cc b/internal/platform/medium_environment.cc index 0d120e97..98ad833a 100644 --- a/internal/platform/medium_environment.cc +++ b/internal/platform/medium_environment.cc @@ -1045,7 +1045,7 @@ api::WifiHotspotMedium* MediumEnvironment::GetWifiHotspotMedium( if (info.is_ap && info.hotspot_credentials) { if ((info.hotspot_credentials->GetSSID() == ssid) || (!ip_address.empty() && - (info.hotspot_credentials->GetIPAddress() == ip_address))) { + (info.hotspot_credentials->GetGateway() == ip_address))) { LOG(INFO) << "Found Remote WifiHotspot medium=" << medium_found; return medium_found; } diff --git a/internal/platform/wifi_credential.h b/internal/platform/wifi_credential.h index 646dfb86..b0055db0 100644 --- a/internal/platform/wifi_credential.h +++ b/internal/platform/wifi_credential.h @@ -43,12 +43,8 @@ class HotspotCredentials { std::string GetPassword() const { return password_; } void SetPassword(const std::string& password) { password_ = password; } - // Gets IP Address, which is in byte sequence, in network order. For example, - // for "192.168.1.1", it'll be byte(129)+byte(168)+byte(1)+byte(1). Now only - // ipv4 is supported. - std::string GetIPAddress() const { return ip_address_; } - void SetIPAddress(const std::string& ip_address) { ip_address_ = ip_address; } - + // Gets IP Address in string format. + // This is the IP address at which the service is provided. std::string GetGateway() const { return gateway_; } void SetGateway(const std::string& gateway) { gateway_ = gateway; } @@ -76,8 +72,7 @@ class HotspotCredentials { private: std::string ssid_; std::string password_; - std::string ip_address_; - std::string gateway_ = "0.0.0.0"; + std::string gateway_; int port_ = 0; int frequency_ = -1; location::nearby::proto::connections::ConnectionBand band_; diff --git a/internal/platform/wifi_hotspot_test.cc b/internal/platform/wifi_hotspot_test.cc index e2839488..3e9438c8 100644 --- a/internal/platform/wifi_hotspot_test.cc +++ b/internal/platform/wifi_hotspot_test.cc @@ -140,7 +140,7 @@ TEST_P(WifiHotspotMediumTest, CanStartHotspotThatOtherConnect) { WifiHotspotServerSocket server_socket = wifi_hotspot_a->ListenForService(); EXPECT_TRUE(server_socket.IsValid()); - wifi_hotspot_a->GetCredential()->SetIPAddress(server_socket.GetIPAddress()); + wifi_hotspot_a->GetCredential()->SetGateway(server_socket.GetIPAddress()); WifiHotspotSocket socket_a; WifiHotspotSocket socket_b; @@ -205,7 +205,7 @@ TEST_P(WifiHotspotMediumTest, CanStartHotspotThatOtherCanCancelConnect) { WifiHotspotServerSocket server_socket = wifi_hotspot_a->ListenForService(); EXPECT_TRUE(server_socket.IsValid()); - wifi_hotspot_a->GetCredential()->SetIPAddress(server_socket.GetIPAddress()); + wifi_hotspot_a->GetCredential()->SetGateway(server_socket.GetIPAddress()); WifiHotspotSocket socket_a; WifiHotspotSocket socket_b;