summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus
diff options
context:
space:
mode:
authortengs@chromium.org <tengs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-11 01:26:20 +0000
committertengs@chromium.org <tengs@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-11 01:26:20 +0000
commit73e3bf317ab4dc9b6a059ccc93ba83bb8145a215 (patch)
tree36e312c5af8cd3383a456961632b82941bd16c39 /chromeos/dbus
parent2ad5ef50f9fb03975744312afcb43392cd2a0d54 (diff)
downloadchromium_src-73e3bf317ab4dc9b6a059ccc93ba83bb8145a215.zip
chromium_src-73e3bf317ab4dc9b6a059ccc93ba83bb8145a215.tar.gz
chromium_src-73e3bf317ab4dc9b6a059ccc93ba83bb8145a215.tar.bz2
Hook up RSSI and host transmit power Bluetooth device properties for ChromeOS.
BUG=365966 Review URL: https://codereview.chromium.org/273953002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269676 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus')
-rw-r--r--chromeos/dbus/bluetooth_device_client.cc54
-rw-r--r--chromeos/dbus/bluetooth_device_client.h30
-rw-r--r--chromeos/dbus/fake_bluetooth_device_client.cc27
-rw-r--r--chromeos/dbus/fake_bluetooth_device_client.h13
4 files changed, 116 insertions, 8 deletions
diff --git a/chromeos/dbus/bluetooth_device_client.cc b/chromeos/dbus/bluetooth_device_client.cc
index 033daf3..b505401 100644
--- a/chromeos/dbus/bluetooth_device_client.cc
+++ b/chromeos/dbus/bluetooth_device_client.cc
@@ -41,6 +41,10 @@ BluetoothDeviceClient::Properties::Properties(
RegisterProperty(bluetooth_device::kLegacyPairingProperty, &legacy_pairing);
RegisterProperty(bluetooth_device::kModaliasProperty, &modalias);
RegisterProperty(bluetooth_device::kRSSIProperty, &rssi);
+ RegisterProperty(bluetooth_device::kConnectionRSSI, &connection_rssi);
+ RegisterProperty(bluetooth_device::kConnectionTXPower, &connection_tx_power);
+ RegisterProperty(bluetooth_device::kConnectionTXPowerMax,
+ &connection_tx_power_max);
}
BluetoothDeviceClient::Properties::~Properties() {
@@ -267,6 +271,56 @@ class BluetoothDeviceClientImpl
weak_ptr_factory_.GetWeakPtr(), error_callback));
}
+ // BluetoothDeviceClient override.
+ virtual void StartConnectionMonitor(
+ const dbus::ObjectPath& object_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ dbus::MethodCall method_call(bluetooth_device::kBluetoothDeviceInterface,
+ bluetooth_device::kStartConnectionMonitor);
+
+ dbus::ObjectProxy* object_proxy =
+ object_manager_->GetObjectProxy(object_path);
+ if (!object_proxy) {
+ error_callback.Run(kUnknownDeviceError, "");
+ return;
+ }
+ object_proxy->CallMethodWithErrorCallback(
+ &method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&BluetoothDeviceClientImpl::OnSuccess,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback),
+ base::Bind(&BluetoothDeviceClientImpl::OnError,
+ weak_ptr_factory_.GetWeakPtr(),
+ error_callback));
+ }
+
+ // BluetoothDeviceClient override.
+ virtual void StopConnectionMonitor(
+ const dbus::ObjectPath& object_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE {
+ dbus::MethodCall method_call(bluetooth_device::kBluetoothDeviceInterface,
+ bluetooth_device::kStopConnectionMonitor);
+
+ dbus::ObjectProxy* object_proxy =
+ object_manager_->GetObjectProxy(object_path);
+ if (!object_proxy) {
+ error_callback.Run(kUnknownDeviceError, "");
+ return;
+ }
+ object_proxy->CallMethodWithErrorCallback(
+ &method_call,
+ dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
+ base::Bind(&BluetoothDeviceClientImpl::OnSuccess,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback),
+ base::Bind(&BluetoothDeviceClientImpl::OnError,
+ weak_ptr_factory_.GetWeakPtr(),
+ error_callback));
+ }
+
protected:
virtual void Init(dbus::Bus* bus) OVERRIDE {
object_manager_ = bus->GetObjectManager(
diff --git a/chromeos/dbus/bluetooth_device_client.h b/chromeos/dbus/bluetooth_device_client.h
index 11f5a1c..a09b4ef 100644
--- a/chromeos/dbus/bluetooth_device_client.h
+++ b/chromeos/dbus/bluetooth_device_client.h
@@ -76,9 +76,24 @@ class CHROMEOS_EXPORT BluetoothDeviceClient : public DBusClient {
// Remote Device ID information in Linux kernel modalias format. Read-only.
dbus::Property<std::string> modalias;
- // Received signal strength indicator. Read-only.
+ // Received signal strength indicator that is set when the device is
+ // discovered during inquiry. Read-only.
dbus::Property<int16> rssi;
+ // Received signal strength indicator when a connection is open to the
+ // device. This property is not set unless connection monitor is enabled.
+ // Read-only.
+ dbus::Property<int16> connection_rssi;
+
+ // The transmit power level of the host when a connection is open
+ // to the device. This property is not set unless connection monitor is
+ // enabled. Read-only.
+ dbus::Property<int16> connection_tx_power;
+
+ // The maximum transmit power level of the host that can be set
+ // when connected to the device. Read-only.
+ dbus::Property<int16> connection_tx_power_max;
+
Properties(dbus::ObjectProxy* object_proxy,
const std::string& interface_name,
const PropertyChangedCallback& callback);
@@ -169,6 +184,19 @@ class CHROMEOS_EXPORT BluetoothDeviceClient : public DBusClient {
const base::Closure& callback,
const ErrorCallback& error_callback) = 0;
+ // Starts connection monitor for the device with object path
+ // |object_path|. Connection monitor is a mode the connection properties,
+ // RSSI and TX power are tracked and updated when they change.
+ virtual void StartConnectionMonitor(const dbus::ObjectPath& object_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
+
+ // Stops connection monitor for the device with object path
+ // |object_path|.
+ virtual void StopConnectionMonitor(const dbus::ObjectPath& object_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) = 0;
+
// Creates the instance.
static BluetoothDeviceClient* Create();
diff --git a/chromeos/dbus/fake_bluetooth_device_client.cc b/chromeos/dbus/fake_bluetooth_device_client.cc
index 44b9a0b..2dd5aae 100644
--- a/chromeos/dbus/fake_bluetooth_device_client.cc
+++ b/chromeos/dbus/fake_bluetooth_device_client.cc
@@ -220,7 +220,8 @@ FakeBluetoothDeviceClient::FakeBluetoothDeviceClient()
: simulation_interval_ms_(kSimulationIntervalMs),
discovery_simulation_step_(0),
incoming_pairing_simulation_step_(0),
- pairing_cancelled_(false) {
+ pairing_cancelled_(false),
+ connection_monitor_started_(false) {
Properties* properties = new Properties(base::Bind(
&FakeBluetoothDeviceClient::OnPropertyChanged,
base::Unretained(this),
@@ -459,6 +460,22 @@ void FakeBluetoothDeviceClient::CancelPairing(
callback.Run();
}
+void FakeBluetoothDeviceClient::StartConnectionMonitor(
+ const dbus::ObjectPath& object_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ VLOG(1) << "StartConnectionMonitor: " << object_path.value();
+ connection_monitor_started_ = true;
+ callback.Run();
+}
+
+void FakeBluetoothDeviceClient::StopConnectionMonitor(
+ const dbus::ObjectPath& object_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ connection_monitor_started_ = false;
+ callback.Run();
+}
void FakeBluetoothDeviceClient::BeginDiscoverySimulation(
const dbus::ObjectPath& adapter_path) {
@@ -677,12 +694,12 @@ void FakeBluetoothDeviceClient::DiscoverySimulationTimer() {
dbus::ObjectPath(kLowEnergyPath));
} else if (discovery_simulation_step_ == 4) {
+ UpdateDeviceRSSI(dbus::ObjectPath(kLowEnergyPath),
+ base::RandInt(kMinRSSI, kMaxRSSI));
CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
dbus::ObjectPath(kDisplayPinCodePath));
CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
dbus::ObjectPath(kVanishingDevicePath));
- UpdateDeviceRSSI(dbus::ObjectPath(kLowEnergyPath),
- base::RandInt(kMinRSSI, kMaxRSSI));
} else if (discovery_simulation_step_ == 7) {
CreateDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
@@ -713,10 +730,10 @@ void FakeBluetoothDeviceClient::DiscoverySimulationTimer() {
base::RandInt(kMinRSSI, kMaxRSSI));
} else if (discovery_simulation_step_ == 13) {
- RemoveDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
- dbus::ObjectPath(kVanishingDevicePath));
UpdateDeviceRSSI(dbus::ObjectPath(kLowEnergyPath),
base::RandInt(kMinRSSI, kMaxRSSI));
+ RemoveDevice(dbus::ObjectPath(FakeBluetoothAdapterClient::kAdapterPath),
+ dbus::ObjectPath(kVanishingDevicePath));
} else if (discovery_simulation_step_ == 14) {
UpdateDeviceRSSI(dbus::ObjectPath(kLowEnergyPath),
diff --git a/chromeos/dbus/fake_bluetooth_device_client.h b/chromeos/dbus/fake_bluetooth_device_client.h
index 827fdcb..af3a7dc 100644
--- a/chromeos/dbus/fake_bluetooth_device_client.h
+++ b/chromeos/dbus/fake_bluetooth_device_client.h
@@ -69,6 +69,14 @@ class CHROMEOS_EXPORT FakeBluetoothDeviceClient
virtual void CancelPairing(const dbus::ObjectPath& object_path,
const base::Closure& callback,
const ErrorCallback& error_callback) OVERRIDE;
+ virtual void StartConnectionMonitor(
+ const dbus::ObjectPath& object_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE;
+ virtual void StopConnectionMonitor(
+ const dbus::ObjectPath& object_path,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) OVERRIDE;
void SetSimulationIntervalMs(int interval_ms);
@@ -192,8 +200,8 @@ class CHROMEOS_EXPORT FakeBluetoothDeviceClient
const dbus::ObjectPath& object_path,
Properties* properties);
- // Updates the RSSI property of fake device with object path |object_path|
- // to |rssi|, if the fake device exists.
+ // Updates the inquiry RSSI property of fake device with object path
+ // |object_path| to |rssi|, if the fake device exists.
void UpdateDeviceRSSI(const dbus::ObjectPath& object_path, int16 rssi);
void PinCodeCallback(
@@ -242,6 +250,7 @@ class CHROMEOS_EXPORT FakeBluetoothDeviceClient
uint32_t discovery_simulation_step_;
uint32_t incoming_pairing_simulation_step_;
bool pairing_cancelled_;
+ bool connection_monitor_started_;
};
} // namespace chromeos