From 09eb749704afd9e226e1347cb20c90be2016cd21 Mon Sep 17 00:00:00 2001 From: Christopher Wiley Date: Mon, 9 Nov 2015 15:06:15 -0800 Subject: libbinder: Add binder::Status type This object implements equivalent functionality to the Java logic which serializes and re-throws exceptions from services. Bug: 25615695 Test: Integration test for generated AIDL code reveals this to work correctly. Change-Id: Ic80c9def0dd232582ea9c49717ec50894af6bfc2 --- libs/binder/Parcel.cpp | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'libs/binder/Parcel.cpp') diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index c808948e0f..c1e6f0e949 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -69,9 +70,6 @@ static size_t pad_size(size_t s) { // Note: must be kept in sync with android/os/StrictMode.java's PENALTY_GATHER #define STRICT_MODE_PENALTY_GATHER (0x40 << 16) -// Note: must be kept in sync with android/os/Parcel.java's EX_HAS_REPLY_HEADER -#define EX_HAS_REPLY_HEADER -128 - // XXX This can be made public if we want to provide // support for typed data. struct small_flat_data @@ -1206,7 +1204,8 @@ restart_write: status_t Parcel::writeNoException() { - return writeInt32(0); + binder::Status status; + return status.writeToParcel(this); } void Parcel::remove(size_t /*start*/, size_t /*amt*/) @@ -1619,18 +1618,9 @@ wp Parcel::readWeakBinder() const int32_t Parcel::readExceptionCode() const { - int32_t exception_code = readAligned(); - if (exception_code == EX_HAS_REPLY_HEADER) { - int32_t header_start = dataPosition(); - int32_t header_size = readAligned(); - // Skip over fat responses headers. Not used (or propagated) in - // native code - setDataPosition(header_start + header_size); - // And fat response headers are currently only used when there are no - // exceptions, so return no error: - return 0; - } - return exception_code; + binder::Status status; + status.readFromParcel(*this); + return status.exceptionCode(); } native_handle* Parcel::readNativeHandle() const -- cgit v1.2.3-59-g8ed1b