diff options
| author | 2019-02-20 19:36:25 -0600 | |
|---|---|---|
| committer | 2019-02-21 14:03:10 -0600 | |
| commit | 409ec1a880f770844120e8b0fdd02837bf0c3bf7 (patch) | |
| tree | fb921b5a716275dcd2c63220e5e1bdfd22c22f9e /libs/input/InputDevice.cpp | |
| parent | b45635c8a3f4b38298ebe60922a6f61c4b99e491 (diff) | |
Use InputDeviceIdentifier.getCanonicalName
Currently, there are 2 places with identical logic in InputDevice.cpp.
This is because the file name adjustment to only contain
alphanumerics, dash, and underscore is done for virtual key maps and for
other devices together.
Use the recently added api to simplify this. Also, this will prevent
having to iterate through Vendor_*_Product_* filenames, since those are
already guaranteed to be compliant.
Bug: 113575658
Test: atest libinput_tests inputflinger_tests
Change-Id: Icb22f6e76b83b6d7d170b9e537787f0455db1c1f
Diffstat (limited to 'libs/input/InputDevice.cpp')
| -rw-r--r-- | libs/input/InputDevice.cpp | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp index 7dcad5a6a9..dab6eac2f4 100644 --- a/libs/input/InputDevice.cpp +++ b/libs/input/InputDevice.cpp @@ -46,15 +46,9 @@ static bool isValidNameChar(char ch) { static void appendInputDeviceConfigurationFileRelativePath(std::string& path, const std::string& name, InputDeviceConfigurationFileType type) { - path.append(CONFIGURATION_FILE_DIR[type]); - for (size_t i = 0; i < name.length(); i++) { - char ch = name[i]; - if (!isValidNameChar(ch)) { - ch = '_'; - } - path.append(&ch, 1); - } - path.append(CONFIGURATION_FILE_EXTENSION[type]); + path += CONFIGURATION_FILE_DIR[type]; + path += name; + path += CONFIGURATION_FILE_EXTENSION[type]; } std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( @@ -84,7 +78,7 @@ std::string getInputDeviceConfigurationFilePathByDeviceIdentifier( } // Try device name. - return getInputDeviceConfigurationFilePathByName(deviceIdentifier.name, type); + return getInputDeviceConfigurationFilePathByName(deviceIdentifier.getCanonicalName(), type); } std::string getInputDeviceConfigurationFilePathByName( |