https://blog.csdn.net/yun_hen/article/details/78590991 上一个activity的暂停、进程启动、绑定进程与创建application的网址
一、AMS的进程的启动
1. startProcessLocked (......) {
.....
try {
try {
final int userId = UserHandle.getUserId(app.uid);
AppGlobals.getPackageManager().checkPackageStartable(app.info.packageName, userId);
} catch (RemoteException e) {
throw e.rethrowAsRuntimeException();
}
int uid = app.uid;
int[] gids = null;
int mountExternal = Zygote.MOUNT_EXTERNAL_NONE;
/*
* Add shared application and profile GIDs so applications can share some
* resources like shared libraries and access user-wide resources
*/ 这里可以添加你想要的组的其他ID数值
if (ArrayUtils.isEmpty(permGids)) {
gids = new int[3];
} else {
gids = new int[permGids.length + 3];
System.arraycopy(permGids, 0, gids, 3, permGids.length);
}
gids[0] = UserHandle.getSharedAppGid(UserHandle.getAppId(uid));
gids[1] = UserHandle.getCacheAppGid(UserHandle.getAppId(uid));
gids[2] = UserHandle.getUserGid(UserHandle.getUserId(uid));
// Replace any invalid GIDs
if (gids[0] == UserHandle.ERR_GID) gids[0] = gids[2];
if (gids[1] == UserHandle.ERR_GID) gids[1] = gids[2];
// MIUI ADD
// EP MOD: START
// gids = ActivityManagerServiceInjector.computeGids(UserHandle.getUserId(uid), gids, app);
gids = ActivityManagerServiceInjector.computeGids(mContext, UserHandle.getUserId(uid), gids, app);
// END
}
........
//这段代码可以孵化出一个进程的启动和
Process.ProcessStartResult startResult = Process.start(entryPoint, app.processName, uid, uid, gids,
debugFlags, mountExternal, app.info.targetSdkVersion, app.info.seinfo, requiredAbi,
instructionSet, app.info.dataDir, entryPointArgs);
}