aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormosimchah <mosimchah@gmail.com>2025-12-06 07:30:24 -0500
committermosimchah <mosimchah@gmail.com>2025-12-06 07:30:24 -0500
commit4d19c277dc57dec41b000cb90ce2ad357453a733 (patch)
tree7da21ebf9d209acdb87ab9ee4faa0d946c18e090
parentd0900097b00e0abcc3e46bb737577407014a4714 (diff)
aicp: add our adaway from w16.0_pre-rebase_12-3-25
https://github.com/AICP/vendor_aicp/tree/w16.0_pre-rebase-12-3-25 commit df27c04b9aab33641744b1a9c3c850c7393286c6 Author: Tony Jose <gmoto1179@gmail.com> Date: Wed Jun 2 16:54:37 2021 +0530 adaway: Whitelist a Youtube subdomain Fixes: Watch history not working on YT Vanced Ref: https://github.com/AdAway/AdAway/issues/2071 Change-Id: I376f249d9da0db61506858890f8e4e9cb2c4aaa6 commit 6027381635813b2ef042c90999b959b11dbeec68 Author: George Zacharia <george.zcharia@gmail.com> Date: Fri Jan 1 19:01:38 2021 +0530 adaway: Minor improvements - Sync up custom host file with stock AOSP hosts - Use assigment operator rather than a 'if' block in the Makefile for custom hosts Change-Id: I21dc649f5de9d2ab1c1132093f10ed2486b9d1e2 commit 8790697c6f4da50fe9387fdb5124c97cca7ebe49 Author: George Zacharia <george.zcharia@gmail.com> Date: Fri Jul 31 16:51:08 2020 +0530 aicp: adblock: Allow overriding the input hosts file Because of the modular nature of the StevenBlack's hosts, the user may be tempted to modify the hosts to match personal preferences. Accommodate such changes. Retains the earlier behaviour to pass multiple files to be conbined. Also remove the shell script "middleman", earlier shell script was used to fetch the file versions, which now is handled within the python script itself Change-Id: I4a348f29c9dbec6eb9eafe387a14be7280ce2412 commit dd0ffc375bf937d5cccf471c173bd906427d91e1 Author: Michele Bono <bono.michele94@gmail.com> Date: Tue May 26 18:02:04 2020 +0200 vendor: whitelist some google adservices They spam logcat as hell! Change-Id: I0e4abde69615ce6f297bf52f80fa4e7ce5277b1d commit 3d86e05110b58db8285e1f644d9bdd43907d70e8 Author: SpiritCroc <dev@spiritcroc.de> Date: Fri May 8 10:55:17 2020 +0200 hosts.aicp_adblock: sync from git, update on build [2/2] Change-Id: I5d9ad3307f7137879c407791fb6cd66c1463f4cf commit 67e42478cb4541fa5ab4f87b39b46a880316df46 Author: Michele Bono <bono.michele94@gmail.com> Date: Sun May 3 12:26:51 2020 +0200 vendor: Add StevenBlack source Change-Id: I89eedb7ad2a34b769b0a029dd1e29893a157f24f commit 9867edd3f013181d1e8978bf212bfbd74a713735 Author: SpiritCroc <dev@spiritcroc.de> Date: Sun Apr 26 11:12:20 2020 +0200 vendor/aicp: Toggle-able adblock hosts file [2/3] Regenerate with ./adaway/generate.sh Change-Id: Ia389457746f9af1060a1c1ae62af0cb9ca643a71 Change-Id: Ibe8dc27b71d73c6c8520f53418201d2a81447dfe
-rw-r--r--adaway/.hosts/.gitignore2
-rw-r--r--adaway/Android.mk18
-rw-r--r--adaway/generate.py82
3 files changed, 102 insertions, 0 deletions
diff --git a/adaway/.hosts/.gitignore b/adaway/.hosts/.gitignore
new file mode 100644
index 000000000..d6b7ef32c
--- /dev/null
+++ b/adaway/.hosts/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/adaway/Android.mk b/adaway/Android.mk
new file mode 100644
index 000000000..74fed5a8d
--- /dev/null
+++ b/adaway/Android.mk
@@ -0,0 +1,18 @@
+# Use 'export INPUT_ADBLOCK_FILE=<custom host file location>' before build/envsetup.sh to build custom adblock
+INPUT_ADBLOCK_FILE ?= external/hosts/hosts
+
+ADBLOCK_SCRIPT := vendor/aicp/adaway/generate.py
+
+TARGET_GENERATED_HOSTS_BLOCKER := $(TARGET_OUT_INTERMEDIATES)/ADBLOCK/hosts.aicp_adblock
+$(TARGET_GENERATED_HOSTS_BLOCKER): INTERMEDIATES := $(TARGET_OUT_INTERMEDIATES)/ADBLOCK
+$(TARGET_GENERATED_HOSTS_BLOCKER): $(ADBLOCK_SCRIPT) $(INPUT_ADBLOCK_FILE)
+ python3 $(ADBLOCK_SCRIPT) $@ $(INPUT_ADBLOCK_FILE)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := hosts.aicp_adblock
+LOCAL_MODULE_CLASS := ETC
+
+include $(BUILD_SYSTEM)/base_rules.mk
+
+$(LOCAL_BUILT_MODULE): $(TARGET_GENERATED_HOSTS_BLOCKER)
+ @cp $< $@
diff --git a/adaway/generate.py b/adaway/generate.py
new file mode 100644
index 000000000..2fd6748c3
--- /dev/null
+++ b/adaway/generate.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python3
+
+from os.path import dirname
+from subprocess import check_output, CalledProcessError
+from datetime import datetime
+import sys
+
+# Don't add these from adaway sources, but handle manually if needed
+BLACKLIST = [
+ "localhost",
+ "localhost.localdomain",
+ "local",
+ "broadcasthost",
+ "ip6-localhost",
+ "ip6-loopback",
+ "ip6-localnet",
+ "ip6-mcastprefix",
+ "ip6-allnodes",
+ "ip6-allrouters",
+ "ip6-allhosts",
+ "0.0.0.0",
+ "ad.doubleclick.net",
+ "www.googleadservices.com",
+ "s.youtube.com",
+]
+
+def get_revision_string(directory):
+ try:
+ repo_url = check_output(
+ ["git", "config", "--get", "remote.github.url"], cwd=directory, universal_newlines=True)
+ head_id = check_output(
+ ["git", "rev-parse", "HEAD"], cwd=directory, universal_newlines=True)
+ return f"# {repo_url}# {head_id}"
+ # If the file is not in a git repo
+ except CalledProcessError:
+ return f"# File at {directory} not versioned\n"
+
+def write_header(f, source_revision):
+ f.write("# This hosts file has been generated on:\n# {}\n# This file is generated from the following sources:\n".format(datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
+ f.write("{}\n".format(source_revision))
+ f.write("\n127.0.0.1 localhost\n::1 ip6-localhost\n\n")
+
+def read_redirect(line):
+ source = None
+ target = None
+ for l in line.split(" "):
+ if l.startswith("#"):
+ # Ignore comments
+ return None
+ if len(l) > 0:
+ if source == None:
+ source = l
+ else:
+ target = l
+ return (source, target)
+ return None
+
+if __name__ == "__main__":
+ source_revision = ""
+ outfile = sys.argv[1]
+ sources = sys.argv[2:]
+ redirects = []
+ with open(outfile, 'w') as fout:
+ # Read hosts sources
+ for infile in sources:
+ with open(infile, 'r') as fin:
+ for line in fin:
+ line = line.split('\n')[0]
+ redirect = read_redirect(line)
+ if redirect != None:
+ redirects.append(redirect)
+ source_revision += get_revision_string(dirname(infile))
+ write_header(fout, source_revision)
+ # Remove duplicates and sort it
+ redirects = sorted(list(set(redirects)))
+ # Write it
+ for redirect in redirects:
+ if redirect[1] in BLACKLIST:
+ continue
+ if redirect[0] != "127.0.0.1" and redirect[0] != "0.0.0.0":
+ continue
+ fout.write("127.0.0.1 {}\n".format(redirect[1]))