Revert "Support touchpad gesture properties in IDC files"
Revert submission 21750284-touchpad-specific-tuning
Reason for revert: resolves flake b/272308130 according to culprit assistant https://android-build.googleplex.com/builds/culprit-assistant/run/6257e5da-1bb0-437a-8fab-f04c27d462b3 verified by 6 runs in abtd https://android-build.googleplex.com/builds/abtd/run/L75900000959044402
Reverted changes: /q/submissionid:21750284-touchpad-specific-tuning
Change-Id: I62078104a96d588bd321459e5a069dd0de5933bd
diff --git a/include/input/PropertyMap.h b/include/input/PropertyMap.h
index 18ce16d..28e4816 100644
--- a/include/input/PropertyMap.h
+++ b/include/input/PropertyMap.h
@@ -18,10 +18,7 @@
#include <android-base/result.h>
#include <utils/Tokenizer.h>
-
-#include <string>
#include <unordered_map>
-#include <unordered_set>
namespace android {
@@ -60,9 +57,6 @@
*/
void addProperty(const std::string& key, const std::string& value);
- /* Returns a set of all property keys starting with the given prefix. */
- std::unordered_set<std::string> getKeysWithPrefix(const std::string& prefix) const;
-
/* Gets the value of a property and parses it.
* Returns true and sets outValue if the key was found and its value was parsed successfully.
* Otherwise returns false and does not modify outValue. (Also logs a warning.)
@@ -71,7 +65,6 @@
bool tryGetProperty(const std::string& key, bool& outValue) const;
bool tryGetProperty(const std::string& key, int32_t& outValue) const;
bool tryGetProperty(const std::string& key, float& outValue) const;
- bool tryGetProperty(const std::string& key, double& outValue) const;
/* Adds all values from the specified property map. */
void addAll(const PropertyMap* map);
diff --git a/libs/input/Android.bp b/libs/input/Android.bp
index 869458c..f38dd98 100644
--- a/libs/input/Android.bp
+++ b/libs/input/Android.bp
@@ -167,7 +167,6 @@
cc_defaults {
name: "libinput_fuzz_defaults",
- cpp_std: "c++20",
host_supported: true,
shared_libs: [
"libutils",
diff --git a/libs/input/PropertyMap.cpp b/libs/input/PropertyMap.cpp
index 9a4f10b..ed9ac9f 100644
--- a/libs/input/PropertyMap.cpp
+++ b/libs/input/PropertyMap.cpp
@@ -16,8 +16,6 @@
#define LOG_TAG "PropertyMap"
-#include <cstdlib>
-
#include <input/PropertyMap.h>
#include <log/log.h>
@@ -46,16 +44,6 @@
mProperties.emplace(key, value);
}
-std::unordered_set<std::string> PropertyMap::getKeysWithPrefix(const std::string& prefix) const {
- std::unordered_set<std::string> keys;
- for (const auto& [key, _] : mProperties) {
- if (key.starts_with(prefix)) {
- keys.insert(key);
- }
- }
- return keys;
-}
-
bool PropertyMap::hasProperty(const std::string& key) const {
return mProperties.find(key) != mProperties.end();
}
@@ -114,23 +102,6 @@
return true;
}
-bool PropertyMap::tryGetProperty(const std::string& key, double& outValue) const {
- std::string stringValue;
- if (!tryGetProperty(key, stringValue) || stringValue.length() == 0) {
- return false;
- }
-
- char* end;
- double value = strtod(stringValue.c_str(), &end);
- if (*end != '\0') {
- ALOGW("Property key '%s' has invalid value '%s'. Expected a double.", key.c_str(),
- stringValue.c_str());
- return false;
- }
- outValue = value;
- return true;
-}
-
void PropertyMap::addAll(const PropertyMap* map) {
for (const auto& [key, value] : map->mProperties) {
mProperties.emplace(key, value);
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
index 3309767..d3af402 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.cpp
@@ -20,7 +20,6 @@
#include <optional>
#include <android/input.h>
-#include <ftl/enum.h>
#include <input/PrintTools.h>
#include <linux/input-event-codes.h>
#include <log/log_main.h>
@@ -217,11 +216,6 @@
std::list<NotifyArgs> TouchpadInputMapper::configure(nsecs_t when,
const InputReaderConfiguration* config,
uint32_t changes) {
- if (!changes) {
- // First time configuration
- mPropertyProvider.loadPropertiesFromIdcFile(getDeviceContext().getConfiguration());
- }
-
if (!changes || (changes & InputReaderConfiguration::CHANGE_DISPLAY_INFO)) {
std::optional<int32_t> displayId = mPointerController->getDisplayId();
ui::Rotation orientation = ui::ROTATION_0;
diff --git a/services/inputflinger/reader/mapper/gestures/PropertyProvider.cpp b/services/inputflinger/reader/mapper/gestures/PropertyProvider.cpp
index 3d88338..089f45a 100644
--- a/services/inputflinger/reader/mapper/gestures/PropertyProvider.cpp
+++ b/services/inputflinger/reader/mapper/gestures/PropertyProvider.cpp
@@ -84,29 +84,6 @@
return dump;
}
-void PropertyProvider::loadPropertiesFromIdcFile(const PropertyMap& idcProperties) {
- // For compatibility with the configuration file syntax, gesture property names in IDC files are
- // prefixed with "gestureProp." and have spaces replaced by underscores. So, for example, the
- // configuration key "gestureProp.Palm_Width" refers to the "Palm Width" property.
- const std::string gesturePropPrefix = "gestureProp.";
- for (const std::string key : idcProperties.getKeysWithPrefix(gesturePropPrefix)) {
- std::string propertyName = key.substr(gesturePropPrefix.length());
- for (size_t i = 0; i < propertyName.length(); i++) {
- if (propertyName[i] == '_') {
- propertyName[i] = ' ';
- }
- }
-
- auto it = mProperties.find(propertyName);
- if (it != mProperties.end()) {
- it->second.trySetFromIdcProperty(idcProperties, key);
- } else {
- ALOGE("Gesture property \"%s\" specified in IDC file does not exist for this device.",
- propertyName.c_str());
- }
- }
-}
-
GesturesProp* PropertyProvider::createIntArrayProperty(const std::string& name, int* loc,
size_t count, const int* init) {
const auto [it, inserted] =
@@ -234,59 +211,6 @@
setValues(std::get<double*>(mDataPointer), values);
}
-namespace {
-
-// Helper to std::visit with lambdas.
-template <typename... V>
-struct Visitor : V... {};
-// explicit deduction guide (not needed as of C++20)
-template <typename... V>
-Visitor(V...) -> Visitor<V...>;
-
-} // namespace
-
-void GesturesProp::trySetFromIdcProperty(const android::PropertyMap& idcProperties,
- const std::string& propertyName) {
- if (mCount != 1) {
- ALOGE("Gesture property \"%s\" is an array, and so cannot be set in an IDC file.",
- mName.c_str());
- return;
- }
- bool parsedSuccessfully = false;
- Visitor setVisitor{
- [&](int*) {
- int32_t value;
- parsedSuccessfully = idcProperties.tryGetProperty(propertyName, value);
- if (parsedSuccessfully) {
- setIntValues({value});
- }
- },
- [&](GesturesPropBool*) {
- bool value;
- parsedSuccessfully = idcProperties.tryGetProperty(propertyName, value);
- if (parsedSuccessfully) {
- setBoolValues({value});
- }
- },
- [&](double*) {
- double value;
- parsedSuccessfully = idcProperties.tryGetProperty(propertyName, value);
- if (parsedSuccessfully) {
- setRealValues({value});
- }
- },
- [&](const char**) {
- ALOGE("Gesture property \"%s\" is a string, and so cannot be set in an IDC file.",
- mName.c_str());
- },
- };
- std::visit(setVisitor, mDataPointer);
-
- ALOGE_IF(!parsedSuccessfully, "Gesture property \"%s\" could set due to a type mismatch.",
- mName.c_str());
- return;
-}
-
template <typename T, typename U>
const std::vector<T> GesturesProp::getValues(U* dataPointer) const {
if (mGetter != nullptr) {
diff --git a/services/inputflinger/reader/mapper/gestures/PropertyProvider.h b/services/inputflinger/reader/mapper/gestures/PropertyProvider.h
index c7e0858..50451a3 100644
--- a/services/inputflinger/reader/mapper/gestures/PropertyProvider.h
+++ b/services/inputflinger/reader/mapper/gestures/PropertyProvider.h
@@ -22,7 +22,6 @@
#include <vector>
#include "include/gestures.h"
-#include "input/PropertyMap.h"
namespace android {
@@ -36,8 +35,6 @@
GesturesProp& getProperty(const std::string& name);
std::string dump() const;
- void loadPropertiesFromIdcFile(const PropertyMap& idcProperties);
-
// Methods to be called by the gestures library:
GesturesProp* createIntArrayProperty(const std::string& name, int* loc, size_t count,
const int* init);
@@ -86,9 +83,6 @@
// Setting string values isn't supported since we don't have a use case yet and the memory
// management adds additional complexity.
- void trySetFromIdcProperty(const android::PropertyMap& idcProperties,
- const std::string& propertyName);
-
private:
// Two type parameters are required for these methods, rather than one, due to the gestures
// library using its own bool type.
diff --git a/services/inputflinger/tests/PropertyProvider_test.cpp b/services/inputflinger/tests/PropertyProvider_test.cpp
index 8a40e78..42a6a9f 100644
--- a/services/inputflinger/tests/PropertyProvider_test.cpp
+++ b/services/inputflinger/tests/PropertyProvider_test.cpp
@@ -18,7 +18,6 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
-#include "TestConstants.h"
#include "include/gestures.h"
namespace android {
@@ -284,68 +283,4 @@
EXPECT_FALSE(mProvider.hasProperty("Foo"));
}
-class PropertyProviderIdcLoadingTest : public testing::Test {
-protected:
- void SetUp() override {
- int initialInt = 0;
- GesturesPropBool initialBool = false;
- double initialReal = 0.0;
- gesturePropProvider.create_int_fn(&mProvider, "An Integer", &mIntData, 1, &initialInt);
- gesturePropProvider.create_bool_fn(&mProvider, "A Boolean", &mBoolData, 1, &initialBool);
- gesturePropProvider.create_real_fn(&mProvider, "A Real", &mRealData, 1, &initialReal);
- }
-
- PropertyProvider mProvider;
-
- int mIntData;
- GesturesPropBool mBoolData;
- double mRealData;
-};
-
-TEST_F(PropertyProviderIdcLoadingTest, AllCorrect) {
- PropertyMap idcProps;
- idcProps.addProperty("gestureProp.An_Integer", "42");
- idcProps.addProperty("gestureProp.A_Boolean", "1");
- idcProps.addProperty("gestureProp.A_Real", "3.14159");
-
- mProvider.loadPropertiesFromIdcFile(idcProps);
- EXPECT_THAT(mProvider.getProperty("An Integer").getIntValues(), ElementsAre(42));
- EXPECT_THAT(mProvider.getProperty("A Boolean").getBoolValues(), ElementsAre(true));
- EXPECT_NEAR(mProvider.getProperty("A Real").getRealValues()[0], 3.14159, EPSILON);
-}
-
-TEST_F(PropertyProviderIdcLoadingTest, InvalidPropsIgnored) {
- int intArrayData[2];
- int initialInts[2] = {0, 1};
- gesturePropProvider.create_int_fn(&mProvider, "Two Integers", intArrayData, 2, initialInts);
-
- PropertyMap idcProps;
- // Wrong type
- idcProps.addProperty("gestureProp.An_Integer", "37.25");
- // Wrong size
- idcProps.addProperty("gestureProp.Two_Integers", "42");
- // Doesn't exist
- idcProps.addProperty("gestureProp.Some_Nonexistent_Property", "1");
- // A valid assignment that should still be applied despite the others being invalid
- idcProps.addProperty("gestureProp.A_Real", "3.14159");
-
- mProvider.loadPropertiesFromIdcFile(idcProps);
- EXPECT_THAT(mProvider.getProperty("An Integer").getIntValues(), ElementsAre(0));
- EXPECT_THAT(mProvider.getProperty("Two Integers").getIntValues(), ElementsAre(0, 1));
- EXPECT_FALSE(mProvider.hasProperty("Some Nonexistent Property"));
- EXPECT_NEAR(mProvider.getProperty("A Real").getRealValues()[0], 3.14159, EPSILON);
-}
-
-TEST_F(PropertyProviderIdcLoadingTest, FunkyName) {
- int data;
- int initialData = 0;
- gesturePropProvider.create_int_fn(&mProvider, " I lOvE sNAKes ", &data, 1, &initialData);
-
- PropertyMap idcProps;
- idcProps.addProperty("gestureProp.__I_lOvE_sNAKes_", "42");
-
- mProvider.loadPropertiesFromIdcFile(idcProps);
- EXPECT_THAT(mProvider.getProperty(" I lOvE sNAKes ").getIntValues(), ElementsAre(42));
-}
-
} // namespace android
diff --git a/services/inputflinger/tests/TestConstants.h b/services/inputflinger/tests/TestConstants.h
index ad48b0f..27881f6 100644
--- a/services/inputflinger/tests/TestConstants.h
+++ b/services/inputflinger/tests/TestConstants.h
@@ -16,10 +16,6 @@
#pragma once
-#include <chrono>
-
-#include <utils/Timers.h>
-
namespace android {
using std::chrono_literals::operator""ms;