Allow debug logging of dispatcher's inbound events to be enabled on the fly
Enabling debug logs via adb commands required a reboot of the shell. In
order to debug flaky tests more easily, we allow raw event logs to be
enabled and disabled without the need for a restart on debuggable
builds.
We limit this ability to debuggable builds ensure there is no
performance overhead on user builds.
This change allows us to enable more verbose logging on flaky tests that
are hard to reproduce.
Bug: 193231132
Test: Manual, using adb command to enable debug logs on userdebug builds
Change-Id: Idf6f7fb35ad02e059582b1f0e7b3b2d006ff0730
diff --git a/services/inputflinger/dispatcher/Entry.cpp b/services/inputflinger/dispatcher/Entry.cpp
index 621543a..b625a1b 100644
--- a/services/inputflinger/dispatcher/Entry.cpp
+++ b/services/inputflinger/dispatcher/Entry.cpp
@@ -14,11 +14,13 @@
* limitations under the License.
*/
+#define LOG_TAG "InputDispatcher"
+
#include "Entry.h"
#include "Connection.h"
+#include "DebugConfig.h"
-#include <android-base/properties.h>
#include <android-base/stringprintf.h>
#include <cutils/atomic.h>
#include <inttypes.h>
@@ -27,13 +29,6 @@
namespace android::inputdispatcher {
-static const bool DEBUGGABLE =
-#if defined(__ANDROID__)
- android::base::GetBoolProperty("ro.debuggable", false);
-#else
- true;
-#endif
-
VerifiedKeyEvent verifiedKeyEventFromKeyEntry(const KeyEntry& entry) {
return {{VerifiedInputEvent::Type::KEY, entry.deviceId, entry.eventTime, entry.source,
entry.displayId},
@@ -178,7 +173,7 @@
KeyEntry::~KeyEntry() {}
std::string KeyEntry::getDescription() const {
- if (!DEBUGGABLE) {
+ if (!IS_DEBUGGABLE_BUILD) {
return "KeyEvent";
}
return StringPrintf("KeyEvent(deviceId=%d, eventTime=%" PRIu64 ", source=%s, displayId=%" PRId32
@@ -248,7 +243,7 @@
MotionEntry::~MotionEntry() {}
std::string MotionEntry::getDescription() const {
- if (!DEBUGGABLE) {
+ if (!IS_DEBUGGABLE_BUILD) {
return "MotionEvent";
}
std::string msg;
@@ -298,7 +293,7 @@
deviceId, inputEventSourceToString(source).c_str(),
ftl::enum_string(sensorType).c_str(), accuracy, hwTimestamp);
- if (DEBUGGABLE) {
+ if (IS_DEBUGGABLE_BUILD) {
for (size_t i = 0; i < values.size(); i++) {
if (i > 0) {
msg += ", ";