libbinder_ndk: add AStatus_getDescription
API to get a description of the status.
Bug: 136027762
Test: using API
Change-Id: I04be1dcba27f03751c4db5627432fe94d3636d44
diff --git a/libs/binder/ndk/status.cpp b/libs/binder/ndk/status.cpp
index 1f75b0b..87e1341 100644
--- a/libs/binder/ndk/status.cpp
+++ b/libs/binder/ndk/status.cpp
@@ -66,6 +66,17 @@
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;
}