Skip to content

Commit f20b6ba

Browse files
committed
InputDevice: modernize IDC probe debugging logs
* Use the new-style stream syntax for readability * Upgrade DEBUGs to INFOs (since the new-style stream syntax filters DEBUG logs by default, and since these are hidden behind a compile-time constant it's fine to promote them) * Include the reason we didn't find a particular IDC file Bug: 365593937 Test: set DEBUG_PROBE to true, check logcat for the InputReader tag while connecting an input device Flag: EXEMPT code disabled by compile-time constant Change-Id: I7801252b688b4869911792aa66d2dcdceed8713b
1 parent 90a7572 commit f20b6ba

2 files changed

Lines changed: 18 additions & 17 deletions

File tree

include/input/InputDevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ enum class InputDeviceConfigurationFileType : int32_t {
389389
CONFIGURATION = 0, /* .idc file */
390390
KEY_LAYOUT = 1, /* .kl file */
391391
KEY_CHARACTER_MAP = 2, /* .kcm file */
392+
ftl_last = KEY_CHARACTER_MAP,
392393
};
393394

394395
/*

libs/input/InputDevice.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
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

3233
namespace android {
3334

35+
// Set to true to log detailed debugging messages about IDC file probing.
36+
static constexpr bool DEBUG_PROBE = false;
37+
3438
static 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

Comments
 (0)