From 0606cd572ad345fb2c40456509feac626c68dee3 Mon Sep 17 00:00:00 2001 From: "Torne (Richard Coles)" Date: Tue, 5 Aug 2014 16:12:09 +0100 Subject: [PATCH] Log the version of the WebView package used. To aid in debugging app behaviour when WebView updates may be present, log the package name, version name, and version code of the WebView package when we are about to load it into an application. Do this before we actually load any part of the package in case of an issue loading it in the first place. Change-Id: Id653bad431760b7ead8e3f8eb29f9d6a8bb68d07 --- core/java/android/webkit/WebViewFactory.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java index fa16faec2e10a..d93ca2c7db96b 100644 --- a/core/java/android/webkit/WebViewFactory.java +++ b/core/java/android/webkit/WebViewFactory.java @@ -21,6 +21,7 @@ import android.app.Application; import android.app.AppGlobals; import android.content.Context; import android.content.pm.ApplicationInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Build; import android.os.Process; @@ -109,8 +110,14 @@ public final class WebViewFactory { private static Class getFactoryClass() throws ClassNotFoundException { Application initialApplication = AppGlobals.getInitialApplication(); try { - Context webViewContext = initialApplication.createPackageContext( - getWebViewPackageName(), + // 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 + ")"); + + // Construct a package context to load the Java code into the current app. + Context webViewContext = initialApplication.createPackageContext(packageName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); initialApplication.getAssets().addAssetPath( webViewContext.getApplicationInfo().sourceDir);