Loading core/java/com/android/internal/os/RuntimeInit.java +4 −48 Original line number Diff line number Diff line Loading @@ -43,8 +43,8 @@ import org.apache.harmony.luni.internal.util.TimezoneGetter; * @hide */ public class RuntimeInit { private final static String TAG = "AndroidRuntime"; private final static boolean DEBUG = false; final static String TAG = "AndroidRuntime"; final static boolean DEBUG = false; /** true if commonInit() has been called */ private static boolean initialized; Loading @@ -53,7 +53,6 @@ public class RuntimeInit { private static volatile boolean mCrashing = false; private static final native void nativeZygoteInit(); private static final native void nativeFinishInit(); private static final native void nativeSetExitWithoutCleanup(boolean exitWithoutCleanup); Loading Loading @@ -133,7 +132,7 @@ public class RuntimeInit { } } private static final void commonInit() { protected static final void commonInit() { if (DEBUG) Slog.d(TAG, "Entered RuntimeInit!"); /* Loading Loading @@ -287,50 +286,7 @@ public class RuntimeInit { if (DEBUG) Slog.d(TAG, "Leaving RuntimeInit!"); } /** * 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.<p> * * Current recognized args: * <ul> * <li> <code> [--] <start class name> <args> * </ul> * * @param targetSdkVersion target SDK version * @param argv arg strings */ public static final void zygoteInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) throws Zygote.MethodAndArgsCaller { if (DEBUG) Slog.d(TAG, "RuntimeInit: Starting application from zygote"); Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "RuntimeInit"); redirectLogStreams(); commonInit(); nativeZygoteInit(); applicationInit(targetSdkVersion, argv, classLoader); } /** * The main function called when an application is started through a * wrapper process. * * When the wrapper starts, the runtime starts {@link RuntimeInit#main} * which calls {@link WrapperInit#main} which then calls this method. * So we don't need to call commonInit() here. * * @param targetSdkVersion target SDK version * @param argv arg strings */ public static void wrapperInit(int targetSdkVersion, String[] argv) throws Zygote.MethodAndArgsCaller { if (DEBUG) Slog.d(TAG, "RuntimeInit: Starting application from wrapper"); applicationInit(targetSdkVersion, argv, null); } private static void applicationInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) protected static void applicationInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) throws Zygote.MethodAndArgsCaller { // If the application calls System.exit(), terminate the process // immediately without running any shutdown hooks. It is not possible to Loading core/java/com/android/internal/os/WrapperInit.java +22 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.os.Process; import android.os.Trace; import android.util.BootTimingsTraceLog; import android.util.Slog; import com.android.internal.os.Zygote.MethodAndArgsCaller; import dalvik.system.VMRuntime; import java.io.DataOutputStream; import java.io.FileDescriptor; Loading Loading @@ -83,7 +83,7 @@ public class WrapperInit { // Launch the application. String[] runtimeArgs = new String[args.length - 2]; System.arraycopy(args, 2, runtimeArgs, 0, runtimeArgs.length); RuntimeInit.wrapperInit(targetSdkVersion, runtimeArgs); WrapperInit.wrapperInit(targetSdkVersion, runtimeArgs); } catch (Zygote.MethodAndArgsCaller caller) { caller.run(); } Loading Loading @@ -124,4 +124,24 @@ public class WrapperInit { Zygote.appendQuotedShellArgs(command, args); Zygote.execShell(command.toString()); } /** * The main function called when an application is started through a * wrapper process. * * When the wrapper starts, the runtime starts {@link RuntimeInit#main} * which calls {@link main} which then calls this method. * So we don't need to call commonInit() here. * * @param targetSdkVersion target SDK version * @param argv arg strings */ private static void wrapperInit(int targetSdkVersion, String[] argv) throws Zygote.MethodAndArgsCaller { if (RuntimeInit.DEBUG) { Slog.d(RuntimeInit.TAG, "RuntimeInit: Starting application from wrapper"); } RuntimeInit.applicationInit(targetSdkVersion, argv, null); } } core/java/com/android/internal/os/ZygoteConnection.java +1 −1 Original line number Diff line number Diff line Loading @@ -789,7 +789,7 @@ class ZygoteConnection { VMRuntime.getCurrentInstructionSet(), pipeFd, parsedArgs.remainingArgs); } else { RuntimeInit.zygoteInit(parsedArgs.targetSdkVersion, ZygoteInit.zygoteInit(parsedArgs.targetSdkVersion, parsedArgs.remainingArgs, null /* classLoader */); } } Loading core/java/com/android/internal/os/ZygoteInit.java +31 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.text.Hyphenator; import android.util.BootTimingsTraceLog; import android.util.EventLog; import android.util.Log; import android.util.Slog; import android.webkit.WebViewFactory; import android.widget.TextView; Loading Loading @@ -471,7 +472,7 @@ public class ZygoteInit { /* * Pass the remaining arguments to SystemServer. */ RuntimeInit.zygoteInit(parsedArgs.targetSdkVersion, parsedArgs.remainingArgs, cl); ZygoteInit.zygoteInit(parsedArgs.targetSdkVersion, parsedArgs.remainingArgs, cl); } /* should never reach here */ Loading Loading @@ -771,4 +772,33 @@ public class ZygoteInit { */ private ZygoteInit() { } /** * 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.<p> * * Current recognized args: * <ul> * <li> <code> [--] <start class name> <args> * </ul> * * @param targetSdkVersion target SDK version * @param argv arg strings */ public static final void zygoteInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) throws Zygote.MethodAndArgsCaller { if (RuntimeInit.DEBUG) { Slog.d(RuntimeInit.TAG, "RuntimeInit: Starting application from zygote"); } Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "ZygoteInit"); RuntimeInit.redirectLogStreams(); RuntimeInit.commonInit(); ZygoteInit.nativeZygoteInit(); RuntimeInit.applicationInit(targetSdkVersion, argv, classLoader); } private static final native void nativeZygoteInit(); } core/jni/AndroidRuntime.cpp +19 −10 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ static void com_android_internal_os_RuntimeInit_nativeFinishInit(JNIEnv* env, jo gCurRuntime->onStarted(); } static void com_android_internal_os_RuntimeInit_nativeZygoteInit(JNIEnv* env, jobject clazz) static void com_android_internal_os_ZygoteInit_nativeZygoteInit(JNIEnv* env, jobject clazz) { gCurRuntime->onZygoteInit(); } Loading @@ -230,19 +230,27 @@ static void com_android_internal_os_RuntimeInit_nativeSetExitWithoutCleanup(JNIE /* * JNI registration. */ static const JNINativeMethod gMethods[] = { int register_com_android_internal_os_RuntimeInit(JNIEnv* env) { const JNINativeMethod methods[] = { { "nativeFinishInit", "()V", (void*) com_android_internal_os_RuntimeInit_nativeFinishInit }, { "nativeZygoteInit", "()V", (void*) com_android_internal_os_RuntimeInit_nativeZygoteInit }, { "nativeSetExitWithoutCleanup", "(Z)V", (void*) com_android_internal_os_RuntimeInit_nativeSetExitWithoutCleanup }, }; return jniRegisterNativeMethods(env, "com/android/internal/os/RuntimeInit", methods, NELEM(methods)); } int register_com_android_internal_os_RuntimeInit(JNIEnv* env) int register_com_android_internal_os_ZygoteInit(JNIEnv* env) { return jniRegisterNativeMethods(env, "com/android/internal/os/RuntimeInit", gMethods, NELEM(gMethods)); const JNINativeMethod methods[] = { { "nativeZygoteInit", "()V", (void*) com_android_internal_os_ZygoteInit_nativeZygoteInit }, }; return jniRegisterNativeMethods(env, "com/android/internal/os/ZygoteInit", methods, NELEM(methods)); } // ---------------------------------------------------------------------- Loading Loading @@ -1271,6 +1279,7 @@ static int register_jni_procs(const RegJNIRec array[], size_t count, JNIEnv* env static const RegJNIRec gRegJNI[] = { REG_JNI(register_com_android_internal_os_RuntimeInit), REG_JNI(register_com_android_internal_os_ZygoteInit), REG_JNI(register_android_os_SystemClock), REG_JNI(register_android_util_EventLog), REG_JNI(register_android_util_Log), Loading Loading
core/java/com/android/internal/os/RuntimeInit.java +4 −48 Original line number Diff line number Diff line Loading @@ -43,8 +43,8 @@ import org.apache.harmony.luni.internal.util.TimezoneGetter; * @hide */ public class RuntimeInit { private final static String TAG = "AndroidRuntime"; private final static boolean DEBUG = false; final static String TAG = "AndroidRuntime"; final static boolean DEBUG = false; /** true if commonInit() has been called */ private static boolean initialized; Loading @@ -53,7 +53,6 @@ public class RuntimeInit { private static volatile boolean mCrashing = false; private static final native void nativeZygoteInit(); private static final native void nativeFinishInit(); private static final native void nativeSetExitWithoutCleanup(boolean exitWithoutCleanup); Loading Loading @@ -133,7 +132,7 @@ public class RuntimeInit { } } private static final void commonInit() { protected static final void commonInit() { if (DEBUG) Slog.d(TAG, "Entered RuntimeInit!"); /* Loading Loading @@ -287,50 +286,7 @@ public class RuntimeInit { if (DEBUG) Slog.d(TAG, "Leaving RuntimeInit!"); } /** * 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.<p> * * Current recognized args: * <ul> * <li> <code> [--] <start class name> <args> * </ul> * * @param targetSdkVersion target SDK version * @param argv arg strings */ public static final void zygoteInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) throws Zygote.MethodAndArgsCaller { if (DEBUG) Slog.d(TAG, "RuntimeInit: Starting application from zygote"); Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "RuntimeInit"); redirectLogStreams(); commonInit(); nativeZygoteInit(); applicationInit(targetSdkVersion, argv, classLoader); } /** * The main function called when an application is started through a * wrapper process. * * When the wrapper starts, the runtime starts {@link RuntimeInit#main} * which calls {@link WrapperInit#main} which then calls this method. * So we don't need to call commonInit() here. * * @param targetSdkVersion target SDK version * @param argv arg strings */ public static void wrapperInit(int targetSdkVersion, String[] argv) throws Zygote.MethodAndArgsCaller { if (DEBUG) Slog.d(TAG, "RuntimeInit: Starting application from wrapper"); applicationInit(targetSdkVersion, argv, null); } private static void applicationInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) protected static void applicationInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) throws Zygote.MethodAndArgsCaller { // If the application calls System.exit(), terminate the process // immediately without running any shutdown hooks. It is not possible to Loading
core/java/com/android/internal/os/WrapperInit.java +22 −2 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ import android.os.Process; import android.os.Trace; import android.util.BootTimingsTraceLog; import android.util.Slog; import com.android.internal.os.Zygote.MethodAndArgsCaller; import dalvik.system.VMRuntime; import java.io.DataOutputStream; import java.io.FileDescriptor; Loading Loading @@ -83,7 +83,7 @@ public class WrapperInit { // Launch the application. String[] runtimeArgs = new String[args.length - 2]; System.arraycopy(args, 2, runtimeArgs, 0, runtimeArgs.length); RuntimeInit.wrapperInit(targetSdkVersion, runtimeArgs); WrapperInit.wrapperInit(targetSdkVersion, runtimeArgs); } catch (Zygote.MethodAndArgsCaller caller) { caller.run(); } Loading Loading @@ -124,4 +124,24 @@ public class WrapperInit { Zygote.appendQuotedShellArgs(command, args); Zygote.execShell(command.toString()); } /** * The main function called when an application is started through a * wrapper process. * * When the wrapper starts, the runtime starts {@link RuntimeInit#main} * which calls {@link main} which then calls this method. * So we don't need to call commonInit() here. * * @param targetSdkVersion target SDK version * @param argv arg strings */ private static void wrapperInit(int targetSdkVersion, String[] argv) throws Zygote.MethodAndArgsCaller { if (RuntimeInit.DEBUG) { Slog.d(RuntimeInit.TAG, "RuntimeInit: Starting application from wrapper"); } RuntimeInit.applicationInit(targetSdkVersion, argv, null); } }
core/java/com/android/internal/os/ZygoteConnection.java +1 −1 Original line number Diff line number Diff line Loading @@ -789,7 +789,7 @@ class ZygoteConnection { VMRuntime.getCurrentInstructionSet(), pipeFd, parsedArgs.remainingArgs); } else { RuntimeInit.zygoteInit(parsedArgs.targetSdkVersion, ZygoteInit.zygoteInit(parsedArgs.targetSdkVersion, parsedArgs.remainingArgs, null /* classLoader */); } } Loading
core/java/com/android/internal/os/ZygoteInit.java +31 −1 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ import android.text.Hyphenator; import android.util.BootTimingsTraceLog; import android.util.EventLog; import android.util.Log; import android.util.Slog; import android.webkit.WebViewFactory; import android.widget.TextView; Loading Loading @@ -471,7 +472,7 @@ public class ZygoteInit { /* * Pass the remaining arguments to SystemServer. */ RuntimeInit.zygoteInit(parsedArgs.targetSdkVersion, parsedArgs.remainingArgs, cl); ZygoteInit.zygoteInit(parsedArgs.targetSdkVersion, parsedArgs.remainingArgs, cl); } /* should never reach here */ Loading Loading @@ -771,4 +772,33 @@ public class ZygoteInit { */ private ZygoteInit() { } /** * 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.<p> * * Current recognized args: * <ul> * <li> <code> [--] <start class name> <args> * </ul> * * @param targetSdkVersion target SDK version * @param argv arg strings */ public static final void zygoteInit(int targetSdkVersion, String[] argv, ClassLoader classLoader) throws Zygote.MethodAndArgsCaller { if (RuntimeInit.DEBUG) { Slog.d(RuntimeInit.TAG, "RuntimeInit: Starting application from zygote"); } Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "ZygoteInit"); RuntimeInit.redirectLogStreams(); RuntimeInit.commonInit(); ZygoteInit.nativeZygoteInit(); RuntimeInit.applicationInit(targetSdkVersion, argv, classLoader); } private static final native void nativeZygoteInit(); }
core/jni/AndroidRuntime.cpp +19 −10 Original line number Diff line number Diff line Loading @@ -216,7 +216,7 @@ static void com_android_internal_os_RuntimeInit_nativeFinishInit(JNIEnv* env, jo gCurRuntime->onStarted(); } static void com_android_internal_os_RuntimeInit_nativeZygoteInit(JNIEnv* env, jobject clazz) static void com_android_internal_os_ZygoteInit_nativeZygoteInit(JNIEnv* env, jobject clazz) { gCurRuntime->onZygoteInit(); } Loading @@ -230,19 +230,27 @@ static void com_android_internal_os_RuntimeInit_nativeSetExitWithoutCleanup(JNIE /* * JNI registration. */ static const JNINativeMethod gMethods[] = { int register_com_android_internal_os_RuntimeInit(JNIEnv* env) { const JNINativeMethod methods[] = { { "nativeFinishInit", "()V", (void*) com_android_internal_os_RuntimeInit_nativeFinishInit }, { "nativeZygoteInit", "()V", (void*) com_android_internal_os_RuntimeInit_nativeZygoteInit }, { "nativeSetExitWithoutCleanup", "(Z)V", (void*) com_android_internal_os_RuntimeInit_nativeSetExitWithoutCleanup }, }; return jniRegisterNativeMethods(env, "com/android/internal/os/RuntimeInit", methods, NELEM(methods)); } int register_com_android_internal_os_RuntimeInit(JNIEnv* env) int register_com_android_internal_os_ZygoteInit(JNIEnv* env) { return jniRegisterNativeMethods(env, "com/android/internal/os/RuntimeInit", gMethods, NELEM(gMethods)); const JNINativeMethod methods[] = { { "nativeZygoteInit", "()V", (void*) com_android_internal_os_ZygoteInit_nativeZygoteInit }, }; return jniRegisterNativeMethods(env, "com/android/internal/os/ZygoteInit", methods, NELEM(methods)); } // ---------------------------------------------------------------------- Loading Loading @@ -1271,6 +1279,7 @@ static int register_jni_procs(const RegJNIRec array[], size_t count, JNIEnv* env static const RegJNIRec gRegJNI[] = { REG_JNI(register_com_android_internal_os_RuntimeInit), REG_JNI(register_com_android_internal_os_ZygoteInit), REG_JNI(register_android_os_SystemClock), REG_JNI(register_android_util_EventLog), REG_JNI(register_android_util_Log), Loading