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

Commit 09773674 authored by Steven Moreland's avatar Steven Moreland
Browse files

libbinder_ndk: ScopedAStatus: remaining helpers

This allows, say:
return ScopedAStatus(AStatus_fromExceptionCode(EX_UNSUPPORTED_OPERATION));
=>
return ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);

It only saves a couple of characters, but not having to type 'AStatus'
twice is a huge psychological win.

Bug: 136027762
Test: using these
Change-Id: Idc574fa1377c98f382cd985e39ab20488853ecf8
parent df9ad97a
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -219,9 +219,31 @@ class ScopedAStatus : public impl::ScopedAResource<AStatus*, void, AStatus_delet
    binder_status_t getStatus() const { return AStatus_getStatus(get()); }

    /**
     * Convenience method for okay status.
     * See AStatus_getMessage
     */
    const char* getMessage() const { return AStatus_getMessage(get()); }

    /**
     * Convenience methods for creating scoped statuses.
     */
    static ScopedAStatus ok() { return ScopedAStatus(AStatus_newOk()); }
    static ScopedAStatus fromExceptionCode(binder_exception_t exception) {
        return ScopedAStatus(AStatus_fromExceptionCode(exception));
    }
    static ScopedAStatus fromExceptionCodeWithMessage(binder_exception_t exception,
                                                      const char* message) {
        return ScopedAStatus(AStatus_fromExceptionCodeWithMessage(exception, message));
    }
    static ScopedAStatus fromServiceSpecificError(int32_t serviceSpecific) {
        return ScopedAStatus(AStatus_fromServiceSpecificError(serviceSpecific));
    }
    static ScopedAStatus fromServiceSpecificErrorWithMessage(int32_t serviceSpecific,
                                                             const char* message) {
        return ScopedAStatus(AStatus_fromServiceSpecificErrorWithMessage(serviceSpecific, message));
    }
    static ScopedAStatus fromStatus(binder_status_t status) {
        return ScopedAStatus(AStatus_fromStatus(status));
    }
};

/**