android L 之 SystemServer

一、SystemServer 的源码位置

frameworks/base/services/java/com/android/server/SystemServer.java

二、SystemServer调用流程

/**
 * Startup class for the zygote process.          
 *
 * Pre-initializes some classes, and then waits for commands on a UNIX domain
 * socket. Based on these commands, forks off child processes that inherit
 * the initial state of the VM.
 *
 * Please see {@link ZygoteConnection.Arguments} for documentation on the                                                                                                                                                                                                
 * client protocol.
 *
 * @hide
 */    
public class ZygoteInit {
    private static final String TAG = "Zygote";

    public static void main(String argv[]) {
        try {                                     
            // Start profiling the zygote initialization.      
            SamplingProfilerIntegration.start();  


            boolean startSystemServer = false;    
            String socketName = "zygote";         
            String abiList = null;                
            for (int i = 1; i < argv.length; i++) {                
                if ("start-system-server".equals(argv[i])) {           
                    startSystemServer = true;     
                } else if (argv[i].startsWith(ABI_LIST_ARG)) {         
                    abiList = argv[i].substring(ABI_LIST_ARG.length());
                } else if (argv[i].startsWith(SOCKET_NAME_ARG)) {      
                    socketName = argv[i].substring(SOCKET_NAME_ARG.length());                                                                                                                                                                                            
                } else {
                    throw new RuntimeException("Unknown command line argument: " + argv[i]);                                                                                                                                                                             
                }
            }

            registerZygoteSocket(socketName);     
            EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_START,   
                SystemClock.uptimeMillis());      
            preload();
            EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_END,     
                SystemClock.uptimeMillis());


            if (startSystemServer) {
                <span style="color:#ff0000;">startSystemServer</span>(abiList, socketName);    //这里启动SystemServer    
            }


            Log.i(TAG, "Accepting command socket connections");
            runSelectLoop(abiList);


            closeServerSocket();
        } catch (MethodAndArgsCaller caller) {    
            caller.run();
        } catch (RuntimeException ex) {           
            Log.e(TAG, "Zygote died with exception", ex);      
            closeServerSocket();
            throw ex;
        }
    }  


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值