summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-04-17 16:52:41 -0700
committerJeff Brown <jeffbrown@google.com>2012-04-17 17:56:32 -0700
commit6ec6f79e1ac1714e3b837796e99f07ff88f66601 (patch)
tree02aa55617bfa6dd2eb0bec29156e279c8afaaa0d /include
parenta3bc565882dd3984e995363642b1295fe3d24d10 (diff)
downloadframeworks_base-6ec6f79e1ac1714e3b837796e99f07ff88f66601.zip
frameworks_base-6ec6f79e1ac1714e3b837796e99f07ff88f66601.tar.gz
frameworks_base-6ec6f79e1ac1714e3b837796e99f07ff88f66601.tar.bz2
Support loading keyboard layout overlays from resources.
Added the concept of a keyboard layout overlay, which is a key character map file that has "type OVERLAY". Added support for loading keyboard layout overlays from resources dynamically. The layouts are reloaded whenever they are changed in the Settings application or an application is installed. This is somewhat more aggressive than necessary so we might want to optimize it later. Before system-ready, the input system uses just the generic keyboard layouts that are included on the device system image. After system-ready, it considers the user's selected keyboard layout overlay and attempts to load it as necessary. We need to wait until system-ready before doing this because we need to be in a state where it is safe to start applications or access their resources. Bug: 6110399 Change-Id: Iae0886d3356649b0d2440aa00910a888cedd8323
Diffstat (limited to 'include')
-rw-r--r--include/androidfw/KeyCharacterMap.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/include/androidfw/KeyCharacterMap.h b/include/androidfw/KeyCharacterMap.h
index 3cc1cb2..e0e6ffa 100644
--- a/include/androidfw/KeyCharacterMap.h
+++ b/include/androidfw/KeyCharacterMap.h
@@ -49,6 +49,17 @@ public:
KEYBOARD_TYPE_ALPHA = 3,
KEYBOARD_TYPE_FULL = 4,
KEYBOARD_TYPE_SPECIAL_FUNCTION = 5,
+ KEYBOARD_TYPE_OVERLAY = 6,
+ };
+
+ enum Format {
+ // Base keyboard layout, may contain device-specific options, such as "type" declaration.
+ FORMAT_BASE = 0,
+ // Overlay keyboard layout, more restrictive, may be published by applications,
+ // cannot override device-specific options.
+ FORMAT_OVERLAY = 1,
+ // Either base or overlay layout ok.
+ FORMAT_ANY = 2,
};
// Substitute key code and meta state for fallback action.
@@ -58,7 +69,15 @@ public:
};
/* Loads a key character map from a file. */
- static status_t load(const String8& filename, sp<KeyCharacterMap>* outMap);
+ static status_t load(const String8& filename, Format format, sp<KeyCharacterMap>* outMap);
+
+ /* Loads a key character map from its string contents. */
+ static status_t loadContents(const String8& filename,
+ const char* contents, Format format, sp<KeyCharacterMap>* outMap);
+
+ /* Combines a base key character map and an overlay. */
+ static sp<KeyCharacterMap> combine(const sp<KeyCharacterMap>& base,
+ const sp<KeyCharacterMap>& overlay);
/* Returns an empty key character map. */
static sp<KeyCharacterMap> empty();
@@ -115,6 +134,7 @@ protected:
private:
struct Behavior {
Behavior();
+ Behavior(const Behavior& other);
/* The next behavior in the list, or NULL if none. */
Behavior* next;
@@ -131,6 +151,7 @@ private:
struct Key {
Key();
+ Key(const Key& other);
~Key();
/* The single character label printed on the key, or 0 if none. */
@@ -166,11 +187,12 @@ private:
KeyCharacterMap* mMap;
Tokenizer* mTokenizer;
+ Format mFormat;
State mState;
int32_t mKeyCode;
public:
- Parser(KeyCharacterMap* map, Tokenizer* tokenizer);
+ Parser(KeyCharacterMap* map, Tokenizer* tokenizer, Format format);
~Parser();
status_t parse();
@@ -188,6 +210,7 @@ private:
int mType;
KeyCharacterMap();
+ KeyCharacterMap(const KeyCharacterMap& other);
bool getKey(int32_t keyCode, const Key** outKey) const;
bool getKeyBehavior(int32_t keyCode, int32_t metaState,
@@ -195,6 +218,8 @@ private:
bool findKey(char16_t ch, int32_t* outKeyCode, int32_t* outMetaState) const;
+ static status_t load(Tokenizer* tokenizer, Format format, sp<KeyCharacterMap>* outMap);
+
static void addKey(Vector<KeyEvent>& outEvents,
int32_t deviceId, int32_t keyCode, int32_t metaState, bool down, nsecs_t time);
static void addMetaKeys(Vector<KeyEvent>& outEvents,