summaryrefslogtreecommitdiff
path: root/libs/input/InputDevice.cpp
diff options
context:
space:
mode:
author Xin Li <delphij@google.com> 2024-11-12 22:22:43 -0800
committer Xin Li <delphij@google.com> 2024-11-12 22:22:43 -0800
commit6dc15689f6bb4b04c102ac3107f31377ee91f05e (patch)
tree3ca9d372bc99ac1182fdb4bc895c556d0f108bd3 /libs/input/InputDevice.cpp
parentd4d02798539f29d00059d458fd01e5b2869acbb6 (diff)
parentf151262626f1c08a104cc35d9864493ea8a72dec (diff)
Merge 24Q4 (ab/12406339) into aosp-main-future
Bug: 370570306 Merged-In: I9be1254c3e2685b0aa950b314c581824f40ce26c Change-Id: I35bc501a2b1d9eb100aaab25cd660cf2e0542f99
Diffstat (limited to 'libs/input/InputDevice.cpp')
-rw-r--r--libs/input/InputDevice.cpp42
1 files changed, 25 insertions, 17 deletions
diff --git a/libs/input/InputDevice.cpp b/libs/input/InputDevice.cpp
index 9333ab83a6..c9030312f9 100644
--- a/libs/input/InputDevice.cpp
+++ b/libs/input/InputDevice.cpp
@@ -20,6 +20,7 @@
#include <unistd.h>
#include <ctype.h>
+#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <ftl/enum.h>
@@ -31,6 +32,9 @@ using android::base::StringPrintf;
namespace android {
+// Set to true to log detailed debugging messages about IDC file probing.
+static constexpr bool DEBUG_PROBE = false;
+
static const char* CONFIGURATION_FILE_DIR[] = {
"idc/",
"keylayout/",
@@ -114,15 +118,18 @@ std::string getInputDeviceConfigurationFilePathByName(
for (const auto& prefix : pathPrefixes) {
path = prefix;
appendInputDeviceConfigurationFileRelativePath(path, name, type);
-#if DEBUG_PROBE
- ALOGD("Probing for system provided input device configuration file: path='%s'",
- path.c_str());
-#endif
if (!access(path.c_str(), R_OK)) {
-#if DEBUG_PROBE
- ALOGD("Found");
-#endif
+ LOG_IF(INFO, DEBUG_PROBE)
+ << "Found system-provided input device configuration file at " << path;
return path;
+ } else if (errno != ENOENT) {
+ LOG(WARNING) << "Couldn't find a system-provided input device configuration file at "
+ << path << " due to error " << errno << " (" << strerror(errno)
+ << "); there may be an IDC file there that cannot be loaded.";
+ } else {
+ LOG_IF(ERROR, DEBUG_PROBE)
+ << "Didn't find system-provided input device configuration file at " << path
+ << ": " << strerror(errno);
}
}
@@ -135,21 +142,22 @@ std::string getInputDeviceConfigurationFilePathByName(
}
path += "/system/devices/";
appendInputDeviceConfigurationFileRelativePath(path, name, type);
-#if DEBUG_PROBE
- ALOGD("Probing for system user input device configuration file: path='%s'", path.c_str());
-#endif
if (!access(path.c_str(), R_OK)) {
-#if DEBUG_PROBE
- ALOGD("Found");
-#endif
+ LOG_IF(INFO, DEBUG_PROBE) << "Found system user input device configuration file at "
+ << path;
return path;
+ } else if (errno != ENOENT) {
+ LOG(WARNING) << "Couldn't find a system user input device configuration file at " << path
+ << " due to error " << errno << " (" << strerror(errno)
+ << "); there may be an IDC file there that cannot be loaded.";
+ } else {
+ LOG_IF(ERROR, DEBUG_PROBE) << "Didn't find system user input device configuration file at "
+ << path << ": " << strerror(errno);
}
// Not found.
-#if DEBUG_PROBE
- ALOGD("Probe failed to find input device configuration file: name='%s', type=%d",
- name.c_str(), type);
-#endif
+ LOG_IF(INFO, DEBUG_PROBE) << "Probe failed to find input device configuration file with name '"
+ << name << "' and type " << ftl::enum_string(type);
return "";
}