引用注明出处,出错见谅!http://write.blog.csdn.net/postedit/6664806
研究了一下输入法:
frameworks/base/services/java/com/android/server/SystemServer.java
系统启动过程中建立InputMethodManager服务,并添加到ServiceManger维护的列表中:
try {
Slog.i(TAG, "Input Method Service");
imm = new InputMethodManagerService(context, statusBar);
ServiceManager.addService(Context.INPUT_METHOD_SERVICE, imm);
} catch (Throwable e) {
Slog.e(TAG, "Failure starting Input Manager Service", e);
}
}
frameworks/base/services/java/com/android/server/InputMethodManagerService.java
获取系统已经安装的所有输入法:
List<ResolveInfo> services = pm.queryIntentServices(
new Intent(InputMethod.SERVICE_INTERFACE),
PackageManager.GET_META_DATA);
然后将系统所有输入法添加到InutMethodManagerService列表中。
public void systemReady() {
synchronized (mMethodMap) {
if (!mSystemReady) {
mSystemReady = true;
try {
startInputInnerLocked();
} catch (RuntimeException e) {
Slog.w(TAG, "Unexpected exception", e);
}
}
}
}
开机启动输入法完成。
切换window:
frameworks/base/core/java/android/view/ViewRoot.java
ViewRoot 接收来自WindowManagerService 的焦点变化消息:WINDOW_FOCUS_CHANGED, 启动输入法:
客户端进程的InputMethodManager发起启动输入法的过程:
frameworks/base/core/java/android/view/inputmethod/InputMethodManager.java首先获取服务的对象的信息:
FocusInLocked() 获取当前服务对象:
void focusInLocked(View view) {