diff --git a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java index 9f057182d..a58ed4206 100755 --- a/framework/src/org/apache/cordova/engine/SystemWebViewClient.java +++ b/framework/src/org/apache/cordova/engine/SystemWebViewClient.java @@ -29,6 +29,8 @@ Licensed to the Apache Software Foundation (ASF) under one import android.webkit.HttpAuthHandler; import android.webkit.MimeTypeMap; import android.webkit.RenderProcessGoneDetail; +import android.webkit.ServiceWorkerClient; +import android.webkit.ServiceWorkerController; import android.webkit.SslErrorHandler; import android.webkit.WebResourceRequest; import android.webkit.WebResourceResponse; @@ -116,6 +118,18 @@ public SystemWebViewClient(SystemWebViewEngine parentEngine) { }); this.assetLoader = assetLoaderBuilder.build(); + boolean setAsServiceWorkerClient = parentEngine.preferences.getBoolean("ResolveServiceWorkerRequests", false); + ServiceWorkerController controller = null; + + if (setAsServiceWorkerClient) { + controller = ServiceWorkerController.getInstance(); + controller.setServiceWorkerClient(new ServiceWorkerClient(){ + @Override + public WebResourceResponse shouldInterceptRequest(WebResourceRequest request) { + return assetLoader.shouldInterceptRequest(request.getUrl()); + } + }); + } } /**