Index: device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.cc |
diff --git a/device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.cc b/device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.cc |
index dd044d21b99b00a3d8eaaa1f0f9de1e79c65cc75..71125ee18c8fe3e2523fae6fbe67254b84f1f270 100644 |
--- a/device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.cc |
+++ b/device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.cc |
@@ -72,7 +72,15 @@ void BluetoothLocalGattServiceBlueZ::Unregister( |
GetAdapter()->UnregisterGattService(this, callback, error_callback); |
} |
-const std::vector<std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ>>& |
+device::BluetoothLocalGattCharacteristic* |
+BluetoothLocalGattServiceBlueZ::GetCharacteristic( |
+ const std::string& identifier) { |
+ const auto& service = characteristics_.find(dbus::ObjectPath(identifier)); |
+ return service == characteristics_.end() ? nullptr : service->second.get(); |
+}; |
+ |
+const std::map<dbus::ObjectPath, |
+ std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ>>& |
BluetoothLocalGattServiceBlueZ::GetCharacteristics() const { |
return characteristics_; |
} |
@@ -88,7 +96,7 @@ dbus::ObjectPath BluetoothLocalGattServiceBlueZ::AddGuidToObjectPath( |
void BluetoothLocalGattServiceBlueZ::AddCharacteristic( |
std::unique_ptr<BluetoothLocalGattCharacteristicBlueZ> characteristic) { |
- characteristics_.push_back(std::move(characteristic)); |
+ characteristics_[characteristic->object_path()] = std::move(characteristic); |
} |
} // namespace bluez |