事件分发前的拦截过程

时间:2024-04-02 08:02:10

https://m.2cto.com/kf/201611/563390.html

第一次事件拦截    interceptKeyBeforeQueueing

事件分发前的拦截过程

返回0则意味着事件被拦截,返回1则意味着事件允许被发送到应用程序中

第二次事件拦截   interceptKeyBeforeDispatching

事件分发前的拦截过程

private static final boolean warnopenOrclose = TopwiseProp.getDefaultSettingBoolean("default_lakala_fangchai_warnning",false);

//返回值为-1则说明事件被拦截,返回值为0则说明事件被放行
@Override
public long interceptKeyBeforeDispatching(WindowState win, KeyEvent event, int policyFlags) {
    final int keyCode = event.getKeyCode();
    final int repeatCount = event.getRepeatCount();//重复次数
    //add for 触发状态下禁止导航栏的功能
    Log.i("wqtest","keyCode: " + keyCode);
    if(warnopenOrclose && SystemProperties.get("sys.fangchai.tigger","0").equals("1")){
        if(keyCode == KeyEvent.KEYCODE_MENU||keyCode == KeyEvent.KEYCODE_HOME || keyCode == KeyEvent.KEYCODE_BACK){
            return -1;
        }
    }
    if(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN){
    String title = win.getAttrs().packageName;
        if (title != null && (title.equals("com.topwise.pinpadservice"))){
            return -1;
        }
    }
}

相关文章