|
20 | 20 | #include <unistd.h> |
21 | 21 | #include <ctype.h> |
22 | 22 |
|
| 23 | +#include <android-base/properties.h> |
23 | 24 | #include <android-base/stringprintf.h> |
24 | 25 | #include <ftl/enum.h> |
25 | 26 | #include <gui/constants.h> |
26 | 27 | #include <input/InputDevice.h> |
27 | 28 | #include <input/InputEventLabels.h> |
28 | 29 |
|
| 30 | +using android::base::GetProperty; |
29 | 31 | using android::base::StringPrintf; |
30 | 32 |
|
31 | 33 | namespace android { |
@@ -96,21 +98,22 @@ std::string getInputDeviceConfigurationFilePathByName( |
96 | 98 |
|
97 | 99 | // Treblized input device config files will be located /product/usr, /system_ext/usr, |
98 | 100 | // /odm/usr or /vendor/usr. |
99 | | - // These files may also be in the com.android.input.config APEX. |
100 | | - const char* rootsForPartition[]{ |
101 | | - "/product", |
102 | | - "/system_ext", |
103 | | - "/odm", |
104 | | - "/vendor", |
105 | | - "/apex/com.android.input.config/etc", |
106 | | - getenv("ANDROID_ROOT"), |
| 101 | + std::vector<std::string> pathPrefixes{ |
| 102 | + "/product/usr/", |
| 103 | + "/system_ext/usr/", |
| 104 | + "/odm/usr/", |
| 105 | + "/vendor/usr/", |
107 | 106 | }; |
108 | | - for (size_t i = 0; i < size(rootsForPartition); i++) { |
109 | | - if (rootsForPartition[i] == nullptr) { |
110 | | - continue; |
111 | | - } |
112 | | - path = rootsForPartition[i]; |
113 | | - path += "/usr/"; |
| 107 | + // These files may also be in the APEX pointed by input_device.config_file.apex sysprop. |
| 108 | + if (auto apex = GetProperty("input_device.config_file.apex", ""); !apex.empty()) { |
| 109 | + pathPrefixes.push_back("/apex/" + apex + "/etc/usr/"); |
| 110 | + } |
| 111 | + // ANDROID_ROOT may not be set on host |
| 112 | + if (auto android_root = getenv("ANDROID_ROOT"); android_root != nullptr) { |
| 113 | + pathPrefixes.push_back(std::string(android_root) + "/usr/"); |
| 114 | + } |
| 115 | + for (const auto& prefix : pathPrefixes) { |
| 116 | + path = prefix; |
114 | 117 | appendInputDeviceConfigurationFileRelativePath(path, name, type); |
115 | 118 | #if DEBUG_PROBE |
116 | 119 | ALOGD("Probing for system provided input device configuration file: path='%s'", |
|
0 commit comments