diff options
| author | Torne (Richard Coles) <torne@google.com> | 2017-10-02 17:09:32 -0400 |
|---|---|---|
| committer | Torne (Richard Coles) <torne@google.com> | 2017-10-03 10:40:20 -0400 |
| commit | ff937ac226c73f992df79b61a16973b41b406772 (patch) | |
| tree | b1d69caf68bc96f5a5f535b170b7c311db34c43f /core/java/android/webkit/WebViewUpdateService.java | |
| parent | f27d5f0afc5a7badcb16bdcc34a8fa79613f18f4 (diff) | |
Improve handling of devices without a WebView.
Use the presence of FEATURE_WEBVIEW to determine whether a device is
intended to have a WebView implementation or not, instead of trying to
fall back to NullWebViewFactoryProvider after loading WebView fails.
This removes the need for nullwebview entirely, and eliminates a class
of possible bug where unexpected exceptions during loading cause the
fallback mechanism not to work reliably.
On devices which don't have the feature, don't start
WebViewUpdateService at all. Guard all the places which try to access
the service to return reasonable (empty/null) results when this is the
case, instead of throwing exceptions.
Change-Id: I839adaaf0abee28f4989e3fbc0c49c0732d0ec1c
Bug: 31849211
Fixes: 28529980
Test: on wear and non-wear, cts-tradefed run cts -m CtsWebkitTestCases
Diffstat (limited to 'core/java/android/webkit/WebViewUpdateService.java')
| -rw-r--r-- | core/java/android/webkit/WebViewUpdateService.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/core/java/android/webkit/WebViewUpdateService.java b/core/java/android/webkit/WebViewUpdateService.java index 2f7d6854803d..629891cca4f6 100644 --- a/core/java/android/webkit/WebViewUpdateService.java +++ b/core/java/android/webkit/WebViewUpdateService.java @@ -31,8 +31,12 @@ public final class WebViewUpdateService { * Fetch all packages that could potentially implement WebView. */ public static WebViewProviderInfo[] getAllWebViewPackages() { + IWebViewUpdateService service = getUpdateService(); + if (service == null) { + return new WebViewProviderInfo[0]; + } try { - return getUpdateService().getAllWebViewPackages(); + return service.getAllWebViewPackages(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -42,8 +46,12 @@ public final class WebViewUpdateService { * Fetch all packages that could potentially implement WebView and are currently valid. */ public static WebViewProviderInfo[] getValidWebViewPackages() { + IWebViewUpdateService service = getUpdateService(); + if (service == null) { + return new WebViewProviderInfo[0]; + } try { - return getUpdateService().getValidWebViewPackages(); + return service.getValidWebViewPackages(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -53,8 +61,12 @@ public final class WebViewUpdateService { * Used by DevelopmentSetting to get the name of the WebView provider currently in use. */ public static String getCurrentWebViewPackageName() { + IWebViewUpdateService service = getUpdateService(); + if (service == null) { + return null; + } try { - return getUpdateService().getCurrentWebViewPackageName(); + return service.getCurrentWebViewPackageName(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } |
