publicstaticfinalvoidinit2() {
Slog.i(TAG, "Entered the Android system server!");
Thread thr = new ServerThread();
thr.setName("android.server.ServerThread");
thr.start();
}
ServerThread的run方法:
publicvoidrun() {
...
// 开启Android各种服务并且添加到ServiceManager去管理
Slog.i(TAG, "Device Policy");
devicePolicy = new DevicePolicyManagerService(context);
ServiceManager.addService(Context.DEVICE_POLICY_SERVICE, ottle =
// We now tell the activity manager it is okay to run third party// code. It will call back into us once it has gotten to the state// where third party code can really run (but before it has actually// started launching the initial applications), for us to complete our// initialization.// 各种服务开启后调用ActivityManagerService.systemReady
((ActivityManagerService)ActivityManagerNative.getDefault())
.systemReady(new Runnable() {
publicvoidrun() {
Slog.i(TAG, "Making services ready");
finalboolean resumeTopActivityLocked(ActivityRecord prev) {
// Find the first activity that is not finishing.// 没有已经打开的Activity next为 null
ActivityRecord next = topRunningActivityLocked(null);
// Remember how we'll process this pause/resume situation, and ensure// that the state is reset however we wind up proceeding.finalboolean userLeaving = mUserLeaving;
mUserLeaving = false;
if (next == null) {
// There are no more activities! Let's just start up the// Launcher...if (mMainStack) {
// 启动lucher应用的锁屏界面return mService.startHomeActivityLocked();
}
}