summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc')
-rw-r--r--chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc20
1 files changed, 19 insertions, 1 deletions
diff --git a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc b/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
index 55784a9..dbbdcc3 100644
--- a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
+++ b/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
@@ -8,6 +8,8 @@
#include "base/message_loop/message_loop.h"
#include "base/rand_util.h"
#include "base/time/time.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
+#include "chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace chromeos {
@@ -207,12 +209,28 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics(
// be handled by BlueZ, automatically set up notifications for now.
ScheduleHeartRateMeasurementValueChange();
- // TODO(armansito): Add descriptors.
+ // Expose CCC descriptor for Heart Rate Measurement characteristic.
+ FakeBluetoothGattDescriptorClient* descriptor_client =
+ static_cast<FakeBluetoothGattDescriptorClient*>(
+ DBusThreadManager::Get()->GetBluetoothGattDescriptorClient());
+ dbus::ObjectPath ccc_path(descriptor_client->ExposeDescriptor(
+ dbus::ObjectPath(heart_rate_measurement_path_),
+ FakeBluetoothGattDescriptorClient::
+ kClientCharacteristicConfigurationUUID));
+ DCHECK(ccc_path.IsValid());
+ heart_rate_measurement_ccc_desc_path_ = ccc_path.value();
}
void FakeBluetoothGattCharacteristicClient::HideHeartRateCharacteristics() {
VLOG(2) << "Hiding fake Heart Rate characteristics.";
+ // Hide the descriptors.
+ FakeBluetoothGattDescriptorClient* descriptor_client =
+ static_cast<FakeBluetoothGattDescriptorClient*>(
+ DBusThreadManager::Get()->GetBluetoothGattDescriptorClient());
+ descriptor_client->HideDescriptor(
+ dbus::ObjectPath(heart_rate_measurement_ccc_desc_path_));
+
// Notify the observers before deleting the properties structures so that they
// can be accessed from the observer method.
NotifyCharacteristicRemoved(dbus::ObjectPath(heart_rate_measurement_path_));