一、查看需要定义的按键码
frameworks/base/data/keyboards/Generic.kl
key 2 1
key 3 2
二、新增按键上报键值
device/rockchip/common/rk29-keypad.kl
key 59 MENU
key 102 HOME
key 114 VOLUME_DOWN
key 115 VOLUME_UP
key 116 POWER
key 143 NOTIFICATION
key 158 BACK
key 212 CAMERA
key 217 SEARCH
key 2 1
key 3 2
三、DTS中修改linux,code 和 label 样式按照其他按键的来
/*vol-up-key {
linux,code = <115>;
label = "volume up";
rockchip,adc_value = <1>;
};
vol-down-key {
linux,code = <114>;
label = "volume down";
rockchip,adc_value = <170>;
};*/
vol-up-key {
linux,code = <2>;
label = "1";
rockchip,adc_value = <1>;
};
vol-down-key {
linux,code = <3>;
label = "2";
rockchip,adc_value = <170>;
};
四、PhoneWindowManager.java中增加按键功能
/** {@inheritDoc} */
@Override
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
if (!mSystemBooted) {
// If we have not yet booted, don't let key events do anything.
return 0;
}
case KeyEvent.KEYCODE_2: {
if(down){
Intent intent_navigation = new Intent("lyzk.intent.systemui.hidenavigation");
Intent intent_statusbar = new Intent("lyzk.intent.systemui.hidestatusbar");
mContext.sendBroadcast(intent_navigation);
mContext.sendBroadcast(intent_statusbar);
//interceptBackKeyDown();
}else{
}
break;
}
case KeyEvent.KEYCODE_1: {
if(down){
Intent intent_navigation = new Intent("lyzk.intent.systemui.shownavigation");
Intent intent_statusbar = new Intent("lyzk.intent.systemui.showstatusbar");
mContext.sendBroadcast(intent_navigation);
mContext.sendBroadcast(intent_statusbar);
//interceptBackKeyDown();
}else{
}
break;
}