/frameworks/base/core/java/android/view/KeyEvent.java
public static final int KEYCODE_PROFILE_SWITCH =288;
// 定义添加物理按键
public static final int KEYCODE_PTT =289;
public static final int KEYCODE_SOS =290;
public static final int KEYCODE_HANDS_FREE =291;
/frameworks/native/include/input/InputEventLabels.h
static const InputEventLabel KEYCODES[]={
// NOTE: If you add a new keycode here you must also add it to several other files.
// Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
DEFINE_KEYCODE(UNKNOWN),
DEFINE_KEYCODE(SOFT_LEFT),
......
DEFINE_KEYCODE(PROFILE_SWITCH),
DEFINE_KEYCODE(PTT),
DEFINE_KEYCODE(SOS),
DEFINE_KEYCODE(HANDS_FREE),
{ nullptr, 0}};
最后执行指令更新下api,再触发编译
make update-api
/frameworks/base/api/current.txt
/frameworks/base/core/java/android/view/KeyEvent.javapublic static final int KEYCODE_PROFILE_SWITCH = 288;// 定义添加物理按键public static final int KEYCODE_PTT = 289;public static final int KEYCODE_SOS = 290;public static final int KEYCODE_HANDS_FREE = 291