Merge "Fix binder_to_string.h for NDK" am: 66f9970444 am: 3fc1c34118 am: 0fe7341965
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1607793
MUST ONLY BE SUBMITTED BY AUTOMERGER
Change-Id: Iee3fed1ac21b27b633ee5a1b4c7666f3839e27c4
diff --git a/libs/binder/ndk/include_cpp/android/binder_to_string.h b/libs/binder/ndk/include_cpp/android/binder_to_string.h
index 5842925..ef71a81 100644
--- a/libs/binder/ndk/include_cpp/android/binder_to_string.h
+++ b/libs/binder/ndk/include_cpp/android/binder_to_string.h
@@ -136,8 +136,7 @@
template <typename _U>
static std::enable_if_t<
#ifdef HAS_NDK_INTERFACE
- std::is_base_of_v<::ndk::ICInterface, _U> || std::is_same_v<::ndk::SpAIBinder, _U> ||
- std::is_same_v<::ndk::ScopedFileDescriptor, _U> ||
+ std::is_base_of_v<::ndk::ICInterface, _U> ||
std::is_same_v<::ndk::AParcelableHolder, _U>
#else
std::is_base_of_v<IInterface, _U> || std::is_same_v<IBinder, _U> ||
@@ -168,13 +167,19 @@
return std::to_string(t);
} else if constexpr (std::is_same_v<std::string, _T>) {
return t;
+#ifdef HAS_NDK_INTERFACE
+ } else if constexpr (std::is_same_v<::ndk::SpAIBinder, _T>) {
+ return (t.get() == nullptr) ? "(null)" : "";
+ } else if constexpr (std::is_same_v<::ndk::ScopedFileDescriptor, _T>) {
+ return (t.get() == -1) ? "(null)" : "";
+#endif
#ifdef HAS_STRING16
} else if constexpr (std::is_same_v<String16, _T>) {
std::stringstream out;
out << t;
return out.str();
#endif
- } else if constexpr (details::IsPointerLike<_T>::value) {
+ } else if constexpr (details::IsPointerLike<_T>::value || std::is_pointer_v<_T>) {
if (!t) return "(null)";
std::stringstream out;
out << ToString(*t);