Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a9f804bf authored by Sergio Giro's avatar Sergio Giro Committed by android-build-merger
Browse files

Merge "ZygoteInit: warm up JCA providers during preload" into nyc-dev

am: 5a68af38

* commit '5a68af38':
  ZygoteInit: warm up JCA providers during preload

Change-Id: I3cf53b5125331fc3c59183c09c79516a98a62347
parents 36eb3771 5a68af38
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -56,6 +56,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;

/**
@@ -198,6 +200,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");
    }

@@ -219,6 +222,24 @@ public class ZygoteInit {
        TextView.preloadFontCache();
    }

    /**
     * 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.