Merge "ZygoteInit: warm up JCA providers during preload"

am: aa733e0b41

* commit 'aa733e0b41e4e15908a4c89e935f824cc5908b4d':
  ZygoteInit: warm up JCA providers during preload

Change-Id: If96e2e482e3fc01c2d3be5eee6d405f9bb5a6571
This commit is contained in:
Sergio Giro
2016-05-17 15:56:32 +00:00
committed by android-build-merger

View File

@@ -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");
}
@@ -213,6 +216,24 @@ public class ZygoteInit {
Hyphenator.init();
}
/**
* 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.