feat: add backwards compatibility mode for WebViewAssetLoader (#1222)

This commit is contained in:
Niklas Merz 2021-05-06 08:17:58 +02:00 committed by GitHub
parent f9e8ce8fab
commit ff1ae2125a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -46,9 +46,14 @@ public class ConfigXmlParser {
}
public String getLaunchUrl() {
if (launchUrl == null) {
if (launchUrl == null) {
launchUrl = "https://" + this.prefs.getString("hostname", "localhost");
}
if (this.prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
launchUrl = "file:///android_asset/www/index.html";
}
return launchUrl;
}
@ -142,7 +147,11 @@ public class ConfigXmlParser {
if (src.charAt(0) == '/') {
src = src.substring(1);
}
launchUrl = "https://" + this.prefs.getString("hostname", "localhost") + "/" + src;
if (this.prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
launchUrl = "file:///android_asset/www/" + src;
} else {
launchUrl = "https://" + this.prefs.getString("hostname", "localhost") + "/" + src;
}
}
}
}

View File

@ -159,6 +159,14 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
settings.setSaveFormData(false);
settings.setSavePassword(false);
if (preferences.getBoolean("AndroidInsecureFileModeEnabled", false)) {
//These settings are deprecated and loading content via file:// URLs is generally discouraged,
//but we allow this for compatibility reasons
LOG.d(TAG, "Enabled insecure file access");
settings.setAllowFileAccess(true);
settings.setAllowUniversalAccessFromFileURLs(true);
}
settings.setMediaPlaybackRequiresUserGesture(false);
// Enable database