Launcher图标加载

android 系统启动流程

  • 加载BootLoader引导程序,启动init.cpp, 解析init.rc配置文件
  • 启动zygote孵化器进程,
    1、启动虚拟机和注册JNI方法
    2、注册Socket服务端、预加载系统资源文件
    3、执行runSleepLoop等待其他进程注册
  • 启动SystemServer进程,通过Zygote孵化器进程fork出来,创建Biner线程池,执行main方法,创建系统上下文,启动三个系统服务(引导、核心、其他)

在startBootstrapServices中启动AMS、PMS等引导服务,其中PMS主要作用是系统中的APK的解析和安装;AMS主要用于四大组件的启动 和管理,因此LauncherActivity通过AMS启动,startOtherServices开启启动其他服务中启动Launcher的入口为AMS的systemReady方法,

 /**
     * Ready. Set. Go!
     */
    public void systemReady(final Runnable goingCallback, @NonNull TimingsTraceAndSlog t) {
   
    ...
     mAtmInternal.startHomeOnAllDisplays(currentUserId, "systemReady");
    ...
    }

ActivityTaskManagerService.startHomeOnAllDisplays->RootWindowContainer.startHomeOnDisplay-> startHomeOnTaskDisplayArea->

boolean startHomeOnTaskDisplayArea(int userId, String reason, TaskDisplayArea taskDisplayArea,
            boolean allowInstrumenting, boolean fromHomeKey) {
   
        // Fallback to top focused display area if the provided one is invalid.
        if (taskDisplayArea == null) {
   
            final Task rootTask = getTopDisplayFocusedRootTask();
            taskDisplayArea = rootTask != null ? rootTask.getDisplayArea()
                    : getDefaultTaskDisplayArea();
        }

        Intent homeIntent = null;
        ActivityInfo aInfo = null;
        if (taskDisplayArea == getDefaultTaskDisplayArea()) {
   
            // 将会返回附带Intent.CATEGORY_HOME属性的Intent,方面后续从系统的AndroidManifest.xml中查找对应的Activity。
            homeIntent = mService.getHomeIntent();
            // resolveActivityInfo()这里将会查找出桌面Activity,然后返回ActivityInfo对象
            aInfo = resolveHomeActivity(userId, homeIntent);
        } else if (shouldPlaceSecondaryHomeOnDisplayArea(taskDisplayArea)) {
   
            Pair<ActivityInfo, Intent> info = resolveSecondaryHomeActivity(userId, taskDisplayArea);
            aInfo = info.first;
            homeIntent = info.second;
        }
        if (aInfo == null || homeIntent == null) {
   
            return false;
        }

        if (!canStartHomeOnDisplayArea(aInfo, taskDisplayArea, allowInstrumenting)) {
   
            return false;
        }

        // Updates the home component of the intent.
        homeIntent.setComponent(new ComponentName(aInfo.applicationInfo.packageName, aInfo.name));
        homeIntent.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值