Commit a29a5d73 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS Tether] Filter BLE discovery to LE devices only.

Instant Tethering only uses BLE connections. This filter was not
previously used due to a potential workaround which had been resolved
(see https://crbug.com/759090).

Bug: 759091, 672263
Change-Id: I161efd638f683d21596e445a5f1db2f90a838e75
Reviewed-on: https://chromium-review.googlesource.com/919426Reviewed-by: default avatarRahul Chaturvedi <rkc@chromium.org>
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537140}
parent b71e9cb2
......@@ -87,13 +87,9 @@ void BleSynchronizer::ProcessQueue() {
current_command_->start_discovery_args.get();
DCHECK(start_discovery_args);
// Note: Ideally, we would use a filter for only LE devices here. However,
// using a filter here triggers a bug in some kernel implementations which
// causes LE scanning to toggle rapidly on and off. This can cause race
// conditions which result in Bluetooth bugs. See crbug.com/759090.
// TODO(mcchou): Once these issues have been resolved, add the filter
// back. See crbug.com/759091.
bluetooth_adapter_->StartDiscoverySession(
bluetooth_adapter_->StartDiscoverySessionWithFilter(
std::make_unique<device::BluetoothDiscoveryFilter>(
device::BLUETOOTH_TRANSPORT_LE),
base::Bind(&BleSynchronizer::OnDiscoverySessionStarted,
weak_ptr_factory_.GetWeakPtr()),
base::Bind(&BleSynchronizer::OnErrorStartingDiscoverySession,
......
......@@ -92,6 +92,10 @@ class MockBluetoothAdapterWithAdvertisements
MOCK_METHOD1(RegisterAdvertisementWithArgsStruct,
void(RegisterAdvertisementArgs*));
MOCK_METHOD3(StartDiscoverySessionWithFilterRaw,
void(device::BluetoothDiscoveryFilter*,
const device::BluetoothAdapter::DiscoverySessionCallback&,
const device::BluetoothAdapter::ErrorCallback&));
void RegisterAdvertisement(
std::unique_ptr<device::BluetoothAdvertisement::Data> advertisement_data,
......@@ -102,6 +106,14 @@ class MockBluetoothAdapterWithAdvertisements
*advertisement_data->service_uuids(), callback, error_callback));
}
void StartDiscoverySessionWithFilter(
std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter,
const device::BluetoothAdapter::DiscoverySessionCallback& callback,
const device::BluetoothAdapter::ErrorCallback& error_callback) override {
StartDiscoverySessionWithFilterRaw(discovery_filter.get(), callback,
error_callback);
}
protected:
~MockBluetoothAdapterWithAdvertisements() override = default;
};
......@@ -208,7 +220,7 @@ class BleSynchronizerTest : public testing::Test {
ON_CALL(*mock_adapter_, RegisterAdvertisementWithArgsStruct(_))
.WillByDefault(
Invoke(this, &BleSynchronizerTest::OnAdapterRegisterAdvertisement));
ON_CALL(*mock_adapter_, StartDiscoverySession(_, _))
ON_CALL(*mock_adapter_, StartDiscoverySessionWithFilterRaw(_, _, _))
.WillByDefault(
Invoke(this, &BleSynchronizerTest::OnAdapterStartDiscoverySession));
......@@ -234,8 +246,11 @@ class BleSynchronizerTest : public testing::Test {
}
void OnAdapterStartDiscoverySession(
device::BluetoothDiscoveryFilter* discovery_filter,
const device::BluetoothAdapter::DiscoverySessionCallback& callback,
const device::BluetoothAdapter::ErrorCallback& error_callback) {
EXPECT_EQ(device::BluetoothTransport::BLUETOOTH_TRANSPORT_LE,
discovery_filter->GetTransport());
start_discovery_args_list_.emplace_back(base::WrapUnique(
new StartDiscoverySessionArgs(callback, error_callback)));
}
......
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