InputReader: Get Bluetooth address from InputDeviceIdentifier
The InputDevice class in Reader stores the InputDeviceIdentifier. When
the policy wants to get the Bluetooth address of an InputDevice, fetch
it from there.
Bug: 243005009
Test: atest inputflinger_tests
Change-Id: I5d881a11cb1bc318258faf1f498db1ca29ae8537
diff --git a/services/inputflinger/reader/InputReader.cpp b/services/inputflinger/reader/InputReader.cpp
index 903d072..f8b1b3f 100644
--- a/services/inputflinger/reader/InputReader.cpp
+++ b/services/inputflinger/reader/InputReader.cpp
@@ -875,6 +875,16 @@
return std::nullopt;
}
+std::optional<std::string> InputReader::getBluetoothAddress(int32_t deviceId) const {
+ std::scoped_lock _l(mLock);
+
+ InputDevice* device = findInputDeviceLocked(deviceId);
+ if (device) {
+ return device->getBluetoothAddress();
+ }
+ return std::nullopt;
+}
+
bool InputReader::isInputDeviceEnabled(int32_t deviceId) {
std::scoped_lock _l(mLock);