summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorSergio Giro <sgiro@google.com>2016-05-17 16:52:33 +0100
committerSergio Giro <sgiro@google.com>2016-05-23 11:24:34 +0100
commit80755a5a25de5b7c9f2d61e6dba7c2a4656bca89 (patch)
tree5cd9aad45789bedc4254d93513d980eb2ec1843e /core/java
parent6f4b5661696355d230c515a45aca2dddd8fe99b1 (diff)
ZygoteInit: install AndroidKeyStoreProvider in the Zygote
Instead of in activity thread. That way, we can warm up (ie, precompute cached values) this provider and AndroidBCWorkaroundProvider (which are installed together) so that the computation doesn't happen in the app. As a result, the time spent in the first call to SSLSocketFactory.getDefault() decreases by ~5ms in angler userdebug. Measured with an app calling SSLSocketFactory.getDefault in onCreate and timed it with System.currentTimeMillis() . (cherry picked from commit 69de32071c8ca7fa2277e4340a320b7df6fe963d) Bug: 28545496 Change-Id: Ic4e11d058fb404eaa92db925a3e765fc3bef7ae2
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/ActivityThread.java3
-rw-r--r--core/java/com/android/internal/os/ZygoteInit.java16
2 files changed, 14 insertions, 5 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 5fb3635d73f1..0386cff9edea 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -98,7 +98,6 @@ import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.renderscript.RenderScriptCacheDir;
-import android.security.keystore.AndroidKeyStoreProvider;
import android.system.Os;
import android.system.OsConstants;
import android.system.ErrnoException;
@@ -5461,8 +5460,6 @@ public final class ActivityThread {
// Set the reporter for event logging in libcore
EventLogger.setReporter(new EventLoggingReporter());
- AndroidKeyStoreProvider.install();
-
// Make sure TrustedCertificateStore looks in the right place for CA certificates
final File configDir = Environment.getUserConfigDirectory(UserHandle.myUserId());
TrustedCertificateStore.setDefaultUserDirectory(configDir);
diff --git a/core/java/com/android/internal/os/ZygoteInit.java b/core/java/com/android/internal/os/ZygoteInit.java
index 83ffb54af583..8c6653d1e3f0 100644
--- a/core/java/com/android/internal/os/ZygoteInit.java
+++ b/core/java/com/android/internal/os/ZygoteInit.java
@@ -31,6 +31,7 @@ import android.os.Process;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
+import android.security.keystore.AndroidKeyStoreProvider;
import android.system.ErrnoException;
import android.system.Os;
import android.system.OsConstants;
@@ -247,7 +248,7 @@ public class ZygoteInit {
}
/**
- * Warm up the providers that are already registered.
+ * Register AndroidKeyStoreProvider and 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.
@@ -255,12 +256,23 @@ public class ZygoteInit {
private static void warmUpJcaProviders() {
long startTime = SystemClock.uptimeMillis();
Trace.traceBegin(
+ Trace.TRACE_TAG_DALVIK, "Starting installation of AndroidKeyStoreProvider");
+ // AndroidKeyStoreProvider.install() manipulates the list of JCA providers to insert
+ // preferred providers. Note this is not done via security.properties as the JCA providers
+ // are not on the classpath in the case of, for example, raw dalvikvm runtimes.
+ AndroidKeyStoreProvider.install();
+ Log.i(TAG, "Installed AndroidKeyStoreProvider in "
+ + (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();
}
Log.i(TAG, "Warmed up JCA providers in "
- + (SystemClock.uptimeMillis()-startTime) + "ms.");
+ + (SystemClock.uptimeMillis() - startTime) + "ms.");
Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
}