summaryrefslogtreecommitdiff
path: root/libs/androidfw/Keyboard.cpp
diff options
context:
space:
mode:
author Jeff Brown <jeffbrown@google.com> 2012-04-10 14:30:49 -0700
committer Jeff Brown <jeffbrown@google.com> 2012-04-10 18:23:58 -0700
commit9f25b7fdf216c9ef0bd2322cd223eeaf0d60f77f (patch)
treeb0b509a261874435cab3f5f1a727c02b399bd91c /libs/androidfw/Keyboard.cpp
parent54ae14749bc7f9e73cfda35a8b49f9efa80a77fb (diff)
Request key maps from input manager service.
Instead of each application loading the KeyCharacterMap from the file system, get them from the input manager service as part of the InputDevice object. Refactored InputManager to be a proper singleton instead of having a bunch of static methods. InputManager now maintains a cache of all InputDevice objects that it has loaded. Currently we never invalidate the cache which can cause InputDevice to return stale motion ranges if the device is reconfigured. This will be fixed in a future change. Added a fake InputDevice with ID -1 to represent the virtual keyboard. Change-Id: If7a695839ad0972317a5aab89e9d1e42ace28eb7
Diffstat (limited to 'libs/androidfw/Keyboard.cpp')
-rw-r--r--libs/androidfw/Keyboard.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/libs/androidfw/Keyboard.cpp b/libs/androidfw/Keyboard.cpp
index e97a5eb6c2c0..a84a8c7678c9 100644
--- a/libs/androidfw/Keyboard.cpp
+++ b/libs/androidfw/Keyboard.cpp
@@ -24,6 +24,7 @@
#include <androidfw/KeycodeLabels.h>
#include <androidfw/KeyLayoutMap.h>
#include <androidfw/KeyCharacterMap.h>
+#include <androidfw/InputDevice.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <cutils/properties.h>
@@ -32,13 +33,10 @@ namespace android {
// --- KeyMap ---
-KeyMap::KeyMap() :
- keyLayoutMap(NULL), keyCharacterMap(NULL) {
+KeyMap::KeyMap() {
}
KeyMap::~KeyMap() {
- delete keyLayoutMap;
- delete keyCharacterMap;
}
status_t KeyMap::load(const InputDeviceIdentifier& deviceIdenfifier,
@@ -114,14 +112,12 @@ status_t KeyMap::loadKeyLayout(const InputDeviceIdentifier& deviceIdentifier,
return NAME_NOT_FOUND;
}
- KeyLayoutMap* map;
- status_t status = KeyLayoutMap::load(path, &map);
+ status_t status = KeyLayoutMap::load(path, &keyLayoutMap);
if (status) {
return status;
}
keyLayoutFile.setTo(path);
- keyLayoutMap = map;
return OK;
}
@@ -133,14 +129,12 @@ status_t KeyMap::loadKeyCharacterMap(const InputDeviceIdentifier& deviceIdentifi
return NAME_NOT_FOUND;
}
- KeyCharacterMap* map;
- status_t status = KeyCharacterMap::load(path, &map);
+ status_t status = KeyCharacterMap::load(path, &keyCharacterMap);
if (status) {
return status;
}
keyCharacterMapFile.setTo(path);
- keyCharacterMap = map;
return OK;
}