From 50cf7b3722b8649d5e34ed090aaee4a9a00e3a2e Mon Sep 17 00:00:00 2001 From: Anton Utkin Date: Fri, 19 May 2023 15:50:03 +0300 Subject: [PATCH] UEventObserver: Fix logging for uevent messages Every uevent message in buffer contains '\0' characters and only part of the message is displayed right now. So, all '\0' characters should be replaced for correct logging. Test: checked uvent message in logcat Change-Id: I5bcdf117208feae542f0d4619cb03eddbcfce32c Signed-off-by: Anton Utkin --- core/jni/android_os_UEventObserver.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/jni/android_os_UEventObserver.cpp b/core/jni/android_os_UEventObserver.cpp index 2df74b05d97bd..eda50758bca9b 100644 --- a/core/jni/android_os_UEventObserver.cpp +++ b/core/jni/android_os_UEventObserver.cpp @@ -71,7 +71,11 @@ static jstring nativeWaitForNextEvent(JNIEnv *env, jclass clazz) { } buffer[length] = '\0'; - ALOGV("Received uevent message: %s", buffer); + IF_ALOGV() { + std::string message(buffer, length); + std::replace(message.begin(), message.end(), '\0', ' '); + ALOGV("Received uevent message: %s", message.c_str()); + } if (isMatch(buffer, length)) { // Assume the message is ASCII.