bug系列------为何kl的wake失效了

来源:互联网 发布:微博淘客软件 编辑:程序博客网 时间:2024/04/28 08:32

    之前说了kl文件里的wake是唤醒系统的关键,但是最近遇到的bug是哪怕把kl里的wake拿掉还是会唤醒系统,也就是wake还在

这就很奇怪了。于是追代码:

有个两个因素会影响wake,一个是kl文件中的wake的flag,还有就是
PhoneWindowManager.java里的interceptKeyBeforeQueueing这个函数。在interceptKeyBeforeQueueing这个函数最好调用了wakeUp(event.getEventTime(), 
mAllowTheaterModeWakeFromKey, "android.policy:KEY");唤醒了系统。经过实验,目前的M里,不论kl的flag是否存在,都会导致wakeup的发生。所以是在
interceptKeyBeforeQueueing里
        boolean isWakeKey = (policyFlags & WindowManagerPolicy.FLAG_WAKE) != 0
                || event.isWakeKey();

这个event.isWakeKey()就在KeyEvent.java里

then 

if (isWakeKey) {
Log.d(TAG,"matt-  if (isWakeKey) ");
            wakeUp(event.getEventTime(), mAllowTheaterModeWakeFromKey, "android.policy:KEY");  //wake up system
        }
  public static final boolean isWakeKey(int keyCode) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
            case KeyEvent.KEYCODE_MENU:
            case KeyEvent.KEYCODE_HOME:
            case KeyEvent.KEYCODE_WAKEUP:
            case KeyEvent.KEYCODE_PAIRING:
                return true;
        }
        return false;
    }
这里把三个key都设成wake

$ git blame ./KeyEvent.java 

337d9d2e (Michael Wright                  2014-04-22 15:03:48 -0700 1903)     public static final boolean isWakeKey(int keyCode) {
337d9d2e (Michael Wright                  2014-04-22 15:03:48 -0700 1904)         switch (keyCode) {
337d9d2e (Michael Wright                  2014-04-22 15:03:48 -0700 1905)             case KeyEvent.KEYCODE_BACK:
337d9d2e (Michael Wright                  2014-04-22 15:03:48 -0700 1906)             case KeyEvent.KEYCODE_MENU:
00000000 (Not Committed Yet               2016-07-25 16:02:49 +0800 1907)             //case KeyEvent.KEYCODE_HOME:
337d9d2e (Michael Wright                  2014-04-22 15:03:48 -0700 1908)             case KeyEvent.KEYCODE_WAKEUP:
8ac485a3 (Michael Wright                  2014-06-04 12:38:18 -0700 1909)             case KeyEvent.KEYCODE_PAIRING:
337d9d2e (Michael Wright                  2014-04-22 15:03:48 -0700 1910)                 return true;
337d9d2e (Michael Wright                  2014-04-22 15:03:48 -0700 1911)         }



git show 337d9d2e


google提交的原因如下
commit 337d9d2edc262141f9b8f684e53aae5e47f0ae13
Author: Michael Wright <michaelwr@google.com>
Date:   Tue Apr 22 15:03:48 2014 -0700


    Move key attribute information into KeyEvent.
    
    This consolidates all of the information that was in the native
    KeyEvent and the KeyLayout files into the managed KeyEvent class.
    
    It also moves the definition for all of the key names to the native
    side, rather than having them in both places.

0 0
原创粉丝点击