Let InputReader handle its own thread
Previously, InputManager created and managed the InputReaderThread,
which interacted with InputReader through the loopOnce() method in
InputReaderInterface.
We move the threading logic from InputManager to InputReader by removing
the loopOnce() method from InputReaderInterface and adding a start() and
stop() method in its place.
Once InputReader is created, InputManager will call
InputReaderInterface::start(), which creates and starts InputReader's
own thread. InputManager can also call InputReaderInterface::stop() to
halt further processing on InputReader's thread.
Bug: 130819454
Test: atest inputflinger_tests
Test: Touch input works on crosshatch
Change-Id: Ic732436d4f00a831e317be1f16ac106a11652cff
diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp
index 7d30672..34a04df 100644
--- a/services/inputflinger/InputManager.cpp
+++ b/services/inputflinger/InputManager.cpp
@@ -46,7 +46,6 @@
}
void InputManager::initialize() {
- mReaderThread = new InputReaderThread(mReader);
mDispatcherThread = new InputDispatcherThread(mDispatcher);
}
@@ -57,9 +56,9 @@
return result;
}
- result = mReaderThread->run("InputReader", PRIORITY_URGENT_DISPLAY);
+ result = mReader->start();
if (result) {
- ALOGE("Could not start InputReader thread due to error %d.", result);
+ ALOGE("Could not start InputReader due to error %d.", result);
mDispatcherThread->requestExit();
return result;
@@ -69,9 +68,9 @@
}
status_t InputManager::stop() {
- status_t result = mReaderThread->requestExitAndWait();
+ status_t result = mReader->stop();
if (result) {
- ALOGW("Could not stop InputReader thread due to error %d.", result);
+ ALOGW("Could not stop InputReader due to error %d.", result);
}
result = mDispatcherThread->requestExitAndWait();