IBase: add ping method
Add ping method to IBase. We deleted this from libhwbinder types, so
moving it to hidl types.
Bug: 34501346
Test: hidl_test
Change-Id: I1e13a48f1ca3668450def6434650763483baf34e
diff --git a/Interface.cpp b/Interface.cpp
index 564a534..e1999c9 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -46,7 +46,8 @@
LAST_CALL_TRANSACTION = 0x00efffff,
/////////////////// HIDL reserved
FIRST_HIDL_TRANSACTION = 0x00f00000,
- HIDL_DESCRIPTOR_CHAIN_TRANSACTION = FIRST_HIDL_TRANSACTION,
+ HIDL_PING_TRANSACTION = FIRST_HIDL_TRANSACTION,
+ HIDL_DESCRIPTOR_CHAIN_TRANSACTION,
HIDL_GET_DESCRIPTOR_TRANSACTION,
HIDL_SYSPROPS_CHANGED_TRANSACTION,
HIDL_LINK_TO_DEATH_TRANSACTION,
@@ -67,6 +68,38 @@
return "interface " + localName();
}
+bool Interface::fillPingMethod(Method *method) const {
+ if (method->name() != "ping") {
+ return false;
+ }
+
+ method->fillImplementation(
+ HIDL_PING_TRANSACTION,
+ {
+ {IMPL_HEADER,
+ [](auto &out) {
+ out << "return ::android::hardware::Void();\n";
+ }
+ },
+ {IMPL_STUB_IMPL,
+ [](auto &out) {
+ out << "return ::android::hardware::Void();\n";
+ }
+ }
+ }, /*cppImpl*/
+ {
+ {IMPL_HEADER,
+ [this](auto &out) {
+ out << "return;\n";
+ }
+ },
+ {IMPL_STUB, nullptr /* don't generate code */}
+ } /*javaImpl*/
+ );
+
+ return true;
+}
+
bool Interface::fillLinkToDeathMethod(Method *method) const {
if (method->name() != "linkToDeath") {
return false;
@@ -367,7 +400,8 @@
std::map<int32_t, Method *> reservedMethodsById;
for (const auto &pair : gAllReservedMethods) {
Method *method = pair.second->copySignature();
- bool fillSuccess = fillDescriptorChainMethod(method)
+ bool fillSuccess = fillPingMethod(method)
+ || fillDescriptorChainMethod(method)
|| fillGetDescriptorMethod(method)
|| fillSyspropsChangedMethod(method)
|| fillLinkToDeathMethod(method)
diff --git a/Interface.h b/Interface.h
index 376a78c..1b3ebb5 100644
--- a/Interface.h
+++ b/Interface.h
@@ -114,6 +114,7 @@
std::vector<Method *> mUserMethods;
std::vector<Method *> mReservedMethods;
mutable bool mIsJavaCompatibleInProgress;
+ bool fillPingMethod(Method *method) const;
bool fillDescriptorChainMethod(Method *method) const;
bool fillGetDescriptorMethod(Method *method) const;
bool fillSyspropsChangedMethod(Method *method) const;
diff --git a/test/main.cpp b/test/main.cpp
index f21cb9c..78d9e08 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -582,6 +582,10 @@
// statement can be written here.
}
+TEST_F(HidlTest, PingTest) {
+ EXPECT_OK(manager->ping());
+}
+
TEST_F(HidlTest, ServiceListTest) {
static const std::set<std::string> binderizedSet = {
"android.hardware.tests.pointer@1.0::IPointer/pointer",