Android 开发中屏蔽物理键盘

VR项目中,通过无线鼠标连接蓝牙来控制VR,但是蓝牙连接上后点击搜索框时无法弹出输入法键盘,这是有物理键盘造成的, 需屏蔽物理键盘来解决这个问题, 实现如下:
frameworks/base/services/Java/com/Android/server/wm/WindowManagerService.java 中的 computeScreenConfigurationLocked 方法 将hardKeyboardAvailable = false。

  // Determine whether a hard keyboard is available and enabled.
            boolean hardKeyboardAvailable =false;//config.keyboard != Configuration.KEYBOARD_NOKEYS;
            if (hardKeyboardAvailable != mHardKeyboardAvailable) {
                mHardKeyboardAvailable = hardKeyboardAvailable;
                mHardKeyboardEnabled = hardKeyboardAvailable;
                mH.removeMessages(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
                mH.sendEmptyMessage(H.REPORT_HARD_KEYBOARD_STATUS_CHANGE);
            }
            if (!mHardKeyboardEnabled) {
                config.keyboard = Configuration.KEYBOARD_NOKEYS;
            }

你可能感兴趣的:(Android开发,源码)