input: use optionals for PropertyMap getters
Using optionals rather than returning a boolean forces the caller to
check whether the property is present, enforced by the compiler, and
also allows a more succinct syntax in some cases.
Bug: 245989146
Test: atest inputflinger_test
Test: connect Apple Magic Trackpad 2, check that gesture properties are
set correctly in dumpsys input
Change-Id: Ia0fde1f67269e6e7149f297def626e572fd7790f
diff --git a/services/inputflinger/host/InputDriver.cpp b/services/inputflinger/host/InputDriver.cpp
index 97d57e4..ec0388d 100644
--- a/services/inputflinger/host/InputDriver.cpp
+++ b/services/inputflinger/host/InputDriver.cpp
@@ -242,13 +242,13 @@
input_property_t* InputDriver::inputGetDeviceProperty(input_property_map_t* map, const char* key) {
if (map != nullptr) {
- std::string value;
- auto prop = std::make_unique<input_property_t>();
- if (!map->propertyMap->tryGetProperty(key, value)) {
+ std::optional<std::string> value = map->propertyMap->getString(key);
+ if (!value.has_value()) {
return nullptr;
}
+ auto prop = std::make_unique<input_property_t>();
prop->key = key;
- prop->value = value.c_str();
+ prop->value = value->c_str();
return prop.release();
}
return nullptr;