| Index: device/bluetooth/dbus/bluetooth_gatt_application_service_provider.cc
|
| diff --git a/device/bluetooth/dbus/bluetooth_gatt_application_service_provider.cc b/device/bluetooth/dbus/bluetooth_gatt_application_service_provider.cc
|
| index 4b0e04775aecefbfed34fdf7c2f14e3fd40af331..d0fedb9158677ea0380342629fb3b205e9bec4f8 100644
|
| --- a/device/bluetooth/dbus/bluetooth_gatt_application_service_provider.cc
|
| +++ b/device/bluetooth/dbus/bluetooth_gatt_application_service_provider.cc
|
| @@ -6,22 +6,96 @@
|
|
|
| #include <string>
|
| #include <utility>
|
| -#include <vector>
|
|
|
| #include "base/memory/ptr_util.h"
|
| +#include "device/bluetooth/bluetooth_gatt_characteristic.h"
|
| #include "device/bluetooth/bluetooth_uuid.h"
|
| #include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h"
|
| #include "device/bluetooth/dbus/bluetooth_gatt_application_service_provider_impl.h"
|
| #include "device/bluetooth/dbus/bluetooth_gatt_characteristic_delegate_wrapper.h"
|
| -#include "device/bluetooth/dbus/bluetooth_gatt_characteristic_service_provider.h"
|
| #include "device/bluetooth/dbus/bluetooth_gatt_descriptor_delegate_wrapper.h"
|
| -#include "device/bluetooth/dbus/bluetooth_gatt_descriptor_service_provider.h"
|
| -#include "device/bluetooth/dbus/bluetooth_gatt_service_service_provider.h"
|
| #include "device/bluetooth/dbus/bluez_dbus_manager.h"
|
| #include "device/bluetooth/dbus/fake_bluetooth_gatt_application_service_provider.h"
|
| +#include "third_party/cros_system_api/dbus/service_constants.h"
|
|
|
| namespace bluez {
|
|
|
| +namespace {
|
| +
|
| +const std::vector<std::string> FlagsFromProperties(
|
| + device::BluetoothGattCharacteristic::Properties properties) {
|
| + static_assert(
|
| + device::BluetoothGattCharacteristic::NUM_PROPERTY == 1 << 14,
|
| + "Update required if the number of characteristic properties changes.");
|
| + std::vector<std::string> flags;
|
| + if (properties & device::BluetoothGattCharacteristic::PROPERTY_BROADCAST)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagBroadcast);
|
| + if (properties & device::BluetoothGattCharacteristic::PROPERTY_READ)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagRead);
|
| + if (properties &
|
| + device::BluetoothGattCharacteristic::PROPERTY_WRITE_WITHOUT_RESPONSE)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagWriteWithoutResponse);
|
| + if (properties & device::BluetoothGattCharacteristic::PROPERTY_WRITE)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagWrite);
|
| + if (properties & device::BluetoothGattCharacteristic::PROPERTY_NOTIFY)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagNotify);
|
| + if (properties & device::BluetoothGattCharacteristic::PROPERTY_INDICATE)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagIndicate);
|
| + if (properties &
|
| + device::BluetoothGattCharacteristic::PROPERTY_AUTHENTICATED_SIGNED_WRITES)
|
| + flags.push_back(
|
| + bluetooth_gatt_characteristic::kFlagAuthenticatedSignedWrites);
|
| + if (properties &
|
| + device::BluetoothGattCharacteristic::PROPERTY_EXTENDED_PROPERTIES)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagExtendedProperties);
|
| + if (properties & device::BluetoothGattCharacteristic::PROPERTY_RELIABLE_WRITE)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagReliableWrite);
|
| + if (properties &
|
| + device::BluetoothGattCharacteristic::PROPERTY_WRITABLE_AUXILIARIES)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagWritableAuxiliaries);
|
| + if (properties & device::BluetoothGattCharacteristic::PROPERTY_READ_ENCRYPTED)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagEncryptRead);
|
| + if (properties &
|
| + device::BluetoothGattCharacteristic::PROPERTY_WRITE_ENCRYPTED)
|
| + flags.push_back(bluetooth_gatt_characteristic::kFlagEncryptWrite);
|
| + if (properties & device::BluetoothGattCharacteristic::
|
| + PROPERTY_READ_ENCRYPTED_AUTHENTICATED)
|
| + flags.push_back(
|
| + bluetooth_gatt_characteristic::kFlagEncryptAuthenticatedRead);
|
| + if (properties & device::BluetoothGattCharacteristic::
|
| + PROPERTY_WRITE_ENCRYPTED_AUTHENTICATED)
|
| + flags.push_back(
|
| + bluetooth_gatt_characteristic::kFlagEncryptAuthenticatedWrite);
|
| + return flags;
|
| +}
|
| +
|
| +const std::vector<std::string> FlagsFromPermissions(
|
| + device::BluetoothGattCharacteristic::Permissions permissions) {
|
| + static_assert(
|
| + device::BluetoothGattCharacteristic::NUM_PERMISSION == 1 << 6,
|
| + "Update required if the number of attribute permissions changes.");
|
| + std::vector<std::string> flags;
|
| + if (permissions & device::BluetoothGattCharacteristic::PERMISSION_READ)
|
| + flags.push_back(bluetooth_gatt_descriptor::kFlagRead);
|
| + if (permissions & device::BluetoothGattCharacteristic::PERMISSION_WRITE)
|
| + flags.push_back(bluetooth_gatt_descriptor::kFlagWrite);
|
| + if (permissions &
|
| + device::BluetoothGattCharacteristic::PERMISSION_READ_ENCRYPTED)
|
| + flags.push_back(bluetooth_gatt_descriptor::kFlagEncryptRead);
|
| + if (permissions &
|
| + device::BluetoothGattCharacteristic::PERMISSION_WRITE_ENCRYPTED)
|
| + flags.push_back(bluetooth_gatt_descriptor::kFlagEncryptWrite);
|
| + if (permissions & device::BluetoothGattCharacteristic::
|
| + PERMISSION_READ_ENCRYPTED_AUTHENTICATED)
|
| + flags.push_back(bluetooth_gatt_descriptor::kFlagEncryptAuthenticatedRead);
|
| + if (permissions & device::BluetoothGattCharacteristic::
|
| + PERMISSION_WRITE_ENCRYPTED_AUTHENTICATED)
|
| + flags.push_back(bluetooth_gatt_descriptor::kFlagEncryptAuthenticatedWrite);
|
| + return flags;
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| BluetoothGattApplicationServiceProvider::
|
| BluetoothGattApplicationServiceProvider() {}
|
|
|
| @@ -51,14 +125,16 @@ void BluetoothGattApplicationServiceProvider::CreateAttributeServiceProviders(
|
| base::WrapUnique(new BluetoothGattCharacteristicDelegateWrapper(
|
| service.second, characteristic.second.get())),
|
| characteristic.second->GetUUID().value(),
|
| - std::vector<std::string>(), service.second->object_path())));
|
| + FlagsFromProperties(characteristic.second->GetProperties()),
|
| + service.second->object_path())));
|
| for (const auto& descriptor : characteristic.second->GetDescriptors()) {
|
| descriptor_providers->push_back(
|
| base::WrapUnique(BluetoothGattDescriptorServiceProvider::Create(
|
| bus, descriptor->object_path(),
|
| base::WrapUnique(new BluetoothGattDescriptorDelegateWrapper(
|
| service.second, descriptor.get())),
|
| - descriptor->GetUUID().value(), std::vector<std::string>(),
|
| + descriptor->GetUUID().value(),
|
| + FlagsFromPermissions(descriptor->GetPermissions()),
|
| characteristic.second->object_path())));
|
| }
|
| }
|
|
|