Commit ba888e64 authored by Michael Hansen's avatar Michael Hansen Committed by Commit Bot

[Nearby] Inject new options during Nearby Connections advertising.

This is a follow-up from the Nearby Connections uprev to add the
|enable_bluetooth_listening| advertising option which allows listening
on incoming Bluetooth Classic connections.

Bug: 1131986
Change-Id: I76c5ee5583264e0e65afdc6f48db4455922f5c1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2432197
Commit-Queue: Michael Hansen <hansenmichael@google.com>
Reviewed-by: default avatarAlex Gough <ajgo@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811405}
parent ceada96f
......@@ -82,8 +82,9 @@ void NearbyConnectionsManagerImpl::StartAdvertising(
}
bool is_high_power = power_level == PowerLevel::kHighPower;
bool use_ble = !is_high_power;
auto allowed_mediums = MediumSelection::New(
/*bluetooth=*/is_high_power, /*ble=*/!is_high_power,
/*bluetooth=*/is_high_power, /*ble=*/use_ble,
ShouldEnableWebRtc(data_usage, power_level),
/*wifi_lan=*/is_high_power && kIsWifiLanSupported);
......@@ -98,6 +99,7 @@ void NearbyConnectionsManagerImpl::StartAdvertising(
kStrategy, std::move(allowed_mediums),
/*auto_upgrade_bandwidth=*/is_high_power,
/*enforce_topology_constraints=*/true,
/*enable_bluetooth_listening=*/use_ble,
/*fast_advertisement_service_uuid=*/
device::BluetoothUUID(kFastAdvertisementServiceUuid)),
std::move(lifecycle_listener), std::move(callback));
......
......@@ -1216,8 +1216,7 @@ class NearbyConnectionsManagerImplTestMediums
: public NearbyConnectionsManagerImplTest,
public testing::WithParamInterface<MediumsTestParam> {};
TEST_P(NearbyConnectionsManagerImplTestMediums,
StartAdvertising_MediumSelection) {
TEST_P(NearbyConnectionsManagerImplTestMediums, StartAdvertising_Options) {
const MediumsTestParam& param = GetParam();
PowerLevel power_level = std::get<0>(param);
DataUsage data_usage = std::get<1>(param);
......@@ -1255,6 +1254,7 @@ TEST_P(NearbyConnectionsManagerImplTestMediums,
NearbyConnectionsMojom::StartAdvertisingCallback callback) {
EXPECT_EQ(is_high_power, options->auto_upgrade_bandwidth);
EXPECT_EQ(expected_mediums, options->allowed_mediums);
EXPECT_EQ(!is_high_power, options->enable_bluetooth_listening);
std::move(callback).Run(Status::kSuccess);
});
EXPECT_CALL(callback, Run(testing::Eq(Status::kSuccess)));
......
......@@ -203,6 +203,7 @@ void NearbyConnections::StartAdvertising(
.allowed = MediumSelectorFromMojom(options->allowed_mediums.get()),
.auto_upgrade_bandwidth = options->auto_upgrade_bandwidth,
.enforce_topology_constraints = options->enforce_topology_constraints,
.enable_bluetooth_listening = options->enable_bluetooth_listening,
.fast_advertisement_service_uuid =
options->fast_advertisement_service_uuid.canonical_value()};
......
......@@ -47,14 +47,16 @@ const char kPayload[] = {0x0f, 0x0a, 0x0c, 0x0e};
const char kBluetoothMacAddress[] = {0x00, 0x00, 0xe6, 0x88, 0x64, 0x13};
mojom::AdvertisingOptionsPtr CreateAdvertisingOptions() {
bool use_ble = false;
auto allowed_mediums = mojom::MediumSelection::New(/*bluetooth=*/true,
/*ble=*/false,
/*ble=*/use_ble,
/*web_rtc=*/false,
/*wifi_lan=*/true);
return mojom::AdvertisingOptions::New(
mojom::Strategy::kP2pPointToPoint, std::move(allowed_mediums),
/*auto_upgrade_bandwidth=*/true,
/*enforce_topology_constraints=*/true,
/*enable_bluetooth_listening=*/use_ble,
/*fast_advertisement_service_uuid=*/
device::BluetoothUUID(kFastAdvertisementServiceUuid));
}
......
......@@ -134,6 +134,9 @@ struct AdvertisingOptions {
// you can initially connect as a kP2pCluster and then trim connections until
// you match kP2pStar or kP2pPointToPoint before upgrading the bandwidth.
bool enforce_topology_constraints = true;
// By default, this option is false. If true, this allows listening on
// incoming Bluetooth Classic connections while BLE advertising.
bool enable_bluetooth_listening = false;
// Optional. If set, BLE advertisements will be in their "fast advertisement"
// form, use this UUID, and non-connectable; if empty, BLE advertisements
// will otherwise be normal and connectable.
......
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