Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Unified Diff: device/bluetooth/bluetooth_device_chromeos.cc

Issue 273953002: Hook up RSSI and host transmit power Bluetooth device properties for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang warnings, test flakiness, and bluetooth.connect should succeed even if monitor fails Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_device_chromeos.h ('k') | device/bluetooth/bluetooth_device_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f668e9a5855bda582e3bb8297240961d898a94b0 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,39 @@ 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() && connection_monitor_started_
+ ? properties->connection_tx_power.value()
+ : 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()
+ : kUnknownPower;
}
bool BluetoothDeviceChromeOS::IsPaired() const {
@@ -459,6 +481,19 @@ void BluetoothDeviceChromeOS::ClearOutOfBandPairingData(
error_callback.Run();
}
+void BluetoothDeviceChromeOS::StartConnectionMonitor(
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ DBusThreadManager::Get()->GetBluetoothDeviceClient()->StartConnectionMonitor(
+ object_path_,
+ base::Bind(&BluetoothDeviceChromeOS::OnStartConnectionMonitor,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback),
+ base::Bind(&BluetoothDeviceChromeOS::OnStartConnectionMonitorError,
+ weak_ptr_factory_.GetWeakPtr(),
+ error_callback));
+}
+
BluetoothPairingChromeOS* BluetoothDeviceChromeOS::BeginPairing(
BluetoothDevice::PairingDelegate* pairing_delegate) {
pairing_.reset(new BluetoothPairingChromeOS(this, pairing_delegate));
@@ -655,6 +690,22 @@ void BluetoothDeviceChromeOS::OnSetTrusted(bool success) {
<< ": Failed to set device as trusted";
}
+void BluetoothDeviceChromeOS::OnStartConnectionMonitor(
+ const base::Closure& callback) {
+ connection_monitor_started_ = true;
+ callback.Run();
+}
+
+void BluetoothDeviceChromeOS::OnStartConnectionMonitorError(
+ const ErrorCallback& error_callback,
+ const std::string& error_name,
+ const std::string& error_message) {
+ LOG(WARNING) << object_path_.value()
+ << ": Failed to start connection monitor: " << error_name << ": "
+ << error_message;
+ error_callback.Run();
+}
+
void BluetoothDeviceChromeOS::OnDisconnect(const base::Closure& callback) {
VLOG(1) << object_path_.value() << ": Disconnected";
callback.Run();
« no previous file with comments | « device/bluetooth/bluetooth_device_chromeos.h ('k') | device/bluetooth/bluetooth_device_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698