Implement method to build AWDL upgrade frame

PiperOrigin-RevId: 755607718
This commit is contained in:
Guogang Li
2025-05-06 18:30:30 -07:00
committed by Copybara-Service
parent 62413e4de9
commit 946e865db2
3 changed files with 48 additions and 1 deletions
@@ -297,6 +297,26 @@ ByteArray ForBwuWifiLanPathAvailable(const std::string& ip_address,
return ToBytes(std::move(frame));
}
ByteArray ForBwuAwdlPathAvailable(const std::string& service_name,
const std::string& service_type) {
OfflineFrame frame;
frame.set_version(OfflineFrame::V1);
auto* v1_frame = frame.mutable_v1();
v1_frame->set_type(V1Frame::BANDWIDTH_UPGRADE_NEGOTIATION);
auto* sub_frame = v1_frame->mutable_bandwidth_upgrade_negotiation();
sub_frame->set_event_type(
BandwidthUpgradeNegotiationFrame::UPGRADE_PATH_AVAILABLE);
auto* upgrade_path_info = sub_frame->mutable_upgrade_path_info();
upgrade_path_info->set_medium(UpgradePathInfo::AWDL);
upgrade_path_info->set_supports_client_introduction_ack(true);
auto* awdl_socket = upgrade_path_info->mutable_awdl_credentials();
awdl_socket->set_service_name(service_name);
awdl_socket->set_service_type(service_type);
return ToBytes(std::move(frame));
}
ByteArray ForBwuWifiAwarePathAvailable(const std::string& service_id,
const std::string& service_info,
const std::string& password,
+3 -1
View File
@@ -19,8 +19,8 @@
#include <string>
#include <vector>
#include "connections/implementation/proto/offline_wire_formats.pb.h"
#include "connections/connection_options.h"
#include "connections/implementation/proto/offline_wire_formats.pb.h"
#include "connections/medium_selector.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/exception.h"
@@ -82,6 +82,8 @@ ByteArray ForBwuWifiHotspotPathAvailable(const std::string& ssid,
bool supports_disabling_encryption);
ByteArray ForBwuWifiLanPathAvailable(const std::string& ip_address,
std::int32_t port);
ByteArray ForBwuAwdlPathAvailable(const std::string& service_name,
const std::string& service_type);
ByteArray ForBwuWifiAwarePathAvailable(const std::string& service_id,
const std::string& service_info,
const std::string& password,
@@ -422,6 +422,31 @@ TEST(OfflineFramesTest, CanGenerateBwuWifiLanPathAvailable) {
EXPECT_THAT(message, EqualsProto(kExpected));
}
TEST(OfflineFramesTest, CanGenerateBwuAwdlPathAvailable) {
constexpr absl::string_view kExpected =
R"pb(
version: V1
v1: <
type: BANDWIDTH_UPGRADE_NEGOTIATION
bandwidth_upgrade_negotiation: <
event_type: UPGRADE_PATH_AVAILABLE
upgrade_path_info: <
medium: AWDL
supports_client_introduction_ack: true
awdl_credentials: <
service_name: "service_name"
service_type: "nearby_upgrade"
>
>
>
>)pb";
ByteArray bytes = ForBwuAwdlPathAvailable("service_name", "nearby_upgrade");
auto response = FromBytes(bytes);
ASSERT_TRUE(response.ok());
OfflineFrame message = response.result();
EXPECT_THAT(message, EqualsProto(kExpected));
}
TEST(OfflineFramesTest, CanGenerateBwuWifiAwarePathAvailable) {
constexpr absl::string_view kExpected =
R"pb(