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
1 file changed