|
|
@ -20,7 +20,6 @@ package eu.faircode.email;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.net.Uri;
|
|
|
|
|
|
|
|
import android.os.SystemClock;
|
|
|
|
import android.os.SystemClock;
|
|
|
|
|
|
|
|
|
|
|
|
import org.json.JSONArray;
|
|
|
|
import org.json.JSONArray;
|
|
|
@ -84,18 +83,10 @@ public class DisconnectBlacklist {
|
|
|
|
JSONObject jsites = (JSONObject) jblock.get(name);
|
|
|
|
JSONObject jsites = (JSONObject) jblock.get(name);
|
|
|
|
Iterator<String> sites = jsites.keys();
|
|
|
|
Iterator<String> sites = jsites.keys();
|
|
|
|
if (sites.hasNext()) {
|
|
|
|
if (sites.hasNext()) {
|
|
|
|
List<String> domains = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String site = sites.next();
|
|
|
|
String site = sites.next();
|
|
|
|
String host = Uri.parse(site).getHost();
|
|
|
|
|
|
|
|
if (host != null)
|
|
|
|
|
|
|
|
domains.add(host.toLowerCase(Locale.ROOT));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray jdomains = jsites.getJSONArray(site);
|
|
|
|
JSONArray jdomains = jsites.getJSONArray(site);
|
|
|
|
for (int d = 0; d < jdomains.length(); d++)
|
|
|
|
for (int d = 0; d < jdomains.length(); d++) {
|
|
|
|
domains.add(jdomains.getString(d).toLowerCase(Locale.ROOT));
|
|
|
|
String domain = jdomains.getString(d).toLowerCase(Locale.ROOT);
|
|
|
|
|
|
|
|
|
|
|
|
for (String domain : domains) {
|
|
|
|
|
|
|
|
if (!map.containsKey(domain))
|
|
|
|
if (!map.containsKey(domain))
|
|
|
|
map.put(domain, new ArrayList<>());
|
|
|
|
map.put(domain, new ArrayList<>());
|
|
|
|
List<String> list = map.get(domain);
|
|
|
|
List<String> list = map.get(domain);
|
|
|
@ -134,25 +125,32 @@ public class DisconnectBlacklist {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static List<String> getCategories(String domain) {
|
|
|
|
static List<String> getCategories(String domain) {
|
|
|
|
if (domain == null)
|
|
|
|
return _getCategories(domain);
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
synchronized (map) {
|
|
|
|
|
|
|
|
List<String> result = map.get(domain.toLowerCase(Locale.ROOT));
|
|
|
|
|
|
|
|
return (result == null || result.size() == 0 ? null : result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static boolean isTracking(String host) {
|
|
|
|
static boolean isTracking(String host) {
|
|
|
|
if (host == null)
|
|
|
|
List<String> categories = _getCategories(host);
|
|
|
|
|
|
|
|
if (categories == null || categories.size() == 0)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return !categories.contains("Content");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<String> _getCategories(String domain) {
|
|
|
|
|
|
|
|
if (domain == null)
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
synchronized (map) {
|
|
|
|
synchronized (map) {
|
|
|
|
List<String> result = map.get(host.toLowerCase(Locale.ROOT));
|
|
|
|
String d = domain.toLowerCase(Locale.ROOT);
|
|
|
|
if (result == null || result.size() == 0)
|
|
|
|
while (d.contains(".")) {
|
|
|
|
return false;
|
|
|
|
List<String> result = map.get(d);
|
|
|
|
return !result.contains("Content");
|
|
|
|
if (result != null)
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
int dot = d.indexOf(".");
|
|
|
|
|
|
|
|
d = d.substring(dot + 1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static File getFile(Context context) {
|
|
|
|
private static File getFile(Context context) {
|
|
|
|