mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
feat: add backwards compatibility mode for WebViewAssetLoader (#1222)
This commit is contained in:
parent
f9e8ce8fab
commit
ff1ae2125a
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user