performance-unnecessary-value-param where possible

*-adapter libraries don't have ABI requirements, so they can be changed

Fixes: 121200893
Test: make with:
 WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,performance-unnecessary-value-param

Change-Id: Ia238907101ba53d101d9e642c34abe67697100ad
diff --git a/Android.bp b/Android.bp
index 95e21bb..5e3566f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -34,8 +34,8 @@
         "-Werror",
         "-Wextra-semi",
     ],
-    // b/121200893, hidl generated *All.cpp files use value parameters
     tidy_checks: [
+        // _hidl_cb and addOnewayTask are stuck because of the legacy ABI
         "-performance-unnecessary-value-param",
     ],
     product_variables: {
diff --git a/generateCppAdapter.cpp b/generateCppAdapter.cpp
index a83e9f3..1d88d3c 100644
--- a/generateCppAdapter.cpp
+++ b/generateCppAdapter.cpp
@@ -54,7 +54,7 @@
             out << "public:\n";
             out << "typedef " << mockName << " Pure;\n";
 
-            out << klassName << "(::android::sp<" << mockName << "> impl);\n";
+            out << klassName << "(const ::android::sp<" << mockName << ">& impl);\n";
 
             generateMethods(out, [&](const Method* method, const Interface* /* interface */) {
                 if (method->isHidlReserved()) {
@@ -103,8 +103,8 @@
 
         const std::string mockName = getInterface()->fqName().cppName();
 
-        out << klassName << "::" << klassName << "(::android::sp<" << mockName
-            << "> impl) : mImpl(impl) {}";
+        out << klassName << "::" << klassName << "(const ::android::sp<" << mockName
+            << ">& impl) : mImpl(impl) {}";
 
         generateMethods(out, [&](const Method* method, const Interface* /* interface */) {
             generateAdapterMethod(out, method);