From 7a57b8a3cf048b3d5e7587bed1a74b4693d80b0a Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Mon, 10 Feb 2020 14:18:45 -0800 Subject: [PATCH] String16: operator<< Before, this was printing the pointer to the char16_t* because of an automatic conversion. However, this is almost never intended. Bug: N/A Test: dumpsys_test Change-Id: Iaafcb2145cf93028cf3271813c56b8b74948f943 --- libutils/include/utils/String16.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libutils/include/utils/String16.h b/libutils/include/utils/String16.h index adc3e7de9..c7dd41825 100644 --- a/libutils/include/utils/String16.h +++ b/libutils/include/utils/String16.h @@ -17,7 +17,8 @@ #ifndef ANDROID_STRING16_H #define ANDROID_STRING16_H -#include // for std::string +#include +#include #include #include @@ -203,6 +204,11 @@ public: // require any change to the underlying SharedBuffer contents or reference count. ANDROID_TRIVIAL_MOVE_TRAIT(String16) +static inline std::ostream& operator<<(std::ostream& os, const String16& str) { + os << String8(str).c_str(); + return os; +} + // --------------------------------------------------------------------------- /*