2024年6月3日发(作者:)
SystemServer进程启动
private static boolean startSystemServer()
}
throws MethodAndArgsCaller, RuntimeException {
/* Hardcoded command line to start the system server */
String args[] = {
"--setuid=1000",
"--setgid=1000",
"--setgroups=1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1018,3001,3002,3003,3006,
};
nts parsedArgs = null;
int pid;
try {
}
/* For child process */
if (pid == 0) {
}
return true;
handleSystemServerProcess(parsedArgs);
parsedArgs = new nts(args);
ebuggerSystemProperty(parsedArgs);
nvokeWithSystemProperty(parsedArgs);
/* Request to fork the system server process */
pid = stemServer(
, ,
,
lags,
null,
tedCapabilities,
iveCapabilities);
"--capabilities=130104352,130104352",
"--runtime-init",
"--nice-name=system_server",
"Server",
3007",
} catch (IllegalArgumentException ex) {
throw new RuntimeException(ex);
创建SystemServer进程分两个步骤:
forkSystemServer() 调用fork系统调用创建SystemServer进程
handleSystemServerProcess() SystemServer进程的执行函数
public static int forkSystemServer(int uid, int gid, int[] gids,
}
int debugFlags, int[][] rlimits,
long permittedCapabilities, long effectiveCapabilities) {
preFork();
int pid = nativeForkSystemServer(uid, gid, gids, debugFlags, rlimits,
permittedCapabilities,
effectiveCapabilities);
postFork();
return pid;
native public static int nativeForkSystemServer(int uid, int gid,
int[] gids, int debugFlags, int[][] rlimits,
long permittedCapabilities, long effectiveCapabilities);
static void Dalvik_dalvik_system_Zygote_forkAndSpecialize(const u4* args,
JValue* pResult)
{
pid_t pid;
pid = forkAndSpecializeCommon(args, false);
RETURN_INT(pid);
}
static pid_t forkAndSpecializeCommon(const u4* args, bool isSystemServer)
{
pid_t pid;
uid_t uid = (uid_t) args[0];
gid_t gid = (gid_t) args[1];
ArrayObject* gids = (ArrayObject *)args[2];
u4 debugFlags = args[3];
ArrayObject *rlimits = (ArrayObject *)args[4];
int64_t permittedCapabilities, effectiveCapabilities;
if (isSystemServer) {
/*
* Don't use GET_ARG_LONG here for now. gcc is generating code


发布评论