Support to enable profiling dynamically.
* Add an additonal reserved method setHALInstrumentation to
enable/disable instrumentation during the hal execution.
Test: make hidl-gen
Change-Id: Iaf20e3f798a51b111bffd2e7294973bce0cabf9e
diff --git a/Interface.cpp b/Interface.cpp
index 4c9e9a5..77681d4 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -50,6 +50,7 @@
HIDL_SYSPROPS_CHANGED_TRANSACTION,
HIDL_LINK_TO_DEATH_TRANSACTION,
HIDL_UNLINK_TO_DEATH_TRANSACTION,
+ HIDL_SET_HAL_INSTRUMENTATION_TRANSACTION,
LAST_HIDL_TRANSACTION = 0x00ffffff,
};
@@ -61,6 +62,7 @@
mReservedMethods.push_back(createSyspropsChangedMethod());
mReservedMethods.push_back(createLinkToDeathMethod());
mReservedMethods.push_back(createUnlinkToDeathMethod());
+ mReservedMethods.push_back(createSetHALInstrumentationMethod());
}
std::string Interface::typeName() const {
@@ -185,6 +187,44 @@
);
}
+Method *Interface::createSetHALInstrumentationMethod() const {
+ return new Method("setHALInstrumentation",
+ new std::vector<TypedVar *>() /*args */,
+ new std::vector<TypedVar *>() /*results */,
+ true /*oneway */,
+ new std::vector<Annotation *>(),
+ HIDL_SET_HAL_INSTRUMENTATION_TRANSACTION,
+ {
+ {IMPL_HEADER,
+ [this](auto &out) {
+ // do nothing for base class.
+ out << "return ::android::hardware::Void();\n";
+ }
+ },
+ {IMPL_PROXY,
+ [](auto &out) {
+ out << "configureInstrumentation();\n";
+ out << "return ::android::hardware::Void();\n";
+ }
+ },
+ {IMPL_STUB,
+ [](auto &out) {
+ out << "configureInstrumentation();\n";
+ }
+ },
+ {IMPL_PASSTHROUGH,
+ [](auto &out) {
+ out << "configureInstrumentation();\n";
+ out << "return ::android::hardware::Void();\n";
+ }
+ },
+ }, /*cppImpl */
+ { { IMPL_HEADER, [](auto & /*out*/) { /* javaImpl */
+ // Not support for Java Impl for now.
+ } } } /*javaImpl */
+ );
+}
+
Method *Interface::createDescriptorChainMethod() const {
VectorType *vecType = new VectorType();
vecType->setElementType(new StringType());