Chromium Code Reviews| Index: device/bluetooth/bluetooth_device_chromeos.cc |
| diff --git a/device/bluetooth/bluetooth_device_chromeos.cc b/device/bluetooth/bluetooth_device_chromeos.cc |
| index 05359279bcd46aa6a3c71a3ed6bf0e50340abd76..ee7895cf38ef2efd9bee1939c0218c0a97515a3d 100644 |
| --- a/device/bluetooth/bluetooth_device_chromeos.cc |
| +++ b/device/bluetooth/bluetooth_device_chromeos.cc |
| @@ -128,6 +128,7 @@ BluetoothDeviceChromeOS::BluetoothDeviceChromeOS( |
| : adapter_(adapter), |
| object_path_(object_path), |
| num_connecting_calls_(0), |
| + connection_monitor_started_(false), |
| ui_task_runner_(ui_task_runner), |
| socket_thread_(socket_thread), |
| weak_ptr_factory_(this) { |
| @@ -223,18 +224,38 @@ uint16 BluetoothDeviceChromeOS::GetDeviceID() const { |
| } |
| int BluetoothDeviceChromeOS::GetRSSI() const { |
| - NOTIMPLEMENTED(); |
| - return kUnknownPower; |
| + BluetoothDeviceClient::Properties* properties = |
| + DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
| + object_path_); |
| + DCHECK(properties); |
| + |
| + if (!IsConnected()) { |
| + NOTIMPLEMENTED(); |
| + return kUnknownPower; |
| + } |
| + |
| + return connection_monitor_started_ ? properties->connection_rssi.value() |
| + : kUnknownPower; |
| } |
| int BluetoothDeviceChromeOS::GetCurrentHostTransmitPower() const { |
| - NOTIMPLEMENTED(); |
| - return kUnknownPower; |
| + BluetoothDeviceClient::Properties* properties = |
| + DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
| + object_path_); |
| + DCHECK(properties); |
| + |
| + return IsConnected() ? properties->connection_tx_power.value() |
|
keybuk
2014/05/09 19:06:38
shouldn't this also be connection monitor?
Tim Song
2014/05/09 20:08:01
Done.
|
| + : kUnknownPower; |
| } |
| int BluetoothDeviceChromeOS::GetMaximumHostTransmitPower() const { |
| - NOTIMPLEMENTED(); |
| - return kUnknownPower; |
| + BluetoothDeviceClient::Properties* properties = |
| + DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
| + object_path_); |
| + DCHECK(properties); |
| + |
| + return IsConnected() ? properties->connection_tx_power_max.value() |
|
keybuk
2014/05/09 19:06:38
ditto
Tim Song
2014/05/09 20:08:01
The maximum TX power doesn't need to be tracked, a
|
| + : kUnknownPower; |
| } |
| bool BluetoothDeviceChromeOS::IsPaired() const { |
| @@ -655,6 +676,30 @@ void BluetoothDeviceChromeOS::OnSetTrusted(bool success) { |
| << ": Failed to set device as trusted"; |
| } |
| +void BluetoothDeviceChromeOS::StartConnectionMonitor() { |
| + if (connection_monitor_started_) |
| + return; |
| + |
| + DBusThreadManager::Get()->GetBluetoothDeviceClient()->StartConnectionMonitor( |
| + object_path_, |
| + base::Bind(&base::DoNothing), |
| + base::Bind(&BluetoothDeviceChromeOS::OnStartConnectionMonitorError, |
| + weak_ptr_factory_.GetWeakPtr())); |
| +} |
| + |
| +void BluetoothDeviceChromeOS::OnStartConnectionMonitor() { |
| + connection_monitor_started_ = true; |
| +} |
| + |
| +void BluetoothDeviceChromeOS::OnStartConnectionMonitorError( |
| + const std::string& error_name, |
| + const std::string& error_message) { |
| + connection_monitor_started_ = false; |
| + LOG(WARNING) << object_path_.value() |
| + << ": Failed to start connection monitor: " << error_name << ": " |
| + << error_message; |
| +} |
| + |
| void BluetoothDeviceChromeOS::OnDisconnect(const base::Closure& callback) { |
| VLOG(1) << object_path_.value() << ": Disconnected"; |
| callback.Run(); |