android系统Launcher启动时机

今天有空研究了一下系统启动流程中的Launcher启动时机,有必要给大家分享一下阅读代码的成果;

首先我们知道系统启动先会生成init进程,init进程会去启动各种守护进程类似usbd,adbd等,同时将启动Zygote进程,而之后Zygote进程会去起SystemServer进程,这个SystemServer是启动大部分服务的进程,同时将这些服务注册到ServiceManager中,其实应该能想到服务启动完之后就会去启动SystemUI和Launcher,于是进入SystemServer.java看一下:

 System.loadLibrary("android_servers");
        nativeInit();

        // Check whether we failed to shut down last time we tried.
        // This call may not return.
        performPendingShutdown();

        // Initialize the system context.
        createSystemContext();

        // Create the system service manager.
        mSystemServiceManager = new SystemServiceManager(mSystemContext);
        LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);

        // Start services.
        try {
            startBootstrapServices();
            startCoreServices();
            startOtherServices();
        } catch (Throwable ex) {
            Slog.e("System", "******************************************");
            Slog.e("System", "************ Failure starting system services", ex);
            throw ex;
        }

        // For debug builds, log event loop stalls to dropbox for analysis.
        if (StrictMode.conditionallyEnableDebugLogging()) {
            Slog.i(TAG, "Enabled StrictMode for system server main thread.");
        }

以上代码可以看到,会先去启动启动引导服务,然后去启动核心服务,其实这两类服务都是去启动平台服务,接下去去启动其他服务,其他服务就是硬件服务,继续看代码startOther

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值