|
|
|
|
@@ -117,7 +117,7 @@ public class ZygoteInit {
|
|
|
|
|
/**
|
|
|
|
|
* Controls whether we should preload resources during zygote init.
|
|
|
|
|
*/
|
|
|
|
|
public static final boolean PRELOAD_RESOURCES = true;
|
|
|
|
|
private static final boolean PRELOAD_RESOURCES = true;
|
|
|
|
|
|
|
|
|
|
private static final int UNPRIVILEGED_UID = 9999;
|
|
|
|
|
private static final int UNPRIVILEGED_GID = 9999;
|
|
|
|
|
@@ -159,7 +159,7 @@ public class ZygoteInit {
|
|
|
|
|
sPreloadComplete = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void lazyPreload() {
|
|
|
|
|
static void lazyPreload() {
|
|
|
|
|
Preconditions.checkState(!sPreloadComplete);
|
|
|
|
|
Log.i(TAG, "Lazily preloading resources.");
|
|
|
|
|
|
|
|
|
|
@@ -364,7 +364,7 @@ public class ZygoteInit {
|
|
|
|
|
}
|
|
|
|
|
if ("true".equals(prop)) {
|
|
|
|
|
Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "ResetJitCounters");
|
|
|
|
|
runtime.resetJitCounters();
|
|
|
|
|
VMRuntime.resetJitCounters();
|
|
|
|
|
Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -418,8 +418,6 @@ public class ZygoteInit {
|
|
|
|
|
* larger.
|
|
|
|
|
*/
|
|
|
|
|
private static void preloadResources() {
|
|
|
|
|
final VMRuntime runtime = VMRuntime.getRuntime();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
mResources = Resources.getSystem();
|
|
|
|
|
mResources.startPreloading();
|
|
|
|
|
@@ -463,9 +461,7 @@ public class ZygoteInit {
|
|
|
|
|
int N = ar.length();
|
|
|
|
|
for (int i = 0; i < N; i++) {
|
|
|
|
|
int id = ar.getResourceId(i, 0);
|
|
|
|
|
if (false) {
|
|
|
|
|
Log.v(TAG, "Preloading resource #" + Integer.toHexString(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id != 0) {
|
|
|
|
|
if (mResources.getColorStateList(id, null) == null) {
|
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
|
@@ -483,9 +479,7 @@ public class ZygoteInit {
|
|
|
|
|
int N = ar.length();
|
|
|
|
|
for (int i = 0; i < N; i++) {
|
|
|
|
|
int id = ar.getResourceId(i, 0);
|
|
|
|
|
if (false) {
|
|
|
|
|
Log.v(TAG, "Preloading resource #" + Integer.toHexString(id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id != 0) {
|
|
|
|
|
if (mResources.getDrawable(id, null) == null) {
|
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
|
@@ -688,13 +682,12 @@ public class ZygoteInit {
|
|
|
|
|
final String packageName = "*";
|
|
|
|
|
final String outputPath = null;
|
|
|
|
|
final int dexFlags = 0;
|
|
|
|
|
final String compilerFilter = systemServerFilter;
|
|
|
|
|
final String uuid = StorageManager.UUID_PRIVATE_INTERNAL;
|
|
|
|
|
final String seInfo = null;
|
|
|
|
|
final int targetSdkVersion = 0; // SystemServer targets the system's SDK version
|
|
|
|
|
try {
|
|
|
|
|
installd.dexopt(classPathElement, Process.SYSTEM_UID, packageName,
|
|
|
|
|
instructionSet, dexoptNeeded, outputPath, dexFlags, compilerFilter,
|
|
|
|
|
instructionSet, dexoptNeeded, outputPath, dexFlags, systemServerFilter,
|
|
|
|
|
uuid, classLoaderContext, seInfo, false /* downgrade */,
|
|
|
|
|
targetSdkVersion, /*profileName*/ null, /*dexMetadataPath*/ null,
|
|
|
|
|
"server-dexopt");
|
|
|
|
|
@@ -770,7 +763,7 @@ public class ZygoteInit {
|
|
|
|
|
capabilities &= ((long) data[0].effective) | (((long) data[1].effective) << 32);
|
|
|
|
|
|
|
|
|
|
/* Hardcoded command line to start the system server */
|
|
|
|
|
String args[] = {
|
|
|
|
|
String[] args = {
|
|
|
|
|
"--setuid=1000",
|
|
|
|
|
"--setgid=1000",
|
|
|
|
|
"--setgroups=1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1018,1021,1023,"
|
|
|
|
|
@@ -781,7 +774,7 @@ public class ZygoteInit {
|
|
|
|
|
"--target-sdk-version=" + VMRuntime.SDK_VERSION_CUR_DEVELOPMENT,
|
|
|
|
|
"com.android.server.SystemServer",
|
|
|
|
|
};
|
|
|
|
|
ZygoteArguments parsedArgs = null;
|
|
|
|
|
ZygoteArguments parsedArgs;
|
|
|
|
|
|
|
|
|
|
int pid;
|
|
|
|
|
|
|
|
|
|
@@ -870,7 +863,7 @@ public class ZygoteInit {
|
|
|
|
|
* @param argv Command line arguments used to specify the Zygote's configuration.
|
|
|
|
|
*/
|
|
|
|
|
@UnsupportedAppUsage
|
|
|
|
|
public static void main(String argv[]) {
|
|
|
|
|
public static void main(String[] argv) {
|
|
|
|
|
ZygoteServer zygoteServer = null;
|
|
|
|
|
|
|
|
|
|
// Mark zygote start. This ensures that thread creation will throw
|
|
|
|
|
@@ -1029,7 +1022,7 @@ public class ZygoteInit {
|
|
|
|
|
* are enabled)
|
|
|
|
|
* @param argv arg strings
|
|
|
|
|
*/
|
|
|
|
|
public static final Runnable zygoteInit(int targetSdkVersion, long[] disabledCompatChanges,
|
|
|
|
|
public static Runnable zygoteInit(int targetSdkVersion, long[] disabledCompatChanges,
|
|
|
|
|
String[] argv, ClassLoader classLoader) {
|
|
|
|
|
if (RuntimeInit.DEBUG) {
|
|
|
|
|
Slog.d(RuntimeInit.TAG, "RuntimeInit: Starting application from zygote");
|
|
|
|
|
@@ -1049,11 +1042,10 @@ public class ZygoteInit {
|
|
|
|
|
* to zygoteInit(), which skips calling into initialization routines that start the Binder
|
|
|
|
|
* threadpool.
|
|
|
|
|
*/
|
|
|
|
|
static final Runnable childZygoteInit(
|
|
|
|
|
int targetSdkVersion, String[] argv, ClassLoader classLoader) {
|
|
|
|
|
static Runnable childZygoteInit(String[] argv) {
|
|
|
|
|
RuntimeInit.Arguments args = new RuntimeInit.Arguments(argv);
|
|
|
|
|
return RuntimeInit.findStaticMain(args.startClass, args.startArgs, classLoader);
|
|
|
|
|
return RuntimeInit.findStaticMain(args.startClass, args.startArgs, /* classLoader= */null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static final native void nativeZygoteInit();
|
|
|
|
|
private static native void nativeZygoteInit();
|
|
|
|
|
}
|
|
|
|
|
|