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

Commit 0222489d authored by Sebastian Poreba's avatar Sebastian Poreba Committed by Gerrit Code Review
Browse files

Merge "Preload HttpEngine into the Zygote via an API" into main

parents 1bf8d3aa d36e3ab3
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -89,6 +89,7 @@ aconfig_declarations_group {
        "com.android.media.flags.editing-aconfig-java",
        "com.android.media.flags.editing-aconfig-java",
        "com.android.media.flags.performance-aconfig-java",
        "com.android.media.flags.performance-aconfig-java",
        "com.android.media.flags.projection-aconfig-java",
        "com.android.media.flags.projection-aconfig-java",
        "com.android.net.http.flags-aconfig-exported-java",
        "com.android.net.thread.platform.flags-aconfig-java",
        "com.android.net.thread.platform.flags-aconfig-java",
        "com.android.ranging.flags.ranging-aconfig-java-export",
        "com.android.ranging.flags.ranging-aconfig-java-export",
        "com.android.server.contextualsearch.flags-java",
        "com.android.server.contextualsearch.flags-java",
+20 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,8 @@ package com.android.internal.os;
import static android.system.OsConstants.S_IRWXG;
import static android.system.OsConstants.S_IRWXG;
import static android.system.OsConstants.S_IRWXO;
import static android.system.OsConstants.S_IRWXO;


import static android.net.http.Flags.preloadHttpengineInZygote;

import static com.android.internal.util.FrameworkStatsLog.BOOT_TIME_EVENT_ELAPSED_TIME__EVENT__SECONDARY_ZYGOTE_INIT_START;
import static com.android.internal.util.FrameworkStatsLog.BOOT_TIME_EVENT_ELAPSED_TIME__EVENT__SECONDARY_ZYGOTE_INIT_START;
import static com.android.internal.util.FrameworkStatsLog.BOOT_TIME_EVENT_ELAPSED_TIME__EVENT__ZYGOTE_INIT_START;
import static com.android.internal.util.FrameworkStatsLog.BOOT_TIME_EVENT_ELAPSED_TIME__EVENT__ZYGOTE_INIT_START;


@@ -27,6 +29,7 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.pm.SharedLibraryInfo;
import android.content.pm.SharedLibraryInfo;
import android.content.res.Resources;
import android.content.res.Resources;
import android.os.Build;
import android.os.Build;
import android.net.http.HttpEngine;
import android.os.Environment;
import android.os.Environment;
import android.os.IInstalld;
import android.os.IInstalld;
import android.os.Process;
import android.os.Process;
@@ -144,6 +147,23 @@ public class ZygoteInit {
        Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
        Trace.traceEnd(Trace.TRACE_TAG_DALVIK);
        preloadSharedLibraries();
        preloadSharedLibraries();
        preloadTextResources();
        preloadTextResources();

        // TODO: remove the try/catch and the flag read as soon as the flag is ramped and 25Q2
        // starts building from source.
        if (preloadHttpengineInZygote()) {
            try {
                HttpEngine.preload();
            } catch (NoSuchMethodError e){
                // The flag protecting this API is not an exported
                // flag because ZygoteInit happens before the
                // system service has initialized the flag which means
                // that we can't query the real value of the flag
                // from the tethering module. In order to avoid crashing
                // in the case where we have (new zygote, old tethering).
                // we catch the NoSuchMethodError and just log.
                Log.d(TAG, "HttpEngine.preload() threw " + e);
            }
        }
        // Ask the WebViewFactory to do any initialization that must run in the zygote process,
        // Ask the WebViewFactory to do any initialization that must run in the zygote process,
        // for memory sharing purposes.
        // for memory sharing purposes.
        WebViewFactory.prepareWebViewInZygote();
        WebViewFactory.prepareWebViewInZygote();