Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d2ef0440 authored by Jeongik Cha's avatar Jeongik Cha Committed by android-build-merger
Browse files

Merge "Add exceptionToString method into binder::Status" am: 7cee1b48

am: ab8995fc

Change-Id: I9b5aa74c5d7b4f4f8906f4cf865e75ef1b31074f
parents 0ff0e4d0 ab8995fc
Loading
Loading
Loading
Loading
+21 −1
Original line number Original line Diff line number Diff line
@@ -63,6 +63,26 @@ Status Status::fromStatusT(status_t status) {
    return ret;
    return ret;
}
}


std::string Status::exceptionToString(int32_t exceptionCode) {
    switch (exceptionCode) {
        #define EXCEPTION_TO_CASE(EXCEPTION) case EXCEPTION: return #EXCEPTION;
        EXCEPTION_TO_CASE(EX_NONE)
        EXCEPTION_TO_CASE(EX_SECURITY)
        EXCEPTION_TO_CASE(EX_BAD_PARCELABLE)
        EXCEPTION_TO_CASE(EX_ILLEGAL_ARGUMENT)
        EXCEPTION_TO_CASE(EX_NULL_POINTER)
        EXCEPTION_TO_CASE(EX_ILLEGAL_STATE)
        EXCEPTION_TO_CASE(EX_NETWORK_MAIN_THREAD)
        EXCEPTION_TO_CASE(EX_UNSUPPORTED_OPERATION)
        EXCEPTION_TO_CASE(EX_SERVICE_SPECIFIC)
        EXCEPTION_TO_CASE(EX_PARCELABLE)
        EXCEPTION_TO_CASE(EX_HAS_REPLY_HEADER)
        EXCEPTION_TO_CASE(EX_TRANSACTION_FAILED)
        #undef EXCEPTION_TO_CASE
        default: return std::to_string(exceptionCode);
    }
}

Status::Status(int32_t exceptionCode, int32_t errorCode)
Status::Status(int32_t exceptionCode, int32_t errorCode)
    : mException(exceptionCode),
    : mException(exceptionCode),
      mErrorCode(errorCode) {}
      mErrorCode(errorCode) {}
@@ -184,7 +204,7 @@ String8 Status::toString8() const {
    if (mException == EX_NONE) {
    if (mException == EX_NONE) {
        ret.append("No error");
        ret.append("No error");
    } else {
    } else {
        ret.appendFormat("Status(%d): '", mException);
        ret.appendFormat("Status(%d, %s): '", mException, exceptionToString(mException).c_str());
        if (mException == EX_SERVICE_SPECIFIC ||
        if (mException == EX_SERVICE_SPECIFIC ||
            mException == EX_TRANSACTION_FAILED) {
            mException == EX_TRANSACTION_FAILED) {
            ret.appendFormat("%d: ", mErrorCode);
            ret.appendFormat("%d: ", mErrorCode);
+3 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@


#include <binder/Parcel.h>
#include <binder/Parcel.h>
#include <utils/String8.h>
#include <utils/String8.h>
#include <string>


namespace android {
namespace android {
namespace binder {
namespace binder {
@@ -97,6 +98,8 @@ public:


    static Status fromStatusT(status_t status);
    static Status fromStatusT(status_t status);


    static std::string exceptionToString(status_t exceptionCode);

    Status() = default;
    Status() = default;
    ~Status() = default;
    ~Status() = default;