Initial InputMappers for evdev input HAL.
The previous design of the InputHost wrapper classes made it very
painful to do testing, so this change also reverts to a more classical
C++ pattern for non-copyable objects. The InputHost classes still simply
call through to the input_host_t and callbacks as before.
Updated unittests to use gmock for mocking the InputHost interactions.
Change-Id: I4b70df2c89ed48af77446b8f5b87a4bde94510bf
diff --git a/modules/input/evdev/EvdevModule.cpp b/modules/input/evdev/EvdevModule.cpp
index 1171a1a..93ccd35 100644
--- a/modules/input/evdev/EvdevModule.cpp
+++ b/modules/input/evdev/EvdevModule.cpp
@@ -37,7 +37,8 @@
class EvdevModule {
public:
- explicit EvdevModule(InputHost inputHost);
+ // Takes ownership of the InputHostInterface
+ explicit EvdevModule(InputHostInterface* inputHost);
void init();
void notifyReport(input_report_t* r);
@@ -45,7 +46,7 @@
private:
void loop();
- InputHost mInputHost;
+ std::unique_ptr<InputHostInterface> mInputHost;
std::shared_ptr<InputDeviceManager> mDeviceManager;
std::unique_ptr<InputHub> mInputHub;
std::thread mPollThread;
@@ -53,9 +54,9 @@
static std::unique_ptr<EvdevModule> gEvdevModule;
-EvdevModule::EvdevModule(InputHost inputHost) :
+EvdevModule::EvdevModule(InputHostInterface* inputHost) :
mInputHost(inputHost),
- mDeviceManager(std::make_shared<InputDeviceManager>(mInputHost)),
+ mDeviceManager(std::make_shared<InputDeviceManager>(mInputHost.get())),
mInputHub(std::make_unique<InputHub>(mDeviceManager)) {}
void EvdevModule::init() {
@@ -97,7 +98,7 @@
static void input_init(const input_module_t* module,
input_host_t* host, input_host_callbacks_t cb) {
LOG_ALWAYS_FATAL_IF(strcmp(module->common.id, INPUT_HARDWARE_MODULE_ID) != 0);
- InputHost inputHost = {host, cb};
+ auto inputHost = new InputHost(host, cb);
gEvdevModule = std::make_unique<EvdevModule>(inputHost);
gEvdevModule->init();
}