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

Unified Diff: chromeos/dbus/fake_bluetooth_gatt_descriptor_client.cc

Issue 309623002: device/bluetooth: Update GATT descriptor value D-Bus bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed clang error Created 6 years, 6 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
Index: chromeos/dbus/fake_bluetooth_gatt_descriptor_client.cc
diff --git a/chromeos/dbus/fake_bluetooth_gatt_descriptor_client.cc b/chromeos/dbus/fake_bluetooth_gatt_descriptor_client.cc
index 4bb5255b08330ab08cc5b815d7f8edd10e75c6d0..a39a160526a5dc115ac1f57e896c251ce4b13850 100644
--- a/chromeos/dbus/fake_bluetooth_gatt_descriptor_client.cc
+++ b/chromeos/dbus/fake_bluetooth_gatt_descriptor_client.cc
@@ -42,19 +42,13 @@ void FakeBluetoothGattDescriptorClient::Properties::Set(
dbus::PropertyBase* property,
dbus::PropertySet::SetCallback callback) {
VLOG(1) << "Set " << property->name();
- if (property->name() != value.name()) {
- callback.Run(false);
- return;
- }
+ callback.Run(false);
+}
- // TODO(armansito): Setting the "Value" property should be allowed based
- // on permissions.
- if (uuid.value() != kClientCharacteristicConfigurationUUID) {
- callback.Run(false);
- return;
- }
- callback.Run(true);
- property->ReplaceValueWithSetValue();
+FakeBluetoothGattDescriptorClient::DescriptorData::DescriptorData() {
+}
+
+FakeBluetoothGattDescriptorClient::DescriptorData::~DescriptorData() {
}
FakeBluetoothGattDescriptorClient::FakeBluetoothGattDescriptorClient()
@@ -91,7 +85,37 @@ FakeBluetoothGattDescriptorClient::GetProperties(
PropertiesMap::const_iterator iter = properties_.find(object_path);
if (iter == properties_.end())
return NULL;
- return iter->second;
+ return iter->second->properties.get();
+}
+
+void FakeBluetoothGattDescriptorClient::ReadValue(
+ const dbus::ObjectPath& object_path,
+ const ValueCallback& callback,
+ const ErrorCallback& error_callback) {
+ PropertiesMap::iterator iter = properties_.find(object_path);
+ if (iter == properties_.end()) {
+ error_callback.Run(kUnknownDescriptorError, "");
+ return;
+ }
+
+ callback.Run(iter->second->value);
+}
+
+void FakeBluetoothGattDescriptorClient::WriteValue(
+ const dbus::ObjectPath& object_path,
+ const std::vector<uint8>& value,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ if (properties_.find(object_path) == properties_.end()) {
+ error_callback.Run(kUnknownDescriptorError, "");
+ return;
+ }
+
+ // Since the only fake descriptor is "Client Characteristic Configuration"
+ // and BlueZ doesn't allow writing to it, return failure.
+ error_callback.Run("org.bluez.Error.Failed",
+ "Writing to the Client Characteristic Configuration "
+ "descriptor not allowed");
}
dbus::ObjectPath FakeBluetoothGattDescriptorClient::ExposeDescriptor(
@@ -118,14 +142,16 @@ dbus::ObjectPath FakeBluetoothGattDescriptorClient::ExposeDescriptor(
&FakeBluetoothGattDescriptorClient::OnPropertyChanged,
weak_ptr_factory_.GetWeakPtr(),
object_path));
- properties_[object_path] = properties;
properties->uuid.ReplaceValue(uuid);
properties->characteristic.ReplaceValue(characteristic_path);
- std::vector<uint8> value;
- value.push_back(0); // Notifications/Indications disabled.
- value.push_back(0);
- properties->value.ReplaceValue(value);
+ DescriptorData* data = new DescriptorData();
+ data->properties.reset(properties);
+
+ data->value.push_back(1); // Notifications enabled.
+ data->value.push_back(0);
+
+ properties_[object_path] = data;
NotifyDescriptorAdded(object_path);
@@ -154,9 +180,6 @@ void FakeBluetoothGattDescriptorClient::OnPropertyChanged(
FOR_EACH_OBSERVER(BluetoothGattDescriptorClient::Observer, observers_,
GattDescriptorPropertyChanged(object_path, property_name));
-
- // TODO(armansito): Implement CCC behavior (enable/disable notifications
- // or indications characteristics).
}
void FakeBluetoothGattDescriptorClient::NotifyDescriptorAdded(
« no previous file with comments | « chromeos/dbus/fake_bluetooth_gatt_descriptor_client.h ('k') | device/bluetooth/bluetooth_gatt_chromeos_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698