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

Commit 43a759ee 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

am: d2ef0440

Change-Id: I2b93d1f0bed6784246ff0d26650ae968e6e7dfb6
parents 605d689f d2ef0440
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -63,6 +63,26 @@ Status Status::fromStatusT(status_t status) {
    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)
    : mException(exceptionCode),
      mErrorCode(errorCode) {}
@@ -184,7 +204,7 @@ String8 Status::toString8() const {
    if (mException == EX_NONE) {
        ret.append("No error");
    } else {
        ret.appendFormat("Status(%d): '", mException);
        ret.appendFormat("Status(%d, %s): '", mException, exceptionToString(mException).c_str());
        if (mException == EX_SERVICE_SPECIFIC ||
            mException == EX_TRANSACTION_FAILED) {
            ret.appendFormat("%d: ", mErrorCode);
+3 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

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

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

    static Status fromStatusT(status_t status);

    static std::string exceptionToString(status_t exceptionCode);

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