diff options
author | Tobias Thierer <tobiast@google.com> | 2019-09-26 16:03:28 +0100 |
---|---|---|
committer | Tobias Thierer <tobiast@google.com> | 2019-09-26 16:08:59 +0100 |
commit | a45917eb7781384a0d58936d56fdfbc71cc8443c (patch) | |
tree | c3c5ab5044c68e1f98237332cdb5fee484255324 | |
parent | a11beeca12748fe0af659f5d8c1247009ea7fd4c (diff) |
Introduce ZygoteInit.preForkInit().
Until recently, I and apparently some others were under the assumption
that RuntimeInit.commonInit() runs before the Zygote fork. Actually, it
does not.
This CL introduces a method ZygoteInit.preForkInit() which runs before
the Zygote fork. For now, only enableDdms() moves into it and can become
private. This should not alter behavior since enableDdms() is called
from the same places as before, and because enableDdms() (now private)
was already not part of any API surface.
The CL also removes the qualifier "final" from the (static) method
enableDdms(), because it is redundant.
Note: This CL was uploaded with --no-verify because of preexisting
import ordering issues in RuntimeInit.java
Test: Treehugger
Change-Id: I8f637e160a2d7810feb43b6a43ec7d628af18fb8
-rw-r--r-- | core/java/com/android/internal/os/RuntimeInit.java | 13 | ||||
-rw-r--r-- | core/java/com/android/internal/os/ZygoteInit.java | 2 |
2 files changed, 12 insertions, 3 deletions
diff --git a/core/java/com/android/internal/os/RuntimeInit.java b/core/java/com/android/internal/os/RuntimeInit.java index 1de2e7272f4d..d6caa0930243 100644 --- a/core/java/com/android/internal/os/RuntimeInit.java +++ b/core/java/com/android/internal/os/RuntimeInit.java @@ -192,6 +192,15 @@ public class RuntimeInit { } } + /** + * Common initialization that (unlike {@link #commonInit()} should happen prior to + * the Zygote fork. + */ + public static void preForkInit() { + if (DEBUG) Slog.d(TAG, "Entered preForkInit."); + RuntimeInit.enableDdms(); + } + @UnsupportedAppUsage protected static final void commonInit() { if (DEBUG) Slog.d(TAG, "Entered RuntimeInit!"); @@ -324,7 +333,7 @@ public class RuntimeInit { @UnsupportedAppUsage public static final void main(String[] argv) { - enableDdms(); + preForkInit(); if (argv.length == 2 && argv[1].equals("application")) { if (DEBUG) Slog.d(TAG, "RuntimeInit: Starting application"); redirectLogStreams(); @@ -418,7 +427,7 @@ public class RuntimeInit { /** * Enable DDMS. */ - static final void enableDdms() { + private static void enableDdms() { // Register handlers for DDM messages. android.ddm.DdmRegister.registerHandlers(); } diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java index ea4b63af117c..72d24645a2e7 100644 --- a/core/java/com/android/internal/os/ZygoteInit.java +++ b/core/java/com/android/internal/os/ZygoteInit.java @@ -835,7 +835,7 @@ public class ZygoteInit { TimingsTraceLog bootTimingsTraceLog = new TimingsTraceLog(bootTimeTag, Trace.TRACE_TAG_DALVIK); bootTimingsTraceLog.traceBegin("ZygoteInit"); - RuntimeInit.enableDdms(); + RuntimeInit.preForkInit(); boolean startSystemServer = false; String zygoteSocketName = "zygote"; |