From 7472c810d39040bf16fe02de2967092474316d91 Mon Sep 17 00:00:00 2001 From: hai007 Date: Tue, 5 Aug 2025 11:37:00 -0700 Subject: [PATCH] Correct AWDL related error codes PiperOrigin-RevId: 791303156 --- .../analytics/analytics_recorder.cc | 2 ++ .../implementation/awdl_bwu_handler.cc | 10 +++---- connections/implementation/mediums/awdl.cc | 28 +++++++++---------- .../implementation/p2p_cluster_pcp_handler.cc | 2 +- 4 files changed, 22 insertions(+), 20 deletions(-) diff --git a/connections/implementation/analytics/analytics_recorder.cc b/connections/implementation/analytics/analytics_recorder.cc index ba33a9cd..6a98c7bd 100644 --- a/connections/implementation/analytics/analytics_recorder.cc +++ b/connections/implementation/analytics/analytics_recorder.cc @@ -998,6 +998,8 @@ OperationResultCode AnalyticsRecorder::GetChannelIoErrorResultCodeFromMedium( return OperationResultCode::CONNECTIVITY_CHANNEL_IO_ERROR_ON_WIFI_DIRECT; case Medium::WEB_RTC: return OperationResultCode::CONNECTIVITY_CHANNEL_IO_ERROR_ON_WEB_RTC; + case Medium::AWDL: + return OperationResultCode::CONNECTIVITY_CHANNEL_IO_ERROR_ON_AWDL; default: return OperationResultCode:: CONNECTIVITY_CHANNEL_IO_ERROR_ON_UNKNOWN_MEDIUM; diff --git a/connections/implementation/awdl_bwu_handler.cc b/connections/implementation/awdl_bwu_handler.cc index 2441fb21..b1580b94 100644 --- a/connections/implementation/awdl_bwu_handler.cc +++ b/connections/implementation/awdl_bwu_handler.cc @@ -67,7 +67,7 @@ AwdlBwuHandler::CreateUpgradedEndpointChannel( std::string upgrade_service_id = WrapInitiatorUpgradeServiceId(service_id); if (!upgrade_path_info.has_awdl_credentials()) { return { - Error(OperationResultCode::CONNECTIVITY_WIFI_LAN_INVALID_CREDENTIAL)}; + Error(OperationResultCode::CONNECTIVITY_AWDL_INVALID_CREDENTIAL)}; } const UpgradePathInfo::AwdlCredentials& awdl_credentials = @@ -77,7 +77,7 @@ AwdlBwuHandler::CreateUpgradedEndpointChannel( !awdl_credentials.has_password()) { LOG(ERROR) << "Failed to upgrade AWDL due to invalid credentials."; return { - Error(OperationResultCode::CONNECTIVITY_WIFI_LAN_INVALID_CREDENTIAL)}; + Error(OperationResultCode::CONNECTIVITY_AWDL_INVALID_CREDENTIAL)}; } std::string service_name = awdl_credentials.service_name(); @@ -129,7 +129,7 @@ AwdlBwuHandler::CreateUpgradedEndpointChannel( << service_name << ", service_type:" << service_type << ") for endpoint " << endpoint_id; return {Error( - OperationResultCode::NEARBY_LAN_ENDPOINT_CHANNEL_CREATION_FAILURE)}; + OperationResultCode::NEARBY_AWDL_ENDPOINT_CHANNEL_CREATION_FAILURE)}; } if (!latch.Await(kAwdlDiscoveryTimeout)) { @@ -138,7 +138,7 @@ AwdlBwuHandler::CreateUpgradedEndpointChannel( << ") due to timeout."; awdl_medium_.StopDiscovery(upgrade_service_id); return {Error( - OperationResultCode::NEARBY_LAN_ENDPOINT_CHANNEL_CREATION_FAILURE)}; + OperationResultCode::NEARBY_AWDL_ENDPOINT_CHANNEL_CREATION_FAILURE)}; } LOG(INFO) << "Discovered the AWDL service " @@ -174,7 +174,7 @@ AwdlBwuHandler::CreateUpgradedEndpointChannel( awdl_medium_.StopDiscovery(upgrade_service_id); socket_result.value().Close(); return {Error( - OperationResultCode::NEARBY_LAN_ENDPOINT_CHANNEL_CREATION_FAILURE)}; + OperationResultCode::NEARBY_AWDL_ENDPOINT_CHANNEL_CREATION_FAILURE)}; } return {std::move(channel)}; diff --git a/connections/implementation/mediums/awdl.cc b/connections/implementation/mediums/awdl.cc index d4559228..cf380fcb 100644 --- a/connections/implementation/mediums/awdl.cc +++ b/connections/implementation/mediums/awdl.cc @@ -82,7 +82,7 @@ ErrorOr Awdl::StartAdvertising(const std::string& service_id, if (!IsAvailableLocked()) { LOG(INFO) << "Can't turn on Awdl advertising. Awdl is not available."; - return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_LAN_NOT_AVAILABLE)}; + return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_AWDL_NOT_AVAILABLE)}; } if (!nsd_service_info.IsValid()) { @@ -94,7 +94,7 @@ ErrorOr Awdl::StartAdvertising(const std::string& service_id, if (IsAdvertisingLocked(service_id)) { LOG(INFO) << "Failed to Awdl advertise because we're already advertising."; - return {Error(OperationResultCode::CLIENT_WIFI_LAN_DUPLICATE_ADVERTISING)}; + return {Error(OperationResultCode::CLIENT_AWDL_DUPLICATE_ADVERTISING)}; } if (!IsAcceptingConnectionsLocked(service_id)) { @@ -104,7 +104,7 @@ ErrorOr Awdl::StartAdvertising(const std::string& service_id, << ", service_id=" << service_id << ". Should accept connections before advertising."; return {Error(OperationResultCode:: - CLIENT_DUPLICATE_ACCEPTING_LAN_CONNECTION_REQUEST)}; + CLIENT_DUPLICATE_ACCEPTING_AWDL_CONNECTION_REQUEST)}; } nsd_service_info.SetServiceType(GenerateServiceType( @@ -120,7 +120,7 @@ ErrorOr Awdl::StartAdvertising(const std::string& service_id, << ", service_name=" << nsd_service_info.GetServiceName() << ", service_id=" << service_id; return {Error( - OperationResultCode::CONNECTIVITY_WIFI_LAN_START_ADVERTISING_FAILURE)}; + OperationResultCode::CONNECTIVITY_AWDL_START_ADVERTISING_FAILURE)}; } LOG(INFO) << "Turned on Awdl advertising with nsd_service_info=" @@ -170,13 +170,13 @@ ErrorOr Awdl::StartDiscovery(const std::string& service_id, if (!IsAvailableLocked()) { LOG(INFO) << "Can't discover Awdl services because Awdl isn't available."; return {Error( - OperationResultCode::MEDIUM_UNAVAILABLE_WIFI_AWARE_NOT_AVAILABLE)}; + OperationResultCode::MEDIUM_UNAVAILABLE_AWDL_NOT_AVAILABLE)}; } if (IsDiscoveringLocked(service_id)) { LOG(INFO) << "Refusing to start discovery of Awdl services because another " "discovery is already in-progress."; - return {Error(OperationResultCode::CLIENT_WIFI_LAN_DUPLICATE_DISCOVERING)}; + return {Error(OperationResultCode::CLIENT_AWDL_DUPLICATE_DISCOVERING)}; } std::string service_type = GenerateServiceType( @@ -186,7 +186,7 @@ ErrorOr Awdl::StartDiscovery(const std::string& service_id, if (!ret) { LOG(INFO) << "Failed to start discovery of Awdl services."; return {Error( - OperationResultCode::CONNECTIVITY_WIFI_LAN_START_DISCOVERY_FAILURE)}; + OperationResultCode::CONNECTIVITY_AWDL_START_DISCOVERY_FAILURE)}; } LOG(INFO) << "Turned on Awdl discovering with service_id=" << service_id; @@ -370,7 +370,7 @@ ErrorOr Awdl::InternalStartAcceptingConnections( LOG(INFO) << "Can't start accepting Awdl connections [service_id=" << service_id << "]; Awdl not available."; return {Error( - OperationResultCode::MEDIUM_UNAVAILABLE_WIFI_AWARE_NOT_AVAILABLE)}; + OperationResultCode::MEDIUM_UNAVAILABLE_AWDL_NOT_AVAILABLE)}; } if (IsAcceptingConnectionsLocked(service_id)) { @@ -378,7 +378,7 @@ ErrorOr Awdl::InternalStartAcceptingConnections( << service_id << "]; Awdl server is already in-progress with the same name."; return {Error(OperationResultCode:: - CLIENT_DUPLICATE_ACCEPTING_LAN_CONNECTION_REQUEST)}; + CLIENT_DUPLICATE_ACCEPTING_AWDL_CONNECTION_REQUEST)}; } auto port_range = medium_.GetDynamicPortRange(); @@ -398,7 +398,7 @@ ErrorOr Awdl::InternalStartAcceptingConnections( LOG(INFO) << "Failed to start accepting Awdl connections for service_id=" << service_id; return {Error(OperationResultCode:: - CLIENT_CANCELLATION_WIFI_LAN_SERVER_SOCKET_CREATION)}; + CLIENT_CANCELLATION_AWDL_SERVER_SOCKET_CREATION)}; } // Mark the fact that there's an in-progress Awdl server accepting @@ -447,13 +447,13 @@ ErrorOr Awdl::InternalConnect( if (!IsAvailableLocked()) { LOG(INFO) << "Can't create client Awdl socket [service_id=" << service_id << "]; Awdl isn't available."; - return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_LAN_NOT_AVAILABLE)}; + return {Error(OperationResultCode::MEDIUM_UNAVAILABLE_AWDL_NOT_AVAILABLE)}; } if (cancellation_flag->Cancelled()) { LOG(INFO) << "Can't create client Awdl socket due to cancel."; return {Error(OperationResultCode:: - CLIENT_CANCELLATION_CANCEL_LAN_OUTGOING_CONNECTION)}; + CLIENT_CANCELLATION_CANCEL_AWDL_OUTGOING_CONNECTION)}; } if (service_info.GetServiceName().empty() || @@ -461,7 +461,7 @@ ErrorOr Awdl::InternalConnect( LOG(INFO) << "Can't create client Awdl socket due to invalid service " "information."; return { - Error(OperationResultCode::CONNECTIVITY_WIFI_LAN_INVALID_CREDENTIAL)}; + Error(OperationResultCode::CONNECTIVITY_AWDL_INVALID_CREDENTIAL)}; } socket = @@ -471,7 +471,7 @@ ErrorOr Awdl::InternalConnect( if (!socket.IsValid()) { LOG(INFO) << "Failed to Connect via Awdl [service_id=" << service_id << "]"; return {Error( - OperationResultCode::CONNECTIVITY_LAN_CLIENT_SOCKET_CREATION_FAILURE)}; + OperationResultCode::CONNECTIVITY_AWDL_CLIENT_SOCKET_CREATION_FAILURE)}; } LOG(INFO) << "Successfully connected via Awdl [service_id=" << service_id diff --git a/connections/implementation/p2p_cluster_pcp_handler.cc b/connections/implementation/p2p_cluster_pcp_handler.cc index 3691a2c7..fad301a4 100644 --- a/connections/implementation/p2p_cluster_pcp_handler.cc +++ b/connections/implementation/p2p_cluster_pcp_handler.cc @@ -3128,7 +3128,7 @@ ErrorOr P2pClusterPcpHandler::StartAwdlAdvertising( << absl::BytesToHexString(local_endpoint_info.data()) << "}."; awdl_medium_.StopAcceptingConnections(service_id); return { - Error(OperationResultCode::NEARBY_WIFI_LAN_ADVERTISE_TO_BYTES_FAILURE)}; + Error(OperationResultCode::NEARBY_AWDL_ADVERTISE_TO_BYTES_FAILURE)}; } LOG(INFO) << "In StartAwdlAdvertising(" << absl::BytesToHexString(local_endpoint_info.data())