diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-06-15 01:31:58 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2010-06-15 16:43:18 -0700 |
commit | 54bc281639e5ff6955d7a86104f6f21624941aca (patch) | |
tree | b8c1a3094530f39942f26a436cc97e3989c5deaa /libs/ui/InputManager.cpp | |
parent | 4607338eaf2988dc4dc4b0b738098f17878a90ab (diff) | |
download | frameworks_native-54bc281639e5ff6955d7a86104f6f21624941aca.zip frameworks_native-54bc281639e5ff6955d7a86104f6f21624941aca.tar.gz frameworks_native-54bc281639e5ff6955d7a86104f6f21624941aca.tar.bz2 |
More work in progress on native events.
Refactored the code to eliminate potential deadlocks due to re-entrant
calls from the policy into the dispatcher. Also added some plumbing
that will be used to notify the framework about ANRs.
Change-Id: Iba7a10de0cb3c56cd7520d6ce716db52fdcc94ff
Diffstat (limited to 'libs/ui/InputManager.cpp')
-rw-r--r-- | libs/ui/InputManager.cpp | 65 |
1 files changed, 28 insertions, 37 deletions
diff --git a/libs/ui/InputManager.cpp b/libs/ui/InputManager.cpp index ab354a5..7538dd0 100644 --- a/libs/ui/InputManager.cpp +++ b/libs/ui/InputManager.cpp @@ -14,29 +14,30 @@ namespace android { -InputManager::InputManager(const sp<EventHubInterface>& eventHub, - const sp<InputDispatchPolicyInterface>& policy) : - mEventHub(eventHub), mPolicy(policy) { - mDispatcher = new InputDispatcher(policy); - mReader = new InputReader(eventHub, policy, mDispatcher); - - mDispatcherThread = new InputDispatcherThread(mDispatcher); - mReaderThread = new InputReaderThread(mReader); +InputManager::InputManager( + const sp<EventHubInterface>& eventHub, + const sp<InputReaderPolicyInterface>& readerPolicy, + const sp<InputDispatcherPolicyInterface>& dispatcherPolicy) { + mDispatcher = new InputDispatcher(dispatcherPolicy); + mReader = new InputReader(eventHub, readerPolicy, mDispatcher); + initialize(); +} - configureExcludedDevices(); +InputManager::InputManager( + const sp<InputReaderInterface>& reader, + const sp<InputDispatcherInterface>& dispatcher) : + mReader(reader), + mDispatcher(dispatcher) { + initialize(); } InputManager::~InputManager() { stop(); } -void InputManager::configureExcludedDevices() { - Vector<String8> excludedDeviceNames; - mPolicy->getExcludedDeviceNames(excludedDeviceNames); - - for (size_t i = 0; i < excludedDeviceNames.size(); i++) { - mEventHub->addExcludedDevice(excludedDeviceNames[i]); - } +void InputManager::initialize() { + mReaderThread = new InputReaderThread(mReader); + mDispatcherThread = new InputDispatcherThread(mDispatcher); } status_t InputManager::start() { @@ -79,36 +80,26 @@ status_t InputManager::unregisterInputChannel(const sp<InputChannel>& inputChann return mDispatcher->unregisterInputChannel(inputChannel); } -int32_t InputManager::getScanCodeState(int32_t deviceId, int32_t deviceClasses, int32_t scanCode) - const { - int32_t vkKeyCode, vkScanCode; - if (mReader->getCurrentVirtualKey(& vkKeyCode, & vkScanCode)) { - if (vkScanCode == scanCode) { - return KEY_STATE_VIRTUAL; - } - } - - return mEventHub->getScanCodeState(deviceId, deviceClasses, scanCode); +void InputManager::getInputConfiguration(InputConfiguration* outConfiguration) const { + mReader->getCurrentInputConfiguration(outConfiguration); } -int32_t InputManager::getKeyCodeState(int32_t deviceId, int32_t deviceClasses, int32_t keyCode) - const { - int32_t vkKeyCode, vkScanCode; - if (mReader->getCurrentVirtualKey(& vkKeyCode, & vkScanCode)) { - if (vkKeyCode == keyCode) { - return KEY_STATE_VIRTUAL; - } - } +int32_t InputManager::getScanCodeState(int32_t deviceId, int32_t deviceClasses, + int32_t scanCode) const { + return mReader->getCurrentScanCodeState(deviceId, deviceClasses, scanCode); +} - return mEventHub->getKeyCodeState(deviceId, deviceClasses, keyCode); +int32_t InputManager::getKeyCodeState(int32_t deviceId, int32_t deviceClasses, + int32_t keyCode) const { + return mReader->getCurrentKeyCodeState(deviceId, deviceClasses, keyCode); } int32_t InputManager::getSwitchState(int32_t deviceId, int32_t deviceClasses, int32_t sw) const { - return mEventHub->getSwitchState(deviceId, deviceClasses, sw); + return mReader->getCurrentSwitchState(deviceId, deviceClasses, sw); } bool InputManager::hasKeys(size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) const { - return mEventHub->hasKeys(numCodes, keyCodes, outFlags); + return mReader->hasKeys(numCodes, keyCodes, outFlags); } } // namespace android |