Commit 569f9d9b authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

[Nearby] Specify BLE vs Bluetooth during advertising.

Before this change, Nearby advertising, even in "low power" mode, was
always advertising over Bluetooth Classic -- poor for battery
performance, and dangerous for users' privacy.

Bug: 1128179
Change-Id: Idfeab6e02c442183ec03acb9b00cc048750611e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2413175
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarJames Vecore <vecore@google.com>
Reviewed-by: default avatarAlex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809006}
parent c1258b02
......@@ -83,7 +83,8 @@ void NearbyConnectionsManagerImpl::StartAdvertising(
bool is_high_power = power_level == PowerLevel::kHighPower;
auto allowed_mediums = MediumSelection::New(
/*bluetooth=*/is_high_power, ShouldEnableWebRtc(data_usage, power_level),
/*bluetooth=*/is_high_power, /*ble=*/!is_high_power,
ShouldEnableWebRtc(data_usage, power_level),
/*wifi_lan=*/is_high_power && kIsWifiLanSupported);
mojo::PendingRemote<ConnectionLifecycleListener> lifecycle_listener;
......@@ -169,7 +170,7 @@ void NearbyConnectionsManagerImpl::Connect(
auto allowed_mediums = MediumSelection::New(
/*bluetooth=*/true,
ShouldEnableWebRtc(data_usage, PowerLevel::kHighPower),
/*ble=*/false, ShouldEnableWebRtc(data_usage, PowerLevel::kHighPower),
/*wifi_lan=*/kIsWifiLanSupported);
mojo::PendingRemote<ConnectionLifecycleListener> lifecycle_listener;
......
......@@ -466,6 +466,7 @@ TEST_P(NearbyConnectionsManagerImplTestConnectionMediums,
// TODO(crbug.com/1129069): Update when WiFi LAN is supported.
auto expected_mediums = MediumSelection::New(
/*bluetooth=*/true,
/*ble=*/false,
/*web_rtc=*/should_use_web_rtc,
/*wifi_lan=*/false);
......@@ -1236,6 +1237,7 @@ TEST_P(NearbyConnectionsManagerImplTestMediums,
// TODO(crbug.com/1129069): Update when WiFi LAN is supported.
auto expected_mediums = MediumSelection::New(
/*bluetooth=*/is_high_power,
/*ble=*/!is_high_power,
/*web_rtc=*/should_use_web_rtc,
/*wifi_lan=*/false);
......
......@@ -129,6 +129,7 @@ BooleanMediumSelector MediumSelectorFromMojom(
mojom::MediumSelection* allowed_mediums) {
return BooleanMediumSelector{
.bluetooth = allowed_mediums->bluetooth,
.ble = allowed_mediums->ble,
.web_rtc = allowed_mediums->web_rtc,
.wifi_lan = allowed_mediums->wifi_lan,
};
......
......@@ -48,6 +48,7 @@ const char kBluetoothMacAddress[] = {0x00, 0x00, 0xe6, 0x88, 0x64, 0x13};
mojom::AdvertisingOptionsPtr CreateAdvertisingOptions() {
auto allowed_mediums = mojom::MediumSelection::New(/*bluetooth=*/true,
/*ble=*/false,
/*web_rtc=*/false,
/*wifi_lan=*/true);
return mojom::AdvertisingOptions::New(
......@@ -61,6 +62,7 @@ mojom::AdvertisingOptionsPtr CreateAdvertisingOptions() {
mojom::ConnectionOptionsPtr CreateConnectionOptions(
base::Optional<std::vector<uint8_t>> bluetooth_mac_address) {
auto allowed_mediums = mojom::MediumSelection::New(/*bluetooth=*/true,
/*ble=*/false,
/*web_rtc=*/false,
/*wifi_lan=*/true);
return mojom::ConnectionOptions::New(std::move(allowed_mediums),
......
......@@ -107,6 +107,8 @@ enum Strategy {
struct MediumSelection {
// Whether Bluetooth should be allowed.
bool bluetooth;
// Whether BLE should be allowed.
bool ble;
// Whether WebRTC should be allowed.
bool web_rtc;
// Whether WiFi LAN should be allowed.
......
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