widget/gonk/libui/InputManager.cpp

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 * Copyright (C) 2010 The Android Open Source Project
michael@0 3 *
michael@0 4 * Licensed under the Apache License, Version 2.0 (the "License");
michael@0 5 * you may not use this file except in compliance with the License.
michael@0 6 * You may obtain a copy of the License at
michael@0 7 *
michael@0 8 * http://www.apache.org/licenses/LICENSE-2.0
michael@0 9 *
michael@0 10 * Unless required by applicable law or agreed to in writing, software
michael@0 11 * distributed under the License is distributed on an "AS IS" BASIS,
michael@0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
michael@0 13 * See the License for the specific language governing permissions and
michael@0 14 * limitations under the License.
michael@0 15 */
michael@0 16
michael@0 17 #define LOG_TAG "InputManager"
michael@0 18
michael@0 19 //#define LOG_NDEBUG 0
michael@0 20
michael@0 21 #include "InputManager.h"
michael@0 22
michael@0 23 #include "cutils_log.h"
michael@0 24
michael@0 25 namespace android {
michael@0 26
michael@0 27 InputManager::InputManager(
michael@0 28 const sp<EventHubInterface>& eventHub,
michael@0 29 const sp<InputReaderPolicyInterface>& readerPolicy,
michael@0 30 const sp<InputDispatcherPolicyInterface>& dispatcherPolicy) {
michael@0 31 mDispatcher = new InputDispatcher(dispatcherPolicy);
michael@0 32 mReader = new InputReader(eventHub, readerPolicy, mDispatcher);
michael@0 33 initialize();
michael@0 34 }
michael@0 35
michael@0 36 InputManager::InputManager(
michael@0 37 const sp<InputReaderInterface>& reader,
michael@0 38 const sp<InputDispatcherInterface>& dispatcher) :
michael@0 39 mReader(reader),
michael@0 40 mDispatcher(dispatcher) {
michael@0 41 initialize();
michael@0 42 }
michael@0 43
michael@0 44 InputManager::~InputManager() {
michael@0 45 stop();
michael@0 46 }
michael@0 47
michael@0 48 void InputManager::initialize() {
michael@0 49 mReaderThread = new InputReaderThread(mReader);
michael@0 50 mDispatcherThread = new InputDispatcherThread(mDispatcher);
michael@0 51 }
michael@0 52
michael@0 53 status_t InputManager::start() {
michael@0 54 status_t result = mDispatcherThread->run("InputDispatcher", PRIORITY_URGENT_DISPLAY);
michael@0 55 if (result) {
michael@0 56 ALOGE("Could not start InputDispatcher thread due to error %d.", result);
michael@0 57 return result;
michael@0 58 }
michael@0 59
michael@0 60 result = mReaderThread->run("InputReader", PRIORITY_URGENT_DISPLAY);
michael@0 61 if (result) {
michael@0 62 ALOGE("Could not start InputReader thread due to error %d.", result);
michael@0 63
michael@0 64 mDispatcherThread->requestExit();
michael@0 65 return result;
michael@0 66 }
michael@0 67
michael@0 68 return OK;
michael@0 69 }
michael@0 70
michael@0 71 status_t InputManager::stop() {
michael@0 72 status_t result = mReaderThread->requestExitAndWait();
michael@0 73 if (result) {
michael@0 74 ALOGW("Could not stop InputReader thread due to error %d.", result);
michael@0 75 }
michael@0 76
michael@0 77 result = mDispatcherThread->requestExitAndWait();
michael@0 78 if (result) {
michael@0 79 ALOGW("Could not stop InputDispatcher thread due to error %d.", result);
michael@0 80 }
michael@0 81
michael@0 82 return OK;
michael@0 83 }
michael@0 84
michael@0 85 sp<InputReaderInterface> InputManager::getReader() {
michael@0 86 return mReader;
michael@0 87 }
michael@0 88
michael@0 89 sp<InputDispatcherInterface> InputManager::getDispatcher() {
michael@0 90 return mDispatcher;
michael@0 91 }
michael@0 92
michael@0 93 } // namespace android

mercurial