libbinder_ndk: distinguish exception/status_t
Previously here, I had erroneously used EX_* values instead of using
values corresponding to status_t.
This CL defines the set of errors that can be returned from APIs and
constrains the return set to be exactly and only those values.
Exception values are currently not used, but they will be used for
a Status-like object since they are required for communicating with
the SDK (Java). This is also why they were not removed.
Bug: 111445392
Test: ./ndk/runtests.sh
Change-Id: I24bbebae60c167d7e050ee608c24cc1ffc8a9101
diff --git a/libs/binder/ndk/service_manager.cpp b/libs/binder/ndk/service_manager.cpp
index 5bc69b0..9ddc555 100644
--- a/libs/binder/ndk/service_manager.cpp
+++ b/libs/binder/ndk/service_manager.cpp
@@ -15,7 +15,9 @@
*/
#include <android/binder_manager.h>
+
#include "ibinder_internal.h"
+#include "status_internal.h"
#include <binder/IServiceManager.h>
@@ -23,15 +25,17 @@
using ::android::IBinder;
using ::android::IServiceManager;
using ::android::sp;
+using ::android::status_t;
using ::android::String16;
binder_status_t AServiceManager_addService(AIBinder* binder, const char* instance) {
if (binder == nullptr || instance == nullptr) {
- return EX_NULL_POINTER;
+ return STATUS_UNEXPECTED_NULL;
}
sp<IServiceManager> sm = defaultServiceManager();
- return sm->addService(String16(instance), binder->getBinder());
+ status_t status = sm->addService(String16(instance), binder->getBinder());
+ return PruneStatusT(status);
}
AIBinder* AServiceManager_getService(const char* instance) {
if (instance == nullptr) {