Use a sysprop to enable `TouchpadInputMapper`
The new touchpad behaviour can now be toggled using the `setprop`
command followed by a userspace reboot instead of having to change the
const and rebuild.
Bug: 251196347
Test: set the flag with setprop, check the gestures library logs appear
Test: atest inputflinger_tests
Change-Id: Ie4db00219e915fd059647d7541ef84e27e75bd86
diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp
index 150a8aa..8d5377f 100644
--- a/services/inputflinger/reader/InputDevice.cpp
+++ b/services/inputflinger/reader/InputDevice.cpp
@@ -20,6 +20,9 @@
#include <algorithm>
+#if defined(__ANDROID__)
+#include <android/sysprop/InputProperties.sysprop.h>
+#endif
#include <ftl/flags.h>
#include "CursorInputMapper.h"
@@ -209,9 +212,13 @@
}
// Touchscreens and touchpad devices.
- // TODO(b/251196347): replace this with a proper flag.
- constexpr bool ENABLE_NEW_TOUCHPAD_STACK = false;
- if (ENABLE_NEW_TOUCHPAD_STACK && classes.test(InputDeviceClass::TOUCHPAD) &&
+ static const bool ENABLE_TOUCHPAD_GESTURES_LIBRARY =
+#if defined(__ANDROID__)
+ sysprop::InputProperties::enable_touchpad_gestures_library().value_or(false);
+#else
+ false;
+#endif
+ if (ENABLE_TOUCHPAD_GESTURES_LIBRARY && classes.test(InputDeviceClass::TOUCHPAD) &&
classes.test(InputDeviceClass::TOUCH_MT)) {
mappers.push_back(std::make_unique<TouchpadInputMapper>(*contextPtr));
} else if (classes.test(InputDeviceClass::TOUCH_MT)) {