android2

接上,写launcher APP启动

SystemService.startBootstrapServices启动AMS,,,

startOtherServices调用mActivityManagerService.systemReady(() -> {}

AMS的systemReady方法中打开Android系统的第一个Activity

ActivityStack的resumeTopActivityLocked方法启动home界面

    private void startBootstrapServices(){
        ...
        //TODO 启动AMS服务
        mActivityManagerService=mSystemServiceManager.startService(
        ActivityManagerService.Lifecycle.class).getService();//生命周期绑定
        mActivityManagerService.setSystemServiceManager(mSystemServiceManager);//系统服务管理器
        mActivityManagerService.setInstaller(installer);//AMS的APP安装器
        //初始化AMS相关的PMS
        //设置SystemServer
        mActivityManagerService.setSystemProcess();
    }
    
    private void startOtherServices() {
        ActivityManagerNative.getDefault().showBootMessage(...); //TODO 显示启动界面
        mActivityManagerService.systemReady(new Runnable() {      //TODO 此方法中操作
            public void run() {
            }
        });
    }
    
    public void systemReady(final Runnable goingCallback) {
            ...
        // TODO 第一个Activity
        mMainStack.resumeTopActivityLocked(null);
    }
    
    final boolean resumeTopActivityLocked(ActivityRecord prev){
        // Find the first activity that is not finishing.已经打开的app为null
        ActivityRecord next=topRunningActivityLocked(null);
        if(next==null){
            // There are no more activities!  Let's just start up the
            // Launcher...
            
            if(mMainStack){
            // TODO 启动lucher
            return mService.startHomeActivityLocked();
            }
        }
    }

 

你可能感兴趣的:(技术,android)