Generate java method signatures in common code

generateJavaImpl and generateJava both need to generate method
signatures. This makes it so that they can call a method on "Method"
instead of having to add all the logic themselves.

Fixes: 132654975
Test: ./test/run_all_host_tests.sh && ./test/run_all_device_tests.sh
Change-Id: I60ef33da5658139a5f40d71d5e6f6c6a2bbdbee0
diff --git a/Method.cpp b/Method.cpp
index 482bae5..dad0ddf 100644
--- a/Method.cpp
+++ b/Method.cpp
@@ -239,6 +239,30 @@
     emitJavaArgResultSignature(out, results());
 }
 
+void Method::emitJavaSignature(Formatter& out) const {
+    const bool returnsValue = !results().empty();
+    const bool needsCallback = results().size() > 1;
+
+    if (returnsValue && !needsCallback) {
+        out << results()[0]->type().getJavaType();
+    } else {
+        out << "void";
+    }
+
+    out << " " << name() << "(";
+    emitJavaArgSignature(out);
+
+    if (needsCallback) {
+        if (!args().empty()) {
+            out << ", ";
+        }
+
+        out << name() << "Callback _hidl_cb";
+    }
+
+    out << ")";
+}
+
 void Method::dumpAnnotations(Formatter &out) const {
     if (mAnnotations->size() == 0) {
         return;