From 5f3278ba1e7572d4a5624d18fd08ba9038abc575 Mon Sep 17 00:00:00 2001 From: "Torne (Richard Coles)" Date: Mon, 4 Aug 2014 14:04:02 +0100 Subject: [PATCH] Don't let failures to load the null WebView propagate. We load the null WebView if the real WebView package is not available to support devices that aren't intended to have a WebView, but this results in confusing log messages if the real WebView is supposed to be present but is broken/unloadable for some reason. Since the null WebView is in the system classpath on devices that should use it, swallow any failures to load it on the assumption that this is actually just a failure of the real WebView to be loaded. Change-Id: I15820da3517daffde6169343c648a4486c0309d7 --- core/java/android/webkit/WebViewFactory.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/java/android/webkit/WebViewFactory.java b/core/java/android/webkit/WebViewFactory.java index 2e836fbce8c29..fa16faec2e10a 100644 --- a/core/java/android/webkit/WebViewFactory.java +++ b/core/java/android/webkit/WebViewFactory.java @@ -118,8 +118,17 @@ public final class WebViewFactory { return (Class) Class.forName(CHROMIUM_WEBVIEW_FACTORY, true, clazzLoader); } catch (PackageManager.NameNotFoundException e) { - Log.e(LOGTAG, "Chromium WebView package does not exist"); - return (Class) Class.forName(NULL_WEBVIEW_FACTORY); + // If the package doesn't exist, then try loading the null WebView instead. + // If that succeeds, then this is a device without WebView support; if it fails then + // swallow the failure, complain that the real WebView is missing and rethrow the + // original exception. + try { + return (Class) Class.forName(NULL_WEBVIEW_FACTORY); + } catch (ClassNotFoundException e2) { + // Ignore. + } + Log.e(LOGTAG, "Chromium WebView package does not exist", e); + throw new AndroidRuntimeException(e); } }