Loading include/input/VirtualKeyMap.h +1 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ class VirtualKeyMap { public: ~VirtualKeyMap(); static status_t load(const std::string& filename, VirtualKeyMap** outMap); static std::unique_ptr<VirtualKeyMap> load(const std::string& filename); inline const Vector<VirtualKeyDefinition>& getVirtualKeys() const { return mVirtualKeys; Loading libs/input/VirtualKeyMap.cpp +20 −35 Original line number Diff line number Diff line Loading @@ -28,10 +28,6 @@ // Enables debug output for the parser. #define DEBUG_PARSER 0 // Enables debug output for parser performance. #define DEBUG_PARSER_PERFORMANCE 0 namespace android { static const char* WHITESPACE = " \t\r"; Loading @@ -46,39 +42,28 @@ VirtualKeyMap::VirtualKeyMap() { VirtualKeyMap::~VirtualKeyMap() { } status_t VirtualKeyMap::load(const std::string& filename, VirtualKeyMap** outMap) { *outMap = nullptr; Tokenizer* tokenizer; status_t status = Tokenizer::open(String8(filename.c_str()), &tokenizer); if (status) { std::unique_ptr<VirtualKeyMap> VirtualKeyMap::load(const std::string& filename) { Tokenizer* t; status_t status = Tokenizer::open(String8(filename.c_str()), &t); if (status != OK) { ALOGE("Error %d opening virtual key map file %s.", status, filename.c_str()); } else { VirtualKeyMap* map = new VirtualKeyMap(); return nullptr; } std::unique_ptr<Tokenizer> tokenizer(t); // Using 'new' to access a non-public constructor std::unique_ptr<VirtualKeyMap> map(new VirtualKeyMap()); if (!map) { ALOGE("Error allocating virtual key map."); status = NO_MEMORY; } else { #if DEBUG_PARSER_PERFORMANCE nsecs_t startTime = systemTime(SYSTEM_TIME_MONOTONIC); #endif Parser parser(map, tokenizer); status = parser.parse(); #if DEBUG_PARSER_PERFORMANCE nsecs_t elapsedTime = systemTime(SYSTEM_TIME_MONOTONIC) - startTime; ALOGD("Parsed key character map file '%s' %d lines in %0.3fms.", tokenizer->getFilename().string(), tokenizer->getLineNumber(), elapsedTime / 1000000.0); #endif if (status) { delete map; } else { *outMap = map; } return nullptr; } delete tokenizer; Parser parser(map.get(), tokenizer.get()); status = parser.parse(); if (status != OK) { return nullptr; } return status; return map; } Loading services/inputflinger/EventHub.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -202,7 +202,6 @@ EventHub::Device::Device(int fd, int32_t id, const std::string& path, EventHub::Device::~Device() { close(); delete configuration; delete virtualKeyMap; } void EventHub::Device::close() { Loading Loading @@ -1364,8 +1363,8 @@ status_t EventHub::openDeviceLocked(const char* devicePath) { if ((device->classes & INPUT_DEVICE_CLASS_TOUCH)) { // Load the virtual keys for the touch screen, if any. // We do this now so that we can make sure to load the keymap if necessary. status_t status = loadVirtualKeyMapLocked(device); if (!status) { bool success = loadVirtualKeyMapLocked(device); if (success) { device->classes |= INPUT_DEVICE_CLASS_KEYBOARD; } } Loading Loading @@ -1614,15 +1613,16 @@ void EventHub::loadConfigurationLocked(Device* device) { } } status_t EventHub::loadVirtualKeyMapLocked(Device* device) { bool EventHub::loadVirtualKeyMapLocked(Device* device) { // The virtual key map is supplied by the kernel as a system board property file. std::string path; path += "/sys/board_properties/virtualkeys."; path += device->identifier.name; if (access(path.c_str(), R_OK)) { return NAME_NOT_FOUND; return false; } return VirtualKeyMap::load(path, &device->virtualKeyMap); device->virtualKeyMap = VirtualKeyMap::load(path); return device->virtualKeyMap != nullptr; } status_t EventHub::loadKeyMapLocked(Device* device) { Loading services/inputflinger/EventHub.h +2 −2 Original line number Diff line number Diff line Loading @@ -345,7 +345,7 @@ private: std::string configurationFile; PropertyMap* configuration; VirtualKeyMap* virtualKeyMap; std::unique_ptr<VirtualKeyMap> virtualKeyMap; KeyMap keyMap; sp<KeyCharacterMap> overlayKeyMap; Loading Loading @@ -416,7 +416,7 @@ private: bool hasKeycodeLocked(Device* device, int keycode) const; void loadConfigurationLocked(Device* device); status_t loadVirtualKeyMapLocked(Device* device); bool loadVirtualKeyMapLocked(Device* device); status_t loadKeyMapLocked(Device* device); bool isExternalDeviceLocked(Device* device); Loading Loading
include/input/VirtualKeyMap.h +1 −1 Original line number Diff line number Diff line Loading @@ -49,7 +49,7 @@ class VirtualKeyMap { public: ~VirtualKeyMap(); static status_t load(const std::string& filename, VirtualKeyMap** outMap); static std::unique_ptr<VirtualKeyMap> load(const std::string& filename); inline const Vector<VirtualKeyDefinition>& getVirtualKeys() const { return mVirtualKeys; Loading
libs/input/VirtualKeyMap.cpp +20 −35 Original line number Diff line number Diff line Loading @@ -28,10 +28,6 @@ // Enables debug output for the parser. #define DEBUG_PARSER 0 // Enables debug output for parser performance. #define DEBUG_PARSER_PERFORMANCE 0 namespace android { static const char* WHITESPACE = " \t\r"; Loading @@ -46,39 +42,28 @@ VirtualKeyMap::VirtualKeyMap() { VirtualKeyMap::~VirtualKeyMap() { } status_t VirtualKeyMap::load(const std::string& filename, VirtualKeyMap** outMap) { *outMap = nullptr; Tokenizer* tokenizer; status_t status = Tokenizer::open(String8(filename.c_str()), &tokenizer); if (status) { std::unique_ptr<VirtualKeyMap> VirtualKeyMap::load(const std::string& filename) { Tokenizer* t; status_t status = Tokenizer::open(String8(filename.c_str()), &t); if (status != OK) { ALOGE("Error %d opening virtual key map file %s.", status, filename.c_str()); } else { VirtualKeyMap* map = new VirtualKeyMap(); return nullptr; } std::unique_ptr<Tokenizer> tokenizer(t); // Using 'new' to access a non-public constructor std::unique_ptr<VirtualKeyMap> map(new VirtualKeyMap()); if (!map) { ALOGE("Error allocating virtual key map."); status = NO_MEMORY; } else { #if DEBUG_PARSER_PERFORMANCE nsecs_t startTime = systemTime(SYSTEM_TIME_MONOTONIC); #endif Parser parser(map, tokenizer); status = parser.parse(); #if DEBUG_PARSER_PERFORMANCE nsecs_t elapsedTime = systemTime(SYSTEM_TIME_MONOTONIC) - startTime; ALOGD("Parsed key character map file '%s' %d lines in %0.3fms.", tokenizer->getFilename().string(), tokenizer->getLineNumber(), elapsedTime / 1000000.0); #endif if (status) { delete map; } else { *outMap = map; } return nullptr; } delete tokenizer; Parser parser(map.get(), tokenizer.get()); status = parser.parse(); if (status != OK) { return nullptr; } return status; return map; } Loading
services/inputflinger/EventHub.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -202,7 +202,6 @@ EventHub::Device::Device(int fd, int32_t id, const std::string& path, EventHub::Device::~Device() { close(); delete configuration; delete virtualKeyMap; } void EventHub::Device::close() { Loading Loading @@ -1364,8 +1363,8 @@ status_t EventHub::openDeviceLocked(const char* devicePath) { if ((device->classes & INPUT_DEVICE_CLASS_TOUCH)) { // Load the virtual keys for the touch screen, if any. // We do this now so that we can make sure to load the keymap if necessary. status_t status = loadVirtualKeyMapLocked(device); if (!status) { bool success = loadVirtualKeyMapLocked(device); if (success) { device->classes |= INPUT_DEVICE_CLASS_KEYBOARD; } } Loading Loading @@ -1614,15 +1613,16 @@ void EventHub::loadConfigurationLocked(Device* device) { } } status_t EventHub::loadVirtualKeyMapLocked(Device* device) { bool EventHub::loadVirtualKeyMapLocked(Device* device) { // The virtual key map is supplied by the kernel as a system board property file. std::string path; path += "/sys/board_properties/virtualkeys."; path += device->identifier.name; if (access(path.c_str(), R_OK)) { return NAME_NOT_FOUND; return false; } return VirtualKeyMap::load(path, &device->virtualKeyMap); device->virtualKeyMap = VirtualKeyMap::load(path); return device->virtualKeyMap != nullptr; } status_t EventHub::loadKeyMapLocked(Device* device) { Loading
services/inputflinger/EventHub.h +2 −2 Original line number Diff line number Diff line Loading @@ -345,7 +345,7 @@ private: std::string configurationFile; PropertyMap* configuration; VirtualKeyMap* virtualKeyMap; std::unique_ptr<VirtualKeyMap> virtualKeyMap; KeyMap keyMap; sp<KeyCharacterMap> overlayKeyMap; Loading Loading @@ -416,7 +416,7 @@ private: bool hasKeycodeLocked(Device* device, int keycode) const; void loadConfigurationLocked(Device* device); status_t loadVirtualKeyMapLocked(Device* device); bool loadVirtualKeyMapLocked(Device* device); status_t loadKeyMapLocked(Device* device); bool isExternalDeviceLocked(Device* device); Loading