From 1e08fe90df18930691b0c2ec22e5db25d7fcb4cf Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Tue, 15 Nov 2011 17:48:10 -0800 Subject: Eliminate hw.keyboards system properties. Stop using system properties to publish information about the key character map path. Instead, we can retrieve it on demand by asking the window manager. It was possible to exhaust the supply of system properties when repeatedly adding and removing input devices. Bug: 5532806 Change-Id: Idd361a24ad7db2edc185c8546db7fb05f9c28669 --- services/input/EventHub.cpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'services/input/EventHub.cpp') diff --git a/services/input/EventHub.cpp b/services/input/EventHub.cpp index 790b395c7b41..52897417596c 100644 --- a/services/input/EventHub.cpp +++ b/services/input/EventHub.cpp @@ -507,6 +507,15 @@ void EventHub::getVirtualKeyDefinitions(int32_t deviceId, } } +String8 EventHub::getKeyCharacterMapFile(int32_t deviceId) const { + AutoMutex _l(mLock); + Device* device = getDeviceLocked(deviceId); + if (device) { + return device->keyMap.keyCharacterMapFile; + } + return String8(); +} + EventHub::Device* EventHub::getDeviceLocked(int32_t deviceId) const { if (deviceId == 0) { deviceId = mBuiltInKeyboardId; @@ -1013,16 +1022,12 @@ status_t EventHub::openDeviceLocked(const char *devicePath) { // Configure the keyboard, gamepad or virtual keyboard. if (device->classes & INPUT_DEVICE_CLASS_KEYBOARD) { - // Set system properties for the keyboard. - setKeyboardPropertiesLocked(device, false); - // Register the keyboard as a built-in keyboard if it is eligible. if (!keyMapStatus && mBuiltInKeyboardId == -1 && isEligibleBuiltInKeyboard(device->identifier, device->configuration, &device->keyMap)) { mBuiltInKeyboardId = device->id; - setKeyboardPropertiesLocked(device, true); } // 'Q' key support = cheap test of whether this is an alpha-capable kbd @@ -1120,17 +1125,6 @@ status_t EventHub::loadKeyMapLocked(Device* device) { return device->keyMap.load(device->identifier, device->configuration); } -void EventHub::setKeyboardPropertiesLocked(Device* device, bool builtInKeyboard) { - int32_t id = builtInKeyboard ? 0 : device->id; - android::setKeyboardProperties(id, device->identifier, - device->keyMap.keyLayoutFile, device->keyMap.keyCharacterMapFile); -} - -void EventHub::clearKeyboardPropertiesLocked(Device* device, bool builtInKeyboard) { - int32_t id = builtInKeyboard ? 0 : device->id; - android::clearKeyboardProperties(id); -} - bool EventHub::isExternalDeviceLocked(Device* device) { if (device->configuration) { bool value; @@ -1184,9 +1178,7 @@ void EventHub::closeDeviceLocked(Device* device) { LOGW("built-in keyboard device %s (id=%d) is closing! the apps will not like this", device->path.string(), mBuiltInKeyboardId); mBuiltInKeyboardId = -1; - clearKeyboardPropertiesLocked(device, true); } - clearKeyboardPropertiesLocked(device, false); if (epoll_ctl(mEpollFd, EPOLL_CTL_DEL, device->fd, NULL)) { LOGW("Could not remove device fd from epoll instance. errno=%d", errno); -- cgit v1.2.3-59-g8ed1b