#ifndef ANDROID_HARDWARE_MANAGER_HIDLSERVICE_H #define ANDROID_HARDWARE_MANAGER_HIDLSERVICE_H #include #include #include #include namespace android { namespace hidl { namespace manager { namespace implementation { using ::android::hardware::hidl_vec; using ::android::hardware::hidl_string; using ::android::hardware::Return; using ::android::hardware::Void; using ::android::hidl::base::V1_0::IBase; using ::android::hidl::manager::V1_0::IServiceNotification; using ::android::hidl::manager::V1_1::IServiceManager; using ::android::sp; struct HidlService { HidlService(const std::string &interfaceName, const std::string &instanceName, const sp &service, const pid_t pid); HidlService(const std::string &interfaceName, const std::string &instanceName) : HidlService( interfaceName, instanceName, nullptr, static_cast(IServiceManager::PidConstant::NO_PID)) {} /** * Note, getService() can be nullptr. This is because you can have a HidlService * with registered IServiceNotification objects but no service registered yet. */ sp getService() const; void setService(sp service, pid_t pid); pid_t getPid() const; const std::string &getInterfaceName() const; const std::string &getInstanceName() const; void addListener(const sp &listener); bool removeListener(const wp &listener); void registerPassthroughClient(pid_t pid); std::string string() const; // e.x. "android.hidl.manager@1.0::IServiceManager/manager" const std::set &getPassthroughClients() const; private: void sendRegistrationNotifications(); const std::string mInterfaceName; // e.x. "android.hidl.manager@1.0::IServiceManager" const std::string mInstanceName; // e.x. "manager" sp mService; std::vector> mListeners{}; std::set mPassthroughClients{}; pid_t mPid = static_cast(IServiceManager::PidConstant::NO_PID); }; } // namespace implementation } // namespace manager } // namespace hidl } // namespace android #endif // ANDROID_HARDWARE_MANAGER_HIDLSERVICE_H