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

Commit f9fd8dfc authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Consider shared libs when precreating WebView classloader."

parents 4122fd23 5bc14af5
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ public final class WebViewFactory {
     */
    public static int onWebViewProviderChanged(PackageInfo packageInfo) {
        String[] nativeLibs = null;
        String originalSourceDir = packageInfo.applicationInfo.sourceDir;
        ApplicationInfo originalAppInfo = new ApplicationInfo(packageInfo.applicationInfo);
        try {
            fixupStubApplicationInfo(packageInfo.applicationInfo,
                                     AppGlobals.getInitialApplication().getPackageManager());
@@ -474,7 +474,7 @@ public final class WebViewFactory {
            Log.e(LOGTAG, "error preparing webview native library", t);
        }

        WebViewZygote.onWebViewProviderChanged(packageInfo, originalSourceDir);
        WebViewZygote.onWebViewProviderChanged(packageInfo, originalAppInfo);

        return prepareWebViewInSystemServer(nativeLibs);
    }
+14 −5
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.webkit;

import android.app.LoadedApk;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.os.SystemService;
@@ -68,11 +69,11 @@ public class WebViewZygote {
    private static PackageInfo sPackage;

    /**
     * Cache key for the selected WebView package's classloader. This is set from
     * Original ApplicationInfo for the selected WebView package before stub fixup. This is set from
     * #onWebViewProviderChanged().
     */
    @GuardedBy("sLock")
    private static String sPackageCacheKey;
    private static ApplicationInfo sPackageOriginalAppInfo;

    /**
     * Flag for whether multi-process WebView is enabled. If this is false, the zygote
@@ -126,10 +127,11 @@ public class WebViewZygote {
        }
    }

    public static void onWebViewProviderChanged(PackageInfo packageInfo, String cacheKey) {
    public static void onWebViewProviderChanged(PackageInfo packageInfo,
                                                ApplicationInfo originalAppInfo) {
        synchronized (sLock) {
            sPackage = packageInfo;
            sPackageCacheKey = cacheKey;
            sPackageOriginalAppInfo = originalAppInfo;

            // If multi-process is not enabled, then do not start the zygote service.
            if (!sMultiprocessEnabled) {
@@ -218,10 +220,17 @@ public class WebViewZygote {
            final String zip = (zipPaths.size() == 1) ? zipPaths.get(0) :
                    TextUtils.join(File.pathSeparator, zipPaths);

            // In the case where the ApplicationInfo has been modified by the stub WebView,
            // we need to use the original ApplicationInfo to determine what the original classpath
            // would have been to use as a cache key.
            LoadedApk.makePaths(null, false, sPackageOriginalAppInfo, zipPaths, null);
            final String cacheKey = (zipPaths.size() == 1) ? zipPaths.get(0) :
                    TextUtils.join(File.pathSeparator, zipPaths);

            ZygoteProcess.waitForConnectionToZygote(WEBVIEW_ZYGOTE_SOCKET);

            Log.d(LOGTAG, "Preloading package " + zip + " " + librarySearchPath);
            sZygote.preloadPackageForAbi(zip, librarySearchPath, sPackageCacheKey,
            sZygote.preloadPackageForAbi(zip, librarySearchPath, cacheKey,
                                         Build.SUPPORTED_ABIS[0]);
        } catch (Exception e) {
            Log.e(LOGTAG, "Error connecting to " + serviceName, e);
+2 −2
Original line number Diff line number Diff line
@@ -304,6 +304,6 @@ public class SystemImpl implements SystemInterface {

    // flags declaring we want extra info from the package manager for webview providers
    private final static int PACKAGE_FLAGS = PackageManager.GET_META_DATA
            | PackageManager.GET_SIGNATURES | PackageManager.MATCH_DEBUG_TRIAGED_MISSING
            | PackageManager.MATCH_ANY_USER;
            | PackageManager.GET_SIGNATURES | PackageManager.GET_SHARED_LIBRARY_FILES
            | PackageManager.MATCH_DEBUG_TRIAGED_MISSING | PackageManager.MATCH_ANY_USER;
}