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/parcel.cpp b/libs/binder/ndk/parcel.cpp
index ccdfc7b..a896d10 100644
--- a/libs/binder/ndk/parcel.cpp
+++ b/libs/binder/ndk/parcel.cpp
@@ -18,12 +18,14 @@
 #include "parcel_internal.h"
 
 #include "ibinder_internal.h"
+#include "status_internal.h"
 
 #include <binder/Parcel.h>
 
 using ::android::IBinder;
 using ::android::Parcel;
 using ::android::sp;
+using ::android::status_t;
 
 void AParcel_delete(AParcel** parcel) {
     if (parcel == nullptr) {
@@ -40,100 +42,118 @@
 }
 binder_status_t AParcel_readStrongBinder(const AParcel* parcel, AIBinder** binder) {
     sp<IBinder> readBinder = nullptr;
-    binder_status_t status = (*parcel)->readStrongBinder(&readBinder);
-    if (status != EX_NONE) {
-        return status;
+    status_t status = (*parcel)->readStrongBinder(&readBinder);
+    if (status != STATUS_OK) {
+        return PruneStatusT(status);
     }
     sp<AIBinder> ret = ABpBinder::lookupOrCreateFromBinder(readBinder);
     AIBinder_incStrong(ret.get());
     *binder = ret.get();
-    return status;
+    return PruneStatusT(status);
 }
 binder_status_t AParcel_readNullableStrongBinder(const AParcel* parcel, AIBinder** binder) {
     sp<IBinder> readBinder = nullptr;
-    binder_status_t status = (*parcel)->readNullableStrongBinder(&readBinder);
-    if (status != EX_NONE) {
-        return status;
+    status_t status = (*parcel)->readNullableStrongBinder(&readBinder);
+    if (status != STATUS_OK) {
+        return PruneStatusT(status);
     }
     sp<AIBinder> ret = ABpBinder::lookupOrCreateFromBinder(readBinder);
     AIBinder_incStrong(ret.get());
     *binder = ret.get();
-    return status;
+    return PruneStatusT(status);
 }
 
 // See gen_parcel_helper.py. These auto-generated read/write methods use the same types for
 // libbinder and this library.
 // @START
 binder_status_t AParcel_writeInt32(AParcel* parcel, int32_t value) {
-    return (*parcel)->writeInt32(value);
+    status_t status = (*parcel)->writeInt32(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_writeUint32(AParcel* parcel, uint32_t value) {
-    return (*parcel)->writeUint32(value);
+    status_t status = (*parcel)->writeUint32(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_writeInt64(AParcel* parcel, int64_t value) {
-    return (*parcel)->writeInt64(value);
+    status_t status = (*parcel)->writeInt64(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_writeUint64(AParcel* parcel, uint64_t value) {
-    return (*parcel)->writeUint64(value);
+    status_t status = (*parcel)->writeUint64(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_writeFloat(AParcel* parcel, float value) {
-    return (*parcel)->writeFloat(value);
+    status_t status = (*parcel)->writeFloat(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_writeDouble(AParcel* parcel, double value) {
-    return (*parcel)->writeDouble(value);
+    status_t status = (*parcel)->writeDouble(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_writeBool(AParcel* parcel, bool value) {
-    return (*parcel)->writeBool(value);
+    status_t status = (*parcel)->writeBool(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_writeChar(AParcel* parcel, char16_t value) {
-    return (*parcel)->writeChar(value);
+    status_t status = (*parcel)->writeChar(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_writeByte(AParcel* parcel, int8_t value) {
-    return (*parcel)->writeByte(value);
+    status_t status = (*parcel)->writeByte(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_readInt32(const AParcel* parcel, int32_t* value) {
-    return (*parcel)->readInt32(value);
+    status_t status = (*parcel)->readInt32(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_readUint32(const AParcel* parcel, uint32_t* value) {
-    return (*parcel)->readUint32(value);
+    status_t status = (*parcel)->readUint32(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_readInt64(const AParcel* parcel, int64_t* value) {
-    return (*parcel)->readInt64(value);
+    status_t status = (*parcel)->readInt64(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_readUint64(const AParcel* parcel, uint64_t* value) {
-    return (*parcel)->readUint64(value);
+    status_t status = (*parcel)->readUint64(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_readFloat(const AParcel* parcel, float* value) {
-    return (*parcel)->readFloat(value);
+    status_t status = (*parcel)->readFloat(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_readDouble(const AParcel* parcel, double* value) {
-    return (*parcel)->readDouble(value);
+    status_t status = (*parcel)->readDouble(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_readBool(const AParcel* parcel, bool* value) {
-    return (*parcel)->readBool(value);
+    status_t status = (*parcel)->readBool(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_readChar(const AParcel* parcel, char16_t* value) {
-    return (*parcel)->readChar(value);
+    status_t status = (*parcel)->readChar(value);
+    return PruneStatusT(status);
 }
 
 binder_status_t AParcel_readByte(const AParcel* parcel, int8_t* value) {
-    return (*parcel)->readByte(value);
+    status_t status = (*parcel)->readByte(value);
+    return PruneStatusT(status);
 }
 
 // @END