| Index: device/bluetooth/bluez/bluetooth_device_bluez.cc
|
| diff --git a/device/bluetooth/bluez/bluetooth_device_bluez.cc b/device/bluetooth/bluez/bluetooth_device_bluez.cc
|
| index 2df2d4379d4b185dfec6c82d249c8659ff5c232e..bc35e5d0c9e00c699c0843f6e5eeb39e961012a5 100644
|
| --- a/device/bluetooth/bluez/bluetooth_device_bluez.cc
|
| +++ b/device/bluetooth/bluez/bluetooth_device_bluez.cc
|
| @@ -15,6 +15,7 @@
|
| #include "base/metrics/histogram_macros.h"
|
| #include "base/strings/string_number_conversions.h"
|
| #include "base/strings/string_util.h"
|
| +#include "components/device_event_log/device_event_log.h"
|
| #include "dbus/bus.h"
|
| #include "device/bluetooth/bluetooth_socket.h"
|
| #include "device/bluetooth/bluetooth_socket_thread.h"
|
| @@ -79,13 +80,13 @@ void ParseModalias(const dbus::ObjectPath& object_path,
|
| return;
|
| }
|
|
|
| - if (vendor_id_source != NULL)
|
| + if (vendor_id_source != nullptr)
|
| *vendor_id_source = source_value;
|
| - if (vendor_id != NULL)
|
| + if (vendor_id != nullptr)
|
| *vendor_id = vendor_value;
|
| - if (product_id != NULL)
|
| + if (product_id != nullptr)
|
| *product_id = product_value;
|
| - if (device_id != NULL)
|
| + if (device_id != nullptr)
|
| *device_id = device_value;
|
| }
|
|
|
| @@ -164,8 +165,9 @@ BluetoothDeviceBlueZ::BluetoothDeviceBlueZ(
|
| if (IsGattServicesDiscoveryComplete()) {
|
| UpdateGattServices(object_path_);
|
| } else {
|
| - VLOG(2) << "Gatt services have not been fully resolved for device "
|
| - << object_path_.value();
|
| + BLUETOOTH_LOG(DEBUG)
|
| + << "Gatt services have not been fully resolved for device "
|
| + << object_path_.value();
|
| }
|
|
|
| // Update all the data that we cache within Chrome and do not pull from
|
| @@ -262,7 +264,7 @@ void BluetoothDeviceBlueZ::DisconnectGatt() {
|
| DCHECK(properties);
|
|
|
| if (properties->paired.value()) {
|
| - LOG(WARNING) << "Leaking connection to paired device.";
|
| + BLUETOOTH_LOG(ERROR) << "Leaking connection to paired device.";
|
| return;
|
| }
|
|
|
| @@ -281,25 +283,25 @@ std::string BluetoothDeviceBlueZ::GetAddress() const {
|
| BluetoothDevice::VendorIDSource BluetoothDeviceBlueZ::GetVendorIDSource()
|
| const {
|
| VendorIDSource vendor_id_source = VENDOR_ID_UNKNOWN;
|
| - ParseModalias(object_path_, &vendor_id_source, NULL, NULL, NULL);
|
| + ParseModalias(object_path_, &vendor_id_source, nullptr, nullptr, nullptr);
|
| return vendor_id_source;
|
| }
|
|
|
| uint16_t BluetoothDeviceBlueZ::GetVendorID() const {
|
| uint16_t vendor_id = 0;
|
| - ParseModalias(object_path_, NULL, &vendor_id, NULL, NULL);
|
| + ParseModalias(object_path_, nullptr, &vendor_id, nullptr, nullptr);
|
| return vendor_id;
|
| }
|
|
|
| uint16_t BluetoothDeviceBlueZ::GetProductID() const {
|
| uint16_t product_id = 0;
|
| - ParseModalias(object_path_, NULL, NULL, &product_id, NULL);
|
| + ParseModalias(object_path_, nullptr, nullptr, &product_id, nullptr);
|
| return product_id;
|
| }
|
|
|
| uint16_t BluetoothDeviceBlueZ::GetDeviceID() const {
|
| uint16_t device_id = 0;
|
| - ParseModalias(object_path_, NULL, NULL, NULL, &device_id);
|
| + ParseModalias(object_path_, nullptr, nullptr, nullptr, &device_id);
|
| return device_id;
|
| }
|
|
|
| @@ -359,7 +361,7 @@ bool BluetoothDeviceBlueZ::IsConnectable() const {
|
| bluez::BluetoothInputClient::Properties* input_properties =
|
| bluez::BluezDBusManager::Get()->GetBluetoothInputClient()->GetProperties(
|
| object_path_);
|
| - // GetProperties returns NULL when the device does not implement the given
|
| + // GetProperties returns nullptr when the device does not implement the given
|
| // interface. Non HID devices are normally connectable.
|
| if (!input_properties)
|
| return true;
|
| @@ -434,8 +436,9 @@ void BluetoothDeviceBlueZ::GetConnectionInfo(
|
| // DBus method call should gracefully return an error if the device is not
|
| // currently connected.
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetConnInfo(
|
| - object_path_, base::Bind(&BluetoothDeviceBlueZ::OnGetConnInfo,
|
| - weak_ptr_factory_.GetWeakPtr(), callback),
|
| + object_path_,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnGetConnInfo,
|
| + weak_ptr_factory_.GetWeakPtr(), callback),
|
| base::Bind(&BluetoothDeviceBlueZ::OnGetConnInfoError,
|
| weak_ptr_factory_.GetWeakPtr(), callback));
|
| }
|
| @@ -447,8 +450,8 @@ void BluetoothDeviceBlueZ::Connect(
|
| if (num_connecting_calls_++ == 0)
|
| adapter()->NotifyDeviceChanged(this);
|
|
|
| - VLOG(1) << object_path_.value() << ": Connecting, " << num_connecting_calls_
|
| - << " in progress";
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Connecting, "
|
| + << num_connecting_calls_ << " in progress";
|
|
|
| if (IsPaired() || !pairing_delegate) {
|
| // No need to pair, or unable to, skip straight to connection.
|
| @@ -474,8 +477,9 @@ void BluetoothDeviceBlueZ::Pair(
|
| BeginPairing(pairing_delegate);
|
|
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Pair(
|
| - object_path_, base::Bind(&BluetoothDeviceBlueZ::OnPair,
|
| - weak_ptr_factory_.GetWeakPtr(), callback),
|
| + object_path_,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnPair, weak_ptr_factory_.GetWeakPtr(),
|
| + callback),
|
| base::Bind(&BluetoothDeviceBlueZ::OnPairError,
|
| weak_ptr_factory_.GetWeakPtr(), error_callback));
|
| }
|
| @@ -511,6 +515,8 @@ void BluetoothDeviceBlueZ::RejectPairing() {
|
| void BluetoothDeviceBlueZ::CancelPairing() {
|
| bool canceled = false;
|
|
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value() << ": CancelPairing";
|
| +
|
| // If there is a callback in progress that we can reply to then use that
|
| // to cancel the current pairing request.
|
| if (pairing_.get() && pairing_->CancelPairing())
|
| @@ -518,8 +524,9 @@ void BluetoothDeviceBlueZ::CancelPairing() {
|
|
|
| // If not we have to send an explicit CancelPairing() to the device instead.
|
| if (!canceled) {
|
| - VLOG(1) << object_path_.value() << ": No pairing context or callback. "
|
| - << "Sending explicit cancel";
|
| + BLUETOOTH_LOG(DEBUG) << object_path_.value()
|
| + << ": No pairing context or callback. "
|
| + << "Sending explicit cancel";
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->CancelPairing(
|
| object_path_, base::Bind(&base::DoNothing),
|
| base::Bind(&BluetoothDeviceBlueZ::OnCancelPairingError,
|
| @@ -535,17 +542,18 @@ void BluetoothDeviceBlueZ::CancelPairing() {
|
|
|
| void BluetoothDeviceBlueZ::Disconnect(const base::Closure& callback,
|
| const ErrorCallback& error_callback) {
|
| - VLOG(1) << object_path_.value() << ": Disconnecting";
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Disconnecting";
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Disconnect(
|
| - object_path_, base::Bind(&BluetoothDeviceBlueZ::OnDisconnect,
|
| - weak_ptr_factory_.GetWeakPtr(), callback),
|
| + object_path_,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnDisconnect,
|
| + weak_ptr_factory_.GetWeakPtr(), callback),
|
| base::Bind(&BluetoothDeviceBlueZ::OnDisconnectError,
|
| weak_ptr_factory_.GetWeakPtr(), error_callback));
|
| }
|
|
|
| void BluetoothDeviceBlueZ::Forget(const base::Closure& callback,
|
| const ErrorCallback& error_callback) {
|
| - VLOG(1) << object_path_.value() << ": Removing device";
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Removing device";
|
| bluez::BluezDBusManager::Get()->GetBluetoothAdapterClient()->RemoveDevice(
|
| adapter()->object_path(), object_path_, callback,
|
| base::Bind(&BluetoothDeviceBlueZ::OnForgetError,
|
| @@ -556,8 +564,8 @@ void BluetoothDeviceBlueZ::ConnectToService(
|
| const BluetoothUUID& uuid,
|
| const ConnectToServiceCallback& callback,
|
| const ConnectToServiceErrorCallback& error_callback) {
|
| - VLOG(1) << object_path_.value()
|
| - << ": Connecting to service: " << uuid.canonical_value();
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value()
|
| + << ": Connecting to service: " << uuid.canonical_value();
|
| scoped_refptr<BluetoothSocketBlueZ> socket =
|
| BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner_,
|
| socket_thread_);
|
| @@ -569,8 +577,9 @@ void BluetoothDeviceBlueZ::ConnectToServiceInsecurely(
|
| const BluetoothUUID& uuid,
|
| const ConnectToServiceCallback& callback,
|
| const ConnectToServiceErrorCallback& error_callback) {
|
| - VLOG(1) << object_path_.value()
|
| - << ": Connecting insecurely to service: " << uuid.canonical_value();
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value()
|
| + << ": Connecting insecurely to service: "
|
| + << uuid.canonical_value();
|
| scoped_refptr<BluetoothSocketBlueZ> socket =
|
| BluetoothSocketBlueZ::CreateBluetoothSocket(ui_task_runner_,
|
| socket_thread_);
|
| @@ -593,8 +602,9 @@ void BluetoothDeviceBlueZ::CreateGattConnection(
|
|
|
| // TODO(crbug.com/630586): Until there is a way to create a reference counted
|
| // GATT connection in bluetoothd, simply do a regular connect.
|
| - Connect(NULL, base::Bind(&BluetoothDeviceBlueZ::OnCreateGattConnection,
|
| - weak_ptr_factory_.GetWeakPtr(), callback),
|
| + Connect(nullptr,
|
| + base::Bind(&BluetoothDeviceBlueZ::OnCreateGattConnection,
|
| + weak_ptr_factory_.GetWeakPtr(), callback),
|
| error_callback);
|
| }
|
|
|
| @@ -667,7 +677,8 @@ BluetoothAdapterBlueZ* BluetoothDeviceBlueZ::adapter() const {
|
| void BluetoothDeviceBlueZ::GattServiceAdded(
|
| const dbus::ObjectPath& object_path) {
|
| if (GetGattService(object_path.value())) {
|
| - VLOG(1) << "Remote GATT service already exists: " << object_path.value();
|
| + BLUETOOTH_LOG(DEBUG) << "Remote GATT service already exists: "
|
| + << object_path.value();
|
| return;
|
| }
|
|
|
| @@ -677,11 +688,13 @@ void BluetoothDeviceBlueZ::GattServiceAdded(
|
| ->GetProperties(object_path);
|
| DCHECK(properties);
|
| if (properties->device.value() != object_path_) {
|
| - VLOG(2) << "Remote GATT service does not belong to this device.";
|
| + BLUETOOTH_LOG(DEBUG)
|
| + << "Remote GATT service does not belong to this device.";
|
| return;
|
| }
|
|
|
| - VLOG(1) << "Adding new remote GATT service for device: " << GetAddress();
|
| + BLUETOOTH_LOG(EVENT) << "Adding new remote GATT service for device: "
|
| + << GetAddress();
|
|
|
| BluetoothRemoteGattServiceBlueZ* service =
|
| new BluetoothRemoteGattServiceBlueZ(adapter(), this, object_path);
|
| @@ -705,9 +718,9 @@ void BluetoothDeviceBlueZ::GattServiceRemoved(
|
| BluetoothRemoteGattServiceBlueZ* service =
|
| static_cast<BluetoothRemoteGattServiceBlueZ*>(iter->second.get());
|
|
|
| - VLOG(1) << "Removing remote GATT service with UUID: '"
|
| - << service->GetUUID().canonical_value()
|
| - << "' from device: " << GetAddress();
|
| + BLUETOOTH_LOG(EVENT) << "Removing remote GATT service with UUID: '"
|
| + << service->GetUUID().canonical_value()
|
| + << "' from device: " << GetAddress();
|
|
|
| DCHECK(service->object_path() == object_path);
|
| std::unique_ptr<BluetoothRemoteGattService> scoped_service =
|
| @@ -765,9 +778,9 @@ void BluetoothDeviceBlueZ::OnGetConnInfoError(
|
| const ConnectionInfoCallback& callback,
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| - LOG(WARNING) << object_path_.value()
|
| - << ": Failed to get connection info: " << error_name << ": "
|
| - << error_message;
|
| + BLUETOOTH_LOG(ERROR) << object_path_.value()
|
| + << ": Failed to get connection info: " << error_name
|
| + << ": " << error_message;
|
| callback.Run(ConnectionInfo());
|
| }
|
|
|
| @@ -775,9 +788,9 @@ void BluetoothDeviceBlueZ::OnGetServiceRecordsError(
|
| const GetServiceRecordsErrorCallback& error_callback,
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| - VLOG(1) << object_path_.value()
|
| - << ": Failed to get service records: " << error_name << ": "
|
| - << error_message;
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value()
|
| + << ": Failed to get service records: " << error_name
|
| + << ": " << error_message;
|
| BluetoothServiceRecordBlueZ::ErrorCode code =
|
| BluetoothServiceRecordBlueZ::ErrorCode::UNKNOWN;
|
| if (error_name == bluetooth_device::kErrorNotConnected) {
|
| @@ -790,7 +803,7 @@ void BluetoothDeviceBlueZ::ConnectInternal(
|
| bool after_pairing,
|
| const base::Closure& callback,
|
| const ConnectErrorCallback& error_callback) {
|
| - VLOG(1) << object_path_.value() << ": Connecting";
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Connecting";
|
| bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->Connect(
|
| object_path_,
|
| base::Bind(&BluetoothDeviceBlueZ::OnConnect,
|
| @@ -806,8 +819,8 @@ void BluetoothDeviceBlueZ::OnConnect(bool after_pairing,
|
| adapter()->NotifyDeviceChanged(this);
|
|
|
| DCHECK(num_connecting_calls_ >= 0);
|
| - VLOG(1) << object_path_.value() << ": Connected, " << num_connecting_calls_
|
| - << " still in progress";
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Connected, "
|
| + << num_connecting_calls_ << " still in progress";
|
|
|
| SetTrusted();
|
|
|
| @@ -835,11 +848,11 @@ void BluetoothDeviceBlueZ::OnConnectError(
|
| adapter()->NotifyDeviceChanged(this);
|
|
|
| DCHECK(num_connecting_calls_ >= 0);
|
| - LOG(WARNING) << object_path_.value()
|
| - << ": Failed to connect device: " << error_name << ": "
|
| - << error_message;
|
| - VLOG(1) << object_path_.value() << ": " << num_connecting_calls_
|
| - << " still in progress";
|
| + BLUETOOTH_LOG(ERROR) << object_path_.value()
|
| + << ": Failed to connect device: " << error_name << ": "
|
| + << error_message;
|
| + BLUETOOTH_LOG(DEBUG) << object_path_.value() << ": " << num_connecting_calls_
|
| + << " still in progress";
|
|
|
| // Determine the error code from error_name.
|
| ConnectErrorCode error_code = ERROR_UNKNOWN;
|
| @@ -859,7 +872,7 @@ void BluetoothDeviceBlueZ::OnConnectError(
|
| void BluetoothDeviceBlueZ::OnPairDuringConnect(
|
| const base::Closure& callback,
|
| const ConnectErrorCallback& error_callback) {
|
| - VLOG(1) << object_path_.value() << ": Paired";
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Paired";
|
|
|
| EndPairing();
|
|
|
| @@ -874,11 +887,11 @@ void BluetoothDeviceBlueZ::OnPairDuringConnectError(
|
| adapter()->NotifyDeviceChanged(this);
|
|
|
| DCHECK(num_connecting_calls_ >= 0);
|
| - LOG(WARNING) << object_path_.value()
|
| - << ": Failed to pair device: " << error_name << ": "
|
| - << error_message;
|
| - VLOG(1) << object_path_.value() << ": " << num_connecting_calls_
|
| - << " still in progress";
|
| + BLUETOOTH_LOG(ERROR) << object_path_.value()
|
| + << ": Failed to pair device: " << error_name << ": "
|
| + << error_message;
|
| + BLUETOOTH_LOG(DEBUG) << object_path_.value() << ": " << num_connecting_calls_
|
| + << " still in progress";
|
|
|
| EndPairing();
|
|
|
| @@ -890,7 +903,7 @@ void BluetoothDeviceBlueZ::OnPairDuringConnectError(
|
| }
|
|
|
| void BluetoothDeviceBlueZ::OnPair(const base::Closure& callback) {
|
| - VLOG(1) << object_path_.value() << ": Paired";
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Paired";
|
| EndPairing();
|
| callback.Run();
|
| }
|
| @@ -899,9 +912,9 @@ void BluetoothDeviceBlueZ::OnPairError(
|
| const ConnectErrorCallback& error_callback,
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| - LOG(WARNING) << object_path_.value()
|
| - << ": Failed to pair device: " << error_name << ": "
|
| - << error_message;
|
| + BLUETOOTH_LOG(ERROR) << object_path_.value()
|
| + << ": Failed to pair device: " << error_name << ": "
|
| + << error_message;
|
| EndPairing();
|
| ConnectErrorCode error_code = DBusErrorToConnectError(error_name);
|
| RecordPairingResult(error_code);
|
| @@ -911,9 +924,9 @@ void BluetoothDeviceBlueZ::OnPairError(
|
| void BluetoothDeviceBlueZ::OnCancelPairingError(
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| - LOG(WARNING) << object_path_.value()
|
| - << ": Failed to cancel pairing: " << error_name << ": "
|
| - << error_message;
|
| + BLUETOOTH_LOG(ERROR) << object_path_.value()
|
| + << ": Failed to cancel pairing: " << error_name << ": "
|
| + << error_message;
|
| }
|
|
|
| void BluetoothDeviceBlueZ::SetTrusted() {
|
| @@ -929,12 +942,15 @@ void BluetoothDeviceBlueZ::SetTrusted() {
|
| }
|
|
|
| void BluetoothDeviceBlueZ::OnSetTrusted(bool success) {
|
| - LOG_IF(WARNING, !success) << object_path_.value()
|
| - << ": Failed to set device as trusted";
|
| + device_event_log::LogLevel log_level =
|
| + success ? device_event_log::LOG_LEVEL_DEBUG
|
| + : device_event_log::LOG_LEVEL_ERROR;
|
| + DEVICE_LOG(device_event_log::LOG_TYPE_BLUETOOTH, log_level)
|
| + << object_path_.value() << ": OnSetTrusted: " << success;
|
| }
|
|
|
| void BluetoothDeviceBlueZ::OnDisconnect(const base::Closure& callback) {
|
| - VLOG(1) << object_path_.value() << ": Disconnected";
|
| + BLUETOOTH_LOG(EVENT) << object_path_.value() << ": Disconnected";
|
| // Do not notify about changed device since this is already done by
|
| // the dbus::PropertySet and the property change callback for BlueZ.
|
| DidDisconnectGatt(false /* notifyDeviceChanged */);
|
| @@ -945,18 +961,18 @@ void BluetoothDeviceBlueZ::OnDisconnectError(
|
| const ErrorCallback& error_callback,
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| - LOG(WARNING) << object_path_.value()
|
| - << ": Failed to disconnect device: " << error_name << ": "
|
| - << error_message;
|
| + BLUETOOTH_LOG(ERROR) << object_path_.value()
|
| + << ": Failed to disconnect device: " << error_name
|
| + << ": " << error_message;
|
| error_callback.Run();
|
| }
|
|
|
| void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback,
|
| const std::string& error_name,
|
| const std::string& error_message) {
|
| - LOG(WARNING) << object_path_.value()
|
| - << ": Failed to remove device: " << error_name << ": "
|
| - << error_message;
|
| + BLUETOOTH_LOG(ERROR) << object_path_.value()
|
| + << ": Failed to remove device: " << error_name << ": "
|
| + << error_message;
|
| error_callback.Run();
|
| }
|
|
|
|
|