509 lines
20 KiB
Diff
509 lines
20 KiB
Diff
![]() |
From 4ac855656e2df723abb5da9768b3bce77a135490 Mon Sep 17 00:00:00 2001
|
||
|
From: Daniel Micay <danielmicay@gmail.com>
|
||
|
Date: Sat, 14 Mar 2015 18:10:20 -0400
|
||
|
Subject: [PATCH 01/10] add exec-based spawning support
|
||
|
|
||
|
---
|
||
|
.../com/android/internal/os/ExecInit.java | 115 ++++++++++++++++++
|
||
|
.../com/android/internal/os/WrapperInit.java | 2 +-
|
||
|
.../android/internal/os/ZygoteConnection.java | 7 ++
|
||
|
3 files changed, 123 insertions(+), 1 deletion(-)
|
||
|
create mode 100644 core/java/com/android/internal/os/ExecInit.java
|
||
|
|
||
|
diff --git a/core/java/com/android/internal/os/ExecInit.java b/core/java/com/android/internal/os/ExecInit.java
|
||
|
new file mode 100644
|
||
|
index 00000000000..10edd64e0f9
|
||
|
--- /dev/null
|
||
|
+++ b/core/java/com/android/internal/os/ExecInit.java
|
||
|
@@ -0,0 +1,115 @@
|
||
|
+package com.android.internal.os;
|
||
|
+
|
||
|
+import android.os.Trace;
|
||
|
+import android.system.ErrnoException;
|
||
|
+import android.system.Os;
|
||
|
+import android.util.Slog;
|
||
|
+import android.util.TimingsTraceLog;
|
||
|
+import dalvik.system.VMRuntime;
|
||
|
+
|
||
|
+/**
|
||
|
+ * Startup class for the process.
|
||
|
+ * @hide
|
||
|
+ */
|
||
|
+public class ExecInit {
|
||
|
+ /**
|
||
|
+ * Class not instantiable.
|
||
|
+ */
|
||
|
+ private ExecInit() {
|
||
|
+ }
|
||
|
+
|
||
|
+ /**
|
||
|
+ * The main function called when starting a runtime application.
|
||
|
+ *
|
||
|
+ * The first argument is the target SDK version for the app.
|
||
|
+ *
|
||
|
+ * The remaining arguments are passed to the runtime.
|
||
|
+ *
|
||
|
+ * @param args The command-line arguments.
|
||
|
+ */
|
||
|
+ public static void main(String[] args) {
|
||
|
+ // Parse our mandatory argument.
|
||
|
+ int targetSdkVersion = Integer.parseInt(args[0], 10);
|
||
|
+
|
||
|
+ // Mimic system Zygote preloading.
|
||
|
+ ZygoteInit.preload(new TimingsTraceLog("ExecInitTiming",
|
||
|
+ Trace.TRACE_TAG_DALVIK));
|
||
|
+
|
||
|
+ // Launch the application.
|
||
|
+ String[] runtimeArgs = new String[args.length - 1];
|
||
|
+ System.arraycopy(args, 1, runtimeArgs, 0, runtimeArgs.length);
|
||
|
+ Runnable r = execInit(targetSdkVersion, runtimeArgs);
|
||
|
+
|
||
|
+ r.run();
|
||
|
+ }
|
||
|
+
|
||
|
+ /**
|
||
|
+ * Executes a runtime application with exec-based spawning.
|
||
|
+ * This method never returns.
|
||
|
+ *
|
||
|
+ * @param niceName The nice name for the application, or null if none.
|
||
|
+ * @param targetSdkVersion The target SDK version for the app.
|
||
|
+ * @param args Arguments for {@link RuntimeInit#main}.
|
||
|
+ */
|
||
|
+ public static void execApplication(String niceName, int targetSdkVersion,
|
||
|
+ String instructionSet, String[] args) {
|
||
|
+ int niceArgs = niceName == null ? 0 : 1;
|
||
|
+ int baseArgs = 5 + niceArgs;
|
||
|
+ String[] argv = new String[baseArgs + args.length];
|
||
|
+ if (VMRuntime.is64BitInstructionSet(instructionSet)) {
|
||
|
+ argv[0] = "/system/bin/app_process64";
|
||
|
+ } else {
|
||
|
+ argv[0] = "/system/bin/app_process32";
|
||
|
+ }
|
||
|
+ argv[1] = "/system/bin";
|
||
|
+ argv[2] = "--application";
|
||
|
+ if (niceName != null) {
|
||
|
+ argv[3] = "--nice-name=" + niceName;
|
||
|
+ }
|
||
|
+ argv[3 + niceArgs] = "com.android.internal.os.ExecInit";
|
||
|
+ argv[4 + niceArgs] = Integer.toString(targetSdkVersion);
|
||
|
+ System.arraycopy(args, 0, argv, baseArgs, args.length);
|
||
|
+
|
||
|
+ WrapperInit.preserveCapabilities();
|
||
|
+ try {
|
||
|
+ Os.execv(argv[0], argv);
|
||
|
+ } catch (ErrnoException e) {
|
||
|
+ throw new RuntimeException(e);
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ /**
|
||
|
+ * The main function called when an application is started with exec-based spawning.
|
||
|
+ *
|
||
|
+ * When the app 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 Runnable execInit(int targetSdkVersion, String[] argv) {
|
||
|
+ if (RuntimeInit.DEBUG) {
|
||
|
+ Slog.d(RuntimeInit.TAG, "RuntimeInit: Starting application from exec");
|
||
|
+ }
|
||
|
+
|
||
|
+ // Check whether the first argument is a "-cp" in argv, and assume the next argument is the
|
||
|
+ // classpath. If found, create a PathClassLoader and use it for applicationInit.
|
||
|
+ ClassLoader classLoader = null;
|
||
|
+ if (argv != null && argv.length > 2 && argv[0].equals("-cp")) {
|
||
|
+ classLoader = ZygoteInit.createPathClassLoader(argv[1], targetSdkVersion);
|
||
|
+
|
||
|
+ // Install this classloader as the context classloader, too.
|
||
|
+ Thread.currentThread().setContextClassLoader(classLoader);
|
||
|
+
|
||
|
+ // Remove the classpath from the arguments.
|
||
|
+ String removedArgs[] = new String[argv.length - 2];
|
||
|
+ System.arraycopy(argv, 2, removedArgs, 0, argv.length - 2);
|
||
|
+ argv = removedArgs;
|
||
|
+ }
|
||
|
+
|
||
|
+ // Perform the same initialization that would happen after the Zygote forks.
|
||
|
+ Zygote.nativePreApplicationInit();
|
||
|
+ return RuntimeInit.applicationInit(targetSdkVersion, argv, classLoader);
|
||
|
+ }
|
||
|
+}
|
||
|
diff --git a/core/java/com/android/internal/os/WrapperInit.java b/core/java/com/android/internal/os/WrapperInit.java
|
||
|
index f0e779694c9..9f41a4136db 100644
|
||
|
--- a/core/java/com/android/internal/os/WrapperInit.java
|
||
|
+++ b/core/java/com/android/internal/os/WrapperInit.java
|
||
|
@@ -183,7 +183,7 @@ public class WrapperInit {
|
||
|
* This is acceptable here as failure will leave the wrapped app with strictly less
|
||
|
* capabilities, which may make it crash, but not exceed its allowances.
|
||
|
*/
|
||
|
- private static void preserveCapabilities() {
|
||
|
+ public static void preserveCapabilities() {
|
||
|
StructCapUserHeader header = new StructCapUserHeader(
|
||
|
OsConstants._LINUX_CAPABILITY_VERSION_3, 0);
|
||
|
StructCapUserData[] data;
|
||
|
diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java
|
||
|
index f537e3e2897..7d51be259c2 100644
|
||
|
--- a/core/java/com/android/internal/os/ZygoteConnection.java
|
||
|
+++ b/core/java/com/android/internal/os/ZygoteConnection.java
|
||
|
@@ -880,6 +880,13 @@ class ZygoteConnection {
|
||
|
throw new IllegalStateException("WrapperInit.execApplication unexpectedly returned");
|
||
|
} else {
|
||
|
if (!isZygote) {
|
||
|
+ if (SystemProperties.getBoolean("sys.spawn.exec", true)) {
|
||
|
+ ExecInit.execApplication(parsedArgs.niceName, parsedArgs.targetSdkVersion,
|
||
|
+ VMRuntime.getCurrentInstructionSet(), parsedArgs.remainingArgs);
|
||
|
+
|
||
|
+ // Should not get here.
|
||
|
+ throw new IllegalStateException("ExecInit.execApplication unexpectedly returned");
|
||
|
+ }
|
||
|
return ZygoteInit.zygoteInit(parsedArgs.targetSdkVersion, parsedArgs.remainingArgs,
|
||
|
null /* classLoader */);
|
||
|
} else {
|
||
|
--
|
||
|
2.21.0
|
||
|
|
||
|
|
||
|
From 654f1cc80bd8d51a04f01c56e97bface4bce7811 Mon Sep 17 00:00:00 2001
|
||
|
From: Daniel Micay <danielmicay@gmail.com>
|
||
|
Date: Tue, 14 May 2019 14:24:21 -0400
|
||
|
Subject: [PATCH 02/10] add parameter for avoiding full preload with exec
|
||
|
|
||
|
---
|
||
|
core/java/com/android/internal/os/ExecInit.java | 2 +-
|
||
|
core/java/com/android/internal/os/ZygoteInit.java | 6 +++++-
|
||
|
2 files changed, 6 insertions(+), 2 deletions(-)
|
||
|
|
||
|
diff --git a/core/java/com/android/internal/os/ExecInit.java b/core/java/com/android/internal/os/ExecInit.java
|
||
|
index 10edd64e0f9..3ba4664ae8c 100644
|
||
|
--- a/core/java/com/android/internal/os/ExecInit.java
|
||
|
+++ b/core/java/com/android/internal/os/ExecInit.java
|
||
|
@@ -33,7 +33,7 @@ public class ExecInit {
|
||
|
|
||
|
// Mimic system Zygote preloading.
|
||
|
ZygoteInit.preload(new TimingsTraceLog("ExecInitTiming",
|
||
|
- Trace.TRACE_TAG_DALVIK));
|
||
|
+ Trace.TRACE_TAG_DALVIK), false);
|
||
|
|
||
|
// Launch the application.
|
||
|
String[] runtimeArgs = new String[args.length - 1];
|
||
|
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
index da195601f72..6acaccbbc3e 100644
|
||
|
--- a/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
+++ b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
@@ -120,7 +120,7 @@ public class ZygoteInit {
|
||
|
|
||
|
private static boolean sPreloadComplete;
|
||
|
|
||
|
- static void preload(TimingsTraceLog bootTimingsTraceLog) {
|
||
|
+ static void preload(TimingsTraceLog bootTimingsTraceLog, boolean fullPreload) {
|
||
|
Log.d(TAG, "begin preload");
|
||
|
bootTimingsTraceLog.traceBegin("BeginIcuCachePinning");
|
||
|
beginIcuCachePinning();
|
||
|
@@ -149,6 +149,10 @@ public class ZygoteInit {
|
||
|
sPreloadComplete = true;
|
||
|
}
|
||
|
|
||
|
+ static void preload(TimingsTraceLog bootTimingsTraceLog) {
|
||
|
+ preload(bootTimingsTraceLog, true);
|
||
|
+ }
|
||
|
+
|
||
|
public static void lazyPreload() {
|
||
|
Preconditions.checkState(!sPreloadComplete);
|
||
|
Log.i(TAG, "Lazily preloading resources.");
|
||
|
--
|
||
|
2.21.0
|
||
|
|
||
|
|
||
|
From fa13759a9f3c7a4860a6e2aa559cd454e31ac621 Mon Sep 17 00:00:00 2001
|
||
|
From: Daniel Micay <danielmicay@gmail.com>
|
||
|
Date: Tue, 14 May 2019 14:28:27 -0400
|
||
|
Subject: [PATCH 03/10] disable OpenGL preloading for exec spawning
|
||
|
|
||
|
---
|
||
|
core/java/com/android/internal/os/ZygoteInit.java | 8 +++++---
|
||
|
1 file changed, 5 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
index 6acaccbbc3e..09ec9f23545 100644
|
||
|
--- a/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
+++ b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
@@ -134,9 +134,11 @@ public class ZygoteInit {
|
||
|
Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadAppProcessHALs");
|
||
|
nativePreloadAppProcessHALs();
|
||
|
Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
|
||
|
- Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadOpenGL");
|
||
|
- preloadOpenGL();
|
||
|
- Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
|
||
|
+ if (fullPreload) {
|
||
|
+ Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadOpenGL");
|
||
|
+ preloadOpenGL();
|
||
|
+ Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
|
||
|
+ }
|
||
|
preloadSharedLibraries();
|
||
|
preloadTextResources();
|
||
|
// Ask the WebViewFactory to do any initialization that must run in the zygote process,
|
||
|
--
|
||
|
2.21.0
|
||
|
|
||
|
|
||
|
From 960ccd579d883ef6426e2d84cff2982cb5e0d83b Mon Sep 17 00:00:00 2001
|
||
|
From: Daniel Micay <danielmicay@gmail.com>
|
||
|
Date: Tue, 14 May 2019 14:28:52 -0400
|
||
|
Subject: [PATCH 04/10] disable resource preloading for exec spawning
|
||
|
|
||
|
---
|
||
|
core/java/com/android/internal/os/ZygoteInit.java | 8 +++++---
|
||
|
1 file changed, 5 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
index 09ec9f23545..17bdfaa79d0 100644
|
||
|
--- a/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
+++ b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
@@ -128,9 +128,11 @@ public class ZygoteInit {
|
||
|
bootTimingsTraceLog.traceBegin("PreloadClasses");
|
||
|
preloadClasses();
|
||
|
bootTimingsTraceLog.traceEnd(); // PreloadClasses
|
||
|
- bootTimingsTraceLog.traceBegin("PreloadResources");
|
||
|
- preloadResources();
|
||
|
- bootTimingsTraceLog.traceEnd(); // PreloadResources
|
||
|
+ if (fullPreload) {
|
||
|
+ bootTimingsTraceLog.traceBegin("PreloadResources");
|
||
|
+ preloadResources();
|
||
|
+ bootTimingsTraceLog.traceEnd(); // PreloadResources
|
||
|
+ }
|
||
|
Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PreloadAppProcessHALs");
|
||
|
nativePreloadAppProcessHALs();
|
||
|
Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
|
||
|
--
|
||
|
2.21.0
|
||
|
|
||
|
|
||
|
From 88e59153886fd6e1c60bdf5b0fe7ab9280cd8cae Mon Sep 17 00:00:00 2001
|
||
|
From: Daniel Micay <danielmicay@gmail.com>
|
||
|
Date: Tue, 14 May 2019 14:29:36 -0400
|
||
|
Subject: [PATCH 05/10] disable ICU cache pinning for exec spawning
|
||
|
|
||
|
---
|
||
|
core/java/com/android/internal/os/ZygoteInit.java | 12 ++++++++----
|
||
|
1 file changed, 8 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
index 17bdfaa79d0..1dfe23e3293 100644
|
||
|
--- a/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
+++ b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
@@ -122,9 +122,11 @@ public class ZygoteInit {
|
||
|
|
||
|
static void preload(TimingsTraceLog bootTimingsTraceLog, boolean fullPreload) {
|
||
|
Log.d(TAG, "begin preload");
|
||
|
- bootTimingsTraceLog.traceBegin("BeginIcuCachePinning");
|
||
|
- beginIcuCachePinning();
|
||
|
- bootTimingsTraceLog.traceEnd(); // BeginIcuCachePinning
|
||
|
+ if (fullPreload) {
|
||
|
+ bootTimingsTraceLog.traceBegin("BeginIcuCachePinning");
|
||
|
+ beginIcuCachePinning();
|
||
|
+ bootTimingsTraceLog.traceEnd(); // BeginIcuCachePinning
|
||
|
+ }
|
||
|
bootTimingsTraceLog.traceBegin("PreloadClasses");
|
||
|
preloadClasses();
|
||
|
bootTimingsTraceLog.traceEnd(); // PreloadClasses
|
||
|
@@ -146,7 +148,9 @@ public class ZygoteInit {
|
||
|
// Ask the WebViewFactory to do any initialization that must run in the zygote process,
|
||
|
// for memory sharing purposes.
|
||
|
WebViewFactory.prepareWebViewInZygote();
|
||
|
- endIcuCachePinning();
|
||
|
+ if (fullPreload) {
|
||
|
+ endIcuCachePinning();
|
||
|
+ }
|
||
|
warmUpJcaProviders();
|
||
|
Log.d(TAG, "end preload");
|
||
|
|
||
|
--
|
||
|
2.21.0
|
||
|
|
||
|
|
||
|
From 96fa644f641d0a90a2642219c9dcd49812ff9411 Mon Sep 17 00:00:00 2001
|
||
|
From: Daniel Micay <danielmicay@gmail.com>
|
||
|
Date: Tue, 14 May 2019 14:30:59 -0400
|
||
|
Subject: [PATCH 06/10] disable class preloading for exec spawning
|
||
|
|
||
|
---
|
||
|
core/java/com/android/internal/os/ZygoteInit.java | 8 +++++---
|
||
|
1 file changed, 5 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
index 1dfe23e3293..fae438512d8 100644
|
||
|
--- a/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
+++ b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
@@ -127,9 +127,11 @@ public class ZygoteInit {
|
||
|
beginIcuCachePinning();
|
||
|
bootTimingsTraceLog.traceEnd(); // BeginIcuCachePinning
|
||
|
}
|
||
|
- bootTimingsTraceLog.traceBegin("PreloadClasses");
|
||
|
- preloadClasses();
|
||
|
- bootTimingsTraceLog.traceEnd(); // PreloadClasses
|
||
|
+ if (fullPreload) {
|
||
|
+ bootTimingsTraceLog.traceBegin("PreloadClasses");
|
||
|
+ preloadClasses();
|
||
|
+ bootTimingsTraceLog.traceEnd(); // PreloadClasses
|
||
|
+ }
|
||
|
if (fullPreload) {
|
||
|
bootTimingsTraceLog.traceBegin("PreloadResources");
|
||
|
preloadResources();
|
||
|
--
|
||
|
2.21.0
|
||
|
|
||
|
|
||
|
From 28dc5c52766abda740c25cc2650b68fa8328d8a8 Mon Sep 17 00:00:00 2001
|
||
|
From: Daniel Micay <danielmicay@gmail.com>
|
||
|
Date: Tue, 14 May 2019 14:31:29 -0400
|
||
|
Subject: [PATCH 07/10] disable WebView reservation for exec spawning
|
||
|
|
||
|
---
|
||
|
core/java/com/android/internal/os/ZygoteInit.java | 8 +++++---
|
||
|
1 file changed, 5 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
index fae438512d8..75d10f6d92a 100644
|
||
|
--- a/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
+++ b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
@@ -147,9 +147,11 @@ public class ZygoteInit {
|
||
|
}
|
||
|
preloadSharedLibraries();
|
||
|
preloadTextResources();
|
||
|
- // Ask the WebViewFactory to do any initialization that must run in the zygote process,
|
||
|
- // for memory sharing purposes.
|
||
|
- WebViewFactory.prepareWebViewInZygote();
|
||
|
+ if (fullPreload) {
|
||
|
+ // Ask the WebViewFactory to do any initialization that must run in the zygote process,
|
||
|
+ // for memory sharing purposes.
|
||
|
+ WebViewFactory.prepareWebViewInZygote();
|
||
|
+ }
|
||
|
if (fullPreload) {
|
||
|
endIcuCachePinning();
|
||
|
}
|
||
|
--
|
||
|
2.21.0
|
||
|
|
||
|
|
||
|
From 8998af03229d57b69f4dd9b2a3656ea310445568 Mon Sep 17 00:00:00 2001
|
||
|
From: Daniel Micay <danielmicay@gmail.com>
|
||
|
Date: Tue, 14 May 2019 14:34:32 -0400
|
||
|
Subject: [PATCH 08/10] disable JCA provider warm up for exec spawning
|
||
|
|
||
|
---
|
||
|
.../com/android/internal/os/ZygoteInit.java | 22 ++++++++++---------
|
||
|
1 file changed, 12 insertions(+), 10 deletions(-)
|
||
|
|
||
|
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
index 75d10f6d92a..214dbd45109 100644
|
||
|
--- a/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
+++ b/core/java/com/android/internal/os/ZygoteInit.java
|
||
|
@@ -155,7 +155,7 @@ public class ZygoteInit {
|
||
|
if (fullPreload) {
|
||
|
endIcuCachePinning();
|
||
|
}
|
||
|
- warmUpJcaProviders();
|
||
|
+ warmUpJcaProviders(fullPreload);
|
||
|
Log.d(TAG, "end preload");
|
||
|
|
||
|
sPreloadComplete = true;
|
||
|
@@ -223,7 +223,7 @@ public class ZygoteInit {
|
||
|
* 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() {
|
||
|
+ private static void warmUpJcaProviders(boolean fullPreload) {
|
||
|
long startTime = SystemClock.uptimeMillis();
|
||
|
Trace.traceBegin(
|
||
|
Trace.TRACE_TAG_DALVIK, "Starting installation of AndroidKeyStoreProvider");
|
||
|
@@ -235,15 +235,17 @@ public class ZygoteInit {
|
||
|
+ (SystemClock.uptimeMillis() - startTime) + "ms.");
|
||
|
Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
|
||
|
|
||
|
- startTime = SystemClock.uptimeMillis();
|
||
|
- Trace.traceBegin(
|
||
|
- Trace.TRACE_TAG_DALVIK, "Starting warm up of JCA providers");
|
||
|
- for (Provider p : Security.getProviders()) {
|
||
|
- p.warmUpServiceProvision();
|
||
|
+ if (fullPreload) {
|
||
|
+ startTime = SystemClock.uptimeMillis();
|
||
|
+ Trace.traceBegin(
|
||
|
+ Trace.TRACE_TAG_DALVIK, "Starting warm up of JCA providers");
|
||
|
+ for (Provider p : Security.getProviders()) {
|
||
|
+ p.warmUpServiceProvision();
|
||
|
+ }
|
||
|
+ Log.i(TAG, "Warmed up JCA providers in "
|
||
|
+ + (SystemClock.uptimeMillis() - startTime) + "ms.");
|
||
|
+ Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
|
||
|
}
|
||
|
- Log.i(TAG, "Warmed up JCA providers in "
|
||
|
- + (SystemClock.uptimeMillis() - startTime) + "ms.");
|
||
|
- Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
--
|
||
|
2.21.0
|
||
|
|
||
|
|
||
|
From a60d5e0c25c9c40eb3cab1ad89ad9f1b37c3918a Mon Sep 17 00:00:00 2001
|
||
|
From: Daniel Micay <danielmicay@gmail.com>
|
||
|
Date: Tue, 14 May 2019 15:11:59 -0400
|
||
|
Subject: [PATCH 09/10] avoid AssetManager errors with exec spawning
|
||
|
|
||
|
This causes harmless errors and wastes time spawning a process that's
|
||
|
not going to succeed.
|
||
|
---
|
||
|
core/jni/android_util_AssetManager.cpp | 4 ++++
|
||
|
1 file changed, 4 insertions(+)
|
||
|
|
||
|
diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp
|
||
|
index fa9f44557d3..08060163017 100644
|
||
|
--- a/core/jni/android_util_AssetManager.cpp
|
||
|
+++ b/core/jni/android_util_AssetManager.cpp
|
||
|
@@ -111,6 +111,10 @@ constexpr inline static ApkAssetsCookie JavaCookieToApkAssetsCookie(jint cookie)
|
||
|
|
||
|
// This is called by zygote (running as user root) as part of preloadResources.
|
||
|
static void NativeVerifySystemIdmaps(JNIEnv* /*env*/, jclass /*clazz*/) {
|
||
|
+ // avoid triggering an error with exec-based spawning
|
||
|
+ if (getuid() != 0) {
|
||
|
+ return;
|
||
|
+ }
|
||
|
switch (pid_t pid = fork()) {
|
||
|
case -1:
|
||
|
PLOG(ERROR) << "failed to fork for idmap";
|
||
|
--
|
||
|
2.21.0
|
||
|
|
||
|
|
||
|
From b086a665c2b3b25535205d29c5dbe9bb2ba6e47a Mon Sep 17 00:00:00 2001
|
||
|
From: Daniel Micay <danielmicay@gmail.com>
|
||
|
Date: Tue, 21 May 2019 23:54:20 -0400
|
||
|
Subject: [PATCH 10/10] disable exec spawning when using debugging options
|
||
|
|
||
|
The debugging options are not yet supported probably, so disable exec
|
||
|
spawning when doing debugging.
|
||
|
---
|
||
|
core/java/com/android/internal/os/ZygoteConnection.java | 2 +-
|
||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/core/java/com/android/internal/os/ZygoteConnection.java b/core/java/com/android/internal/os/ZygoteConnection.java
|
||
|
index 7d51be259c2..48a68d96e84 100644
|
||
|
--- a/core/java/com/android/internal/os/ZygoteConnection.java
|
||
|
+++ b/core/java/com/android/internal/os/ZygoteConnection.java
|
||
|
@@ -880,7 +880,7 @@ class ZygoteConnection {
|
||
|
throw new IllegalStateException("WrapperInit.execApplication unexpectedly returned");
|
||
|
} else {
|
||
|
if (!isZygote) {
|
||
|
- if (SystemProperties.getBoolean("sys.spawn.exec", true)) {
|
||
|
+ if (SystemProperties.getBoolean("sys.spawn.exec", true) && parsedArgs.runtimeFlags == 0) {
|
||
|
ExecInit.execApplication(parsedArgs.niceName, parsedArgs.targetSdkVersion,
|
||
|
VMRuntime.getCurrentInstructionSet(), parsedArgs.remainingArgs);
|
||
|
|
||
|
--
|
||
|
2.21.0
|
||
|
|