Commit cef71a7e authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

[Nearby] Upprev NearbyConnections to 4e3f343b7a1b9faee0cb71dc3b2c0ecf13c7f707

Includes tweaks to ClientProxy subclasses and the tests that
use them, because ClientProxy::OnBandwidthChanged() signature
changed.

Includes tweaks to BleMedium implementation to account
for addition of Fast Advertisement feature, but does not
correctly implement their expectations -- that will be
done in a subsequent CL.

Change-Id: I71fb3f8314abc3439350096243f544cc63e79c02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2410652
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarAlex Gough <ajgo@chromium.org>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Cr-Commit-Position: refs/heads/master@{#807648}
parent 15522bc8
...@@ -346,7 +346,7 @@ vars = { ...@@ -346,7 +346,7 @@ vars = {
# Three lines of non-changing comments so that # Three lines of non-changing comments so that
# the commit queue can handle CLs rolling nearby # the commit queue can handle CLs rolling nearby
# and whatever else without interference from each other. # and whatever else without interference from each other.
'nearby_revision': 'abc1cbf2673a38678eb7033291049590762526d7', 'nearby_revision': '4e3f343b7a1b9faee0cb71dc3b2c0ecf13c7f707',
# Three lines of non-changing comments so that # Three lines of non-changing comments so that
# the commit queue can handle CLs rolling securemessage # the commit queue can handle CLs rolling securemessage
# and whatever else without interference from each other. # and whatever else without interference from each other.
......
...@@ -504,7 +504,7 @@ void NearbyConnectionsManagerImpl::OnDisconnected( ...@@ -504,7 +504,7 @@ void NearbyConnectionsManagerImpl::OnDisconnected(
void NearbyConnectionsManagerImpl::OnBandwidthChanged( void NearbyConnectionsManagerImpl::OnBandwidthChanged(
const std::string& endpoint_id, const std::string& endpoint_id,
int32_t quality) { Medium medium) {
NS_LOG(VERBOSE) << __func__; NS_LOG(VERBOSE) << __func__;
// TODO(crbug/1111458): Support TransferManager. // TODO(crbug/1111458): Support TransferManager.
} }
......
...@@ -92,6 +92,7 @@ class NearbyConnectionsManagerImpl ...@@ -92,6 +92,7 @@ class NearbyConnectionsManagerImpl
using PayloadTransferUpdatePtr = using PayloadTransferUpdatePtr =
location::nearby::connections::mojom::PayloadTransferUpdatePtr; location::nearby::connections::mojom::PayloadTransferUpdatePtr;
using Status = location::nearby::connections::mojom::Status; using Status = location::nearby::connections::mojom::Status;
using Medium = location::nearby::connections::mojom::Medium;
FRIEND_TEST_ALL_PREFIXES(NearbyConnectionsManagerImplTest, FRIEND_TEST_ALL_PREFIXES(NearbyConnectionsManagerImplTest,
DiscoveryProcessStopped); DiscoveryProcessStopped);
...@@ -114,7 +115,7 @@ class NearbyConnectionsManagerImpl ...@@ -114,7 +115,7 @@ class NearbyConnectionsManagerImpl
Status status) override; Status status) override;
void OnDisconnected(const std::string& endpoint_id) override; void OnDisconnected(const std::string& endpoint_id) override;
void OnBandwidthChanged(const std::string& endpoint_id, void OnBandwidthChanged(const std::string& endpoint_id,
int32_t quality) override; Medium medium) override;
// PayloadListener: // PayloadListener:
void OnPayloadReceived(const std::string& endpoint_id, void OnPayloadReceived(const std::string& endpoint_id,
......
...@@ -64,11 +64,11 @@ ConnectionRequestInfo CreateConnectionRequestInfo( ...@@ -64,11 +64,11 @@ ConnectionRequestInfo CreateConnectionRequestInfo(
remote->OnDisconnected(endpoint_id); remote->OnDisconnected(endpoint_id);
}, },
.bandwidth_changed_cb = .bandwidth_changed_cb =
[remote](const std::string& endpoint_id, std::int32_t quality) { [remote](const std::string& endpoint_id, Medium medium) {
if (!remote) if (!remote)
return; return;
remote->OnBandwidthChanged(endpoint_id, quality); remote->OnBandwidthChanged(endpoint_id, MediumToMojom(medium));
}, },
}, },
}; };
......
...@@ -100,6 +100,31 @@ mojom::PayloadStatus PayloadStatusToMojom(PayloadProgressInfo::Status status) { ...@@ -100,6 +100,31 @@ mojom::PayloadStatus PayloadStatusToMojom(PayloadProgressInfo::Status status) {
} }
} }
mojom::Medium MediumToMojom(Medium medium) {
switch (medium) {
case Medium::UNKNOWN_MEDIUM:
return mojom::Medium::kUnknown;
case Medium::MDNS:
return mojom::Medium::kMdns;
case Medium::BLUETOOTH:
return mojom::Medium::kBluetooth;
case Medium::WIFI_HOTSPOT:
return mojom::Medium::kWifiHotspot;
case Medium::BLE:
return mojom::Medium::kBle;
case Medium::WIFI_LAN:
return mojom::Medium::kWifiLan;
case Medium::WIFI_AWARE:
return mojom::Medium::kWifiAware;
case Medium::NFC:
return mojom::Medium::kNfc;
case Medium::WIFI_DIRECT:
return mojom::Medium::kWifiDirect;
case Medium::WEB_RTC:
return mojom::Medium::kWebRtc;
}
}
BooleanMediumSelector MediumSelectorFromMojom( BooleanMediumSelector MediumSelectorFromMojom(
mojom::MediumSelection* allowed_mediums) { mojom::MediumSelection* allowed_mediums) {
return BooleanMediumSelector{ return BooleanMediumSelector{
......
...@@ -32,6 +32,8 @@ ByteArray ByteArrayFromMojom(const std::vector<uint8_t>& byte_array); ...@@ -32,6 +32,8 @@ ByteArray ByteArrayFromMojom(const std::vector<uint8_t>& byte_array);
mojom::PayloadStatus PayloadStatusToMojom(PayloadProgressInfo::Status status); mojom::PayloadStatus PayloadStatusToMojom(PayloadProgressInfo::Status status);
mojom::Medium MediumToMojom(Medium medium);
BooleanMediumSelector MediumSelectorFromMojom( BooleanMediumSelector MediumSelectorFromMojom(
mojom::MediumSelection* allowed_mediums); mojom::MediumSelection* allowed_mediums);
......
...@@ -40,7 +40,6 @@ const char kEndpointInfo[] = {0x0d, 0x07, 0x07, 0x07, 0x07}; ...@@ -40,7 +40,6 @@ const char kEndpointInfo[] = {0x0d, 0x07, 0x07, 0x07, 0x07};
const char kRemoteEndpointInfo[] = {0x0d, 0x07, 0x06, 0x08, 0x09}; const char kRemoteEndpointInfo[] = {0x0d, 0x07, 0x06, 0x08, 0x09};
const char kAuthenticationToken[] = "authentication_token"; const char kAuthenticationToken[] = "authentication_token";
const char kRawAuthenticationToken[] = {0x00, 0x05, 0x04, 0x03, 0x02}; const char kRawAuthenticationToken[] = {0x00, 0x05, 0x04, 0x03, 0x02};
const int32_t kQuality = 5201314;
const int64_t kPayloadId = 612721831; const int64_t kPayloadId = 612721831;
const char kPayload[] = {0x0f, 0x0a, 0x0c, 0x0e}; const char kPayload[] = {0x0f, 0x0a, 0x0c, 0x0e};
const char kBluetoothMacAddress[] = {0x00, 0x00, 0xe6, 0x88, 0x64, 0x13}; const char kBluetoothMacAddress[] = {0x00, 0x00, 0xe6, 0x88, 0x64, 0x13};
...@@ -122,8 +121,8 @@ class FakeConnectionLifecycleListener ...@@ -122,8 +121,8 @@ class FakeConnectionLifecycleListener
} }
void OnBandwidthChanged(const std::string& endpoint_id, void OnBandwidthChanged(const std::string& endpoint_id,
int32_t quality) override { mojom::Medium medium) override {
bandwidth_changed_cb.Run(endpoint_id, quality); bandwidth_changed_cb.Run(endpoint_id, medium);
} }
mojo::Receiver<mojom::ConnectionLifecycleListener> receiver{this}; mojo::Receiver<mojom::ConnectionLifecycleListener> receiver{this};
...@@ -135,7 +134,7 @@ class FakeConnectionLifecycleListener ...@@ -135,7 +134,7 @@ class FakeConnectionLifecycleListener
base::DoNothing(); base::DoNothing();
base::RepeatingCallback<void(const std::string&)> disconnected_cb = base::RepeatingCallback<void(const std::string&)> disconnected_cb =
base::DoNothing(); base::DoNothing();
base::RepeatingCallback<void(const std::string&, int32_t)> base::RepeatingCallback<void(const std::string&, mojom::Medium)>
bandwidth_changed_cb = base::DoNothing(); bandwidth_changed_cb = base::DoNothing();
}; };
...@@ -553,9 +552,9 @@ TEST_F(NearbyConnectionsTest, RequestConnectionOnBandwidthUpgrade) { ...@@ -553,9 +552,9 @@ TEST_F(NearbyConnectionsTest, RequestConnectionOnBandwidthUpgrade) {
base::RunLoop upgraded_run_loop; base::RunLoop upgraded_run_loop;
fake_connection_life_cycle_listener.bandwidth_changed_cb = fake_connection_life_cycle_listener.bandwidth_changed_cb =
base::BindLambdaForTesting( base::BindLambdaForTesting(
[&](const std::string& endpoint_id, int32_t quality) { [&](const std::string& endpoint_id, mojom::Medium medium) {
EXPECT_EQ(endpoint_data.remote_endpoint_id, endpoint_id); EXPECT_EQ(endpoint_data.remote_endpoint_id, endpoint_id);
EXPECT_EQ(kQuality, quality); EXPECT_EQ(mojom::Medium::kWebRtc, medium);
upgraded_run_loop.Quit(); upgraded_run_loop.Quit();
}); });
...@@ -564,7 +563,7 @@ TEST_F(NearbyConnectionsTest, RequestConnectionOnBandwidthUpgrade) { ...@@ -564,7 +563,7 @@ TEST_F(NearbyConnectionsTest, RequestConnectionOnBandwidthUpgrade) {
.WillOnce([&](ClientProxy* client, const std::string& endpoint_id) { .WillOnce([&](ClientProxy* client, const std::string& endpoint_id) {
client_proxy = client; client_proxy = client;
EXPECT_EQ(endpoint_data.remote_endpoint_id, endpoint_id); EXPECT_EQ(endpoint_data.remote_endpoint_id, endpoint_id);
client_proxy->OnBandwidthChanged(endpoint_id, kQuality); client_proxy->OnBandwidthChanged(endpoint_id, Medium::WEB_RTC);
return Status{Status::kSuccess}; return Status{Status::kSuccess};
}); });
base::RunLoop bandwidth_upgrade_run_loop; base::RunLoop bandwidth_upgrade_run_loop;
......
...@@ -19,8 +19,10 @@ BleMedium::~BleMedium() { ...@@ -19,8 +19,10 @@ BleMedium::~BleMedium() {
} }
} }
bool BleMedium::StartAdvertising(const std::string& service_id, bool BleMedium::StartAdvertising(
const ByteArray& advertisement) { const std::string& service_id,
const ByteArray& advertisement,
const std::string& fast_advertisement_service_uuid) {
StopAdvertising(service_id); StopAdvertising(service_id);
auto service_uuid = device::BluetoothUUID(service_id); auto service_uuid = device::BluetoothUUID(service_id);
...@@ -202,7 +204,8 @@ void BleMedium::DeviceAdded(bluetooth::mojom::DeviceInfoPtr device) { ...@@ -202,7 +204,8 @@ void BleMedium::DeviceAdded(bluetooth::mojom::DeviceInfoPtr device) {
if (ble_peripheral->GetAdvertisementBytes(service_id).Empty()) if (ble_peripheral->GetAdvertisementBytes(service_id).Empty())
continue; continue;
it.second.peripheral_discovered_cb(*ble_peripheral, service_id); it.second.peripheral_discovered_cb(*ble_peripheral, service_id,
/*fast_advertisement=*/true);
} }
} }
......
...@@ -30,8 +30,10 @@ class BleMedium : public api::BleMedium, ...@@ -30,8 +30,10 @@ class BleMedium : public api::BleMedium,
BleMedium& operator=(const BleMedium&) = delete; BleMedium& operator=(const BleMedium&) = delete;
// api::BleMedium: // api::BleMedium:
bool StartAdvertising(const std::string& service_id, bool StartAdvertising(
const ByteArray& advertisement) override; const std::string& service_id,
const ByteArray& advertisement,
const std::string& fast_advertisement_service_uuid) override;
bool StopAdvertising(const std::string& service_id) override; bool StopAdvertising(const std::string& service_id) override;
bool StartScanning( bool StartScanning(
const std::string& service_id, const std::string& service_id,
......
...@@ -26,6 +26,8 @@ namespace { ...@@ -26,6 +26,8 @@ namespace {
const char kServiceName[] = "NearbySharing"; const char kServiceName[] = "NearbySharing";
const char kServiceId1[] = "00000000-0000-0000-0000-000000000001"; const char kServiceId1[] = "00000000-0000-0000-0000-000000000001";
const char kFastAdvertisementServiceId1[] =
"00000000-0000-0000-0000-000000000011";
const char kServiceId2[] = "00000000-0000-0000-0000-000000000002"; const char kServiceId2[] = "00000000-0000-0000-0000-000000000002";
const char kDeviceAddress[] = "DeviceAddress"; const char kDeviceAddress[] = "DeviceAddress";
const char kDeviceServiceData1Str[] = "Device_Advertisement1"; const char kDeviceServiceData1Str[] = "Device_Advertisement1";
...@@ -62,7 +64,8 @@ class BleMediumTest : public testing::Test { ...@@ -62,7 +64,8 @@ class BleMediumTest : public testing::Test {
discovered_peripheral_callback_ = { discovered_peripheral_callback_ = {
.peripheral_discovered_cb = .peripheral_discovered_cb =
[this](api::BlePeripheral& peripheral, [this](api::BlePeripheral& peripheral,
const std::string& service_id) { const std::string& service_id, bool fast_advertisement) {
EXPECT_TRUE(fast_advertisement);
OnPeripheralDiscovered(peripheral, service_id); OnPeripheralDiscovered(peripheral, service_id);
}, },
.peripheral_lost_cb = .peripheral_lost_cb =
...@@ -224,14 +227,16 @@ TEST_F(BleMediumTest, TestAdvertising) { ...@@ -224,14 +227,16 @@ TEST_F(BleMediumTest, TestAdvertising) {
ASSERT_FALSE(fake_adapter_->GetRegisteredAdvertisementServiceData( ASSERT_FALSE(fake_adapter_->GetRegisteredAdvertisementServiceData(
device::BluetoothUUID(kServiceId2))); device::BluetoothUUID(kServiceId2)));
ble_medium_->StartAdvertising(kServiceId1, ByteArray(kDeviceServiceData1Str)); ble_medium_->StartAdvertising(kServiceId1, ByteArray(kDeviceServiceData1Str),
kFastAdvertisementServiceId1);
EXPECT_EQ(GetByteVector(kDeviceServiceData1Str), EXPECT_EQ(GetByteVector(kDeviceServiceData1Str),
*fake_adapter_->GetRegisteredAdvertisementServiceData( *fake_adapter_->GetRegisteredAdvertisementServiceData(
device::BluetoothUUID(kServiceId1))); device::BluetoothUUID(kServiceId1)));
EXPECT_FALSE(fake_adapter_->GetRegisteredAdvertisementServiceData( EXPECT_FALSE(fake_adapter_->GetRegisteredAdvertisementServiceData(
device::BluetoothUUID(kServiceId2))); device::BluetoothUUID(kServiceId2)));
ble_medium_->StartAdvertising(kServiceId2, ByteArray(kDeviceServiceData2Str)); ble_medium_->StartAdvertising(kServiceId2, ByteArray(kDeviceServiceData2Str),
kFastAdvertisementServiceId1);
EXPECT_TRUE(fake_adapter_->GetRegisteredAdvertisementServiceData( EXPECT_TRUE(fake_adapter_->GetRegisteredAdvertisementServiceData(
device::BluetoothUUID(kServiceId1))); device::BluetoothUUID(kServiceId1)));
EXPECT_EQ(GetByteVector(kDeviceServiceData2Str), EXPECT_EQ(GetByteVector(kDeviceServiceData2Str),
......
...@@ -89,7 +89,7 @@ interface ConnectionLifecycleListener { ...@@ -89,7 +89,7 @@ interface ConnectionLifecycleListener {
// //
// endpoint_id - The identifier for the remote endpoint. // endpoint_id - The identifier for the remote endpoint.
// quality - The new quality for the connection. // quality - The new quality for the connection.
OnBandwidthChanged(string endpoint_id, int32 quality); OnBandwidthChanged(string endpoint_id, Medium medium);
}; };
// Listener for payload status. Methods in this interface are called from // Listener for payload status. Methods in this interface are called from
......
...@@ -223,3 +223,16 @@ enum BandwidthQuality { ...@@ -223,3 +223,16 @@ enum BandwidthQuality {
// High quality, e.g. connected via WebRTC or WiFi LAN. // High quality, e.g. connected via WebRTC or WiFi LAN.
kHigh, kHigh,
}; };
enum Medium {
kUnknown,
kMdns,
kBluetooth,
kWifiHotspot,
kBle,
kWifiLan,
kWifiAware,
kNfc,
kWifiDirect,
kWebRtc,
};
...@@ -300,6 +300,7 @@ source_set("core_v2_internal") { ...@@ -300,6 +300,7 @@ source_set("core_v2_internal") {
"src/cpp/core_v2/internal/ble_endpoint_channel.cc", "src/cpp/core_v2/internal/ble_endpoint_channel.cc",
"src/cpp/core_v2/internal/bluetooth_device_name.cc", "src/cpp/core_v2/internal/bluetooth_device_name.cc",
"src/cpp/core_v2/internal/bluetooth_endpoint_channel.cc", "src/cpp/core_v2/internal/bluetooth_endpoint_channel.cc",
"src/cpp/core_v2/internal/bwu_manager.cc",
"src/cpp/core_v2/internal/client_proxy.cc", "src/cpp/core_v2/internal/client_proxy.cc",
"src/cpp/core_v2/internal/encryption_runner.cc", "src/cpp/core_v2/internal/encryption_runner.cc",
"src/cpp/core_v2/internal/endpoint_channel_manager.cc", "src/cpp/core_v2/internal/endpoint_channel_manager.cc",
...@@ -314,18 +315,22 @@ source_set("core_v2_internal") { ...@@ -314,18 +315,22 @@ source_set("core_v2_internal") {
"src/cpp/core_v2/internal/payload_manager.cc", "src/cpp/core_v2/internal/payload_manager.cc",
"src/cpp/core_v2/internal/pcp_manager.cc", "src/cpp/core_v2/internal/pcp_manager.cc",
"src/cpp/core_v2/internal/service_controller_router.cc", "src/cpp/core_v2/internal/service_controller_router.cc",
"src/cpp/core_v2/internal/webrtc_bwu_handler.cc",
"src/cpp/core_v2/internal/webrtc_endpoint_channel.cc", "src/cpp/core_v2/internal/webrtc_endpoint_channel.cc",
"src/cpp/core_v2/internal/wifi_lan_endpoint_channel.cc", "src/cpp/core_v2/internal/wifi_lan_endpoint_channel.cc",
"src/cpp/core_v2/internal/wifi_lan_service_info.cc", "src/cpp/core_v2/internal/wifi_lan_service_info.cc",
] ]
public = [ public = [
"src/cpp/core/internal/message_lite.h", "src/cpp/core/internal/message_lite.h",
"src/cpp/core_v2/internal/base_bwu_handler.h",
"src/cpp/core_v2/internal/base_endpoint_channel.h", "src/cpp/core_v2/internal/base_endpoint_channel.h",
"src/cpp/core_v2/internal/base_pcp_handler.h", "src/cpp/core_v2/internal/base_pcp_handler.h",
"src/cpp/core_v2/internal/ble_advertisement.h", "src/cpp/core_v2/internal/ble_advertisement.h",
"src/cpp/core_v2/internal/ble_endpoint_channel.h", "src/cpp/core_v2/internal/ble_endpoint_channel.h",
"src/cpp/core_v2/internal/bluetooth_device_name.h", "src/cpp/core_v2/internal/bluetooth_device_name.h",
"src/cpp/core_v2/internal/bluetooth_endpoint_channel.h", "src/cpp/core_v2/internal/bluetooth_endpoint_channel.h",
"src/cpp/core_v2/internal/bwu_handler.h",
"src/cpp/core_v2/internal/bwu_manager.h",
"src/cpp/core_v2/internal/client_proxy.h", "src/cpp/core_v2/internal/client_proxy.h",
"src/cpp/core_v2/internal/encryption_runner.h", "src/cpp/core_v2/internal/encryption_runner.h",
"src/cpp/core_v2/internal/endpoint_channel.h", "src/cpp/core_v2/internal/endpoint_channel.h",
...@@ -344,6 +349,7 @@ source_set("core_v2_internal") { ...@@ -344,6 +349,7 @@ source_set("core_v2_internal") {
"src/cpp/core_v2/internal/pcp_manager.h", "src/cpp/core_v2/internal/pcp_manager.h",
"src/cpp/core_v2/internal/service_controller.h", "src/cpp/core_v2/internal/service_controller.h",
"src/cpp/core_v2/internal/service_controller_router.h", "src/cpp/core_v2/internal/service_controller_router.h",
"src/cpp/core_v2/internal/webrtc_bwu_handler.h",
"src/cpp/core_v2/internal/webrtc_endpoint_channel.h", "src/cpp/core_v2/internal/webrtc_endpoint_channel.h",
"src/cpp/core_v2/internal/wifi_lan_endpoint_channel.h", "src/cpp/core_v2/internal/wifi_lan_endpoint_channel.h",
"src/cpp/core_v2/internal/wifi_lan_service_info.h", "src/cpp/core_v2/internal/wifi_lan_service_info.h",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment