android4.0 物理键盘与软键盘同时使用修改

用android4.0发现插了扫描枪之后软键盘不出现了,最开始以为是应用软件设置有问题,改了下发现不是,上网搜所了几个说修改

参考:http://blog.csdn.net/DrakeBlue/article/details/39049495

frameworks/base/services/java/com/android/server/wm/WindowManagerService.java

关键代码:行6618 computeScreenConfigurationLocked()方法中

boolean hardKeyboardAvailable = 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;
            }
将mHardKeyboardEnabled直接改成false

这样改软键盘是能用但是物理键盘是用不了的

还是要自己跟踪代码

frameworks/base/core/java/android/inputmethodservice/InputMethodService.java中

onConfigurationChanged方法最后几行代码

// If user uses hard keyboard, IME button should always be shown.
            boolean showing = onEvaluateInputViewShown();
            mImm.setImeWindowStatus(mToken, IME_ACTIVE | (showing ? IME_VISIBLE : 0),
                    mBackDisposition);
我估计这里就是隐藏软键盘的地方  接着找 onEvaluateInputViewShown方法

    public boolean onEvaluateInputViewShown() {
        Configuration config = getResources().getConfiguration();
        return config.keyboard == Configuration.KEYBOARD_NOKEYS
                || config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES;
    }
直接将这个返回值改成true发现软键盘与物理键盘能同时使用 想了下怕有问题 还是接着往下找

frameworks/base/service/input/InputReader.cpp中函数

void InputReader::updateInputConfigurationLocked()

中有这样几行代码:

        if ((sources & AINPUT_SOURCE_TOUCHSCREEN) == AINPUT_SOURCE_TOUCHSCREEN) {
            touchScreenConfig = InputConfiguration::TOUCHSCREEN_FINGER;
        }
        if ((sources & AINPUT_SOURCE_TRACKBALL) == AINPUT_SOURCE_TRACKBALL) {
            navigationConfig = InputConfiguration::NAVIGATION_TRACKBALL;
        } else if ((sources & AINPUT_SOURCE_DPAD) == AINPUT_SOURCE_DPAD) {
            navigationConfig = InputConfiguration::NAVIGATION_DPAD;
        }
        if (deviceInfo.getKeyboardType() == AINPUT_KEYBOARD_TYPE_ALPHABETIC) {
            keyboardConfig = InputConfiguration::KEYBOARD_QWERTY;
        }
直接将最后一个修改如下

        if (deviceInfo.getKeyboardType() == AINPUT_KEYBOARD_TYPE_ALPHABETIC) {
            //keyboardConfig = InputConfiguration::KEYBOARD_QWERTY;//modify by hclydao
        }
直接注释掉

经初步测试软键盘与硬键盘能同时使用,不知道这样修改会不会有问题.




你可能感兴趣的:(android系统,s5pv210)