2020#include < unistd.h>
2121#include < ctype.h>
2222
23+ #include < android-base/logging.h>
2324#include < android-base/properties.h>
2425#include < android-base/stringprintf.h>
2526#include < ftl/enum.h>
@@ -31,6 +32,9 @@ using android::base::StringPrintf;
3132
3233namespace android {
3334
35+ // Set to true to log detailed debugging messages about IDC file probing.
36+ static constexpr bool DEBUG_PROBE = false ;
37+
3438static const char * CONFIGURATION_FILE_DIR[] = {
3539 " idc/" ,
3640 " keylayout/" ,
@@ -114,15 +118,14 @@ std::string getInputDeviceConfigurationFilePathByName(
114118 for (const auto & prefix : pathPrefixes) {
115119 path = prefix;
116120 appendInputDeviceConfigurationFileRelativePath (path, name, type);
117- #if DEBUG_PROBE
118- ALOGD (" Probing for system provided input device configuration file: path='%s'" ,
119- path.c_str ());
120- #endif
121121 if (!access (path.c_str (), R_OK)) {
122- #if DEBUG_PROBE
123- ALOGD (" Found" );
124- #endif
122+ LOG_IF (INFO, DEBUG_PROBE)
123+ << " Found system-provided input device configuration file at " << path;
125124 return path;
125+ } else {
126+ LOG_IF (ERROR, DEBUG_PROBE)
127+ << " Didn't find system-provided input device configuration file at " << path
128+ << " : " << strerror (errno);
126129 }
127130 }
128131
@@ -135,21 +138,18 @@ std::string getInputDeviceConfigurationFilePathByName(
135138 }
136139 path += " /system/devices/" ;
137140 appendInputDeviceConfigurationFileRelativePath (path, name, type);
138- #if DEBUG_PROBE
139- ALOGD (" Probing for system user input device configuration file: path='%s'" , path.c_str ());
140- #endif
141141 if (!access (path.c_str (), R_OK)) {
142- #if DEBUG_PROBE
143- ALOGD (" Found" );
144- #endif
142+ LOG_IF (INFO, DEBUG_PROBE) << " Found system user input device configuration file at "
143+ << path;
145144 return path;
145+ } else {
146+ LOG_IF (ERROR, DEBUG_PROBE) << " Didn't find system user input device configuration file at "
147+ << path << " : " << strerror (errno);
146148 }
147149
148150 // Not found.
149- #if DEBUG_PROBE
150- ALOGD (" Probe failed to find input device configuration file: name='%s', type=%d" ,
151- name.c_str (), type);
152- #endif
151+ LOG_IF (INFO, DEBUG_PROBE) << " Probe failed to find input device configuration file with name '"
152+ << name << " ' and type " << ftl::enum_string (type);
153153 return " " ;
154154}
155155
0 commit comments