Status.h: remove service specific error codes.
These are leftover from binder and are never used in HIDL/hwbinder.
Test: libhidl_test + hidl_test + internal marlin boots/works.
Bug: 36099713
Change-Id: I12b20e1ae54d9df802a961bc9bc99f616291b0fd
diff --git a/base/Status.cpp b/base/Status.cpp
index 449aff3..3b31ee6 100644
--- a/base/Status.cpp
+++ b/base/Status.cpp
@@ -70,7 +70,6 @@
EXCEPTION_TO_STRING_PAIR(EX_ILLEGAL_STATE),
EXCEPTION_TO_STRING_PAIR(EX_NETWORK_MAIN_THREAD),
EXCEPTION_TO_STRING_PAIR(EX_UNSUPPORTED_OPERATION),
- EXCEPTION_TO_STRING_PAIR(EX_SERVICE_SPECIFIC),
EXCEPTION_TO_STRING_PAIR(EX_HAS_REPLY_HEADER),
EXCEPTION_TO_STRING_PAIR(EX_TRANSACTION_FAILED)
}};
@@ -91,15 +90,6 @@
return Status(exceptionCode, OK, message);
}
-Status Status::fromServiceSpecificError(int32_t serviceSpecificErrorCode) {
- return Status(EX_SERVICE_SPECIFIC, serviceSpecificErrorCode);
-}
-
-Status Status::fromServiceSpecificError(int32_t serviceSpecificErrorCode,
- const char *message) {
- return Status(EX_SERVICE_SPECIFIC, serviceSpecificErrorCode, message);
-}
-
Status Status::fromStatusT(status_t status) {
Status ret;
ret.setFromStatusT(status);
@@ -121,11 +111,6 @@
mMessage = message;
}
-void Status::setServiceSpecificError(int32_t errorCode, const char *message) {
- setException(EX_SERVICE_SPECIFIC, message);
- mErrorCode = errorCode;
-}
-
void Status::setFromStatusT(status_t status) {
mException = (status == NO_ERROR) ? EX_NONE : EX_TRANSACTION_FAILED;
mErrorCode = status;
@@ -143,9 +128,7 @@
stream << "No error";
} else {
stream << "Status(" << exceptionToString(s.exceptionCode()) << "): '";
- if (s.exceptionCode() == Status::EX_SERVICE_SPECIFIC) {
- stream << s.serviceSpecificErrorCode() << ": ";
- } else if (s.exceptionCode() == Status::EX_TRANSACTION_FAILED) {
+ if (s.exceptionCode() == Status::EX_TRANSACTION_FAILED) {
stream << statusToString(s.transactionError()) << ": ";
}
stream << s.exceptionMessage() << "'";
diff --git a/base/include/hidl/Status.h b/base/include/hidl/Status.h
index c5c5bd9..a4a83f4 100644
--- a/base/include/hidl/Status.h
+++ b/base/include/hidl/Status.h
@@ -62,7 +62,6 @@
EX_ILLEGAL_STATE = -5,
EX_NETWORK_MAIN_THREAD = -6,
EX_UNSUPPORTED_OPERATION = -7,
- EX_SERVICE_SPECIFIC = -8,
// This is special and Java specific; see Parcel.java.
EX_HAS_REPLY_HEADER = -128,
@@ -75,19 +74,14 @@
static Status ok();
// 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.
+ // Prefer a generic exception code when possible or a status_t
+ // for low level transport errors. Service specific errors
+ // should be at a higher level in HIDL.
static Status fromExceptionCode(int32_t exceptionCode);
static Status fromExceptionCode(int32_t exceptionCode,
const char *message);
- static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode);
- static Status fromServiceSpecificError(int32_t serviceSpecificErrorCode,
- const char *message);
static Status fromStatusT(status_t status);
Status() = default;
@@ -100,8 +94,6 @@
// Set one of the pre-defined exception types defined above.
void setException(int32_t ex, const char *message);
- // Set a service specific exception with error code.
- void setServiceSpecificError(int32_t errorCode, const char *message);
// 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.
@@ -113,9 +105,6 @@
status_t transactionError() const {
return mException == EX_TRANSACTION_FAILED ? mErrorCode : OK;
}
- int32_t serviceSpecificErrorCode() const {
- return mException == EX_SERVICE_SPECIFIC ? mErrorCode : 0;
- }
bool isOk() const { return mException == EX_NONE; }
@@ -132,7 +121,6 @@
//
// Otherwise, we always write |mException| to the parcel.
// If |mException| != EX_NONE, we write |mMessage| as well.
- // If |mException| == EX_SERVICE_SPECIFIC we write |mErrorCode| as well.
int32_t mException = EX_NONE;
int32_t mErrorCode = 0;
std::string mMessage;
diff --git a/test_main.cpp b/test_main.cpp
index b799f6e..7ff8ae3 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -364,10 +364,6 @@
EXPECT_THAT(toString(Status::fromStatusT(-EBUSY)), HasSubstr("busy"));
- auto s = toString(Status::fromServiceSpecificError(20));
- EXPECT_THAT(s, HasSubstr("EX_SERVICE_SPECIFIC"));
- EXPECT_THAT(s, HasSubstr("20"));
-
EXPECT_THAT(toString(Status::fromExceptionCode(Status::EX_NULL_POINTER)),
HasSubstr("EX_NULL_POINTER"));
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp
index 55f9a91..c0601ca 100644
--- a/transport/HidlBinderSupport.cpp
+++ b/transport/HidlBinderSupport.cpp
@@ -109,7 +109,6 @@
status_t readFromParcel(Status *s, const Parcel& parcel) {
int32_t exception;
- int32_t errorCode;
status_t status = parcel.readInt32(&exception);
if (status != OK) {
s->setFromStatusT(status);
@@ -145,19 +144,7 @@
return status;
}
- if (exception == Status::EX_SERVICE_SPECIFIC) {
- status = parcel.readInt32(&errorCode);
- }
- if (status != OK) {
- s->setFromStatusT(status);
- return status;
- }
-
- if (exception == Status::EX_SERVICE_SPECIFIC) {
- s->setServiceSpecificError(errorCode, String8(message));
- } else {
- s->setException(exception, String8(message));
- }
+ s->setException(exception, String8(message));
return status;
}
@@ -176,11 +163,6 @@
return status;
}
status = parcel->writeString16(String16(s.exceptionMessage()));
- if (s.exceptionCode() != Status::EX_SERVICE_SPECIFIC) {
- // We have no more information to write.
- return status;
- }
- status = parcel->writeInt32(s.serviceSpecificErrorCode());
return status;
}