http://blog.csdn.net/yk_hu0621/article/details/6257187
参考PhoneWindowManager.java的adjustConfigurationLw()方法,可以找出以下关键因素:
config_lidKeyboardAccessibility:在frameworks/base/core/res/res/values/config.xml中定义,含义如下:
Indicate whether the lid state impacts the accessibility of the physical keyboard.
0 means it doesn't,
1 means it is accessible when the lid is open,
2 means it is accessible when the lid is closed.
The default is 1.
意为物理键盘是否受滑盖影响,0表示不受滑盖影响,1表示当滑盖打开时物理键盘可用,2表示滑盖关闭时物理键盘可用。
另外PhoneWindowManager.java还有个常量也对物理键盘的状态有影响:
// Debugging: set this to have the system act like there is no hard keyboard.
static final boolean KEYBOARD_ALWAYS_HIDDEN = false;
InputMethodService.java: 判断是否显示软键盘的代码:
onShowInputRequested() {
if (!onEvaluateInputViewShown()) {
return false;
}
......................
}
public boolean onEvaluateInputViewShown() {
Configuration config = getResources().getConfiguration();
return config.keyboard == Configuration.KEYBOARD_NOKEYS
|| config.hardKeyboardHidden == Configuration.KEYBOARDHIDDEN_YES;
}
其中两项config.hardKeyboardHidden就是framworks中config.xml的config_lidKeyboardAccessibility取值
物理键盘映射过程:
手机/system/usr/keylayout/*.kl :内核将keyCode映射成有含义的字符串
KeycodeLabels.h : framework 将字符串映射成keyEvent的keyCode
frameworks/.../res/values/attrs.xml