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

Commit 755eded0 authored by Tao Bai's avatar Tao Bai
Browse files

Load WebViewChromiumFactoryProviderForO

BUG: 34180497
Test: change the name of class to load.

Change-Id: I586e83242d380b1def88de605a4e9dee375c87b2
parent bede0120
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -59,8 +59,8 @@ public final class WebViewFactory {

    // visible for WebViewZygoteInit to look up the class by reflection and call preloadInZygote.
    /** @hide */
    public static final String CHROMIUM_WEBVIEW_FACTORY =
            "com.android.webview.chromium.WebViewChromiumFactoryProvider";
    private static final String CHROMIUM_WEBVIEW_FACTORY =
            "com.android.webview.chromium.WebViewChromiumFactoryProviderForO";

    private static final String CHROMIUM_WEBVIEW_FACTORY_METHOD = "create";

@@ -142,6 +142,23 @@ public final class WebViewFactory {
        }
    }

    /**
     * @hide
     */
    public static Class<WebViewFactoryProvider> getWebViewProviderClass(  ClassLoader clazzLoader)
            throws ClassNotFoundException{
        try {
            return (Class<WebViewFactoryProvider>) Class.forName(CHROMIUM_WEBVIEW_FACTORY,
                    true, clazzLoader);
        } catch (ClassNotFoundException e) {
            // TODO: This loads the provider which is not built for O, should be removed
            // before the release.
            return (Class<WebViewFactoryProvider>) Class.forName(
                    "com.android.webview.chromium.WebViewChromiumFactoryProvider",
                    true, clazzLoader);
        }
    }

    /**
     * Load the native library for the given package name iff that package
     * name is the same as the one providing the webview.
@@ -366,9 +383,9 @@ public final class WebViewFactory {

                Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "Class.forName()");
                try {
                    return (Class<WebViewFactoryProvider>) Class.forName(CHROMIUM_WEBVIEW_FACTORY,
                            true, clazzLoader);
                } finally {
                    return getWebViewProviderClass(clazzLoader);
                }
                finally {
                    Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
                }
            } catch (ClassNotFoundException e) {
+3 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.system.Os;
import android.text.TextUtils;
import android.util.Log;
import android.webkit.WebViewFactory;
import android.webkit.WebViewFactoryProvider;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
@@ -74,8 +75,8 @@ class WebViewZygoteInit {
            // call preloadInZygote() on it to give it the opportunity to preload the native library
            // and perform any other initialisation work that should be shared among the children.
            try {
                Class providerClass = Class.forName(WebViewFactory.CHROMIUM_WEBVIEW_FACTORY, true,
                                                    loader);
                Class<WebViewFactoryProvider> providerClass =
                        WebViewFactory.getWebViewProviderClass(loader);
                Object result = providerClass.getMethod("preloadInZygote").invoke(null);
                if (!((Boolean)result).booleanValue()) {
                    Log.e(TAG, "preloadInZygote returned false");