diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-02-26 10:31:47 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-02-26 10:31:47 +0000 |
commit | 66f997044464201364cc6de8702aba8e1c9a2e23 (patch) | |
tree | 7ca8496de665e87566b599cfe87a7a21b4eba8ba | |
parent | 7dad29dc9a85d04e47e32cebc299dbe6afe47f22 (diff) | |
parent | 9b5e7c674fa9c7ea895210bd79afc46db2e5959a (diff) | |
download | native-66f997044464201364cc6de8702aba8e1c9a2e23.tar.gz |
Merge "Fix binder_to_string.h for NDK"
-rw-r--r-- | libs/binder/ndk/include_cpp/android/binder_to_string.h | 11 |
1 files changed, 8 insertions, 3 deletions
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 584292551b..ef71a81328 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 @@ class ToEmptyString { 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 @@ std::string ToString(const _T& t) { 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); |