2016/5/18

handle Key Event 的位置..

framework/base/policy/src/com/android/internal/policy/impl/PhoneWindow.java 有一段:
    protected boolean onKeyDown(int featureId, int keyCode, KeyEvent event) {
        /* ****************************************************************************
         * HOW TO DECIDE WHERE YOUR KEY HANDLING GOES.
         *
         * If your key handling must happen before the app gets a crack at the event,
         * it goes in PhoneWindowManager.
         *
         * If your key handling should happen in all windows, and does not depend on
         * the state of the current application, other than that the current
         * application can override the behavior by handling the event itself, it
         * should go in PhoneFallbackEventHandler.
         *
         * Only if your handling depends on the window, and the fact that it has
         * a DecorView, should it go here.
         * ****************************************************************************/
  • 在所有 app 能拿到之前 : PhoneWindowManager
  • 除非 app 有自己處理,否則交給你處理: PhoneFallbackEventHandler
  • 你有用到 DecoView... : PhoneWindow.java

沒有留言:

張貼留言