1.SystemUI启动
SystemUI是核心系统应用,需要开机启动,启动SystemUI进程,是通过启动SystemUIService来实现的。
frameworks\base\services\java\com\android\server\SystemServer.java
SystemServer启动后,会在SystemServer Main Thread启动ActivityManagerService,当ActivityManagerService systemReady后,会去启动SystemUIService。
mActivityManagerService.systemReady(new Runnable() {
@Override
public void run() {
@Override
public void run() {
...
try {
startSystemUi(context);
} catch (Throwable e) {
reportWtf("starting System UI", e);
}
startSystemUi(context);
} catch (Throwable e) {
reportWtf("starting System UI", e);
}
由如上可以看出,startSystemUi不是在SystemServer Main thread,而是在ActivityManagerService Thread。
static final void startSystemUi(Context context) {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.systemui",
"com.android.systemui.SystemUIService"));
//Slog.d(TAG, "Starting service: " + intent);
context.startServiceAsUser(intent, UserHandle.OWNER);
}
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.systemui",
"com.android.systemui.SystemUIService"));
//Slog.d(TAG, "Starting service: " + intent);
context.startServiceAsUser(intent, UserHandle.OWNER);
}
通过start