Wrapper service: only register if enabled.

- wrapper services should only register themselves if
  persist.hal.binderization is true (which is set in system
  settings).
- If binderization is disabled, we just block the service (otherwise it
  will just be restarted by init).

Bug: 34256441
Test: nfc and lights work with ag/1833821 with persist.hal.binderization
set to on and off. There are no additional selinux denials. No other
services are affected by this (ENABLE_TREBLE also now requires setting
a hal to hwbinder in the manifest to force/guarantee it to be binderized).

Change-Id: Ibc314338db5ac9857479609d293ea73672d90849
diff --git a/transport/include/hidl/LegacySupport.h b/transport/include/hidl/LegacySupport.h
index fab8a1d..9ee0635 100644
--- a/transport/include/hidl/LegacySupport.h
+++ b/transport/include/hidl/LegacySupport.h
@@ -26,12 +26,25 @@
 namespace android {
 namespace hardware {
 
+namespace details {
+bool blockingHalBinderizationEnabled();
+void blockIfBinderizationDisabled(const std::string& interface,
+                                  const std::string& instance);
+} // namespace details
+
 /**
  * Registers passthrough service implementation.
  */
 template<class Interface>
 status_t registerPassthroughServiceImplementation(
-      std::string name = "default") {
+        std::string name = "default") {
+    // TODO(b/34274385)
+    // If binderization is enabled, we should start up. Otherwise, wait around.
+    // If we return/kill ourselves, we will just be restarted by init. This
+    // function is only called from thin wrapping services, so blocking won't
+    // stop anything important from happening.
+    details::blockIfBinderizationDisabled(Interface::descriptor, name);
+
     sp<Interface> service = Interface::getService(name, true /* getStub */);
 
     if (service == nullptr) {