Add support to call hidl reserved methods in vts.
* Update the driver generator to handle call of reserved methods.
* Update mirror_object.py to allow calling of reserved methods.
* Currently only support calling of notifySyspropsChanged.
Test: make vts and test locally.
Change-Id: Iee08da6225af6d50a92bf543acb908b4b33c3bcf
diff --git a/sysfuzzer/vtscompiler/code_gen/driver/HalHidlCodeGen.cpp b/sysfuzzer/vtscompiler/code_gen/driver/HalHidlCodeGen.cpp
index 4e6c081..573c9d4 100644
--- a/sysfuzzer/vtscompiler/code_gen/driver/HalHidlCodeGen.cpp
+++ b/sysfuzzer/vtscompiler/code_gen/driver/HalHidlCodeGen.cpp
@@ -1019,12 +1019,31 @@
GenerateDriverImplForMethod(out, message, api);
}
+ GenerateDriverImplForReservedMethods(out);
+
out << "return false;\n";
out.unindent();
out << "}\n";
}
}
+void HalHidlCodeGen::GenerateDriverImplForReservedMethods(Formatter& out) {
+ // Generate call for reserved method: notifySyspropsChanged.
+ out << "if (!strcmp(func_name, \"notifySyspropsChanged\")) {\n";
+ out.indent();
+
+ out << "cout << \"Call notifySyspropsChanged\" << endl;" << "\n";
+ out << kInstanceVariableName << "->notifySyspropsChanged();\n";
+ out << "result_msg->set_name(\"notifySyspropsChanged\");\n";
+ out << "cout << \"called\" << endl;\n";
+ out << "return true;\n";
+
+ out.unindent();
+ out << "}\n";
+ // TODO(zhuoyao): Add generation code for other reserved method,
+ // e.g interfaceChain
+}
+
void HalHidlCodeGen::GenerateDriverImplForMethod(Formatter& out,
const ComponentSpecificationMessage& message,
const FunctionSpecificationMessage& func_msg) {
diff --git a/sysfuzzer/vtscompiler/code_gen/driver/HalHidlCodeGen.h b/sysfuzzer/vtscompiler/code_gen/driver/HalHidlCodeGen.h
index 93d5226..4ac7744 100644
--- a/sysfuzzer/vtscompiler/code_gen/driver/HalHidlCodeGen.h
+++ b/sysfuzzer/vtscompiler/code_gen/driver/HalHidlCodeGen.h
@@ -106,6 +106,9 @@
// Generates a scalar type in C/C++.
void GenerateScalarTypeInC(Formatter& out, const string& type);
+ // Generates the driver function implementation for hidl reserved methods.
+ void GenerateDriverImplForReservedMethods(Formatter& out);
+
// Generates the driver function implementation for a method.
void GenerateDriverImplForMethod(Formatter& out,
const ComponentSpecificationMessage& message,
diff --git a/sysfuzzer/vtscompiler/test/golden/DRIVER/Nfc.driver.cpp b/sysfuzzer/vtscompiler/test/golden/DRIVER/Nfc.driver.cpp
index 85e30e9..a45d5ec 100644
--- a/sysfuzzer/vtscompiler/test/golden/DRIVER/Nfc.driver.cpp
+++ b/sysfuzzer/vtscompiler/test/golden/DRIVER/Nfc.driver.cpp
@@ -303,6 +303,13 @@
cout << "called" << endl;
return true;
}
+ if (!strcmp(func_name, "notifySyspropsChanged")) {
+ cout << "Call notifySyspropsChanged" << endl;
+ hw_binder_proxy_->notifySyspropsChanged();
+ result_msg->set_name("notifySyspropsChanged");
+ cout << "called" << endl;
+ return true;
+ }
return false;
}
diff --git a/utils/python/mirror/mirror_object.py b/utils/python/mirror/mirror_object.py
index 64d56c8..b5576d1 100644
--- a/utils/python/mirror/mirror_object.py
+++ b/utils/python/mirror/mirror_object.py
@@ -181,6 +181,11 @@
None otherwise
"""
logging.debug("GetAPI %s for %s", api_name, self._if_spec_msg)
+ # handle reserved methods first.
+ if api_name == "notifySyspropsChanged":
+ func_msg = CompSpecMsg.FunctionSpecificationMessage()
+ func_msg.name = api_name
+ return func_msg
if isinstance(self._if_spec_msg, CompSpecMsg.ComponentSpecificationMessage):
if len(self._if_spec_msg.interface.api) > 0:
for api in self._if_spec_msg.interface.api: