| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" | 5 #include "device/bluetooth/dbus/fake_bluetooth_gatt_descriptor_client.h" |
| 6 | 6 |
| 7 #include <vector> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" |
| 11 #include "base/callback_forward.h" |
| 8 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "dbus/bus.h" |
| 14 #include "dbus/property.h" |
| 9 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" | 15 #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_client.h" |
| 10 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | 16 #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| 11 #include "third_party/cros_system_api/dbus/service_constants.h" | 17 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 12 | 18 |
| 13 namespace bluez { | 19 namespace bluez { |
| 14 | 20 |
| 15 const char FakeBluetoothGattDescriptorClient:: | 21 const char FakeBluetoothGattDescriptorClient:: |
| 16 kClientCharacteristicConfigurationPathComponent[] = "desc0000"; | 22 kClientCharacteristicConfigurationPathComponent[] = "desc0000"; |
| 17 const char FakeBluetoothGattDescriptorClient:: | 23 const char FakeBluetoothGattDescriptorClient:: |
| 18 kClientCharacteristicConfigurationUUID[] = | 24 kClientCharacteristicConfigurationUUID[] = |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 const std::vector<uint8_t>& value, | 129 const std::vector<uint8_t>& value, |
| 124 const base::Closure& callback, | 130 const base::Closure& callback, |
| 125 const ErrorCallback& error_callback) { | 131 const ErrorCallback& error_callback) { |
| 126 if (properties_.find(object_path) == properties_.end()) { | 132 if (properties_.find(object_path) == properties_.end()) { |
| 127 error_callback.Run(kUnknownDescriptorError, ""); | 133 error_callback.Run(kUnknownDescriptorError, ""); |
| 128 return; | 134 return; |
| 129 } | 135 } |
| 130 | 136 |
| 131 // Since the only fake descriptor is "Client Characteristic Configuration" | 137 // Since the only fake descriptor is "Client Characteristic Configuration" |
| 132 // and BlueZ doesn't allow writing to it, return failure. | 138 // and BlueZ doesn't allow writing to it, return failure. |
| 133 error_callback.Run("org.bluez.Error.NotPermitted", | 139 error_callback.Run(bluetooth_gatt_service::kErrorWriteNotPermitted, |
| 134 "Writing to the Client Characteristic Configuration " | 140 "Writing to the Client Characteristic Configuration " |
| 135 "descriptor not allowed"); | 141 "descriptor not allowed"); |
| 136 } | 142 } |
| 137 | 143 |
| 138 dbus::ObjectPath FakeBluetoothGattDescriptorClient::ExposeDescriptor( | 144 dbus::ObjectPath FakeBluetoothGattDescriptorClient::ExposeDescriptor( |
| 139 const dbus::ObjectPath& characteristic_path, | 145 const dbus::ObjectPath& characteristic_path, |
| 140 const std::string& uuid) { | 146 const std::string& uuid) { |
| 141 if (uuid != kClientCharacteristicConfigurationUUID) { | 147 if (uuid != kClientCharacteristicConfigurationUUID) { |
| 142 VLOG(2) << "Unsupported UUID: " << uuid; | 148 VLOG(2) << "Unsupported UUID: " << uuid; |
| 143 return dbus::ObjectPath(); | 149 return dbus::ObjectPath(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 GattDescriptorAdded(object_path)); | 206 GattDescriptorAdded(object_path)); |
| 201 } | 207 } |
| 202 | 208 |
| 203 void FakeBluetoothGattDescriptorClient::NotifyDescriptorRemoved( | 209 void FakeBluetoothGattDescriptorClient::NotifyDescriptorRemoved( |
| 204 const dbus::ObjectPath& object_path) { | 210 const dbus::ObjectPath& object_path) { |
| 205 FOR_EACH_OBSERVER(BluetoothGattDescriptorClient::Observer, observers_, | 211 FOR_EACH_OBSERVER(BluetoothGattDescriptorClient::Observer, observers_, |
| 206 GattDescriptorRemoved(object_path)); | 212 GattDescriptorRemoved(object_path)); |
| 207 } | 213 } |
| 208 | 214 |
| 209 } // namespace bluez | 215 } // namespace bluez |
| OLD | NEW |