3,KeyCode -> Keyevent。
KeyEvent.java中的对应KeyCode:(文件路径:/frameworks/base/core/java/android/view/KeyEvent.java)。
KeyEvent.java中有一个非常重要的提示,那就是我们自己填特殊按键的流程,但是我这是瑞芯微3168,Android4.2.2的源代码,源码中的注释路径是有误的!:
// NOTE: If you add a new keycode here you must also add it to:
// isSystem()
// native/include/android/keycodes.h
// frameworks/base/include/ui/KeycodeLabels.h 应该为:/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 new key codes to have, you
// MUST contribute a patch to the open source project to define
// those new codes. This is intended to maintain a consistent
// set of key code definitions across all Android devices.
如果改动了KeyEvent,影响到API则需要调用make update-api。
LAST_KEYCODE修改:
/** 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修改)
names.append(KEYCODE_ASSIST, "KEYCODE_ASSIST");
names.append(KEYCODE_HELP, "KEYCODE_HELP");
....
4、根据上面提示修改isSystem(),代码跟踪:
isSystem() 在/frameworks/base/core/java/android/view/KeyEvent.java
public final boolean isSystem() {
return native_isSystemKey(mKeyCode);
}