Remove explicit cast from Return<*>.
- also moving failure check to implicit cast operator.
(after talking to malchev@)
Bug: 31348667
Test: pass
Change-Id: I5a136a3596c2fa7c502ce9d53ab754b796d66fed
diff --git a/base/include/hidl/Status.h b/base/include/hidl/Status.h
index 1246ae0..06aa09c 100644
--- a/base/include/hidl/Status.h
+++ b/base/include/hidl/Status.h
@@ -149,21 +149,17 @@
Return(T v) : mVal{v} {}
Return(Status s) : mStatus(s) {}
- T get() const {
+ bool isOk() const {
+ return mStatus.isOk();
+ }
+
+ operator T() const {
if (!mStatus.isOk()) {
logAlwaysFatal("Attempted to retrieve value from hidl service, "
"but there was a transport error.");
}
return mVal;
}
- bool isOk() const {
- return mStatus.isOk();
- }
-
- // TODO(b/31348667) deprecate, remove all usage, remove function
- // Can't mark as deprecated yet because of all the projects built with -Werror.
- // [[deprecated("Replaced by get()")]]
- operator T() const { return mVal; }
const Status& getStatus() const {
return mStatus;
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index fb209c4..1851870 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -372,7 +372,7 @@
[&success, &sm, &serviceName, &binderIface](const auto &chain) { \
::android::hardware::Return<bool> addRet = \
sm->add(chain, serviceName.c_str(), binderIface); \
- success = addRet.isOk() && addRet.get(); \
+ success = addRet.isOk() && addRet; \
}); \
success = success && ret.getStatus().isOk(); \
return success ? ::android::OK : ::android::UNKNOWN_ERROR; \
@@ -393,7 +393,7 @@
sm->registerForNotifications(PACKAGE "::I" #INTERFACE, \
serviceName, \
notification); \
- return success.isOk() && success.get(); \
+ return success.isOk() && success; \
}