From f15a8aa344946fb274b1db9f546d5fed746cae70 Mon Sep 17 00:00:00 2001 From: Prabir Pradhan Date: Tue, 5 Nov 2019 01:10:04 +0000 Subject: Reland "Let InputReader handle its own thread" This CL was first landed in Ic732436d4f00a831e317be1f16ac106a11652cff but was reverted due to flaky tests. The flaky tests were caused by races between the instrumented test classes and the InputReader class under test, which now runs in a new thread. In addition to re-landing the change, this CL fixes the flaky tests by changing the tests to eliminate the race condition. - InputReaderTest should send a configuration change request to InputReader every time a device is enabled or disabled, and the test should wait for notifyDeviceReset to be called on the input listener to ensure it was enabled/disabled successfully. Bug: 130819454 Test: atest inputflinger_tests Test: Touch input works on crosshatch Change-Id: I822d3c33384ebdc1bc850a40534e942a27a79ec9 --- services/inputflinger/InputManager.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'services/inputflinger/InputManager.cpp') diff --git a/services/inputflinger/InputManager.cpp b/services/inputflinger/InputManager.cpp index e7640dd6af..1043390f84 100644 --- a/services/inputflinger/InputManager.cpp +++ b/services/inputflinger/InputManager.cpp @@ -46,7 +46,6 @@ InputManager::~InputManager() { } void InputManager::initialize() { - mReaderThread = new InputReaderThread(mReader); mDispatcherThread = new InputDispatcherThread(mDispatcher); } @@ -57,9 +56,9 @@ status_t InputManager::start() { 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::start() { } 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(); -- cgit v1.2.3-59-g8ed1b