summaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2019-05-28 10:23:32 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-05-28 10:23:32 -0700
commitfc811da6f95c2e562fe5aa2103f69ccd30f50744 (patch)
tree9b3ec45234e5b1a2c688a639e102973827937a72 /base
parentcf4ee6f2469512d69f4f42f41ce1921531f5de8c (diff)
parent83d1790b25fdb6f77f5d4edca21105ccb7a835ec (diff)
downloadlibhidl-fc811da6f95c2e562fe5aa2103f69ccd30f50744.tar.gz
Expound on HIDL Return errors. am: 94c4374133
am: 83d1790b25 Change-Id: I2183ead0d214500ef2c18c2924d923ea5f9490c0
Diffstat (limited to 'base')
-rw-r--r--base/Status.cpp22
-rw-r--r--base/include/hidl/Status.h6
2 files changed, 20 insertions, 8 deletions
diff --git a/base/Status.cpp b/base/Status.cpp
index 90474a0..08631cc 100644
--- a/base/Status.cpp
+++ b/base/Status.cpp
@@ -149,19 +149,28 @@ void setProcessHidlReturnRestriction(HidlReturnRestriction restriction) {
}
namespace details {
- void return_status::assertOk() const {
+ void return_status::onValueRetrieval() const {
if (!isOk()) {
LOG(FATAL) << "Attempted to retrieve value from failed HIDL call: " << description();
}
}
+ void return_status::assertOk() const {
+ if (!isOk()) {
+ LOG(FATAL) << "Failed HIDL return status not checked. Usually this happens because of "
+ "a transport error (error parceling, binder driver, or from unparceling)"
+ ". If you see this in code calling into \"Bn\" classes in for a HAL "
+ "server process, then it is likely that the code there is returning "
+ "transport errors there (as opposed to errors defined within its "
+ "protocol). Error is: " << description();
+ }
+ }
+
return_status::~return_status() {
// mCheckedStatus must be checked before isOk since isOk modifies mCheckedStatus
if (mCheckedStatus) return;
- if (!isOk()) {
- LOG(FATAL) << "Failed HIDL return status not checked: " << description();
- }
+ assertOk();
if (gReturnRestriction == HidlReturnRestriction::NONE) {
return;
@@ -176,9 +185,10 @@ namespace details {
}
return_status& return_status::operator=(return_status&& other) noexcept {
- if (!mCheckedStatus && !isOk()) {
- LOG(FATAL) << "Failed HIDL return status not checked: " << description();
+ if (!mCheckedStatus) {
+ assertOk();
}
+
std::swap(mStatus, other.mStatus);
std::swap(mCheckedStatus, other.mCheckedStatus);
return *this;
diff --git a/base/include/hidl/Status.h b/base/include/hidl/Status.h
index 817277f..07d352f 100644
--- a/base/include/hidl/Status.h
+++ b/base/include/hidl/Status.h
@@ -143,6 +143,8 @@ namespace details {
template <typename T, typename U>
friend Return<U> StatusOf(const Return<T> &other);
+ protected:
+ void onValueRetrieval() const;
public:
void assertOk() const;
return_status() {}
@@ -224,7 +226,7 @@ public:
~Return() = default;
operator T() const {
- assertOk();
+ onValueRetrieval(); // assert okay
return mVal;
}
@@ -253,7 +255,7 @@ public:
~Return() = default;
operator sp<T>() const {
- assertOk();
+ onValueRetrieval(); // assert okay
return mVal;
}