From 3608aadd736d28b9594dea54cd07cc628955b4e0 Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Wed, 2 Oct 2019 17:08:26 -0700 Subject: Let InputDispatcher handle its own thread We move the threading logic from InputManger to InputDispatcher by removing dispatchOnce() method from InputDispatcherInterface and adding a start() and stop() method in its place. Bug: 130819454 Test: atest inputflinger_tests Test: Touch input works on crosshatch Change-Id: I1d06be2330a2f8b9261fd5c5323a486d6aa544e8 --- services/inputflinger/InputManager.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'services/inputflinger/InputManager.cpp') diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp index 1043390f84..c7c61cf1ef 100644 --- a/services/inputflinger/InputManager.cpp +++ b/services/inputflinger/InputManager.cpp @@ -20,7 +20,6 @@ #include "InputManager.h" #include "InputDispatcherFactory.h" -#include "InputDispatcherThread.h" #include "InputReaderFactory.h" #include @@ -38,19 +37,14 @@ InputManager::InputManager( mDispatcher = createInputDispatcher(dispatcherPolicy); mClassifier = new InputClassifier(mDispatcher); mReader = createInputReader(readerPolicy, mClassifier); - initialize(); } InputManager::~InputManager() { stop(); } -void InputManager::initialize() { - mDispatcherThread = new InputDispatcherThread(mDispatcher); -} - status_t InputManager::start() { - status_t result = mDispatcherThread->run("InputDispatcher", PRIORITY_URGENT_DISPLAY); + status_t result = mDispatcher->start(); if (result) { ALOGE("Could not start InputDispatcher thread due to error %d.", result); return result; @@ -60,7 +54,7 @@ status_t InputManager::start() { if (result) { ALOGE("Could not start InputReader due to error %d.", result); - mDispatcherThread->requestExit(); + mDispatcher->stop(); return result; } @@ -68,17 +62,21 @@ status_t InputManager::start() { } status_t InputManager::stop() { + status_t status = OK; + status_t result = mReader->stop(); if (result) { ALOGW("Could not stop InputReader due to error %d.", result); + status = result; } - result = mDispatcherThread->requestExitAndWait(); + result = mDispatcher->stop(); if (result) { ALOGW("Could not stop InputDispatcher thread due to error %d.", result); + status = result; } - return OK; + return status; } sp InputManager::getReader() { -- cgit v1.2.3-59-g8ed1b