详细分析Android中实现Zygote的源码

2020-01-06 13:36:52丽君
  • "--runtime-init",  "--nice-name=system_server", // 进程名为system_server 
  • "com.android.server.SystemServer",  }; 
  •   ZygoteConnection.Arguments parsedArgs = null; 
  •   int pid; 
  •   try { 
  • parsedArgs = new ZygoteConnection.Arguments(args);  ZygoteConnection.applyDebuggerSystemProperty(parsedArgs); 
  • ZygoteConnection.applyInvokeWithSystemProperty(parsedArgs);   
  • /* Request to fork the system server process */  pid = Zygote.forkSystemServer( 
  • parsedArgs.uid, parsedArgs.gid,  parsedArgs.gids, 
  • parsedArgs.debugFlags,  null, 
  • parsedArgs.permittedCapabilities,  parsedArgs.effectiveCapabilities 
  • );  } catch (IllegalArgumentException ex) { 
  • throw new RuntimeException(ex);  } 
  •   /* For child process */ 
  • if (pid == 0) {  handleSystemServerProcess(parsedArgs); 
  • }   
  • return true;  }