mirror of
https://github.com/apache/cordova-android.git
synced 2026-04-04 00:02:03 +08:00
Compare commits
1 Commits
master
...
pr-log-mis
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0bbe43b5be |
@@ -111,6 +111,13 @@ public class SystemWebViewClient extends WebViewClient {
|
||||
|
||||
return new WebResourceResponse(mimeType, null, is);
|
||||
} catch (Exception e) {
|
||||
// Some files are requested by default but might not exist in a valid project setup.
|
||||
// When these files are missing, the request should quietly fall through instead of
|
||||
// being logged as an application error.
|
||||
if (isOptionalMissingAsset(path, e)) {
|
||||
LOG.d(TAG, "Optional Web resource not found at \"" + path + "\"");
|
||||
return null;
|
||||
}
|
||||
e.printStackTrace();
|
||||
LOG.e(TAG, "Exception handling Web resource at \"" + path + "\"", e);
|
||||
}
|
||||
@@ -132,6 +139,24 @@ public class SystemWebViewClient extends WebViewClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` when the request failure is expected and non-fatal.
|
||||
*
|
||||
* Some web resources are requested by default but might not exist in a valid project setup:
|
||||
* - {@code cordova_plugins.js} can be absent when no plugins are installed.
|
||||
* - {@code favicon.ico} is often requested by the WebView/Chromium engine automatically.
|
||||
*
|
||||
* When these files are missing, the request should quietly fall through instead of being logged
|
||||
* as an application error.
|
||||
*/
|
||||
private static boolean isOptionalMissingAsset(String path, Exception exception) {
|
||||
if (!(exception instanceof FileNotFoundException)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return "cordova_plugins.js".equals(path) || "favicon.ico".equals(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the host application a chance to take over the control when a new url
|
||||
* is about to be loaded in the current WebView.
|
||||
|
||||
Reference in New Issue
Block a user