avoid caching resources between webxdc apps (#2205)

This commit is contained in:
bjoern
2022-01-27 12:07:34 +01:00
committed by GitHub
parent 5343da7248
commit ee47563f3d
@@ -33,8 +33,6 @@ import java.io.InputStream;
public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcEventDelegate {
private static final String TAG = WebxdcActivity.class.getSimpleName();
private static final String INTERNAL_SCHEMA = "webxdc";
private static final String INTERNAL_DOMAIN = "local.app";
private DcContext dcContext;
private DcMsg dcAppMsg;
@@ -74,7 +72,11 @@ public class WebxdcActivity extends WebViewActivity implements DcEventCenter.DcE
webSettings.setAllowUniversalAccessFromFileURLs(false);
webView.addJavascriptInterface(new InternalJSApi(), "InternalJSApi");
webView.loadUrl(INTERNAL_SCHEMA + "://" + INTERNAL_DOMAIN + "/index.html");
// `msg_id` in the subdomain makes sure, different apps using same files do not share the same cache entry
// (WebView may use a global cache shared across objects).
// (a random-id would also work, but would need maintenance and does not add benefits as we regard the file-part interceptRequest() only,
// also a random-id is not that useful for debugging)
webView.loadUrl("webxdc://msg" + appMessageId + ".localhost/index.html");
Util.runOnAnyBackgroundThread(() -> {
JSONObject info = this.dcAppMsg.getWebxdcInfo();