Remove uses of toBinder in auto-generated code.
It's templated, and it costs space. This is a minor gain, but we need
to start more aggressively watching for these kinds of things:
system/lib64/android.hardware.audio@4.0 . 848400 -> 844256 . -4144
system/lib64/libhidltransport . 540832 -> 536720 . -4112
system.img . 1218138560 -> 1218089408 . -49152
Bug: N/A
Test: boot/hidl_test
Change-Id: I064de46129242e0d1ec2e2f962f4834b2697691e
diff --git a/Interface.cpp b/Interface.cpp
index b591a9b..073e44c 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -817,13 +817,7 @@
out << "} else {\n";
out.indent();
out << "::android::sp<::android::hardware::IBinder> _hidl_binder = "
- << "::android::hardware::toBinder<\n";
- out.indent(2, [&] {
- out << fqName().cppName()
- << ">("
- << name
- << ");\n";
- });
+ << "::android::hardware::getOrCreateCachedBinder(" << name << ".get());\n";
out << "if (_hidl_binder.get() != nullptr) {\n";
out.indent([&] {
out << "_hidl_err = "