Merge "Load WebViewChromiumFactoryProviderForO"
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user