Merge "Load WebView library into the right classloader namespace." into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3df6390d2b
@@ -48700,12 +48700,13 @@ package android.webkit {
|
||||
ctor public WebViewFactory();
|
||||
method public static android.content.pm.PackageInfo getLoadedPackageInfo();
|
||||
method public static java.lang.String getWebViewPackageName();
|
||||
method public static int loadWebViewNativeLibraryFromPackage(java.lang.String);
|
||||
method public static int loadWebViewNativeLibraryFromPackage(java.lang.String, java.lang.ClassLoader);
|
||||
method public static void prepareWebViewInZygote();
|
||||
field public static final java.lang.String CHROMIUM_WEBVIEW_VMSIZE_SIZE_PROPERTY = "persist.sys.webview.vmsize";
|
||||
field public static final int LIBLOAD_ADDRESS_SPACE_NOT_RESERVED = 2; // 0x2
|
||||
field public static final int LIBLOAD_FAILED_JNI_CALL = 7; // 0x7
|
||||
field public static final int LIBLOAD_FAILED_LISTING_WEBVIEW_PACKAGES = 4; // 0x4
|
||||
field public static final int LIBLOAD_FAILED_TO_FIND_NAMESPACE = 10; // 0xa
|
||||
field public static final int LIBLOAD_FAILED_TO_LOAD_LIBRARY = 6; // 0x6
|
||||
field public static final int LIBLOAD_FAILED_TO_OPEN_RELRO_FILE = 5; // 0x5
|
||||
field public static final int LIBLOAD_FAILED_WAITING_FOR_RELRO = 3; // 0x3
|
||||
|
||||
@@ -106,6 +106,9 @@ public final class WebViewFactory {
|
||||
public static final int LIBLOAD_WEBVIEW_BEING_REPLACED = 8;
|
||||
public static final int LIBLOAD_FAILED_WAITING_FOR_WEBVIEW_REASON_UNKNOWN = 9;
|
||||
|
||||
// error for namespace lookup
|
||||
public static final int LIBLOAD_FAILED_TO_FIND_NAMESPACE = 10;
|
||||
|
||||
private static String getWebViewPreparationErrorReason(int error) {
|
||||
switch (error) {
|
||||
case LIBLOAD_FAILED_WAITING_FOR_RELRO:
|
||||
@@ -239,7 +242,8 @@ public final class WebViewFactory {
|
||||
* Load the native library for the given package name iff that package
|
||||
* name is the same as the one providing the webview.
|
||||
*/
|
||||
public static int loadWebViewNativeLibraryFromPackage(String packageName) {
|
||||
public static int loadWebViewNativeLibraryFromPackage(String packageName,
|
||||
ClassLoader clazzLoader) {
|
||||
int ret = waitForProviderAndSetPackageInfo();
|
||||
if (ret != LIBLOAD_SUCCESS) {
|
||||
return ret;
|
||||
@@ -247,7 +251,7 @@ public final class WebViewFactory {
|
||||
if (!sPackageInfo.packageName.equals(packageName))
|
||||
return LIBLOAD_WRONG_PACKAGE_NAME;
|
||||
|
||||
return loadNativeLibrary();
|
||||
return loadNativeLibrary(clazzLoader);
|
||||
}
|
||||
|
||||
static WebViewFactoryProvider getProvider() {
|
||||
@@ -333,15 +337,16 @@ public final class WebViewFactory {
|
||||
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
||||
}
|
||||
|
||||
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.loadNativeLibrary()");
|
||||
loadNativeLibrary();
|
||||
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
||||
|
||||
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.getChromiumProviderClass()");
|
||||
try {
|
||||
initialApplication.getAssets().addAssetPathAsSharedLibrary(
|
||||
webViewContext.getApplicationInfo().sourceDir);
|
||||
ClassLoader clazzLoader = webViewContext.getClassLoader();
|
||||
|
||||
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "WebViewFactory.loadNativeLibrary()");
|
||||
loadNativeLibrary(clazzLoader);
|
||||
Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW);
|
||||
|
||||
Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "Class.forName()");
|
||||
try {
|
||||
return (Class<WebViewFactoryProvider>) Class.forName(CHROMIUM_WEBVIEW_FACTORY,
|
||||
@@ -633,7 +638,7 @@ public final class WebViewFactory {
|
||||
}
|
||||
|
||||
// Assumes that we have waited for relro creation and set sPackageInfo
|
||||
private static int loadNativeLibrary() {
|
||||
private static int loadNativeLibrary(ClassLoader clazzLoader) {
|
||||
if (!sAddressSpaceReserved) {
|
||||
Log.e(LOGTAG, "can't load with relro file; address space not reserved");
|
||||
return LIBLOAD_ADDRESS_SPACE_NOT_RESERVED;
|
||||
@@ -641,9 +646,10 @@ public final class WebViewFactory {
|
||||
|
||||
String[] args = getWebViewNativeLibraryPaths(sPackageInfo);
|
||||
int result = nativeLoadWithRelroFile(args[0] /* path32 */,
|
||||
args[1] /* path64 */,
|
||||
CHROMIUM_WEBVIEW_NATIVE_RELRO_32,
|
||||
CHROMIUM_WEBVIEW_NATIVE_RELRO_64);
|
||||
args[1] /* path64 */,
|
||||
CHROMIUM_WEBVIEW_NATIVE_RELRO_32,
|
||||
CHROMIUM_WEBVIEW_NATIVE_RELRO_64,
|
||||
clazzLoader);
|
||||
if (result != LIBLOAD_SUCCESS) {
|
||||
Log.w(LOGTAG, "failed to load with relro file, proceeding without");
|
||||
} else if (DEBUG) {
|
||||
@@ -672,5 +678,6 @@ public final class WebViewFactory {
|
||||
private static native boolean nativeCreateRelroFile(String lib32, String lib64,
|
||||
String relro32, String relro64);
|
||||
private static native int nativeLoadWithRelroFile(String lib32, String lib64,
|
||||
String relro32, String relro64);
|
||||
String relro32, String relro64,
|
||||
ClassLoader clazzLoader);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user