hook键任意键唤醒屏幕 黑屏时hook键挂断电话

通话,黑屏时按hook键不能挂断电话,因为通话过程黑屏时进入onStop状态,此时不能相应任何keyEvent,按hook键无效;

通话黑屏时要按hook键来挂断电话,必须使得hook键来唤醒屏幕;

本文讲述hook键及其他任意键比如音量键如何唤醒屏幕;

frameworks/base/policy/src/com/android/internal/policy/impl/KeyguardViewMediator.java  中:

==========================================================================

////////仔细看注释;

/**
     * When the keyguard is showing we ignore some keys that might otherwise typically
     * be considered wake keys.  We filter them out here.
     *
     * {@link KeyEvent#KEYCODE_POWER} is notably absent from this list because it
     * is always considered a wake key.
     */

private boolean isWakeKeyWhenKeyguardShowing(int keyCode, boolean isDocked) {
        switch (keyCode) {
            // ignore volume keys unless docked
            case KeyEvent.KEYCODE_VOLUME_UP:
            case KeyEvent.KEYCODE_VOLUME_DOWN:
            case KeyEvent.KEYCODE_VOLUME_MUTE:
                return isDocked;


            // ignore media and camera keys
            case KeyEvent.KEYCODE_MUTE:
            //case KeyEvent.KEYCODE_HEADSETHOOK:
            case KeyEvent.KEYCODE_MEDIA_PLAY:
            case KeyEvent.KEYCODE_MEDIA_PAUSE:
            case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
            case KeyEvent.KEYCODE_MEDIA_STOP:
            case KeyEvent.KEYCODE_MEDIA_NEXT:
            case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
            case KeyEvent.KEYCODE_MEDIA_REWIND:
            case KeyEvent.KEYCODE_MEDIA_RECORD:
            case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
            case KeyEvent.KEYCODE_CAMERA:
                return false;
        }
        return true;
    }

要哪个键唤醒屏幕就注释掉哪一行;

最后一点很重要:

改好后,不要mmm ,必须编译花一两个小时重新编译整个工程才能看到效果;

你可能感兴趣的:(Android系统,Android4.0.4开发,hook,电话,filter,list,up)