From b1e45cd0b5af3dd04d4268ea93b20dbfdb97d74f Mon Sep 17 00:00:00 2001 From: Gustav Sennton Date: Fri, 22 Jan 2016 11:25:34 +0000 Subject: [PATCH] Fetch WebView package even if it is uninstalled for the current user. Since the WebView loading mechanism is global - it doesn't differ between different users, a user for which the current WebView provider is uninstalled won't be able to fetch any information about the current provider without passing a certain flag (MATCH_UNINSTALLED_PACKAGES) to the package manager. Bug: 26677081 Change-Id: Id1b86164bb22fc7285d292da1b1115fb25e4d226 --- core/java/android/webkit/WebViewFactory.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java index 054eafcf2232a..b04b4c0e3b11b 100644 --- a/core/java/android/webkit/WebViewFactory.java +++ b/core/java/android/webkit/WebViewFactory.java @@ -295,15 +295,27 @@ public final class WebViewFactory { Application initialApplication = AppGlobals.getInitialApplication(); Context webViewContext = null; - Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "initialApplication.createPackageContext()"); + Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, "PackageManager.getApplicationInfo()"); try { // Construct a package context to load the Java code into the current app. // This is done as early as possible since by constructing a package context we // register the WebView package as a dependency for the current application so that // when the WebView package is updated this application will be killed. - webViewContext = initialApplication.createPackageContext( - sPackageInfo.packageName, - Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); + ApplicationInfo applicationInfo = + initialApplication.getPackageManager().getApplicationInfo( + sPackageInfo.packageName, PackageManager.GET_SHARED_LIBRARY_FILES + | PackageManager.MATCH_DEBUG_TRIAGED_MISSING + // make sure that we fetch the current provider even if its not installed + // for the current user + | PackageManager.MATCH_UNINSTALLED_PACKAGES); + Trace.traceBegin(Trace.TRACE_TAG_WEBVIEW, + "initialApplication.createApplicationContext"); + try { + webViewContext = initialApplication.createApplicationContext(applicationInfo, + Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY); + } finally { + Trace.traceEnd(Trace.TRACE_TAG_WEBVIEW); + } } catch (PackageManager.NameNotFoundException e) { throw new MissingWebViewPackageException(e); } finally {