class Status

Defined at line 55 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

An object similar in function to a status_t except that it understands

how exceptions are encoded in the prefix of a Parcel. Used like:

Parcel data;

Parcel reply;

status_t status;

binder::Status remote_exception;

if ((status = data.writeInterfaceToken(interface_descriptor)) != OK ||

(status = data.writeInt32(function_input)) != OK) {

// We failed to write into the memory of our local parcel?

}

if ((status = remote()->transact(transaction, data,

&reply

)) != OK) {

// Something has gone wrong in the binder driver or libbinder.

}

if ((status = remote_exception.readFromParcel(reply)) != OK) {

// The remote didn't correctly write the exception header to the

// reply.

}

if (!remote_exception.isOk()) {

// The transaction went through correctly, but the remote reported an

// exception during handling.

}

Public Methods

void Status ()

Defined at line 111 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

Status ok ()

A more readable alias for the default constructor.

Status fromExceptionCode (int32_t exceptionCode)

Authors should explicitly pick whether their integer is:

- an exception code (EX_* above)

- service specific error code

- status_t

Prefer a generic exception code when possible, then a service specific

code, and finally a status_t for low level failures or legacy support.

Exception codes and service specific errors map to nicer exceptions for

Java clients.

Status fromExceptionCode (int32_t exceptionCode, const String8 & message)
Status fromExceptionCode (int32_t exceptionCode, const char * message)
Status fromServiceSpecificError (int32_t serviceSpecificErrorCode)

warning: this is still considered an error if it is constructed with a

zero value error code. Please use Status::ok() instead and avoid zero

error codes

Status fromServiceSpecificError (int32_t serviceSpecificErrorCode, const String8 & message)
Status fromServiceSpecificError (int32_t serviceSpecificErrorCode, const char * message)
Status fromStatusT (status_t status)
std::string exceptionToString (status_t exceptionCode)
void ~Status ()

Defined at line 112 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

void Status (const Status & status)

Status objects are copyable and contain just simple data.

Defined at line 115 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

void Status (Status && status)

Defined at line 116 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

Status & operator= (const Status & status)

Defined at line 117 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

int32_t exceptionCode ()

Get information about an exception.

Defined at line 138 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

const String8 & exceptionMessage ()

Defined at line 139 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

status_t readFromParcel (const Parcel & parcel)

Bear in mind that if the client or service is a Java endpoint, this

is not the logic which will provide/interpret the data here.

status_t writeToParcel (Parcel * parcel)
status_t writeOverParcel (Parcel * parcel)

Convenience API to replace a Parcel with a status value, w/o requiring

calling multiple APIs (makes generated code smaller).

void setException (int32_t ex, const String8 & message)

Set one of the pre-defined exception types defined above.

void setServiceSpecificError (int32_t errorCode, const String8 & message)

Set a service specific exception with error code.

void setFromStatusT (status_t status)

Setting a |status| != OK causes generated code to return |status|

from Binder transactions, rather than writing an exception into the

reply Parcel. This is the least preferable way of reporting errors.

status_t transactionError ()

Defined at line 140 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

int32_t serviceSpecificErrorCode ()

Defined at line 143 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

bool isOk ()

Defined at line 147 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h

String8 toString8 ()

For logging.

Enumerations

enum Exception
Name Value
EX_NONE 0
EX_SECURITY -1
EX_BAD_PARCELABLE -2
EX_ILLEGAL_ARGUMENT -3
EX_NULL_POINTER -4
EX_ILLEGAL_STATE -5
EX_NETWORK_MAIN_THREAD -6
EX_UNSUPPORTED_OPERATION -7
EX_SERVICE_SPECIFIC -8
EX_PARCELABLE -9
EX_HAS_NOTED_APPOPS_REPLY_HEADER -127
EX_HAS_REPLY_HEADER -128
EX_TRANSACTION_FAILED -129

Keep the exception codes in sync with android/os/Parcel.java.

Defined at line 58 of file ../../third_party/android/platform/frameworks/native/libs/binder/include/binder/Status.h