Loading libs/binder/ndk/include_ndk/android/binder_auto_utils.h +8 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include <unistd.h> #include <cstddef> #include <string> namespace ndk { Loading Loading @@ -228,6 +229,13 @@ class ScopedAStatus : public impl::ScopedAResource<AStatus*, void, AStatus_delet */ const char* getMessage() const { return AStatus_getMessage(get()); } std::string getDescription() const { const char* cStr = AStatus_getDescription(get()); std::string ret = cStr; AStatus_deleteDescription(cStr); return ret; } /** * Convenience methods for creating scoped statuses. */ Loading libs/binder/ndk/include_ndk/android/binder_status.h +19 −0 Original line number Diff line number Diff line Loading @@ -246,6 +246,25 @@ binder_status_t AStatus_getStatus(const AStatus* status) __INTRODUCED_IN(29); */ const char* AStatus_getMessage(const AStatus* status) __INTRODUCED_IN(29); /** * Get human-readable description for debugging. * * Available since API level 30. * * \param status the status being queried. * * \return a description, must be deleted with AStatus_deleteDescription. */ __attribute__((warn_unused_result)) const char* AStatus_getDescription(const AStatus* status) __INTRODUCED_IN(30); /** * Delete description. * * \param description value from AStatus_getDescription */ void AStatus_deleteDescription(const char* description) __INTRODUCED_IN(30); /** * Deletes memory associated with the status instance. * Loading libs/binder/ndk/libbinder_ndk.map.txt +2 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ LIBBINDER_NDK30 { # introduced=30 global: AIBinder_getExtension; AIBinder_setExtension; AStatus_getDescription; AStatus_deleteDescription; AIBinder_markSystemStability; # apex AIBinder_markVendorStability; # llndk Loading libs/binder/ndk/status.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,17 @@ const char* AStatus_getMessage(const AStatus* status) { return status->get()->exceptionMessage().c_str(); } const char* AStatus_getDescription(const AStatus* status) { android::String8 description = status->get()->toString8(); char* cStr = new char[description.size() + 1]; memcpy(cStr, description.c_str(), description.size() + 1); return cStr; } void AStatus_deleteDescription(const char* description) { delete[] const_cast<char*>(description); } void AStatus_delete(AStatus* status) { delete status; } Loading libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ TEST(DoubleBinder, CallIntoNdk) { std::string outString; ScopedAStatus status = server->RepeatString("foo", &outString); EXPECT_EQ(STATUS_OK, AStatus_getExceptionCode(status.get())) << serviceName; EXPECT_EQ(STATUS_OK, AStatus_getExceptionCode(status.get())) << serviceName << " " << status.getDescription(); EXPECT_EQ("foo", outString) << serviceName; } } Loading Loading
libs/binder/ndk/include_ndk/android/binder_auto_utils.h +8 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include <unistd.h> #include <cstddef> #include <string> namespace ndk { Loading Loading @@ -228,6 +229,13 @@ class ScopedAStatus : public impl::ScopedAResource<AStatus*, void, AStatus_delet */ const char* getMessage() const { return AStatus_getMessage(get()); } std::string getDescription() const { const char* cStr = AStatus_getDescription(get()); std::string ret = cStr; AStatus_deleteDescription(cStr); return ret; } /** * Convenience methods for creating scoped statuses. */ Loading
libs/binder/ndk/include_ndk/android/binder_status.h +19 −0 Original line number Diff line number Diff line Loading @@ -246,6 +246,25 @@ binder_status_t AStatus_getStatus(const AStatus* status) __INTRODUCED_IN(29); */ const char* AStatus_getMessage(const AStatus* status) __INTRODUCED_IN(29); /** * Get human-readable description for debugging. * * Available since API level 30. * * \param status the status being queried. * * \return a description, must be deleted with AStatus_deleteDescription. */ __attribute__((warn_unused_result)) const char* AStatus_getDescription(const AStatus* status) __INTRODUCED_IN(30); /** * Delete description. * * \param description value from AStatus_getDescription */ void AStatus_deleteDescription(const char* description) __INTRODUCED_IN(30); /** * Deletes memory associated with the status instance. * Loading
libs/binder/ndk/libbinder_ndk.map.txt +2 −0 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ LIBBINDER_NDK30 { # introduced=30 global: AIBinder_getExtension; AIBinder_setExtension; AStatus_getDescription; AStatus_deleteDescription; AIBinder_markSystemStability; # apex AIBinder_markVendorStability; # llndk Loading
libs/binder/ndk/status.cpp +11 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,17 @@ const char* AStatus_getMessage(const AStatus* status) { return status->get()->exceptionMessage().c_str(); } const char* AStatus_getDescription(const AStatus* status) { android::String8 description = status->get()->toString8(); char* cStr = new char[description.size() + 1]; memcpy(cStr, description.c_str(), description.size() + 1); return cStr; } void AStatus_deleteDescription(const char* description) { delete[] const_cast<char*>(description); } void AStatus_delete(AStatus* status) { delete status; } Loading
libs/binder/ndk/test/binderVendorDoubleLoadTest.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,8 @@ TEST(DoubleBinder, CallIntoNdk) { std::string outString; ScopedAStatus status = server->RepeatString("foo", &outString); EXPECT_EQ(STATUS_OK, AStatus_getExceptionCode(status.get())) << serviceName; EXPECT_EQ(STATUS_OK, AStatus_getExceptionCode(status.get())) << serviceName << " " << status.getDescription(); EXPECT_EQ("foo", outString) << serviceName; } } Loading