Android4.2.2 self-increasing physical keys (frameworks)

Source: Internet
Author: User

When we modify the frameworks, it may appear:
Make: * * [Out/target/common/obj/packaging/checkapi-current-timestamp] Error 38
Workaround: Make Update-api


Add physical keys to Android: Keycode_help
1. Android Add button:
KeyEvent, KeyCode, Scancode, Keycodelabel,
-----
1) Key Scan code scancode is an integer type defined by the input driver framework of Linux and can refer to the Input.h header file (./external/kernel-headers/original/linux/input.h).
2) Key code (KEYCODE), this key code is an integer, in the upper Java program mainly through this value to determine the implementation of the system.
----
Implementation process:
1, Scancode-Keycodelabel.
The keyboard layout file (*.KL) converts the Scancode to Keycodelabel. The *.kl file is in the Devices folder of the source code (/DEVICE/ROCKCHIP/RK30SDK_BND/RK29-KEYPAD.KL) or/SYSTEM/USR/KEYLAYOUT/*.KL in the device.
Key 138 Help//Here is our definition of the Android key value of the character form, 138 is the Linux key value, help can not be used for no reason, there must be a defined position, this position is KeycodeLabels.h
2,keycodelabel, KeyCode.
The KeyCode value corresponding to the Keycodelabel string is obtained by finding the keycodes[] array. Keycodes[] in the file/frameworks/base/include/androidfw/keycodelabels.h.
What is defined here is actually the name of the Linux key and the Android key value in the KL file, which is a mapping table of Linux key to Android key; for example, RK29-KEYPAD.KL:
static const Keycodelabel keycodes[] = {
...
{"ASSIST", 219},
Add by HCM
{"Help", 220},
An enumeration value that defines keycode in/frameworks/native/include/android/keycodes.h.
enum {
....
Akeycode_assist = 219,
Add by HCM
Akeycode_help = 220,
......}
Load and parse this MAP:RK29-KEYPAD.KL in EventHub.cpp, then get the Linux key value 138 is a string of key, this string is help, with the above keycodes array, you can get its corresponding Android key value.




3,keycode, KeyEvent.
The corresponding keycode in Keyevent.java: (File path:/frameworks/base/core/java/android/view/keyevent.java).
There is a very important hint in Keyevent.java, that is, we fill in the special key process, but I this is the source code of Rui-core micro 3168,android4.2.2, the source of the comment path is wrong! :
Note:if you add a new keycode This must also add it to:
IsSystem ()
Native/include/android/keycodes.h
The frameworks/base/include/ui/keycodelabels.h should be:/frameworks/base/include/androidfw/keycodelabels.h
External/webkit/webkit/android/plugins/anpkeycodes.h
Frameworks/base/core/res/res/values/attrs.xml
Emulator?
Last_keycode
Keycode_symbolic_names
//
Also Android currently does not reserve code ranges for vendor-
Specific key codes. If you have a new key codes to the, you
must contribute a patch to the open source project to define
Those new codes. This was intended to maintain a consistent
Set of key code definitions across all Android devices.
If you change the keyevent, you will need to call make UPDATE-API to affect the API.
Last_keycode Modification:
/** key code Constant:add by HCM, help key. */
public static final int keycode_help = 220;
private static final int last_keycode = KEYCODE_HELP;
....
(Keycode_symbolic_names modified)
Names.append (Keycode_assist, "keycode_assist");
Names.append (Keycode_help, "keycode_help");
....
4, according to the above tips to modify IsSystem (), Code tracking:
IsSystem () in/frameworks/base/core/java/android/view/keyevent.java
Public Final Boolean IsSystem () {
Return Native_issystemkey (Mkeycode);
}

/frameworks/base/core/jni/android_view_keyevent.cpp
Static Jboolean Native_issystemkey (jnienv* env, Jobject clazz, Jint keycode) {
Return Keyevent::issystemkey (KeyCode);
}

/frameworks/base/libs/androidfw/input.cpp
BOOL Keyevent::issystemkey (int32_t keycode) {
Switch (keycode) {
......
Case Akeycode_search:
Add by HCM
Case AKEYCODE_HELP:
}
}
5,/external/webkit/source/webkit/android/plugins/anpkeycodes.h
Enum Anpkeycodes {
......

Kappswitch_anpkeycode = 187,
Add by HCM
Khelp_anpkeycode = 220,
};
6, Frameworks/base/core/res/res/values/attrs.xml
<attr name= "KeyCode" >
.....................
<enum name= "Keycode_ro" value= "217"/>
<enum name= "Keycode_kana" value= "218"/>
<enum name= "keycode_help" value= "/>"
</attr>
</attr>


After these operations are completed, the key-value mappings for Linux keys to Android are completed. That is, there is one more keycode_help in Android. Its value is 220.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.