summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sergio Giro <sgiro@google.com> 2016-05-17 15:50:50 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2016-05-17 15:50:50 +0000
commitaa733e0b41e4e15908a4c89e935f824cc5908b4d (patch)
tree2ac553a66d6892dc5cddef4e57c4f95e366fbe50
parentd065220a547c985be3bd17bb8f2ff473427aa978 (diff)
parentb07595d1941a25b5f82c62f9b7099c3c77d06056 (diff)
Merge "ZygoteInit: warm up JCA providers during preload"
-rw-r--r--core/java/com/android/internal/os/ZygoteInit.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index d84cb8065f95..1440e5fb559d 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -52,6 +52,8 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.security.Security;
+import java.security.Provider;
import java.util.ArrayList;
/**
@@ -193,6 +195,7 @@ public class ZygoteInit {
// Ask the WebViewFactory to do any initialization that must run in the zygote process,
// for memory sharing purposes.
WebViewFactory.prepareWebViewInZygote();
+ warmUpJcaProviders();
Log.d(TAG, "end preload");
}
@@ -214,6 +217,24 @@ public class ZygoteInit {
}
/**
+ * 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.
+ */
+ private static void warmUpJcaProviders() {
+ long 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);
+ }
+
+ /**
* Performs Zygote process initialization. Loads and initializes
* commonly used classes.
*