Move macros from libhidl[transport] to auto-generated code.

Bug: 32756130

Test: hidl_test
Change-Id: Ic7af37daebc3e465a855e5b62055356e3e00c9d3
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index 0670dd9..24e8e9d 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -742,15 +742,6 @@
 #define HAL_LIBRARY_PATH_ODM "/odm/lib/hw/"
 #endif
 
-#define DECLARE_SERVICE_MANAGER_INTERACTIONS(INTERFACE)                                  \
-    static ::android::sp<I##INTERFACE> getService(                                       \
-            const std::string &serviceName, bool getStub=false);                         \
-    ::android::status_t registerAsService(const std::string &serviceName);               \
-    static bool registerForNotifications(                                                \
-        const std::string &serviceName,                                                  \
-        const ::android::sp<::android::hidl::manager::V1_0::IServiceNotification>        \
-                  &notification);                                                        \
-
 // ----------------------------------------------------------------------
 // Class that provides Hidl instrumentation utilities.
 struct HidlInstrumentor {
diff --git a/transport/include/hidl/HidlBinderSupport.h b/transport/include/hidl/HidlBinderSupport.h
index f906ea4..1dfaecd 100644
--- a/transport/include/hidl/HidlBinderSupport.h
+++ b/transport/include/hidl/HidlBinderSupport.h
@@ -334,91 +334,6 @@
     }
 }
 
-#define IMPLEMENT_SERVICE_MANAGER_INTERACTIONS(INTERFACE, PACKAGE)                       \
-    ::android::sp<I##INTERFACE> I##INTERFACE::getService(                                \
-            const std::string &serviceName, bool getStub)                                \
-    {                                                                                    \
-        using ::android::sp;                                                             \
-        using ::android::hardware::defaultServiceManager;                                \
-        using ::android::hidl::manager::V1_0::IServiceManager;                           \
-        sp<I##INTERFACE> iface;                                                          \
-        const sp<IServiceManager> sm = defaultServiceManager();                          \
-        if (sm != nullptr && !getStub) {                                                 \
-            sp<::android::hidl::base::V1_0::IBase> base;                                 \
-            ::android::hardware::Return<void> ret =                                      \
-                sm->get(PACKAGE "::I" #INTERFACE, serviceName.c_str(),                   \
-                    [&base](sp<::android::hidl::base::V1_0::IBase> found) {              \
-                        base = found;                                                    \
-                    });                                                                  \
-            if (ret.getStatus().isOk()) {                                                \
-                iface = I##INTERFACE::castFrom(base);                                    \
-                if (iface != nullptr) {                                                  \
-                    return iface;                                                        \
-                }                                                                        \
-            }                                                                            \
-        }                                                                                \
-        int dlMode = RTLD_LAZY;                                                          \
-        void *handle = dlopen(HAL_LIBRARY_PATH_ODM PACKAGE "-impl.so", dlMode);          \
-        if (handle == nullptr) {                                                         \
-            handle = dlopen(HAL_LIBRARY_PATH_VENDOR PACKAGE "-impl.so", dlMode);         \
-        }                                                                                \
-        if (handle == nullptr) {                                                         \
-            handle = dlopen(HAL_LIBRARY_PATH_SYSTEM PACKAGE "-impl.so", dlMode);         \
-        }                                                                                \
-        if (handle == nullptr) {                                                         \
-            return iface;                                                                \
-        }                                                                                \
-        I##INTERFACE* (*generator)(const char* name);                                    \
-        *(void **)(&generator) = dlsym(handle, "HIDL_FETCH_I"#INTERFACE);                \
-        if (generator) {                                                                 \
-            iface = (*generator)(serviceName.c_str());                                   \
-            if (iface != nullptr) {                                                      \
-                iface = new Bs##INTERFACE(iface);                                        \
-            }                                                                            \
-        }                                                                                \
-        return iface;                                                                    \
-    }                                                                                    \
-    ::android::status_t I##INTERFACE::registerAsService(                                 \
-            const std::string &serviceName)                                              \
-    {                                                                                    \
-        using ::android::sp;                                                             \
-        using ::android::hardware::defaultServiceManager;                                \
-        using ::android::hidl::manager::V1_0::IServiceManager;                           \
-        const sp<IServiceManager> sm = defaultServiceManager();                          \
-        if (sm == nullptr) {                                                             \
-            return ::android::INVALID_OPERATION;                                         \
-        }                                                                                \
-        bool success = false;                                                            \
-        ::android::hardware::Return<void> ret =                                          \
-            this->interfaceChain(                                                        \
-                [&success, &sm, &serviceName, this](const auto &chain) {                 \
-                    ::android::hardware::Return<bool> addRet =                           \
-                            sm->add(chain, serviceName.c_str(), this);                   \
-                    success = addRet.isOk() && addRet;                                   \
-                });                                                                      \
-        success = success && ret.getStatus().isOk();                                     \
-        return success ? ::android::OK : ::android::UNKNOWN_ERROR;                       \
-    }                                                                                    \
-    bool I##INTERFACE::registerForNotifications(                                         \
-            const std::string &serviceName,                                              \
-            const ::android::sp<::android::hidl::manager::V1_0::IServiceNotification>    \
-                      &notification)                                                     \
-    {                                                                                    \
-        using ::android::sp;                                                             \
-        using ::android::hardware::defaultServiceManager;                                \
-        using ::android::hidl::manager::V1_0::IServiceManager;                           \
-        const sp<IServiceManager> sm = defaultServiceManager();                          \
-        if (sm == nullptr) {                                                             \
-            return false;                                                                \
-        }                                                                                \
-        ::android::hardware::Return<bool> success =                                      \
-                sm->registerForNotifications(PACKAGE "::I" #INTERFACE,                   \
-                                             serviceName,                                \
-                                             notification);                              \
-        return success.isOk() && success;                                                \
-    }
-
-
 }  // namespace hardware
 }  // namespace android