Skip to content

Commit

Permalink
feat: add backwards compatibility mode for WebViewAssetLoader (apache…
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasMerz authored and wedgberto committed May 17, 2022
1 parent 7375d1a commit abaab4e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 11 additions & 2 deletions framework/src/org/apache/cordova/ConfigXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ public ArrayList<PluginEntry> getPluginEntries() {
}

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;
}

Expand Down Expand Up @@ -142,7 +147,11 @@ private void setStartUrl(String src) {
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;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ private void initWebViewSettings() {
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
Expand Down

0 comments on commit abaab4e

Please sign in to comment.