Merge "Remove ref<>."
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 @@
}
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 @@
}
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 @@
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 @@
~Return() = default;
operator T() const {
- assertOk();
+ onValueRetrieval(); // assert okay
return mVal;
}
@@ -253,7 +255,7 @@
~Return() = default;
operator sp<T>() const {
- assertOk();
+ onValueRetrieval(); // assert okay
return mVal;
}