mirror of
https://github.com/apache/cordova-android.git
synced 2025-03-16 08:21:04 +08:00
feat: add backwards compatibility mode for WebViewAssetLoader (#1222)
This commit is contained in:
parent
f9e8ce8fab
commit
ff1ae2125a
@ -49,6 +49,11 @@ public class ConfigXmlParser {
|
|||||||
if (launchUrl == null) {
|
if (launchUrl == null) {
|
||||||
launchUrl = "https://" + this.prefs.getString("hostname", "localhost");
|
launchUrl = "https://" + this.prefs.getString("hostname", "localhost");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.prefs.getBoolean("AndroidInsecureFileModeEnabled", false)) {
|
||||||
|
launchUrl = "file:///android_asset/www/index.html";
|
||||||
|
}
|
||||||
|
|
||||||
return launchUrl;
|
return launchUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +147,11 @@ public class ConfigXmlParser {
|
|||||||
if (src.charAt(0) == '/') {
|
if (src.charAt(0) == '/') {
|
||||||
src = src.substring(1);
|
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.setSaveFormData(false);
|
||||||
settings.setSavePassword(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);
|
settings.setMediaPlaybackRequiresUserGesture(false);
|
||||||
|
|
||||||
// Enable database
|
// Enable database
|
||||||
|
Loading…
x
Reference in New Issue
Block a user