diff options
author | Steven Moreland <smoreland@google.com> | 2018-09-25 09:23:54 -0700 |
---|---|---|
committer | Steven Moreland <smoreland@google.com> | 2018-09-25 11:25:35 -0700 |
commit | 662378eaf66fb19ceb60aad4509c55843c78ff4d (patch) | |
tree | 6e078e27e8c858d84bdb7afac20af36875d60a31 | |
parent | b7798be47e9ad0bed913458278b81af3ffd442fa (diff) | |
download | libhidl-662378eaf66fb19ceb60aad4509c55843c78ff4d.tar.gz |
Status writeToParcel no OK on ERR
This is a port of the original change to libbinder.
The same idea applies here:
Right now, it's possible to have Status such that:
- mException = EX_TRANSACTION_FAILED
- mErrorCode = OK
When this happens, writeToParcel will return OK and also not write
anything to the parcel.
From the comment here:
// Something really bad has happened, and we're not going to even
// try returning rich error data.
The intention here is to use the status_t return from transact for
error messages and also not have clients read the parcel. For instance,
here is the AIDL generated code (primary user of this API):
::android::status_t _aidl_ret_status = ::android::OK;
switch (_aidl_code) {
case ...:
{
...
::android::binder::Status _aidl_status(TestVoidReturn());
_aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply);
if (((_aidl_ret_status) != (::android::OK))) {
break;
}
if (!_aidl_status.isOk()) {
break;
}
}
...
}
return _aidl_ret_status;
As you can see, if writeToParcel returns OK for a non-okay transaction,
the transaction will be considered okay. In general, this doesn't cause
a problem since readToParcel will fail, but the error would be
confusing (out of space).
Bug: 111445392
Test: system/tools/hidl/runtests.sh
Change-Id: I8ce8d229c8a8c9c62e5196a27d04eae6c8048155
-rw-r--r-- | transport/HidlBinderSupport.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/transport/HidlBinderSupport.cpp b/transport/HidlBinderSupport.cpp index add1f5e..a2ca5fa 100644 --- a/transport/HidlBinderSupport.cpp +++ b/transport/HidlBinderSupport.cpp @@ -212,7 +212,8 @@ status_t writeToParcel(const Status &s, Parcel* parcel) { // Something really bad has happened, and we're not going to even // try returning rich error data. if (s.exceptionCode() == Status::EX_TRANSACTION_FAILED) { - return s.transactionError(); + status_t status = s.transactionError(); + return status == OK ? FAILED_TRANSACTION : status; } status_t status = parcel->writeInt32(s.exceptionCode()); |