[Bluetooth] Remove PauseDiscovery and UnpauseDiscovery calls
The PauseDiscovery and UnpauseDiscovery workaround is no longer needed since the kernel now handles Create Connection while Inquiry is in progress (CL:2583225). Bug: b:168725519, chromium:1059953 Change-Id: I94adb3e71c9d8f4264e670ab3d97df1bc1ff0ec6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2583463 Commit-Queue: Sonny Sasaka <sonnysasaka@chromium.org> Reviewed-by: Reilly Grant <reillyg@chromium.org> Reviewed-by: Ryan Hansberry <hansberry@chromium.org> Cr-Commit-Position: refs/heads/master@{#835938}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d449f5f1df
commit
a087cfc002
@ -2377,10 +2377,6 @@ TEST_F(BluetoothBlueZTest, ForgetUnpairedDevice) {
|
||||
ASSERT_TRUE(device->IsConnected());
|
||||
ASSERT_FALSE(device->IsConnecting());
|
||||
|
||||
// Pause discovery to connect without pair.
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
// Make sure the trusted property has been set to true.
|
||||
bluez::FakeBluetoothDeviceClient::Properties* properties =
|
||||
fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath(
|
||||
@ -2430,10 +2426,6 @@ TEST_F(BluetoothBlueZTest, ConnectPairedDevice) {
|
||||
|
||||
EXPECT_TRUE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Pause discovery to connect without pair.
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, ConnectUnpairableDevice) {
|
||||
@ -2464,10 +2456,6 @@ TEST_F(BluetoothBlueZTest, ConnectUnpairableDevice) {
|
||||
EXPECT_TRUE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Pause discovery to connect without pair.
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
// Make sure the trusted property has been set to true.
|
||||
bluez::FakeBluetoothDeviceClient::Properties* properties =
|
||||
fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath(
|
||||
@ -2499,10 +2487,6 @@ TEST_F(BluetoothBlueZTest, ConnectConnectedDevice) {
|
||||
|
||||
ASSERT_TRUE(device->IsConnected());
|
||||
|
||||
// Pause discovery to connect without pair.
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
// Connect again; since the device is already Connected, this shouldn't do
|
||||
// anything to initiate the connection.
|
||||
TestBluetoothAdapterObserver observer(adapter_);
|
||||
@ -2520,10 +2504,6 @@ TEST_F(BluetoothBlueZTest, ConnectConnectedDevice) {
|
||||
|
||||
EXPECT_TRUE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Pause discovery to connect without pair.
|
||||
EXPECT_EQ(2, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(2, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, ConnectDeviceFails) {
|
||||
@ -2551,10 +2531,6 @@ TEST_F(BluetoothBlueZTest, ConnectDeviceFails) {
|
||||
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Pause discovery to connect without pair.
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
// Tests that discovery is unpaused if the device gets removed during a
|
||||
@ -2570,9 +2546,6 @@ TEST_F(BluetoothBlueZTest, RemoveDeviceDuringConnection) {
|
||||
device->Connect(nullptr, GetCallback(),
|
||||
base::BindOnce(&BluetoothBlueZTest::ConnectErrorCallback,
|
||||
base::Unretained(this)));
|
||||
// We pause discovery before connecting.
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
EXPECT_EQ(0, callback_count_);
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
@ -2588,10 +2561,6 @@ TEST_F(BluetoothBlueZTest, RemoveDeviceDuringConnection) {
|
||||
EXPECT_EQ(0, error_callback_count_);
|
||||
|
||||
EXPECT_EQ(1, observer.device_removed_count());
|
||||
|
||||
// If the device gets removed, we should still unpause discovery.
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, DisconnectDevice) {
|
||||
@ -2613,10 +2582,6 @@ TEST_F(BluetoothBlueZTest, DisconnectDevice) {
|
||||
ASSERT_TRUE(device->IsConnected());
|
||||
ASSERT_FALSE(device->IsConnecting());
|
||||
|
||||
// Pause discovery to connect without pair.
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
// Disconnect the device, we should see the observer method fire and the
|
||||
// device get dropped.
|
||||
TestBluetoothAdapterObserver observer(adapter_);
|
||||
@ -2771,10 +2736,6 @@ TEST_F(BluetoothBlueZTest, PairLegacyAutopair) {
|
||||
EXPECT_TRUE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Connect after pair.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
EXPECT_TRUE(device->IsPaired());
|
||||
|
||||
// Verify is a HID device and is connectable.
|
||||
@ -2828,10 +2789,6 @@ TEST_F(BluetoothBlueZTest, PairDisplayPinCode) {
|
||||
EXPECT_TRUE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Connect after pair.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
EXPECT_TRUE(device->IsPaired());
|
||||
|
||||
// Verify is a HID device and is connectable.
|
||||
@ -2905,10 +2862,6 @@ TEST_F(BluetoothBlueZTest, PairDisplayPasskey) {
|
||||
EXPECT_TRUE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Connect after pair.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
EXPECT_TRUE(device->IsPaired());
|
||||
|
||||
// Verify is a HID device.
|
||||
@ -2963,10 +2916,6 @@ TEST_F(BluetoothBlueZTest, PairRequestPinCode) {
|
||||
EXPECT_TRUE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Connect after pair.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
EXPECT_TRUE(device->IsPaired());
|
||||
|
||||
// Verify is not a HID device.
|
||||
@ -3022,10 +2971,6 @@ TEST_F(BluetoothBlueZTest, PairConfirmPasskey) {
|
||||
EXPECT_TRUE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Connect after pair.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
EXPECT_TRUE(device->IsPaired());
|
||||
|
||||
// Non HID devices are always connectable.
|
||||
@ -3077,10 +3022,6 @@ TEST_F(BluetoothBlueZTest, PairRequestPasskey) {
|
||||
EXPECT_TRUE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Connect after pair.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
EXPECT_TRUE(device->IsPaired());
|
||||
|
||||
// Non HID devices are always connectable.
|
||||
@ -3128,10 +3069,6 @@ TEST_F(BluetoothBlueZTest, PairJustWorks) {
|
||||
EXPECT_TRUE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Connect after pair.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
EXPECT_TRUE(device->IsPaired());
|
||||
|
||||
// Non HID devices are always connectable.
|
||||
@ -3176,10 +3113,6 @@ TEST_F(BluetoothBlueZTest, PairUnpairableDeviceFails) {
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
EXPECT_FALSE(device->IsPaired());
|
||||
|
||||
// No connection.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, PairingFails) {
|
||||
@ -3215,10 +3148,6 @@ TEST_F(BluetoothBlueZTest, PairingFails) {
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
EXPECT_FALSE(device->IsPaired());
|
||||
|
||||
// No connection.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, PairingFailsAtConnection) {
|
||||
@ -3258,10 +3187,6 @@ TEST_F(BluetoothBlueZTest, PairingFailsAtConnection) {
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
|
||||
// Connect after pair.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
|
||||
EXPECT_TRUE(device->IsPaired());
|
||||
|
||||
// Make sure the trusted property has been set to true still (since pairing
|
||||
@ -3308,10 +3233,6 @@ TEST_F(BluetoothBlueZTest, PairingRejectedAtPinCode) {
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
EXPECT_FALSE(device->IsPaired());
|
||||
|
||||
// No connection.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, PairingCancelledAtPinCode) {
|
||||
@ -3350,10 +3271,6 @@ TEST_F(BluetoothBlueZTest, PairingCancelledAtPinCode) {
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
EXPECT_FALSE(device->IsPaired());
|
||||
|
||||
// No connection.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, PairingRejectedAtPasskey) {
|
||||
@ -3392,10 +3309,6 @@ TEST_F(BluetoothBlueZTest, PairingRejectedAtPasskey) {
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
EXPECT_FALSE(device->IsPaired());
|
||||
|
||||
// No connection.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, PairingCancelledAtPasskey) {
|
||||
@ -3434,10 +3347,6 @@ TEST_F(BluetoothBlueZTest, PairingCancelledAtPasskey) {
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
EXPECT_FALSE(device->IsPaired());
|
||||
|
||||
// No connection.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, PairingRejectedAtConfirmation) {
|
||||
@ -3476,10 +3385,6 @@ TEST_F(BluetoothBlueZTest, PairingRejectedAtConfirmation) {
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
EXPECT_FALSE(device->IsPaired());
|
||||
|
||||
// No connection.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, PairingCancelledAtConfirmation) {
|
||||
@ -3518,10 +3423,6 @@ TEST_F(BluetoothBlueZTest, PairingCancelledAtConfirmation) {
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
EXPECT_FALSE(device->IsPaired());
|
||||
|
||||
// No connection.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, PairingCancelledInFlight) {
|
||||
@ -3559,10 +3460,6 @@ TEST_F(BluetoothBlueZTest, PairingCancelledInFlight) {
|
||||
EXPECT_FALSE(device->IsConnected());
|
||||
EXPECT_FALSE(device->IsConnecting());
|
||||
EXPECT_FALSE(device->IsPaired());
|
||||
|
||||
// No connection.
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(0, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, IncomingPairRequestPinCode) {
|
||||
@ -4082,10 +3979,6 @@ TEST_F(BluetoothBlueZTest, GetConnectionInfoForConnectedDevice) {
|
||||
EXPECT_EQ(-10, conn_info.rssi);
|
||||
EXPECT_EQ(3, conn_info.transmit_power);
|
||||
EXPECT_EQ(4, conn_info.max_transmit_power);
|
||||
|
||||
// Pause discovery to connect without pair.
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetPauseCount());
|
||||
EXPECT_EQ(1, fake_bluetooth_adapter_client_->GetUnpauseCount());
|
||||
}
|
||||
|
||||
TEST_F(BluetoothBlueZTest, GetDiscoverableTimeout) {
|
||||
|
@ -170,14 +170,6 @@ BluetoothDeviceBlueZ::~BluetoothDeviceBlueZ() {
|
||||
adapter()->NotifyGattServiceRemoved(
|
||||
static_cast<BluetoothRemoteGattServiceBlueZ*>(iter.second.get()));
|
||||
}
|
||||
|
||||
// We pause discovery when trying to connect. Ensure discovery is unpaused if
|
||||
// we get destroyed during a pending connection.
|
||||
if (IsConnecting()) {
|
||||
BLUETOOTH_LOG(EVENT) << object_path_.value()
|
||||
<< ": Unpausing discovery. Device removed.";
|
||||
UnpauseDiscovery();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t BluetoothDeviceBlueZ::GetBluetoothClass() const {
|
||||
@ -500,32 +492,8 @@ void BluetoothDeviceBlueZ::Connect(
|
||||
base::AdaptCallbackForRepeating(std::move(error_callback));
|
||||
|
||||
if (IsPaired() || !pairing_delegate) {
|
||||
BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Pausing discovery";
|
||||
// No need to pair, or unable to, skip straight to connection.
|
||||
bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->PauseDiscovery(
|
||||
adapter()->object_path(),
|
||||
base::BindOnce(
|
||||
[](base::WeakPtr<BluetoothDeviceBlueZ> weak_ptr,
|
||||
base::OnceClosure callback,
|
||||
ConnectErrorCallback error_callback) {
|
||||
BLUETOOTH_LOG(EVENT) << "Successfully paused discovery";
|
||||
if (weak_ptr)
|
||||
weak_ptr->ConnectInternal(std::move(callback),
|
||||
std::move(error_callback));
|
||||
},
|
||||
weak_ptr_factory_.GetWeakPtr(), dupe_callback, dupe_error_callback),
|
||||
base::BindOnce(
|
||||
[](base::WeakPtr<BluetoothDeviceBlueZ> weak_ptr,
|
||||
base::OnceClosure callback, ConnectErrorCallback error_callback,
|
||||
const std::string& error_name,
|
||||
const std::string& error_message) {
|
||||
BLUETOOTH_LOG(EVENT) << "Failed to pause discovery";
|
||||
if (weak_ptr)
|
||||
weak_ptr->ConnectInternal(std::move(callback),
|
||||
std::move(error_callback));
|
||||
},
|
||||
weak_ptr_factory_.GetWeakPtr(), dupe_callback,
|
||||
dupe_error_callback));
|
||||
ConnectInternal(dupe_callback, dupe_error_callback);
|
||||
} else {
|
||||
// Initiate high-security connection with pairing.
|
||||
BeginPairing(pairing_delegate);
|
||||
@ -962,7 +930,6 @@ void BluetoothDeviceBlueZ::ConnectInternal(
|
||||
void BluetoothDeviceBlueZ::OnConnect(base::OnceClosure callback) {
|
||||
BLUETOOTH_LOG(EVENT) << object_path_.value()
|
||||
<< ": Unpausing discovery after connection";
|
||||
UnpauseDiscovery();
|
||||
if (--num_connecting_calls_ == 0)
|
||||
adapter()->NotifyDeviceChanged(this);
|
||||
|
||||
@ -980,7 +947,6 @@ void BluetoothDeviceBlueZ::OnConnectError(ConnectErrorCallback error_callback,
|
||||
const std::string& error_message) {
|
||||
BLUETOOTH_LOG(EVENT) << object_path_.value()
|
||||
<< ": Unpausing discovery after failed connection";
|
||||
UnpauseDiscovery();
|
||||
|
||||
if (--num_connecting_calls_ == 0)
|
||||
adapter()->NotifyDeviceChanged(this);
|
||||
@ -1105,15 +1071,4 @@ void BluetoothDeviceBlueZ::OnForgetError(ErrorCallback error_callback,
|
||||
std::move(error_callback).Run();
|
||||
}
|
||||
|
||||
void BluetoothDeviceBlueZ::UnpauseDiscovery() {
|
||||
bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->UnpauseDiscovery(
|
||||
adapter()->object_path(), base::BindOnce([]() {
|
||||
BLUETOOTH_LOG(EVENT) << "Successfully un-paused discovery";
|
||||
}),
|
||||
base::BindOnce(
|
||||
[](const std::string& error_name, const std::string& error_message) {
|
||||
BLUETOOTH_LOG(EVENT) << "Failed to un-pause discovery";
|
||||
}));
|
||||
}
|
||||
|
||||
} // namespace bluez
|
||||
|
@ -286,8 +286,6 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceBlueZ
|
||||
const std::string& error_name,
|
||||
const std::string& error_message);
|
||||
|
||||
void UnpauseDiscovery();
|
||||
|
||||
// The dbus object path of the device object.
|
||||
dbus::ObjectPath object_path_;
|
||||
|
||||
|
@ -277,56 +277,6 @@ class BluetoothAdapterClientImpl : public BluetoothAdapterClient,
|
||||
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
|
||||
}
|
||||
|
||||
// BluetoothAdapterClient override.
|
||||
void PauseDiscovery(const dbus::ObjectPath& object_path,
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback) override {
|
||||
dbus::MethodCall method_call(bluetooth_adapter::kBluetoothAdapterInterface,
|
||||
bluetooth_adapter::kPauseDiscovery);
|
||||
dbus::MessageWriter writer(&method_call);
|
||||
writer.AppendBool(false); // Not a system suspend
|
||||
|
||||
dbus::ObjectProxy* object_proxy =
|
||||
object_manager_->GetObjectProxy(object_path);
|
||||
if (!object_proxy) {
|
||||
std::move(error_callback).Run(kUnknownAdapterError, "");
|
||||
return;
|
||||
}
|
||||
|
||||
object_proxy->CallMethodWithErrorCallback(
|
||||
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
|
||||
base::BindOnce(&BluetoothAdapterClientImpl::OnSuccess,
|
||||
weak_ptr_factory_.GetWeakPtr(), std::move(callback)),
|
||||
base::BindOnce(&BluetoothAdapterClientImpl::OnError,
|
||||
weak_ptr_factory_.GetWeakPtr(),
|
||||
std::move(error_callback)));
|
||||
}
|
||||
|
||||
// BluetoothAdapterClient override.
|
||||
void UnpauseDiscovery(const dbus::ObjectPath& object_path,
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback) override {
|
||||
dbus::MethodCall method_call(bluetooth_adapter::kBluetoothAdapterInterface,
|
||||
bluetooth_adapter::kUnpauseDiscovery);
|
||||
dbus::MessageWriter writer(&method_call);
|
||||
writer.AppendBool(false); // Not a system suspend
|
||||
|
||||
dbus::ObjectProxy* object_proxy =
|
||||
object_manager_->GetObjectProxy(object_path);
|
||||
if (!object_proxy) {
|
||||
std::move(error_callback).Run(kUnknownAdapterError, "");
|
||||
return;
|
||||
}
|
||||
|
||||
object_proxy->CallMethodWithErrorCallback(
|
||||
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
|
||||
base::BindOnce(&BluetoothAdapterClientImpl::OnSuccess,
|
||||
weak_ptr_factory_.GetWeakPtr(), std::move(callback)),
|
||||
base::BindOnce(&BluetoothAdapterClientImpl::OnError,
|
||||
weak_ptr_factory_.GetWeakPtr(),
|
||||
std::move(error_callback)));
|
||||
}
|
||||
|
||||
// BluetoothAdapterClient override.
|
||||
void RemoveDevice(const dbus::ObjectPath& object_path,
|
||||
const dbus::ObjectPath& device_path,
|
||||
|
@ -187,16 +187,6 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothAdapterClient : public BluezDBusClient {
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback);
|
||||
|
||||
// Pauses all discovery sessions.
|
||||
virtual void PauseDiscovery(const dbus::ObjectPath& object_path,
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback) = 0;
|
||||
|
||||
// Unpauses all discovery sessions.
|
||||
virtual void UnpauseDiscovery(const dbus::ObjectPath& object_path,
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback) = 0;
|
||||
|
||||
// Removes from the adapter with object path |object_path| the remote
|
||||
// device with object path |object_path| from the list of known devices
|
||||
// and discards any pairing information.
|
||||
|
@ -77,8 +77,6 @@ FakeBluetoothAdapterClient::FakeBluetoothAdapterClient()
|
||||
: visible_(true),
|
||||
second_visible_(false),
|
||||
discovering_count_(0),
|
||||
pause_count_(0),
|
||||
unpause_count_(0),
|
||||
set_discovery_filter_should_fail_(false),
|
||||
simulation_interval_ms_(kSimulationIntervalMs),
|
||||
last_handle_(0) {
|
||||
@ -209,22 +207,6 @@ void FakeBluetoothAdapterClient::UpdateDiscoveringProperty(bool discovering) {
|
||||
properties_->discovering.ReplaceValue(discovering);
|
||||
}
|
||||
|
||||
void FakeBluetoothAdapterClient::PauseDiscovery(
|
||||
const dbus::ObjectPath& object_path,
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback) {
|
||||
++pause_count_;
|
||||
std::move(callback).Run();
|
||||
}
|
||||
|
||||
void FakeBluetoothAdapterClient::UnpauseDiscovery(
|
||||
const dbus::ObjectPath& object_path,
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback) {
|
||||
++unpause_count_;
|
||||
std::move(callback).Run();
|
||||
}
|
||||
|
||||
void FakeBluetoothAdapterClient::RemoveDevice(
|
||||
const dbus::ObjectPath& object_path,
|
||||
const dbus::ObjectPath& device_path,
|
||||
|
@ -40,8 +40,6 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAdapterClient
|
||||
|
||||
FakeBluetoothAdapterClient();
|
||||
~FakeBluetoothAdapterClient() override;
|
||||
int GetPauseCount() { return pause_count_; }
|
||||
int GetUnpauseCount() { return unpause_count_; }
|
||||
|
||||
// BluetoothAdapterClient overrides
|
||||
void Init(dbus::Bus* bus, const std::string& bluetooth_service_name) override;
|
||||
@ -53,12 +51,6 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAdapterClient
|
||||
ResponseCallback callback) override;
|
||||
void StopDiscovery(const dbus::ObjectPath& object_path,
|
||||
ResponseCallback callback) override;
|
||||
void PauseDiscovery(const dbus::ObjectPath& object_path,
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback) override;
|
||||
void UnpauseDiscovery(const dbus::ObjectPath& object_path,
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback) override;
|
||||
void RemoveDevice(const dbus::ObjectPath& object_path,
|
||||
const dbus::ObjectPath& device_path,
|
||||
base::OnceClosure callback,
|
||||
@ -140,12 +132,6 @@ class DEVICE_BLUETOOTH_EXPORT FakeBluetoothAdapterClient
|
||||
// Number of times we've been asked to discover.
|
||||
int discovering_count_;
|
||||
|
||||
// Number of times we've been asked to pause discovery.
|
||||
int pause_count_;
|
||||
|
||||
// Number of times we've been asked to unpause discovery.
|
||||
int unpause_count_;
|
||||
|
||||
// Current discovery filter
|
||||
std::unique_ptr<DiscoveryFilter> discovery_filter_;
|
||||
|
||||
|
@ -377,18 +377,6 @@ class DEVICE_BLUETOOTH_EXPORT TestBluetoothAdapterClient
|
||||
std::move(callback).Run(base::nullopt);
|
||||
}
|
||||
|
||||
void PauseDiscovery(const dbus::ObjectPath& object_path,
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback) override {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void UnpauseDiscovery(const dbus::ObjectPath& object_path,
|
||||
base::OnceClosure callback,
|
||||
ErrorCallback error_callback) override {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void RemoveDevice(const dbus::ObjectPath& object_path,
|
||||
const dbus::ObjectPath& device_path,
|
||||
base::OnceClosure callback,
|
||||
|
Reference in New Issue
Block a user