Android系统的流程如下:
1 system server的main函数中:ServerThread thr = new ServerThread(); 启动了Server进程
2 ServerThread类的initAndLoop()函数有如下代码:
boolean disableMedia = SystemProperties.getBoolean("config.disable_media", false);
if (!disableMedia) {
try {
Slog.i(TAG, "Wired Accessory Manager");
// Listen for wired headset changes
inputManager.setWiredAccessoryCallbacks(new WiredAccessoryManager(context, inputManager));
} catch (Throwable e) {
reportWtf("starting WiredAccessoryManager", e);
}
}
上述代码创建了WiredAccessoryManager类
3 在WiredAccessoryManager类的构造函数中:private final WiredAccessoryObserver mObserver; mObserver = new WiredAccessoryObserver();
创建了Observer类
4 WiredAccessoryObserver类,继承自UEventObser