Fix error on user builds with future compiler.

This resolves "Generated code has unused lambda captures"
on future compiler versions.

Test: build hidl modules on user and userdebug variants
Test: boot internal marlin and pass hidl_test
Change-Id: I1b68701646cb4cd860860fb43a3cf276b34e1e2c
Fixes: 37908609
diff --git a/c2hal/test/Android.bp b/c2hal/test/Android.bp
index 2016901..547a099 100644
--- a/c2hal/test/Android.bp
+++ b/c2hal/test/Android.bp
@@ -67,6 +67,7 @@
 
 cc_test_library {
     name: "c2hal_test",
+    defaults: ["hidl-module-defaults"],
     generated_headers: ["c2hal_test_genc++_headers"],
     generated_sources: ["c2hal_test_genc++"],
     export_generated_headers: ["c2hal_test_genc++_headers"],
diff --git a/generateCpp.cpp b/generateCpp.cpp
index 3e50c03..79a45a6 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -697,9 +697,11 @@
     out << "auto _hidl_return = ";
 
     if (method->isOneway()) {
-        out << "addOnewayTask([mImpl = this->mImpl, "
-               "mEnableInstrumentation = this->mEnableInstrumentation, "
-               "mInstrumentationCallbacks = this->mInstrumentationCallbacks";
+        out << "addOnewayTask([mImpl = this->mImpl\n"
+            << "#ifdef __ANDROID_DEBUGGABLE__\n"
+               ", mEnableInstrumentation = this->mEnableInstrumentation, "
+               "mInstrumentationCallbacks = this->mInstrumentationCallbacks\n"
+            << "#endif // __ANDROID_DEBUGGABLE__\n";
         for (const auto &arg : method->args()) {
             out << ", "
                 << (arg->type().isInterface() ? "_hidl_wrapped_" : "")