diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index 04034fb68fbf7..37d0f3f1813e3 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -70,9 +70,8 @@ import java.security.Security; /** * 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. + * 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. @@ -80,6 +79,8 @@ import java.security.Security; * @hide */ public class ZygoteInit { + + // TODO (chriswailes): Change this so it is set with Zygote or ZygoteSecondary as appropriate private static final String TAG = "Zygote"; private static final String PROPERTY_DISABLE_OPENGL_PRELOADING = "ro.zygote.disable_gl_preload"; @@ -88,11 +89,15 @@ public class ZygoteInit { private static final int LOG_BOOT_PROGRESS_PRELOAD_START = 3020; private static final int LOG_BOOT_PROGRESS_PRELOAD_END = 3030; - /** when preloading, GC after allocating this many bytes */ + /** + * when preloading, GC after allocating this many bytes + */ private static final int PRELOAD_GC_THRESHOLD = 50000; private static final String ABI_LIST_ARG = "--abi-list="; + // TODO (chriswailes): Re-name this --zygote-socket-name= and then add a + // --blastula-socket-name parameter. private static final String SOCKET_NAME_ARG = "--socket-name="; /** @@ -105,7 +110,9 @@ public class ZygoteInit { */ private static final String PRELOADED_CLASSES = "/system/etc/preloaded-classes"; - /** Controls whether we should preload resources during zygote init. */ + /** + * Controls whether we should preload resources during zygote init. + */ public static final boolean PRELOAD_RESOURCES = true; private static final int UNPRIVILEGED_UID = 9999; @@ -172,6 +179,7 @@ public class ZygoteInit { } native private static void nativePreloadAppProcessHALs(); + native private static void nativePreloadOpenGL(); private static void preloadOpenGL() { @@ -190,8 +198,8 @@ public class ZygoteInit { /** * Register AndroidKeyStoreProvider and warm up the providers that are already registered. * - * By doing it here we avoid that each app does it when requesting a service from the - * provider for the first time. + * By doing it here we avoid that each app does it when requesting a service from the provider + * for the first time. */ private static void warmUpJcaProviders() { long startTime = SystemClock.uptimeMillis(); @@ -217,11 +225,10 @@ public class ZygoteInit { } /** - * Performs Zygote process initialization. Loads and initializes - * commonly used classes. + * Performs Zygote process initialization. Loads and initializes commonly used classes. * - * Most classes only cause a few hundred bytes to be allocated, but - * a few will allocate a dozen Kbytes (in one case, 500+K). + * Most classes only cause a few hundred bytes to be allocated, but a few will allocate a dozen + * Kbytes (in one case, 500+K). */ private static void preloadClasses() { final VMRuntime runtime = VMRuntime.getRuntime(); @@ -262,8 +269,8 @@ public class ZygoteInit { runtime.setTargetHeapUtilization(0.8f); try { - BufferedReader br - = new BufferedReader(new InputStreamReader(is), 256); + BufferedReader br = + new BufferedReader(new InputStreamReader(is), 256); int count = 0; String line; @@ -304,7 +311,7 @@ public class ZygoteInit { } Log.i(TAG, "...preloaded " + count + " classes in " - + (SystemClock.uptimeMillis()-startTime) + "ms."); + + (SystemClock.uptimeMillis() - startTime) + "ms."); } catch (IOException e) { Log.e(TAG, "Error reading " + PRELOADED_CLASSES + ".", e); } finally { @@ -330,11 +337,10 @@ public class ZygoteInit { } /** - * Load in commonly used resources, so they can be shared across - * processes. + * Load in commonly used resources, so they can be shared across processes. * - * These tend to be a few Kbytes, but are frequently in the 20-40K - * range, and occasionally even larger. + * These tend to be a few Kbytes, but are frequently in the 20-40K range, and occasionally even + * larger. */ private static void preloadResources() { final VMRuntime runtime = VMRuntime.getRuntime(); @@ -351,7 +357,7 @@ public class ZygoteInit { int N = preloadDrawables(ar); ar.recycle(); Log.i(TAG, "...preloaded " + N + " resources in " - + (SystemClock.uptimeMillis()-startTime) + "ms."); + + (SystemClock.uptimeMillis() - startTime) + "ms."); startTime = SystemClock.uptimeMillis(); ar = mResources.obtainTypedArray( @@ -359,7 +365,7 @@ public class ZygoteInit { N = preloadColorStateLists(ar); ar.recycle(); Log.i(TAG, "...preloaded " + N + " resources in " - + (SystemClock.uptimeMillis()-startTime) + "ms."); + + (SystemClock.uptimeMillis() - startTime) + "ms."); if (mResources.getBoolean( com.android.internal.R.bool.config_freeformWindowManagement)) { @@ -380,7 +386,7 @@ public class ZygoteInit { private static int preloadColorStateLists(TypedArray ar) { int N = ar.length(); - for (int i=0; i + * The main function called when started through the zygote process. This could be unified with + * main(), if the native code in nativeFinishInit() were rationalized with Zygote startup.

* * Current recognized args: *