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

Commit a7e4fe9a authored by Torne (Richard Coles)'s avatar Torne (Richard Coles) Committed by Marcin Kosiba
Browse files

Load the WebView Java code via createPackageContext.

Bug: 16329371
Change-Id: I94b4bb0df46a373454eb8ee9742413e13ce1e6a8
parent 3d9bcc06
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package android.webkit;

import android.app.AppGlobals;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.StrictMode;
import android.os.SystemProperties;
@@ -92,6 +95,16 @@ public final class WebViewFactory {
    }

    private static Class<WebViewFactoryProvider> getFactoryClass() throws ClassNotFoundException {
        return (Class<WebViewFactoryProvider>) Class.forName(CHROMIUM_WEBVIEW_FACTORY);
        try {
            Context webViewContext = AppGlobals.getInitialApplication().createPackageContext(
                    getWebViewPackageName(),
                    Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
            ClassLoader clazzLoader = webViewContext.getClassLoader();
            return (Class<WebViewFactoryProvider>) Class.forName(CHROMIUM_WEBVIEW_FACTORY, true,
                                                                 clazzLoader);
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(LOGTAG, "Chromium WebView package does not exist");
            return (Class<WebViewFactoryProvider>) Class.forName(NULL_WEBVIEW_FACTORY);
        }
    }
}