Adds a debug(...) method to IBase, the base class for all Treble interfaces
The default implementation does nothing but this allows implementations to
emit diagnostics to a given file handle in a unified fashion.
Bug: 33961528
Test: hidl_test, hidl_test_java
Change-Id: Id7e8417275934c73032c9832c41e041d2d5d2fb7
diff --git a/Interface.cpp b/Interface.cpp
index e7ed545..174e544 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -53,6 +53,7 @@
HIDL_UNLINK_TO_DEATH_TRANSACTION,
HIDL_SET_HAL_INSTRUMENTATION_TRANSACTION,
HIDL_GET_REF_INFO_TRANSACTION,
+ HIDL_DEBUG_TRANSACTION,
LAST_HIDL_TRANSACTION = 0x00ffffff,
};
@@ -301,6 +302,30 @@
return true;
}
+bool Interface::fillDebugMethod(Method *method) const {
+ if (method->name() != "debug") {
+ return false;
+ }
+
+ method->fillImplementation(
+ HIDL_DEBUG_TRANSACTION,
+ {
+ {IMPL_HEADER,
+ [this](auto &out) {
+ out << "(void)fd;\n"
+ << "(void)options;\n"
+ << "return ::android::hardware::Void();";
+ }
+ },
+ }, /* cppImpl */
+ {
+ /* unused, as the debug method is hidden from Java */
+ } /* javaImpl */
+ );
+
+ return true;
+}
+
static std::map<std::string, Method *> gAllReservedMethods;
bool Interface::addMethod(Method *method) {
@@ -348,7 +373,9 @@
|| fillLinkToDeathMethod(method)
|| fillUnlinkToDeathMethod(method)
|| fillSetHALInstrumentationMethod(method)
- || fillGetDebugInfoMethod(method);
+ || fillGetDebugInfoMethod(method)
+ || fillDebugMethod(method);
+
if (!fillSuccess) {
LOG(ERROR) << "ERROR: hidl-gen does not recognize a reserved method "
<< method->name();