libbinder: Status writeToParcel no OK on ERR

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: libbinder NDK's runtests.sh
Test: AIDL's runtests.sh
Change-Id: I4699999cb2482b357ae0eab278d8e4aaa66b83aa
1 file changed