Android7.1物理按键重映射

一、查看需要定义的按键码
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;
            }
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值