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

Commit 84392d74 authored by Torne (Richard Coles)'s avatar Torne (Richard Coles)
Browse files

Store the WebView's package info.

When loading the WebView, save the PackageInfo for the package so that
it can be retrieved later to access the package name, version data, etc.
This will be used to detect WebView downgrades that may affect an app's
saved WebView-related data.

Bug: 16724751
Change-Id: I05ce469308cc87f79c73206327f43b76b1bab222
parent b734e9d2
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -72,12 +72,17 @@ public final class WebViewFactory {
    private static WebViewFactoryProvider sProviderInstance;
    private static final Object sProviderLock = new Object();
    private static boolean sAddressSpaceReserved = false;
    private static PackageInfo sPackageInfo;

    public static String getWebViewPackageName() {
        return AppGlobals.getInitialApplication().getString(
                com.android.internal.R.string.config_webViewPackageName);
    }

    public static PackageInfo getLoadedPackageInfo() {
        return sPackageInfo;
    }

    static WebViewFactoryProvider getProvider() {
        synchronized (sProviderLock) {
            // For now the main purpose of this function (and the factory abstraction) is to keep
@@ -125,9 +130,9 @@ public final class WebViewFactory {
        try {
            // First fetch the package info so we can log the webview package version.
            String packageName = getWebViewPackageName();
            PackageInfo pi = initialApplication.getPackageManager().getPackageInfo(packageName, 0);
            Log.i(LOGTAG, "Loading " + packageName + " version " + pi.versionName +
                          " (code " + pi.versionCode + ")");
            sPackageInfo = initialApplication.getPackageManager().getPackageInfo(packageName, 0);
            Log.i(LOGTAG, "Loading " + packageName + " version " + sPackageInfo.versionName +
                          " (code " + sPackageInfo.versionCode + ")");

            // Construct a package context to load the Java code into the current app.
            Context webViewContext = initialApplication.createPackageContext(packageName,