2 * Copyright (C) 2010 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #define LOG_TAG "InputManager"
19 //#define LOG_NDEBUG 0
21 #include "InputManager.h"
23 #include <cutils/log.h>
27 InputManager::InputManager(
28 const sp<EventHubInterface>& eventHub,
29 const sp<InputReaderPolicyInterface>& readerPolicy,
30 const sp<InputDispatcherPolicyInterface>& dispatcherPolicy) {
31 mDispatcher = new InputDispatcher(dispatcherPolicy);
32 mReader = new InputReader(eventHub, readerPolicy, mDispatcher);
36 InputManager::InputManager(
37 const sp<InputReaderInterface>& reader,
38 const sp<InputDispatcherInterface>& dispatcher) :
40 mDispatcher(dispatcher) {
44 InputManager::~InputManager() {
48 void InputManager::initialize() {
49 mReaderThread = new InputReaderThread(mReader);
50 mDispatcherThread = new InputDispatcherThread(mDispatcher);
53 status_t InputManager::start() {
54 status_t result = mDispatcherThread->run("InputDispatcher", PRIORITY_URGENT_DISPLAY);
56 ALOGE("Could not start InputDispatcher thread due to error %d.", result);
60 result = mReaderThread->run("InputReader", PRIORITY_URGENT_DISPLAY);
62 ALOGE("Could not start InputReader thread due to error %d.", result);
64 mDispatcherThread->requestExit();
71 status_t InputManager::stop() {
72 status_t result = mReaderThread->requestExitAndWait();
74 ALOGW("Could not stop InputReader thread due to error %d.", result);
77 result = mDispatcherThread->requestExitAndWait();
79 ALOGW("Could not stop InputDispatcher thread due to error %d.", result);
85 sp<InputReaderInterface> InputManager::getReader() {
89 sp<InputDispatcherInterface> InputManager::getDispatcher() {
93 } // namespace android